using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using CoreFS.CA06; using System.Collections; using Core.Mes.Client.Comm.Tool; using Core.Mes.Client.Comm.Server; using com.steering.pss.plnsaleord.order.model; using Core.StlMes.Client.PlnSaleOrd.PopupWindow; using Infragistics.Win.UltraWinGrid; using Core.Mes.Client.Comm; using Infragistics.Win.UltraWinEditors; using System.Globalization; namespace Core.StlMes.Client.PlnSaleOrd { public partial class FrmOrderStatusSet : FrmBase { public FrmOrderStatusSet() { this.IsLoadUserView = true; InitializeComponent(); EntityHelper.ShowGridCaption(ultraGridStatus.DisplayLayout.Bands[0]); } private void FrmOrderStatusSet_Load(object sender, EventArgs e) { ultraDateTimeImportTime.DateTime = DateTime.Now; ultraDateTimeImportTimeTo.DateTime = DateTime.Now; ultraComboOrderStatusSet.SelectedIndex = 0; PlanComm.setGridActivation(ultraGridStatus.DisplayLayout.Bands[0], "CHC"); PlanComm.setGridDigitalCol(ultraGridStatus.DisplayLayout.Bands[0], 5, 0, "NumSetStatus"); DoQuery(); } /// /// 重写基类toolBar方法 /// /// /// public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey) { case "Query": DoQuery(); break; case "Import": DoImport(); break; case "Modefiy": DoModefiy(); break; case "ModefiyMonth": DoModefiyMonth(); break; case"ModefiyCheckMoth": doModefiyCheckMoth(); break; case "ModifyPrio": doModifyPrio(); break; case "Delete": doDelete(); DoQuery(); break; case "Close": this.Close(); break; } } /// /// 查询 /// private void DoQuery() { ArrayList param = new ArrayList(); if (checkBoxForReqORDER_NO.Checked) { param.Add(this.ctrlForQueryORDER_NO.Value.ToString()); } else { param.Add(""); } if (checkBoxIsRollMonth.Checked) { param.Add("0"); param.Add("0"); } else { param.Add(""); param.Add(""); } if (checkBoxIsNot.Checked) { param.Add("0"); param.Add("0"); } else { param.Add(""); param.Add(""); } param.Add(this.ultraDateTimeImportTime.DateTime.ToString("yyyy-MM-dd")); param.Add(this.ultraDateTimeImportTimeTo.DateTime.ToString("yyyy-MM-dd")); List listSorce = EntityHelper.GetData( "com.steering.pss.plnsaleord.order.CoreOrderStatusSet.queryOrderSetLog", new object[] { param }, this.ob); this.slmbindingSourcePlnSaleordSetEntity.DataSource = listSorce; } /// /// 导入 /// private void DoImport() { try { OpenFileDialog dialog = new OpenFileDialog(); if (dialog.ShowDialog() == DialogResult.OK) { FrmImportSetOrder import = new FrmImportSetOrder(this.ob); import.ModelPatch = dialog.FileName; import.ShowDialog(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } DoQuery(); } /// /// 同步状态 /// private void DoModefiy() { try { ultraGridStatus.UpdateData(); ArrayList list = new ArrayList(); IQueryable checkedRows = ultraGridStatus.Rows.AsQueryable().Where(" CHC = True"); if (checkedRows.Count() == 0) { MessageUtil.ShowTips("未勾选任何行!"); return; } WaitFromOpen(); foreach (UltraGridRow uRow in checkedRows) { PlnSaleordSetEntity entity = new PlnSaleordSetEntity(); entity.UpdateMan = UserInfo.GetUserName(); entity.EndStatus = ultraComboOrderStatusSet.Value.ToString(); entity.PlnDivideId = uRow.Cells["PlnDivideId"].Value.ToString(); entity.OrdLnDlyPk = uRow.Cells["OrdLnDlyPk"].Value.ToString(); list.Add(entity); } CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.pss.plnsaleord.order.CoreOrderStatusSet"; ccp.MethodName = "updateOrderStatus"; ccp.ServerParams = new object[] { list }; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); WaitFromColse(); if (ccp.ReturnCode != -1) { if (MessageUtil.ShowYesNoAndQuestion(ccp.ReturnInfo + "\n是否删除同步记录?") == DialogResult.Yes) { doDelete(); } } else { MessageUtil.ShowTips("同步失败!\n" + ccp.ReturnInfo); } } catch (Exception ex) { WaitFromColse(); if (!(ex is MESException)) { MessageBox.Show(ex.Message); } } DoQuery(); } /// /// 同步考核月份 /// private void doModefiyCheckMoth() { try { ultraGridStatus.UpdateData(); ArrayList list = new ArrayList(); IQueryable checkedRows = ultraGridStatus.Rows.AsQueryable().Where(" CHC = True"); if (checkedRows.Count() == 0) { MessageUtil.ShowTips("未勾选任何行!"); return; } WaitFromOpen(); foreach (UltraGridRow uRow in checkedRows) { PlnSaleordSetEntity entity = new PlnSaleordSetEntity(); entity.UpdateMan = UserInfo.GetUserName(); entity.CheckMoth = uRow.Cells["CheckMoth"].Text.ToString(); entity.PlnDivideId = uRow.Cells["PlnDivideId"].Value.ToString(); entity.OrdLnDlyPk = uRow.Cells["OrdLnDlyPk"].Value.ToString(); list.Add(entity); } CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.pss.plnsaleord.order.CoreOrderStatusSet"; ccp.MethodName = "updateOrderCheckMoth"; ccp.ServerParams = new object[] { list }; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); WaitFromColse(); if (ccp.ReturnCode != -1) { if (MessageUtil.ShowYesNoAndQuestion(ccp.ReturnInfo + "\n是否删除同步记录?") == DialogResult.Yes) { doDelete(); } } else { MessageUtil.ShowTips("同步失败!\n" + ccp.ReturnInfo); } } catch (Exception ex) { WaitFromColse(); if (!(ex is MESException)) { MessageBox.Show(ex.Message); } } DoQuery(); } /// /// 同步月份 /// private void DoModefiyMonth() { try { int defailNum = 0; ultraGridStatus.UpdateData(); string messageErr = ""; ArrayList list = new ArrayList(); IQueryable checkedRows = ultraGridStatus.Rows.AsQueryable().Where(" CHC = True"); if (checkedRows.Count() == 0) { MessageUtil.ShowTips("未勾选任何行!"); return; } WaitFromOpen(); foreach (UltraGridRow uRow in checkedRows) { PlnSaleordSetEntity entity = new PlnSaleordSetEntity(); DateTime date = new DateTime(); if (DateTime.TryParseExact(uRow.Cells["RollMonth"].Value.ToString(), "yyyy-MM", null, DateTimeStyles.None, out date)) { entity.RollMonth = date.ToString("yyyy-MM"); } else { messageErr = "月份格式有误!"; defailNum++; continue; } entity.IfSetMonth = "1"; entity.PlnDivideId = uRow.Cells["PlnDivideId"].Value.ToString(); entity.OrdLnDlyPk = uRow.Cells["OrdLnDlyPk"].Value.ToString(); list.Add(entity); } if (list.Count <= 0) { WaitFromColse(); MessageUtil.ShowTips("0条同步成功," + defailNum + "条同步失败。" + messageErr); return; } CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.pss.plnsaleord.order.CoreOrderStatusSet"; ccp.MethodName = "updateOrderStatusMonth"; ccp.ServerParams = new object[] { list }; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); WaitFromColse(); if (ccp.ReturnCode != -1) { if (MessageUtil.ShowYesNoAndQuestion(list.Count + "条同步成功," + defailNum + "条同步失败。\n" + messageErr + "\n是否删除同步记录?") == DialogResult.Yes) { doDelete(); } } else { MessageUtil.ShowTips("同步失败!"); } } catch (Exception ex) { WaitFromColse(); if (!(ex is MESException)) { MessageBox.Show(ex.Message); } } DoQuery(); } /// /// 同步生产分类 /// //private void DoModefiyProSort() //{ // try // { // ultraGridStatus.UpdateData(); // ArrayList list = new ArrayList(); // IQueryable checkedRows = ultraGridStatus.Rows.AsQueryable().Where(" CHC = True"); // if (checkedRows.Count() == 0) // { // MessageUtil.ShowTips("未勾选任何行!"); // return; // } // WaitFromOpen(); // foreach (UltraGridRow uRow in checkedRows) // { // PlnSaleordSetEntity entity = new PlnSaleordSetEntity(); // entity.ProduceSort = uRow.Cells["ProduceSort"].Value.ToString(); // entity.OrderNoSeq = uRow.Cells["OrderNoSeq"].Value.ToString(); // entity.OrdLnDlyPk = uRow.Cells["OrdLnDlyPk"].Value.ToString(); // list.Add(entity); // } // int succed = ServerHelper.SetData("com.steering.pss.plnsaleord.order.CoreOrderStatusSet.updateProSort", // new object[] { list }, this.ob); // WaitFromColse(); // if (succed > 0) // { // if (MessageUtil.ShowYesNoAndQuestion("同步成功!\n是否删除同步记录?") == DialogResult.Yes) // { // doDelete(); // } // } // else // { // MessageUtil.ShowTips("同步失败!"); // } // } // catch (Exception ex) // { // WaitFromColse(); // if (ex is MESException) // { // } // else // { // MessageBox.Show(ex.Message); // } // } // DoQuery(); //} /// /// 同步来源 /// //private void DoModefiyOrderFrom() //{ // try // { // ultraGridStatus.UpdateData(); // ArrayList list = new ArrayList(); // IQueryable checkedRows = ultraGridStatus.Rows.AsQueryable().Where(" CHC = True"); // if (checkedRows.Count() == 0) // { // MessageUtil.ShowTips("未勾选任何行!"); // return; // } // WaitFromOpen(); // foreach (UltraGridRow uRow in checkedRows) // { // PlnSaleordSetEntity entity = new PlnSaleordSetEntity(); // entity.Orderfrom = uRow.Cells["Orderfrom"].Value.ToString(); // entity.OrderNoSeq = uRow.Cells["OrderNoSeq"].Value.ToString(); // entity.OrdLnDlyPk = uRow.Cells["OrdLnDlyPk"].Value.ToString(); // list.Add(entity); // } // int succed = ServerHelper.SetData("com.steering.pss.plnsaleord.order.CoreOrderStatusSet.updateOrderfrom", // new object[] { list }, this.ob); // WaitFromColse(); // if (succed > 0) // { // if (MessageUtil.ShowYesNoAndQuestion("同步成功!\n是否删除同步记录?") == DialogResult.Yes) // { // doDelete(); // } // } // else // { // MessageUtil.ShowTips("同步失败!"); // } // } // catch (Exception ex) // { // WaitFromColse(); // if (ex is MESException) // { // } // else // { // MessageBox.Show(ex.Message); // } // } // DoQuery(); //} /// /// 删除 /// private void doDelete() { try { ultraGridStatus.UpdateData(); ArrayList list = new ArrayList(); IQueryable checkedRows = ultraGridStatus.Rows.AsQueryable().Where(" CHC = True"); if (checkedRows.Count() == 0) { MessageUtil.ShowTips("未勾选任何行!"); return; } WaitFromOpen(); foreach (UltraGridRow uRow in checkedRows) { PlnSaleordSetEntity entity = new PlnSaleordSetEntity(); entity.PlnDivideId = uRow.Cells["PlnDivideId"].Value.ToString(); entity.OrdLnDlyPk = uRow.Cells["OrdLnDlyPk"].Value.ToString(); list.Add(entity); } int succed = ServerHelper.SetData("com.steering.pss.plnsaleord.order.CoreOrderStatusSet.deleteOrderStatus", new object[] { list }, this.ob); WaitFromColse(); if (succed > 0) { MessageUtil.ShowTips("删除成功!"); } else { MessageUtil.ShowTips("删除失败!"); } } catch (Exception ex) { WaitFromColse(); if (!(ex is MESException)) { MessageBox.Show(ex.Message); } } } /// /// 紧急度修改 /// private void doModifyPrio() { try { int defailNum = 0; string messageErr = ""; this.ultraGridStatus.UpdateData(); ArrayList list = new ArrayList(); IQueryable checkRows = ultraGridStatus.Rows.AsQueryable().Where("CHC = 'True'"); if (checkRows.Count() == 0) { MessageUtil.ShowTips("未勾选任何合同!"); return; } PlanComm.WaitFromOpen(this.Cursor); foreach (UltraGridRow uRow in checkRows) { ArrayList param = new ArrayList(); DataTable dtStatus = ServerHelper.GetData("com.steering.pss.plnsaleord.order.CorePlnOrdPriority.querySaleStatus", new object[] { uRow.Cells["OrdLnDlyPk"].Value.ToString(), uRow.Cells["PlnDivideId"].Value.ToString() }, this.ob); if (dtStatus == null || dtStatus.Rows.Count <= 0) { defailNum++; messageErr = "未找到" + uRow.Cells["OrderNoSeq"].Value.ToString() + "/" + uRow.Cells["DeliveryNo"].Value.ToString() + "的记录!"; continue; } param.Add(uRow.Cells["Priority"].Value.ToString()); param.Add(uRow.Cells["PriorityMemo"].Value.ToString()); param.Add(uRow.Cells["OrdLnDlyPk"].Value.ToString()); param.Add(uRow.Cells["PlnDivideId"].Value.ToString()); param.Add(uRow.Cells["Priority"].Value.ToString()); param.Add(uRow.Cells["PriorityMemo"].Value.ToString()); param.Add(uRow.Cells["OrdLnDlyPk"].Value.ToString()); param.Add(uRow.Cells["Priority"].Value.ToString()); param.Add(uRow.Cells["PriorityMemo"].Value.ToString()); param.Add(uRow.Cells["OrdLnDlyPk"].Value.ToString()); param.Add(uRow.Cells["Priority"].Value.ToString()); param.Add(uRow.Cells["PriorityMemo"].Value.ToString()); param.Add(uRow.Cells["OrdLnDlyPk"].Value.ToString()); param.Add(uRow.Cells["Priority"].Value.ToString()); param.Add(uRow.Cells["PriorityMemo"].Value.ToString()); param.Add(uRow.Cells["OrdLnDlyPk"].Value.ToString()); list.Add(param); } if (list.Count == 0) { PlanComm.WaitFromColse(this.Cursor); MessageUtil.ShowTips("0条保存成功," + defailNum + "条保存失败。\n" + messageErr); return; } int succeed = ServerHelper.SetData("com.steering.pss.plnsaleord.order.CorePlnOrdPriority.savePlnOrdPriority", new object[] { list }, this.ob); PlanComm.WaitFromColse(this.Cursor); if (succeed > 0) { if (defailNum == 0) { if (MessageUtil.ShowYesNoAndQuestion("保存成功,共" + list.Count + "条。" + "\n是否删除同步记录?") == DialogResult.Yes) { doDelete(); } } else { MessageUtil.ShowTips(list.Count + "条保存成功," + defailNum + "条保存失败。\n" + messageErr); } } } catch (Exception ex) { PlanComm.WaitFromColse(this.Cursor); if (!(ex is MESException)) { MessageUtil.ShowError(ex.Message); } } DoQuery(); } private void checkBoxForReqORDER_NO_CheckedChanged(object sender, EventArgs e) { if (checkBoxForReqORDER_NO.Checked) { ctrlForQueryORDER_NO.Enabled = true; } else { ctrlForQueryORDER_NO.Enabled = false; } } private void ultraDateTimeImportTime_ValueChanged(object sender, EventArgs e) { ultraDateTimeImportTimeTo.MinDate = ultraDateTimeImportTime.DateTime.Date; } private void ultraDateTimeImportTimeTo_ValueChanged(object sender, EventArgs e) { ultraDateTimeImportTime.MaxDate = ultraDateTimeImportTimeTo.DateTime.AddDays(1).Date.AddSeconds(-1); } private void ultraGridStatus_AfterSelectChange(object sender, AfterSelectChangeEventArgs e) { foreach (UltraGridRow uRow in ultraGridStatus.Selected.Rows) { if (uRow.GetType() != typeof(Infragistics.Win.UltraWinGrid.UltraGridGroupByRow)) { uRow.Cells["CHC"].Value = true; } } } /// /// 等待窗口 /// private void WaitFromOpen() { this.Cursor = Cursors.WaitCursor; //控制鼠标的样式为等待 if (Constant.WaitingForm == null) { Constant.WaitingForm = new WaitingForm(); } Constant.WaitingForm.ShowToUser = true; Constant.WaitingForm.Show(); Constant.WaitingForm.Update(); } /// /// 关闭等待 /// private void WaitFromColse() { this.Cursor = Cursors.Default; Constant.WaitingForm.ShowToUser = false; Constant.WaitingForm.Close(); Constant.WaitingForm = null; } } }