using com.steering.pss.plnsaleord.order.model; using Core.Mes.Client.Comm.Format; using Core.Mes.Client.Comm.Server; using Core.Mes.Client.Comm.Tool; using Core.StlMes.Client.PlnSaleOrd.BaseMethod; using CoreFS.CA06; using CoreFS.SA06; using Infragistics.Win.UltraWinEditors; using Infragistics.Win.UltraWinGrid; using Newtonsoft.Json; 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.PlnSaleOrd.PopupWindow { public partial class FrmCalculateDbk : FrmBase { public bool isChange = false; private List procEntity = null; public FrmCalculateDbk(List _procEntity, OpeBase _ob) { this.IsLoadUserView = true; this.ob = _ob; procEntity = _procEntity; InitializeComponent(); EntityHelper.ShowGridCaption(ultraGridDbk.DisplayLayout.Bands[0]); } private void FrmCalculateDbk_Load(object sender, EventArgs e) { PlanComm.setGridActivation(ultraGridDbk.DisplayLayout.Bands[0], "CHC", "LenCutheadDbk", "LenCutendDbk", "LenScope"); PlanComm.setGridDigitalCol(ultraGridDbk.DisplayLayout.Bands[0], 5, 3, "RollLength", "AimLenRoll", "AimLenEnd", "AimLenDbk", "InWtDbk", "OutWtDbk", "PlanWtD", "RatioDbk","LenZgCalMax", "LenZgCalMin", "LenDbkCalMax", "LenDbkCalMin", "Lengthmin", "Lengthmax", "LenDbkMin", "LenDbkMax","LenDbkZyMin", "LenDbkZyMax"); PlanComm.setGridDigitalCol(ultraGridDbk.DisplayLayout.Bands[0], 5, 2, "DbkCut", "LenDc", "InspectionValue", "CheckJVal", "HeightOrdMin", "HeightOrdMax", "LenCutheadDbk", "LenCutendDbk", "LenLongerDbk", "Burning", "LenScope"); PlanComm.setGridDigitalCol(ultraGridDbk.DisplayLayout.Bands[0], 5, 0, "PlanNumD", "OutNumDbk", "InNumDbk"); //InitColorStyle(); DoQuery(); } /// /// 初始化列状态 /// private void InitColorStyle() { UltraNumericEditor[] uneArr = new UltraNumericEditor[3]; for (int i = 0; i < uneArr.Length; i++) { uneArr[i] = new UltraNumericEditor(); uneArr[i].NumericType = NumericType.Double; if (i == 1) { uneArr[i].MaskInput = "nnnnn"; } else { uneArr[i].MaskInput = "nnnnn.nn"; } uneArr[i].SpinButtonDisplayStyle = Infragistics.Win.ButtonDisplayStyle.Always; this.Controls.Add(uneArr[i]); uneArr[i].Visible = false; } uneArr[0].SpinIncrement = 0.01; uneArr[1].SpinIncrement = 50; uneArr[2].SpinIncrement = 10; ultraGridDbk.DisplayLayout.Bands[0].Columns["LenCutheadDbk"].EditorComponent = uneArr[1]; ultraGridDbk.DisplayLayout.Bands[0].Columns["LenCutendDbk"].EditorComponent = uneArr[1]; ultraGridDbk.DisplayLayout.Bands[0].Columns["LenLongerDbk"].EditorComponent = uneArr[1]; } private void DoQuery() { List listSource = new List(); PlanComm.WaitFromOpen(this.Cursor); CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.pss.plnsaleord.order.CoreCalculateDbk"; ccp.MethodName = "getDbkInoutInf"; ccp.ServerParams = new object[] { procEntity }; ccp = this.ExecuteSortResultByQueryToDataTable(ccp, CoreInvokeType.Internal); if (ccp == null || ccp.ReturnObject == null) { PlanComm.WaitFromColse(this.Cursor); MessageBox.Show("服务端处理失败!"); return; } PlanComm.WaitFromColse(this.Cursor); listSource = (List)JsonConvert.DeserializeObject( ccp.ReturnObject.ToString(), typeof(List)); bindingSourcePlnDkbInfo.DataSource = listSource; return; } private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e) { switch (e.Tool.Key) { case "DoQuery": DoQuery(); break; case "ModifyDbkInSpec": DoChangeBom(); break; case "ModifyBaseMaterial": ModifyBaseMaterial(); break; case "SaveLenRoll": SaveLenRoll(); break; case "ReashCal": RefresCal(); break; case "ConfirmDbk": DoConfirmDbk(); break; case "ConcelDbk": ConcelConfirmDbk(); break; case "Export": PlanComm.Export(ref ultraGridDbk, "镦拔扩投入产出信息" + DateTime.Now.ToString("yyyy-MM-dd")); break; case "Close": this.Close(); break; } } /// /// 保存切头尾,镦粗加长(m) /// private void SaveLenRoll() { ultraGridDbk.UpdateData(); ArrayList errMessage = new ArrayList(); ArrayList list = new ArrayList(); IQueryable uRows = ultraGridDbk.Rows.AsQueryable().Where( a => a.Cells["CHC"].Value.ToString().Equals("True")); if (uRows.Count() == 0) { MessageUtil.ShowTips("未勾选任何行!"); return; } List listId = new List(); foreach (UltraGridRow urow in uRows) { DataTable dt = ServerHelper.GetData("com.steering.pss.plnsaleord.order.CoreCalculateDbk.queryPlnOrdInfo", new object[] { urow.Cells["OrdLnDlyPk"].Value.ToString(), urow.Cells["PlnDivideId"].Value.ToString() }, this.ob); if (dt == null || dt.Rows.Count <= 0) { errMessage.Add("合同:" + urow.Cells["OrderNoSeq"].Value.ToString() + "/" + urow.Cells["DeliveryNo"].Value.ToString() + "未找到排产记录。"); continue; } if (!dt.Rows[0]["PLANSTATUS"].ToString().Equals("1")) { errMessage.Add("合同:" + urow.Cells["OrderNoSeq"].Value.ToString() + "/" + urow.Cells["DeliveryNo"].Value.ToString() + "已经下发。"); continue; } PlnSaleordProcEntity ordProcEntity = new PlnSaleordProcEntity(); ordProcEntity.LenRollMin = urow.Cells["LenZgCalMin"].Value.ToString(); ordProcEntity.LenRollMax = urow.Cells["LenZgCalMax"].Value.ToString(); ordProcEntity.LenCutendDbk = urow.Cells["LenCutheadDbk"].Value.ToString(); ordProcEntity.LenCutendDbk =urow.Cells["LenCutendDbk"].Value.ToString(); ordProcEntity.LenCutendDbk = urow.Cells["LenLongerDbk"].Value.ToString(); ordProcEntity.OrdLnDlyPk = urow.Cells["OrdLnDlyPk"].Value.ToString(); ordProcEntity.PlnDivideId = urow.Cells["PlnDivideId"].Value.ToString(); ordProcEntity.LenScope = urow.Cells["LenScope"].Value.ToString(); list.Add(ordProcEntity); listId.Add(ordProcEntity); } if (list.Count == 0) { MessageUtil.ShowTips("保存失败,共" + errMessage.Count + "条。\n" + errMessage[0]); return; } int suceed = ServerHelper.SetData("com.steering.pss.plnsaleord.order.CoreCalculateDbk.saveLenRoll", new object[] { list }, this.ob); if (suceed > 0) { if (errMessage.Count == 0) { MessageUtil.ShowTips("保存成功,共" + list.Count + "条。"); } else { MessageUtil.ShowTips(list.Count + "条保存成功," + errMessage.Count + "条保存失败。\n" + errMessage[0]); } } DoQueryId(listId); } /// /// 小事能力维护 /// private void ModifyBaseMaterial() { UltraGridRow ugr = ultraGridDbk.ActiveRow; if (ugr == null) { return; } string eInMaterialNo = ugr.Cells["EInMaterialNo"].Value.ToString(); string eOutMaterialNo = ugr.Cells["EOutMaterialNo"].Value.ToString(); string bjType = ugr.Cells["BjType"].Value.ToString(); string bjPine = ""; DataTable dt = ServerHelper.GetData("com.steering.pss.plnsaleord.order.CoreCalculateDbk.selectBjPine", new object[] { bjType }, this.ob); if (dt != null && dt.Rows.Count > 0) { bjPine = dt.Rows[0]["PLINE_CODE"].ToString(); } FrmBaseMaterialEPl eBaseMtPl = new FrmBaseMaterialEPl(eInMaterialNo, eOutMaterialNo, bjPine, this.ob); eBaseMtPl.ShowDialog(); DoQuery(); } /// /// 默认产线Bom更改 /// private void DoChangeBom() { UltraGridRow ugr = ultraGridDbk.ActiveRow; if (ugr == null) { return; } DataTable dt = ServerHelper.GetData("com.steering.pss.plnsaleord.order.CoreCalculateDbk.queryPlnOrdInfo", new object[] { ugr.Cells["OrdLnDlyPk"].Value.ToString(), ugr.Cells["PlnDivideId"].Value.ToString() }, this.ob); if (dt != null && dt.Rows.Count > 0) { if (!dt.Rows[0]["PLANSTATUS"].ToString().Equals("1")) { MessageUtil.ShowTips("合同:" + ugr.Cells["OrderNoSeq"].Value.ToString() + "/" + ugr.Cells["DeliveryNo"].Value.ToString() + "已经下发。"); return; } FrmChangeBomDp changeBomDp = new FrmChangeBomDp(ugr.Cells["OrdLnDlyPk"].Value.ToString(), ugr.Cells["PlnDivideId"].Value.ToString(), this.ob); changeBomDp.Custom = "Dbk"; changeBomDp.ShowDialog(); PlnSaleordProcEntity procEntity = new PlnSaleordProcEntity(); procEntity.OrdLnDlyPk = ugr.Cells["OrdLnDlyPk"].Value.ToString(); procEntity.PlnDivideId = ugr.Cells["PlnDivideId"].Value.ToString(); DoQueryId(new List { procEntity }); isChange = true; } } private void DoQueryId(List listId) { UltraGridRow ugr = ultraGridDbk.ActiveRow; List listSource = new List(); CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.pss.plnsaleord.order.CoreCalculateDbk"; ccp.MethodName = "getDbkInoutInf"; ccp.ServerParams = new object[] { listId }; ccp = this.ExecuteSortResultByQueryToDataTable(ccp, CoreInvokeType.Internal); if (ccp == null || ccp.ReturnObject == null) { PlanComm.WaitFromColse(this.Cursor); MessageBox.Show("服务端处理失败!"); return; } listSource = (List)JsonConvert.DeserializeObject( ccp.ReturnObject.ToString(), typeof(List)); List listSource2 = (List)bindingSourcePlnDkbInfo.DataSource; PlnDbkInOutInfoEntity[] querayable = new PlnDbkInOutInfoEntity[listId.Count]; for (int i = 0; i < listId.Count;i++ ) { PlnDbkInOutInfoEntity[] temp = listSource2.AsQueryable().Where(a => a.OrdLnDlyPk == listId[i].OrdLnDlyPk && a.PlnDivideId == listId[i].PlnDivideId).ToArray(); if (temp.Count() > 0) { querayable[i] = temp[0]; } } if (querayable.Length > 0) { int number = listSource2.IndexOf(querayable[0]); for (int i = 0; i < querayable.Length; i++) { listSource2.Remove(querayable[i]); } for (int i = listSource.Count - 1; i >= 0; i--) { bindingSourcePlnDkbInfo.Insert(number, listSource[i]); } } ultraGridDbk.Refresh(); if (ugr != null) { ultraGridDbk.ActiveRow = ugr; } } /// /// 重算 /// private void RefresCal() { ultraGridDbk.UpdateData(); ArrayList errMessage = new ArrayList(); IQueryable uRows = ultraGridDbk.Rows.AsQueryable().Where(" CHC = 'True' "); if (uRows.Count() == 0) { MessageUtil.ShowTips("未勾选任何行!"); return; } List listId = new List(); foreach (UltraGridRow urow in uRows) { if (!urow.Cells["BjType"].Text.Equals("镦粗")) { if (urow.Cells["LenCutheadDbk"].Text.ToString().Equals("")) { MessageUtil.ShowTips("拔扩切头为空,请维护基础数据!"); return; } if (urow.Cells["LenCutendDbk"].Text.ToString().Equals("")) { MessageUtil.ShowTips("拔扩切尾为空,请维护基础数据!"); return; } } else { if (urow.Cells["LenLongerDbk"].Text.ToString().Equals("")) { MessageUtil.ShowTips("镦粗加长为空,请维护基础数据!"); return; } } if (urow.Cells["LenScope"].Text.ToString().Equals("")) { MessageUtil.ShowTips("壁厚范围%不能为空!"); return; } PlnSaleordProcEntity procEntity = new PlnSaleordProcEntity(); procEntity.LenScope = urow.Cells["LenScope"].Value.ToString(); procEntity.LenCutheadDbk = urow.Cells["LenCutheadDbk"].Value.ToString(); procEntity.LenCutendDbk = urow.Cells["LenCutendDbk"].Value.ToString(); procEntity.LenLongerDbk = urow.Cells["LenLongerDbk"].Value.ToString(); procEntity.RatioDbk = urow.Cells["RatioDbk"].Value.ToString(); procEntity.Burning = urow.Cells["Burning"].Value.ToString(); procEntity.OrdLnDlyPk = urow.Cells["OrdLnDlyPk"].Value.ToString(); procEntity.PlnDivideId = urow.Cells["PlnDivideId"].Value.ToString(); procEntity.OrderNo = urow.Cells["OrderNoSeq"].Value.ToString(); procEntity.DeliveryNo = urow.Cells["DeliveryNo"].Value.ToString(); listId.Add(procEntity); } CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.pss.plnsaleord.order.CoreCalculateDbk"; ccp.MethodName = "recalculation"; ccp.ServerParams = new object[] { listId }; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode == -1) return; MessageUtil.ShowTips(ccp.ReturnInfo); if (ccp.ReturnInfo.Equals("重算成功!")) { DoQueryId(listId); } //RefreCalData(listId); } /// /// 取消镦拔扩确认 /// private void ConcelConfirmDbk() { ultraGridDbk.UpdateData(); ArrayList messageErr = new ArrayList(); ArrayList errMessage = new ArrayList(); List listId = new List(); IQueryable uRows = ultraGridDbk.Rows.AsQueryable().Where(" CHC = 'True' "); if (uRows.Count() == 0) { MessageUtil.ShowTips("未勾选任何行!"); return; } foreach (UltraGridRow urow in uRows) { PlnSaleordProcEntity procEntity = new PlnSaleordProcEntity(); procEntity.OrdLnDlyPk = urow.Cells["OrdLnDlyPk"].Value.ToString(); procEntity.PlnDivideId = urow.Cells["PlnDivideId"].Value.ToString(); procEntity.OrderNo = urow.Cells["OrderNoSeq"].Value.ToString(); procEntity.DeliveryNo = urow.Cells["DeliveryNo"].Value.ToString(); DataTable dtStatus = ServerHelper.GetData("com.steering.pss.plnsaleord.order.CoreCalculateDbk.queryPlnOrdInfo", new object[] { procEntity.OrdLnDlyPk, procEntity.PlnDivideId }, this.ob); if (dtStatus == null || dtStatus.Rows.Count <= 0) { messageErr.Add(""); continue; } if (dtStatus.Rows[0]["PLANSTATUS"].ToString().Equals("1")) { if (dtStatus.Rows[0]["E_IS_OK"].ToString().Equals("0")) { messageErr.Add("合同:" + procEntity.OrderNo + "/" + procEntity.DeliveryNo + "镦拔扩还未确认。"); continue; } procEntity.EIsOk = "0"; listId.Add(procEntity); } else { messageErr.Add("合同:" + procEntity.OrderNo + "/" + procEntity.DeliveryNo + "已经下发。"); continue; } } if (listId.Count == 0) { MessageUtil.ShowTips("取消确认失败,共" + messageErr.Count + "条。\n" + messageErr[0]); return; } CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.pss.plnsaleord.order.CoreCalculateDbk"; ccp.MethodName = "confirmDbk"; ccp.ServerParams = new object[] { listId }; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { if (messageErr.Count == 0) { MessageUtil.ShowTips("取消确认成功,共" + listId.Count + "条。"); } else { MessageUtil.ShowTips(listId.Count + "条取消确认成功," + messageErr.Count + "条取消确认失败。\n" + messageErr[0]); } } isChange = true; DoQueryId(listId); } /// /// 镦拔扩确认 /// private void DoConfirmDbk() { ultraGridDbk.UpdateData(); ArrayList messageErr = new ArrayList(); ArrayList errMessage = new ArrayList(); List listId = new List(); IQueryable uRows = ultraGridDbk.Rows.AsQueryable().Where(" CHC = 'True' "); if (uRows.Count() == 0) { MessageUtil.ShowTips("未勾选任何行!"); return; } foreach (UltraGridRow urow in uRows) { PlnSaleordProcEntity procEntity = new PlnSaleordProcEntity(); procEntity.OrdLnDlyPk = urow.Cells["OrdLnDlyPk"].Value.ToString(); procEntity.PlnDivideId = urow.Cells["PlnDivideId"].Value.ToString(); procEntity.OrderNo = urow.Cells["OrderNoSeq"].Value.ToString(); procEntity.DeliveryNo = urow.Cells["DeliveryNo"].Value.ToString(); DataTable dtStatus = ServerHelper.GetData("com.steering.pss.plnsaleord.order.CoreCalculateDbk.queryPlnOrdInfo", new object[] { procEntity.OrdLnDlyPk, procEntity.PlnDivideId }, this.ob); if (dtStatus == null || dtStatus.Rows.Count <= 0) { messageErr.Add(""); continue; } if (dtStatus.Rows[0]["PLANSTATUS"].ToString().Equals("1")) { if (dtStatus.Rows[0]["E_IS_OK"].ToString().Equals("1")) { messageErr.Add("合同:" + procEntity.OrderNo + "/" + procEntity.DeliveryNo + "已经确认过了。"); continue; } procEntity.EIsOk = "1"; listId.Add(procEntity); } else { messageErr.Add("合同:" + procEntity.OrderNo + "/" + procEntity.DeliveryNo + "已经下发。"); continue; } } if (listId.Count == 0) { MessageUtil.ShowTips("确认失败,共" + messageErr.Count + "条。\n" + messageErr[0]); return; } CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.pss.plnsaleord.order.CoreCalculateDbk"; ccp.MethodName = "confirmDbk"; ccp.ServerParams = new object[] { listId }; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { if (messageErr.Count == 0) { MessageUtil.ShowTips("确认成功,共" + listId.Count + "条。"); } else { MessageUtil.ShowTips(listId.Count + "条确认成功," + messageErr.Count + "条确认失败。\n" + messageErr[0]); } } isChange = true; DoQueryId(listId); } /// /// 调用重算方法 /// /// public void RefreCalData(List listId) { ArrayList errMessage = new ArrayList(); PlanComm.WaitFromOpen(this.Cursor); try { foreach (PlnSaleordProcEntity procEntity in listId) { string message = ""; string ordNo = procEntity.OrderNo + "/" + procEntity.OrderSeq + "/" + procEntity.DeliveryNo; if (!PlnOrdProcRefresCal.RefresCal(procEntity.OrdLnDlyPk, procEntity.PlnDivideId, this.ob, out message)) { errMessage.Add(ordNo + message); } } PlanComm.WaitFromColse(this.Cursor); if (errMessage.Count == listId.Count) { MessageUtil.ShowTips("重算失败!\n" + errMessage[0]); } else if (errMessage.Count != 0) { MessageUtil.ShowTips((listId.Count - errMessage.Count) + "条重算成功," + errMessage.Count + "条重算失败!\n" + errMessage[0]); } else { MessageUtil.ShowTips("重算成功。"); } } catch (Exception e) { PlanComm.WaitFromColse(this.Cursor); MessageBox.Show(e.Message); } } private void ultraGridDbk_AfterSelectChange(object sender, AfterSelectChangeEventArgs e) { foreach (UltraGridRow uRow in ultraGridDbk.Selected.Rows) { if (uRow.GetType() != typeof(Infragistics.Win.UltraWinGrid.UltraGridGroupByRow)) { uRow.Cells["CHC"].Value = true; } } } } }