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 FrmUpdateYearMonthAndBelongName : FrmBase { private string departm = ""; private string plineCode = ""; private string[] plineCodes = { }; private string[] arr = null; public FrmUpdateYearMonthAndBelongName() { InitializeComponent(); this.IsLoadUserView = true; } private void FrmUpdateYearMonthAndBelongName_Load(object sender, EventArgs e) { NativeMethodNew na = new NativeMethodNew(this.ob); departm = UserInfo.GetDepartment(); plineCode = na.GetPCode(departm);//获取 用户 对应的产线 arr = BaseMethod.InitPermissions(this.ValidDataPurviewIds,ob); plineCodes = BaseMethod.GetPlineCode(ValidDataPurviewIds, ob); if (this.UserInfo.GetDeptid().Equals("002")) { ultraComboEditor2.Items.Clear(); ultraComboEditor2.Items.Add("生产计划部"); ultraComboEditor2.Items.Add("168机组"); ultraComboEditor2.Items.Add("258机组"); ultraComboEditor2.Items.Add("250机组"); ultraComboEditor2.Items.Add("460机组"); ultraComboEditor2.Items.Add("产品制造部"); ultraComboEditor2.Items.Add("天淮508机组"); } if (this.UserInfo.GetDeptid().StartsWith("002001")) { ultraComboEditor2.Items.Clear(); ultraComboEditor2.Items.Add("生产计划部"); ultraComboEditor2.Items.Add("168机组"); ultraComboEditor2.Items.Add("258机组"); ultraComboEditor2.Items.Add("250机组"); ultraComboEditor2.Items.Add("460机组"); } if (this.UserInfo.GetDeptid().StartsWith("002023")) { ultraComboEditor2.Items.Clear(); ultraComboEditor2.Items.Add("产品制造部"); ultraComboEditor2.Items.Add("天淮508机组"); } } /// /// 重写基类方法 /// /// /// 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(); switch(this.CustomInfo) { case "PLINE_CODE": dt = ServerHelper.GetData("com.steering.mes.zgmil.report.FrmUpdateBalYearMonth.getApplyBalYearMonth", new Object[] { barYearMonth, JudgeStoveNo, plineCodes }, this.ob); break; case "BELONG_CODE": dt = ServerHelper.GetData("com.steering.mes.zgmil.report.FrmUpdateBalYearMonth.getApplyBalYearMonthBelong", new object[] { barYearMonth, JudgeStoveNo, arr }, ob); break; } 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; } //else //{ // if (!StringUtil.IsNumber(ugr.Cells["BAL_YEAR_MONTH"].Text.ToString())) // { // MessageUtil.ShowTips("请输入正确的时间!"); // return; // } //} //if (ugr.Cells["IS_CARRY_VOER"].Value.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()); 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 = "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(); } } } /// /// 非250、258、168、460的产线代码都为空 /// /// private string getPlineCode() { if (plineCode.Equals("C008") || plineCode.Equals("C009") || plineCode.Equals("C010") || plineCode.Equals("C017")) { return plineCode; } else { return ""; } } /// /// 查询条件 /// /// /// 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"); } } }