using Core.Mes.Client.Comm.Control; using Core.Mes.Client.Comm.Server; using Core.Mes.Client.Comm.Tool; using Core.StlMes.Client.ZGMil.Common; using Core.StlMes.Client.ZGMil.Entity; using CoreFS.CA06; using Infragistics.Win.UltraWinGrid; using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace Core.StlMes.Client.ZGMil.Report { public partial class FrmUpdateYearMonthAndBelongNameGX : FrmBase { private string departm = ""; private string[] plineCode = null; private string[] arr = null; private string[] arrId;//数据权限 public FrmUpdateYearMonthAndBelongNameGX() { InitializeComponent(); this.IsLoadUserView = true; } private void FrmUpdateYearMonthAndBelongNameGX_Load(object sender, EventArgs e) { NativeMethodNew na = new NativeMethodNew(this.ob); departm = UserInfo.GetDepartment(); plineCode = BaseMethod.GetPlineCode(this.ValidDataPurviewIds,this.ob);//获取 用户 对应的产线 arr = BaseMethod.InitPermissions(this.ValidDataPurviewIds,ob); arrId = this.ValidDataPurviewIds;//获取数据权限 } /// /// 重写基类方法 /// /// /// public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey) { case "Query": doQuery(); break; case "UpdateYearMonth": doUpdateYearMonth(); break; case "UpdateBelongName": doUpdateBelongName(); break; case "Export": ExportData(); break; case "Close": this.Close(); break; } } /// /// 调整所属权 /// private void doUpdateBelongName() { ultraGrid1.UpdateData(); UltraGridRow row = ultraGrid1.ActiveRow; if (row == null) { MessageUtil.ShowTips("无数据!"); return; } int count = 0; ArrayList list = new ArrayList(); foreach (UltraGridRow ugr in ultraGrid1.Rows) { if (Convert.ToBoolean(ugr.Cells["CHK"].Text) == true) { count += 1; if (ugr.Cells["TARGET"].Value.ToString().Equals("A")) { MessageUtil.ShowTips("产品标识为【A】的不可调整所属权!"); return; } ArrayList pram = new ArrayList(); pram.Add(ugr.Cells["BELONG_NAME_JUGDE"].Value.ToString()); pram.Add(ugr.Cells["JUGDE_APPLY_CODE"].Value.ToString()); pram.Add(ugr.Cells["JUDGE_STOVE_NO"].Value.ToString()); pram.Add(ugr.Cells["BATCH_NO"].Value.ToString()); pram.Add(ugr.Cells["BATCH_GROUD_NO"].Value.ToString()); pram.Add(ugr.Cells["QUALITY_GROUP"].Value.ToString()); pram.Add(ugr.Cells["MAT_GOWHERE_NAME"].Value.ToString()); pram.Add(ugr.Cells["PLINE_CODE"].Value.ToString()); list.Add(pram); } } if (count == 0 || count > 1) { MessageUtil.ShowTips("请选择一条需要修改的数据!"); return; } if (MessageUtil.ShowYesNoAndQuestion("是否修改?") == DialogResult.No) { return; } CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.mes.zgmil.report.FrmUpdateBalYearMonth"; ccp.MethodName = "doUpdateBelongName"; ccp.ServerParams = new object[] { list }; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { MessageUtil.ShowTips(ccp.ReturnInfo); if (ccp.ReturnInfo.Equals("修改成功!")) { doQuery(); } } } /// /// 查询 /// private void doQuery() { string JudgeStoveNo = ""; string barYearMonth = ""; if (chkJudgeStoveNo.Checked) { if (uteJudgeStoveNo.Text.Trim() == "") { JudgeStoveNo = ""; } else { JudgeStoveNo = uteJudgeStoveNo.Value.ToString(); } } if (chkBalYearMonth.Checked) { if (BAL_YEAR_MONTH.Text.Trim() == "") { barYearMonth = ""; } else { barYearMonth = BAL_YEAR_MONTH.Value.ToString("yyyyMM"); } } WaitingForm2 wf = new WaitingForm2("正在加载,请稍候...."); DataTable dt = new DataTable(); dt = ServerHelper.GetData("com.steering.mes.zgmil.report.FrmUpdateBalYearMonth.getApplyBalYearMonthGX", new Object[] { barYearMonth, JudgeStoveNo, this.CustomInfo.ToString(), plineCode }, this.ob); GridHelper.CopyDataToDatatable(dt, this.dataTable1, true); GridHelper.RefreshAndAutoSize(this.ultraGrid1); wf.Close(); } /// /// 调整结转年月 /// private void doUpdateYearMonth() { ultraGrid1.UpdateData(); UltraGridRow row = ultraGrid1.ActiveRow; if (row == null) { MessageUtil.ShowTips("无数据!"); return; } int count = 0; ArrayList list = new ArrayList(); foreach (UltraGridRow ugr in ultraGrid1.Rows) { if (Convert.ToBoolean(ugr.Cells["CHK"].Text) == true) { count += 1; //if (ugr.Cells["INSTOCK_FLAG"].Text.ToString().Equals("未确认")) //{ // MessageUtil.ShowTips("缴库标志未确认,不允许调整结转年月!"); // return; //} //if (ugr.Cells["TARGET"].Value.ToString().Equals("A") && ugr.Cells["INSTOCK_FLAG"].Text.ToString().Equals("已确认")) //{ // MessageUtil.ShowTips("缴库标志已确认,不允许调整结转年月!"); // return; //} ArrayList pram = new ArrayList(); string bal = DateTime.Parse(ugr.Cells["BAL_YEAR_MONTH"].Text).ToString("yyyyMM"); pram.Add(bal); pram.Add(ugr.Cells["JUGDE_APPLY_CODE"].Value.ToString()); pram.Add(ugr.Cells["JUDGE_STOVE_NO"].Value.ToString()); pram.Add(ugr.Cells["BATCH_NO"].Value.ToString()); pram.Add(ugr.Cells["BATCH_GROUD_NO"].Value.ToString()); pram.Add(ugr.Cells["QUALITY_GROUP"].Value.ToString()); pram.Add(ugr.Cells["MAT_GOWHERE_NAME"].Value.ToString()); pram.Add(ugr.Cells["TARGET"].Value.ToString()); pram.Add(ugr.Cells["PLINE_CODE"].Value.ToString()); pram.Add(DateTime.Parse(ugr.Cells["BAL_YEAR_MONTH"].Text).ToString("yyyy-MM")); pram.Add(ugr.Cells["INSTOCK_FLAG"].Text.ToString()); list.Add(pram); } } if (count == 0 ) { MessageUtil.ShowTips("请选择需要修改的数据!"); return; } if (MessageUtil.ShowYesNoAndQuestion("是否修改?") == DialogResult.No) { return; } CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.mes.zgmil.report.FrmUpdateBalYearMonth"; ccp.MethodName = "doUpdateYearMonth"; ccp.ServerParams = new object[] { list }; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { MessageUtil.ShowTips(ccp.ReturnInfo); if (ccp.ReturnInfo.Equals("修改成功!")) { doQuery(); } } } /// /// 查询条件 /// /// /// private void chkDate_CheckedChanged(object sender, EventArgs e) { if (chkBalYearMonth.Checked) { BAL_YEAR_MONTH.Enabled = true; } else { BAL_YEAR_MONTH.Enabled = false; } //if (chkLotNo.Checked) { uteLotNo.Enabled = true; } else { uteLotNo.Enabled = false; } if (chkJudgeStoveNo.Checked) { uteJudgeStoveNo.Enabled = true; } else { uteJudgeStoveNo.Enabled = false; } } /// /// 导出 /// private void ExportData() { GridHelper.ulGridToExcel(ultraGrid1, "轧管投入产出报表"); } private void ultraGrid1_InitializeLayout(object sender, InitializeLayoutEventArgs e) { foreach (UltraGridRow uRow in ultraGrid1.Selected.Rows) { if (uRow.GetType() != typeof(Infragistics.Win.UltraWinGrid.UltraGridGroupByRow)) { uRow.Cells["CHK"].Value = true; } } } private void ultraGrid1_KeyUp(object sender, KeyEventArgs e) { BaseMethod.setGridCopyActColumn(ultraGrid1, e, "BAL_YEAR_MONTH"); } private void ultraGrid1_AfterSelectChange(object sender, AfterSelectChangeEventArgs e) { foreach (UltraGridRow uRow in ultraGrid1.Selected.Rows) { if (uRow.GetType() != typeof(Infragistics.Win.UltraWinGrid.UltraGridGroupByRow)) { uRow.Cells["CHK"].Value = true; } } } } }