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; using Core.Mes.Client.Comm.Control; 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 Core.StlMes.Client.PlnSaleOrd.工序排产; using Core.StlMes.Client.PlnSaleOrd.高新.entity; using CoreFS.CA06; using Infragistics.Win; using Infragistics.Win.UltraWinEditors; using Infragistics.Win.UltraWinGrid; using Core.StlMes.Client.PlnSaleOrd.OrderManage.froms; using Newtonsoft.Json; using Core.StlMes.Client.PlnSaleOrd.窗体; using Core.Mes.Client.Comm; using Core.StlMes.Client.PlnSaleOrd.PopupWindow; using Core.StlMes.Client.PlnSaleOrd.炉计划.Entity; using Core.StlMes.Client.PlnSaleOrd.炉计划.Tool; namespace Core.StlMes.Client.PlnSaleOrd { ///custominfo==0 表示轧管排产查询界面 /// /// 加工高新 /// public partial class FrmHeatProductionMesGXRZ : FrmBase { private string departm = "";//获取部门ID private string[] plineCode = null;//获取产线代码 /// /// 订单编号 /// private string _ProPlanId = ""; DataTable dtPlinGroup = null; /// /// 排产序号 /// private string _GxPlanNo = ""; UltraComboEditor uceDimaM = new UltraComboEditor();//芯棒直径 /// /// 行首背景色 /// private Color _backColor = new Color(); string proPlanId = ""; string gxPlanNo = ""; /// /// 调整行集合 /// private ArrayList _entityList = null; public FrmHeatProductionMesGXRZ() { InitializeComponent(); this.IsLoadUserView = true; } public override void ToolBar_Click(object sender, string ToolbarKey) { base.ToolBar_Click(sender, ToolbarKey); switch (ToolbarKey) { case "Query"://查询 Query(); break; case "Recalculate"://设置高新 Recalculate(); break; case "Recalculate2"://撤销高新 Recalculate2(); break; case "Export": //导出 //GridHelper.ulGridToExcel(ultraJGGX, "热处理高新"); ExportData(); break; case "Close": //关闭 this.Close(); break; default: break; } } /// /// 导出 /// private void ExportData() { GridHelper.ulGridToExcel(ultraJGGX, "热轧高新"); } private void FrmPlnOrderZgS_Load(object sender, EventArgs e) { if (CustomInfo == null) { CustomInfo = ""; } //设置列头名称 EntityHelper.ShowGridCaption(ultraJGGX.DisplayLayout.Bands[0]); if (CustomInfo == "0") { PlanComm.setGridActivation(this.ultraJGGX.DisplayLayout.Bands[0], "CHC");//, "OutsBilletFl" } else { BaseHelper.setOtherColumnReadOnly(ultraJGGX, new string[] { "CHC", "HighProdWeight", "HighMateWeight", "EstimatedUnitPrice", "EstimatedCost", "HighTechCode" }); //tzh 后续改颜色 BaseHelper.setColumnBackColor(ultraJGGX, new string[] { "HighProdWeight", "HighMateWeight", "EstimatedUnitPrice", "EstimatedCost", "HighTechCode" }); //BaseHelper.setOtherColumnReadOnly(ultraJGGX, new string[] { "CHC"}); //BaseHelper.setOtherColumnReadOnly(ultraRCLGX, new string[] { "CHC", "Mgcd", "DiameterMandrel", "Zzcd", "Ggfqs", "Cpcd", "Qt", "Qw", "Bcs", "Dbcplcd", "Gpzj", "WgH", "WgD", "QuantityPurchased", "RulerLength", "Ssl", "Mz", "Jhlc" }); //tzh 后续改颜色 // BaseHelper.setColumnBackColor(ultraRCLGX, new string[] { "Pass", "Mgcd", "DiameterMandrel", "Zzcd", "Ggfqs", "Cpcd", "Qt", "Qw", "Bcs", "Dbcplcd", "Gpzj", "WgH", "WgD", "HtcgzlMax", "HtcgzlMin", "QuantityPurchased", "RulerLength", "Dbcplzl", "Ssl", "Mz", "Jhlc", "Zzzl", "Zzcd", "Dbcplcd", "QuantityPurchased" }); //BaseHelper.setColumnBackColor2(ultraGridZgS, new string[] { "Mgbh", "Mgwj" }); } //BaseHelper.SetGroupBySum(ultraJGGX, new string[] { "HighMateWeight", "EstimatedCost" }, "CxNo"); //if (CustomInfo != "0") { BaseHelper.ForbidSort(ultraJGGX); } _backColor = ultraJGGX.DisplayLayout.Override.RowSelectorAppearance.BackColor; InitColorStyle(); BaseHelper.GridColumnSum(ultraJGGX, new string[] { "HighMateWeight", "EstimatedCost", "ProdWeight", "MateWeight", "SteelWaste", "EstimatedUnitPrice" }); } /// /// 初始化列状态 /// 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; } decisionFlsg(false); } private void decisionFlsg( Boolean b) { //if (b) //{ // UltraComboEditor uceAbc = new UltraComboEditor(); // ultraJGGX.DisplayLayout.Bands[0].Columns["Pass"].EditorComponent = uceAbc; // ultraJGGX.DisplayLayout.Bands[0].Columns["Pass"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList; // ultraJGGX.DisplayLayout.Bands[0].Columns["DiameterMandrel"].EditorComponent = uceAbc; // ultraJGGX.DisplayLayout.Bands[0].Columns["DiameterMandrel"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList; // ValueList vlistSteel1 = new ValueList(); ; // vlistSteel1.ValueListItems.Insert(0, "1", "1"); // vlistSteel1.ValueListItems.Insert(1, "2", "2"); // vlistSteel1.ValueListItems.Insert(2, "3", "3"); // vlistSteel1.ValueListItems.Insert(3, "4", "4"); // vlistSteel1.ValueListItems.Insert(4, "5", "5"); // vlistSteel1.ValueListItems.Insert(5, "6", "6"); // ultraJGGX.DisplayLayout.Bands[0].Columns["Ggfqs"].ValueList = vlistSteel1; // ultraJGGX.DisplayLayout.Bands[0].Columns["Ggfqs"].CellActivation = Activation.AllowEdit; // ultraJGGX.DisplayLayout.Bands[0].Columns["Bcs"].ValueList = vlistSteel1; // ultraJGGX.DisplayLayout.Bands[0].Columns["Bcs"].CellActivation = Activation.AllowEdit; // DataTable dt = ServerHelper.GetData("com.steering.pss.plnsaleord.processOrder.base.ProducHelper.queryMandrelSpec", // new object[] { "1" }, this.ob); // if (dt != null && dt.Rows.Count > 0) // { // ValueList vlistSteel = PlanComm.GeneralValuelist(ref dt, "XX", "XX"); // //vlistSteel.ValueListItems.Insert(0, "", ""); // ultraJGGX.DisplayLayout.Bands[0].Columns["DiameterMandrel"].ValueList = vlistSteel; // ultraJGGX.DisplayLayout.Bands[0].Columns["DiameterMandrel"].CellActivation = Activation.AllowEdit; // } // DataTable dt1 = ServerHelper.GetData("com.steering.pss.plnsaleord.processOrder.base.ProducHelper.queryMandrelSpec", // new object[] { "2" }, this.ob); // if (dt1 != null && dt1.Rows.Count > 0) // { // ValueList vlistSteel = PlanComm.GeneralValuelist(ref dt1, "XX", "XX"); // //vlistSteel.ValueListItems.Insert(0, "", ""); // ultraJGGX.DisplayLayout.Bands[0].Columns["Pass"].ValueList = vlistSteel; // ultraJGGX.DisplayLayout.Bands[0].Columns["Pass"].CellActivation = Activation.AllowEdit; // } // DataTable dt2 = ServerHelper.GetData("com.steering.pss.plnsaleord.processOrder.base.ProducHelper.queryMandrelSpec", // new object[] { "3" }, this.ob); // if (dt2 != null && dt2.Rows.Count > 0) // { // ValueList vlistSteel = PlanComm.GeneralValuelist(ref dt2, "XX", "XX"); // //vlistSteel.ValueListItems.Insert(0, "", ""); // ultraJGGX.DisplayLayout.Bands[0].Columns["Mgwj"].ValueList = vlistSteel; // ultraJGGX.DisplayLayout.Bands[0].Columns["Mgwj"].CellActivation = Activation.AllowEdit; // } // DataTable dt3 = ServerHelper.GetData("com.steering.pss.plnsaleord.processOrder.base.ProducHelper.queryMandrelSpec", // new object[] { "4" }, this.ob); // if (dt3 != null && dt3.Rows.Count > 0) // { // ValueList vlistSteel = PlanComm.GeneralValuelist(ref dt3, "XX", "XX"); // //vlistSteel.ValueListItems.Insert(0, "", ""); // ultraJGGX.DisplayLayout.Bands[0].Columns["Mgbh"].ValueList = vlistSteel; // ultraJGGX.DisplayLayout.Bands[0].Columns["Mgbh"].CellActivation = Activation.AllowEdit; // } //} DataTable dt = ServerHelper.GetData("com.steering.pss.plnsaleord.GpOptimize.CorePlnZgMStoGp.queryCXcode", new object[] { "1" }, this.ob); if (dt != null && dt.Rows.Count > 0) { ValueList vlistSteel = PlanComm.GeneralValuelist(ref dt, "GX_CODE", "GX_NAME"); ultraJGGX.DisplayLayout.Bands[0].Columns["HighTechCode"].ValueList = vlistSteel; ultraJGGX.DisplayLayout.Bands[0].Columns["HighTechCode"].CellActivation = Activation.AllowEdit; } } private void InitTime() { DateTime now = DateTime.Now; DateTime d1 = new DateTime(now.Year, now.Month, 1); DateTime d2 = d1.AddMonths(1).AddSeconds(-1); } /// /// 查询 /// private void Query() { WaitingForm2 wf3 = new WaitingForm2("正在刷新,请稍候...."); try { this.Cursor = Cursors.WaitCursor; //执行状态 // string[] statusArr = contorlPlanStatus1.statusArr; //查询时间 string acctPeriod = ""; acctPeriod = txtAcctPeriod.Text.Trim(); List listSource = EntityHelper.GetData ("com.steering.pss.plnsaleord.GpOptimize.CorePlnZgMStoGp.selectrzgx", new object[] { acctPeriod }, this.ob); HotHeatProductionMesGxEntityBindingSource.DataSource = listSource; _entityList = null; _ProPlanId = ""; _ProPlanId = ""; } finally { wf3.Close(); this.Cursor = Cursors.Default; } } private void ultraRCLGX_CellChange(object sender, CellEventArgs e) { try { ultraJGGX.UpdateData(); //if (e.Cell.Column.Key.Equals("CHC")) //{ // IQueryable chcRows = ultraJGGX.Rows.AsQueryable().Where(a => a.GetValue("CHC") == "True"); // if (chcRows != null && chcRows.Count() > 0) // { // decisionFlsg(true); // } // else // { // decisionFlsg(false); // } //} foreach (var ultraGridRow in ultraJGGX.Rows) { if ((bool)ultraGridRow.Cells["CHC"].Value) { decimal HighProdWeight = 0; if (ultraGridRow.Cells["HighProdWeight"].Value.ToString() != "") { HighProdWeight = decimal.Parse((ultraGridRow.Cells["HighProdWeight"].Value.ToString()));//高新成品 } decimal HighMateWeight = 0; if (ultraGridRow.Cells["HighMateWeight"].Value.ToString() != "") { HighMateWeight = decimal.Parse(ultraGridRow.Cells["HighMateWeight"].Value.ToString());//高新坯料 } decimal EstimatedUnitPrice = 0; if (ultraGridRow.Cells["HighMateWeight"].Value.ToString() != "" && ultraGridRow.Cells["EstimatedUnitPrice"].Value.ToString() != "") { EstimatedUnitPrice = decimal.Parse(ultraGridRow.Cells["EstimatedUnitPrice"].Value.ToString());//单价 ultraGridRow.Cells["estimatedCost"].Value = HighMateWeight * EstimatedUnitPrice; } decimal ProdWeight = 0; if (ultraGridRow.Cells["ProdWeight"].Value.ToString() != "") { ProdWeight = decimal.Parse((ultraGridRow.Cells["ProdWeight"].Value.ToString()));//正常成品 } decimal MateWeight = 0; if (ultraGridRow.Cells["MateWeight"].Value.ToString() != "") { MateWeight = decimal.Parse(ultraGridRow.Cells["MateWeight"].Value.ToString());//正常来料 } /* if (HighMateWeight > MateWeight) { MessageUtil.ShowTips("高新的来料不能大于正常的来料!"); ultraGridRow.Cells["HighMateWeight"].Value = "0"; }*/ if (HighProdWeight > ProdWeight) { MessageUtil.ShowTips("高新的成品不能大于正常的成品!"); ultraGridRow.Cells["HighProdWeight"].Value = "0"; } if (ultraGridRow.Cells["HighTechCode"].Value.ToString() != "") { ultraGridRow.Cells["HighTechName"].Value = ultraGridRow.Cells["HighTechCode"].Text; } } } } catch (Exception) { } } /// /// 设置高新 /// private void Recalculate() { try { ArrayList messageErr = new ArrayList(); ultraJGGX.UpdateData(); ArrayList list = ProducHelper.GetChcRows(ultraJGGX); if (list == null || list.Count == 0) { MessageUtil.ShowTips("请选择数据!"); return; } ArrayList jsonList = new ArrayList(); foreach (HotProductionMesRZEntity entity in list) { jsonList.Add(JSONFormat.Format(entity)); } if (MessageUtil.ShowYesNoAndQuestion("是否保存高新?") == DialogResult.No) { return; } // PlanComm.WaitFromOpen(this.Cursor); CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.pss.plnsaleord.GpOptimize.CorePlnZgMStoGp"; ccp.MethodName = "recalculateRZ"; ccp.ServerParams = new object[] { jsonList,"1" }; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); //PlanComm.WaitFromColse(this.Cursor); if (ccp.ReturnCode == -1) return; MessageUtil.ShowTips(ccp.ReturnInfo); if (ccp.ReturnInfo.Equals("保存成功!")) { Query(); } } catch (Exception ex) { // PlanComm.WaitFromColse(this.Cursor); if (!(ex is MESException)) { MessageUtil.ShowError(ex.Message); } } } /// /// 撤销高新 /// private void Recalculate2() { try { ArrayList messageErr = new ArrayList(); ultraJGGX.UpdateData(); ArrayList list = ProducHelper.GetChcRows(ultraJGGX); if (list == null || list.Count == 0) { MessageUtil.ShowTips("请选择数据!"); return; } ArrayList jsonList = new ArrayList(); foreach (HotProductionMesRZEntity entity in list) { jsonList.Add(JSONFormat.Format(entity)); } if (MessageUtil.ShowYesNoAndQuestion("是否撤销高新?") == DialogResult.No) { return; } // PlanComm.WaitFromOpen(this.Cursor); CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.pss.plnsaleord.GpOptimize.CorePlnZgMStoGp"; ccp.MethodName = "recalculateRZ"; ccp.ServerParams = new object[] { jsonList,"0" }; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); // PlanComm.WaitFromColse(this.Cursor); if (ccp.ReturnCode == -1) return; MessageUtil.ShowTips(ccp.ReturnInfo); if (ccp.ReturnInfo.Equals("保存成功!")) { Query(); } } catch (Exception ex) { // PlanComm.WaitFromColse(this.Cursor); if (!(ex is MESException)) { MessageUtil.ShowError(ex.Message); } } } } }