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.GlBusiness.Models; using CoreFS.CA06; using Infragistics.Win; 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.Threading.Tasks; using System.Windows.Forms; namespace Core.StlMes.Client.GlBusiness { public partial class FrmTHOrderManage : FrmBase { public FrmTHOrderManage() { InitializeComponent(); EntityHelper.ShowGridCaption(ultraGrid1.DisplayLayout.Bands[0]); this.IsLoadUserView = true; } private void FrmTHOrderManage_Load(object sender, EventArgs e) { //默认查询当前日期-1月——当前日期数据。 udtStart.DateTime = Convert.ToDateTime(DateTime.Now.AddMonths(-1).ToShortDateString()); udtEnd.DateTime = Convert.ToDateTime(DateTime.Now.ToShortDateString()); if (this.CustomInfo.ToString2().Equals("123504")) { ultraGrid1.DisplayLayout.Bands[0].Columns["thOrderNoSeq"].CellAppearance.BackColor = Color.FromArgb(255, 255, 128); ultraGrid1.DisplayLayout.Bands[0].Columns["OrderQty"].Hidden=true; ultraGrid1.DisplayLayout.Bands[0].Columns["Lengthdisc"].Hidden = true; } } private void craftImg_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e) { string filePath = ultraGrid1.ActiveRow.GetValue("CraftFileNo"); DataTable dt = ServerHelper.GetData("com.steering.pss.glbusiness.GlOrderManage.getFilePath", new Object[] { filePath }, this.ob); string file = dt.Rows[0]["CRAFT_PATH"].ToString3(); dlgOrderAskDown askDown = new dlgOrderAskDown(this.ob, file); askDown.DeleteButton.Visible = false; askDown.Show(); } public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey) { case "doQuery": doQuery();//查询 break; case "confirm": doConfirm();//确认 break; case "cancel": doCancel();//取消 break; case "updateField": updateField();//修改信息 break; case "updateWeight": updateWeight();//修改重量 break; case "update": doUpdateThOrder();//修改合同 break; case "AddOrder": // 生成合同 doAddOrder(); break; case "Export": doExport(); break; } } private void doAddOrder() { this.ultraGrid1.UpdateData(); IQueryable checkRows = this.ultraGrid1.Rows.AsQueryable().Where(a => a.GetValue("CHK") == "True"); if (checkRows.Count() == 0) { MessageUtil.ShowTips("请选择数据!"); return; } ArrayList list = new ArrayList(); foreach (UltraGridRow row in checkRows) { PlnOrderZgSEntity entity = row.ListObject as PlnOrderZgSEntity; if (!entity.ProductionThFlag.Equals("123506")) { MessageUtil.ShowTips(entity.ProPlanId + ",合同未确认!"); return; } if (!String.IsNullOrEmpty(entity.ThOrderNoSeq)) { MessageUtil.ShowTips(entity.ProPlanId + "天淮合同已存在!"); return; } list.Add(JSONFormat.Format(entity)); } CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.pss.glbusiness.FrmTHOrderManage"; ccp.MethodName = "doAddOrder"; ccp.ServerParams = new object[] { list }; ccp.IfShowErrMsg = false; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp != null) { if (ccp.ReturnCode == -1) { MessageUtil.ShowWarning(ccp.ReturnInfo); return; } MessageUtil.ShowTips("生成成功!"); doQuery(); } } private void doExport() { GridHelper.ulGridToExcel(ultraGrid1, "关联交易-半成品"); } private void updateField() { this.ultraGrid1.UpdateData(); IQueryable checkRows = this.ultraGrid1.Rows.AsQueryable().Where(a => a.GetValue("CHK") == "True"); if (checkRows.Count() == 0) { MessageUtil.ShowTips("请选择数据!"); return; } ArrayList list = new ArrayList(); foreach (UltraGridRow row in checkRows) { PlnOrderZgSEntity entity = row.ListObject as PlnOrderZgSEntity; list.Add(JSONFormat.Format(entity)); CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.pss.glbusiness.FrmTHOrderManage"; ccp.MethodName = "doupdateField"; ccp.ServerParams = new object[] { list }; ccp.IfShowErrMsg = false; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp != null) { if (ccp.ReturnCode == -1) { MessageUtil.ShowWarning(ccp.ReturnInfo); return; } MessageUtil.ShowTips("修改成功!"); doQuery(); } } } private void updateWeight() { this.ultraGrid1.UpdateData(); IQueryable checkRows = this.ultraGrid1.Rows.AsQueryable().Where(a => a.GetValue("CHK") == "True"); if (checkRows.Count() == 0) { MessageUtil.ShowTips("请选择数据!"); return; } ArrayList list = new ArrayList(); foreach (UltraGridRow row in checkRows) { PlnOrderZgSEntity entity = row.ListObject as PlnOrderZgSEntity; list.Add(JSONFormat.Format(entity)); CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.pss.glbusiness.FrmTHOrderManage"; ccp.MethodName = "doupdateWeight"; ccp.ServerParams = new object[] { list }; ccp.IfShowErrMsg = false; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp != null) { if (ccp.ReturnCode == -1) { MessageUtil.ShowWarning(ccp.ReturnInfo); return; } MessageUtil.ShowTips("修改成功!"); doQuery(); } } } private void doUpdateThOrder() { this.ultraGrid1.UpdateData(); IQueryable checkRows = this.ultraGrid1.Rows.AsQueryable().Where(a => a.GetValue("CHK") == "True"); if (checkRows.Count() == 0) { MessageUtil.ShowTips("请选择数据!"); return; } ArrayList list = new ArrayList(); foreach (UltraGridRow row in checkRows) { PlnOrderZgSEntity entity = row.ListObject as PlnOrderZgSEntity; if (!entity.ProductionThFlag.Equals("123506")) { MessageUtil.ShowTips(entity.ProPlanId + ",合同未确认!"); return; } if (String.IsNullOrEmpty(entity.ThOrderNoSeq)) { MessageUtil.ShowTips(entity.ProPlanId + "天淮合同不能为空!"); return; } list.Add(new object[] { entity.ThOrderNoSeq, entity.ProPlanId, entity.GxPlanNo }); } CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.pss.glbusiness.FrmTHOrderManage"; ccp.MethodName = "doUpdateThOrder"; ccp.ServerParams = new object[] { list }; ccp.IfShowErrMsg = false; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp != null) { if (ccp.ReturnCode == -1) { MessageUtil.ShowWarning(ccp.ReturnInfo); return; } MessageUtil.ShowTips("修改成功!"); doQuery(); } } private void doCancel() { this.ultraGrid1.UpdateData(); IQueryable checkRows = this.ultraGrid1.Rows.AsQueryable().Where(a => a.GetValue("CHK") == "True"); if (checkRows.Count() == 0) { MessageUtil.ShowTips("请选择数据!"); return; } ArrayList list = new ArrayList(); foreach (UltraGridRow row in checkRows) { PlnOrderZgSEntity entity = row.ListObject as PlnOrderZgSEntity; string productionThFlag = ""; // 制造部 if (this.CustomInfo.ToString2().Equals("123501")) { if (!entity.ProductionThFlag.Equals("123502") && !entity.ProductionThFlag.Equals("123503")) { MessageUtil.ShowTips(entity.ProPlanId + "," + entity.ProductionThName+ "状态有误,无法撤销,请确认状态!"); return; } else { productionThFlag = "123501"; } } // 配套服务科 if (this.CustomInfo.ToString2().Equals("123502")) { if (!entity.ProductionThFlag.Equals("123504") && !entity.ProductionThFlag.Equals("123505")) { MessageUtil.ShowTips(entity.ProPlanId + "," + entity.ProductionThName + ",状态有误,无法撤销,请确认状态!"); return; } else { productionThFlag = "123503"; } } // 天淮公司 if (this.CustomInfo.ToString2().Equals("123504")) { if (!entity.ProductionThFlag.Equals("123506")) { MessageUtil.ShowTips(entity.ProPlanId + "," + entity.ProductionThName + ",状态有误,无法撤销,请确认状态!"); return; } else { productionThFlag = "123505"; } } list.Add(new object[] { productionThFlag, entity.ProPlanId, entity.GxPlanNo, this.CustomInfo.ToString2() }); } CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.pss.glbusiness.FrmTHOrderManage"; ccp.MethodName = "doUpdate"; ccp.ServerParams = new object[] { list }; ccp.IfShowErrMsg = false; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp != null) { if (ccp.ReturnCode == -1) { MessageUtil.ShowWarning(ccp.ReturnInfo); return; } MessageUtil.ShowTips("取消确认成功!"); doQuery(); } } private void doConfirm() { this.ultraGrid1.UpdateData(); IQueryable checkRows = this.ultraGrid1.Rows.AsQueryable().Where(a => a.GetValue("CHK") == "True"); if (checkRows.Count() == 0) { MessageUtil.ShowTips("请选择数据!"); return; } ArrayList list = new ArrayList(); foreach(UltraGridRow row in checkRows){ PlnOrderZgSEntity entity = row.ListObject as PlnOrderZgSEntity; string productionThFlag = ""; // 制造部 if (this.CustomInfo.ToString2().Equals("123501")) { if (!(entity.ProductionThFlag.Equals("") || entity.ProductionThFlag.Equals("123501") || entity.ProductionThFlag.Equals("123503"))) { MessageUtil.ShowTips(entity.ProPlanId + "," + entity.ProductionThName + ",状态有误,无法确认,请确认状态!"); return; } else { productionThFlag = "123502"; } } // 配套服务科 if (this.CustomInfo.ToString2().Equals("123502")) { if (!(entity.ProductionThFlag.Equals("123502") || entity.ProductionThFlag.Equals("123503") || entity.ProductionThFlag.Equals("123505"))) { MessageUtil.ShowTips(entity.ProPlanId + "," + entity.ProductionThName + ",状态有误,无法确认,请确认状态!"); return; } else { productionThFlag = "123504"; } } // 天淮公司 if (this.CustomInfo.ToString2().Equals("123504")) { if (!(entity.ProductionThFlag.Equals("123504") || entity.ProductionThFlag.Equals("123505"))) { MessageUtil.ShowTips(entity.ProPlanId + "," + entity.ProductionThName + ",状态有误,无法确认,请确认状态!"); return; } else { productionThFlag = "123506"; } } list.Add(new object[] { productionThFlag, entity.ProPlanId, entity.GxPlanNo, this.CustomInfo.ToString2() }); } CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.pss.glbusiness.FrmTHOrderManage"; ccp.MethodName = "doUpdate"; ccp.ServerParams = new object[] { list }; ccp.IfShowErrMsg = false; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp != null) { if (ccp.ReturnCode == -1) { MessageUtil.ShowWarning(ccp.ReturnInfo); return; } MessageUtil.ShowTips("确认成功!"); doQuery(); } } private void doQuery() { string orderNo = ""; //合同号 string orderStart = ""; string orderEnd = ""; if (uchkOrderNo.Checked) { orderNo = utxtOrderNo.Text.Trim(); } if (uchkDate.Checked) { orderStart = udtStart.DateTime.ToString("yyyy-MM-dd") + " 00:00:01"; orderEnd = udtEnd.DateTime.ToString("yyyy-MM-dd") + " 23:59:59"; } string productionThFlag = this.CustomInfo.ToString2().Equals("123501") ? "" : this.CustomInfo.ToString2(); List listSource = EntityHelper.GetData( "com.steering.pss.glbusiness.FrmTHOrderManage.doQuery", new object[] { orderNo, orderStart, orderEnd, productionThFlag }, this.ob); plnOrderZgSEntityBindingSource.DataSource = listSource; } private void ultraTextEditor1_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e) { this.ultraGrid1.UpdateData(); UltraGridRow row = this.ultraGrid1.ActiveRow; if (row == null) { return; } FrmProInformation fp = new FrmProInformation(ob, row.Cells["PrdcrNo"].Text, row.Cells["IndexSeq"].Text, "D"); fp.ShowDialog(); } } }