using Core.Mes.Client.Comm.Control; using Core.Mes.Client.Comm.Server; using Core.Mes.Client.Comm.Tool; using Core.StlMes.Client.Mcp.Common; using Core.StlMes.Client.Mcp.Control; using Core.StlMes.Client.Mcp.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.Mcp.Coupling { public partial class FrmWeiTuo : FrmBase { public FrmWeiTuo() { InitializeComponent(); this.IsLoadUserView = true; } private void FrmWeiTuo_Load(object sender, EventArgs e) { EntityHelper.ShowGridCaption(ultraGrid1.DisplayLayout.Bands[0]); McpBaseHelper.InitPlineUnit(cmbPlinCode, this.ValidDataPurviewIds, ob, "H"); } public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey) { case "DoQuery": QuerySinglePlan();//查询计划 break; case "DoComplete": DoComplete();//审批通过 break; case "UnDoComplete": UnDoComplete();//审批不通过 break; case "OutsourcReturn": DoOutsourcReturn(); break; case "Close": this.Close(); break; } } private void QuerySinglePlan() { string plnNo = ""; string status = ""; string plinCode = ""; string judgeNo = ""; if (chkwoId.Checked) { if (txtWoId.Text == "") { MessageUtil.ShowTips("委托单号不能为空!"); return; } else { plnNo = txtWoId.Text.ToString().Trim(); } } if (chkPlin.Checked) { if (cmbPlinCode.Text == "") { MessageUtil.ShowTips("生产产线不能为空!"); return; } else { plinCode = cmbPlinCode.Text.Trim().ToString(); } } if (chkJuNo.Checked) { if (txtStatus.Text == "") { MessageUtil.ShowTips("状态不能为空!"); return; } else { status = txtStatus.Value.ToString(); } } if (chkJugeHeatNo.Checked) { judgeNo = txtJugeNo.Text.ToString().Trim(); } ArrayList list = new ArrayList(); list.Add(plnNo); list.Add(plinCode); list.Add(status); list.Add(judgeNo); List listSource = EntityHelper.GetData( "com.steering.mes.mcp.coup.FrmWeiTuo.geQueryEntrusted", new object[] { list}, this.ob); CouplingOutEntitySource.DataSource = listSource; } private void chkStarts_CheckedChanged(object sender, EventArgs e) { if (chkwoId.Checked) { txtWoId.Enabled = true; } else { txtWoId.Enabled = false; } if (chkPlin.Checked) { cmbPlinCode.Enabled = true; } else { cmbPlinCode.Enabled = false; } if (chkJuNo.Checked) { txtStatus.Enabled = true; } else { txtStatus.Enabled = false; } if (chkJugeHeatNo.Checked) { txtJugeNo.Enabled = true; } else { txtJugeNo.Enabled = false; } } private void ContPublic_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { QuerySinglePlan(); } } /// /// 审批通过 /// private void DoComplete() { UltraGridRow row = ultraGrid1.ActiveRow; if (row == null) return; //ultraGridPlnWork.UpdateData(); int AddCount = 0; ArrayList list = new ArrayList(); foreach (UltraGridRow urg in ultraGrid1.Rows) { if (Convert.ToBoolean(urg.Cells["CHK"].Text) == true) { AddCount += 1; ArrayList list1 = new ArrayList(); if (!row.Cells["EntrustedLog"].Text.ToString().Equals("已申请")) { MessageUtil.ShowTips("选中的委外单不是已申请状态,不能审批通过!"); return; } list1.Add(urg.Cells["EntrustedNo"].Text.ToString()); list.Add(list1); } } if (AddCount == 0) { MessageUtil.ShowTips("请选中要审批的委托单!"); return; } if (MessageUtil.ShowYesNoAndQuestion("是否审批委托?") == DialogResult.No) { return; } CoreClientParam ccp = new CoreClientParam(); try { this.Cursor = Cursors.WaitCursor; //控制鼠标的样式为等待 if (Constant.WaitingForm == null) { Constant.WaitingForm = new WaitingForm(); } Constant.WaitingForm.ShowToUser = true; Constant.WaitingForm.Show(); Constant.WaitingForm.Update(); ccp.ServerName = "com.steering.mes.mcp.coup.FrmWeiTuo"; ccp.MethodName = "commEntrustedResult"; ccp.ServerParams = new object[] { list,this.UserInfo.GetUserName() }; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); this.Cursor = Cursors.Default; Constant.WaitingForm.ShowToUser = false; Constant.WaitingForm.Close(); Constant.WaitingForm = null; } catch (Exception ex) { this.Cursor = Cursors.Default; Constant.WaitingForm.ShowToUser = false; Constant.WaitingForm.Close(); Constant.WaitingForm = null; } if (ccp.ReturnCode == -1) return; MessageUtil.ShowTips(ccp.ReturnInfo); if (ccp.ReturnInfo.Equals("审批通过!")) { QuerySinglePlan(); } } /// /// 审批不通过 /// private void UnDoComplete() { UltraGridRow row = ultraGrid1.ActiveRow; if (row == null) return; //ultraGridPlnWork.UpdateData(); int AddCount = 0; ArrayList list = new ArrayList(); foreach (UltraGridRow urg in ultraGrid1.Rows) { if (Convert.ToBoolean(urg.Cells["CHK"].Text) == true) { AddCount += 1; ArrayList list1 = new ArrayList(); if (!row.Cells["EntrustedLog"].Text.ToString().Equals("已申请")) { MessageUtil.ShowTips("选中的委外单不是已申请状态,不能审批不通过!"); return; } list1.Add(urg.Cells["EntrustedNo"].Text.ToString()); list.Add(list1); } } if (AddCount == 0) { MessageUtil.ShowTips("请选中要审批的委托单!"); return; } if (MessageUtil.ShowYesNoAndQuestion("是否审批?") == DialogResult.No) { return; } CoreClientParam ccp = new CoreClientParam(); try { this.Cursor = Cursors.WaitCursor; //控制鼠标的样式为等待 if (Constant.WaitingForm == null) { Constant.WaitingForm = new WaitingForm(); } Constant.WaitingForm.ShowToUser = true; Constant.WaitingForm.Show(); Constant.WaitingForm.Update(); ccp.ServerName = "com.steering.mes.mcp.coup.FrmWeiTuo"; ccp.MethodName = "kownCommEntrustedResult"; ccp.ServerParams = new object[] { list,this.UserInfo.GetUserName() }; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); this.Cursor = Cursors.Default; Constant.WaitingForm.ShowToUser = false; Constant.WaitingForm.Close(); Constant.WaitingForm = null; } catch (Exception ex) { this.Cursor = Cursors.Default; Constant.WaitingForm.ShowToUser = false; Constant.WaitingForm.Close(); Constant.WaitingForm = null; } if (ccp.ReturnCode == -1) return; MessageUtil.ShowTips(ccp.ReturnInfo); if (ccp.ReturnInfo.Equals("审批不通过!")) { QuerySinglePlan(); } } /// /// 委外回报 /// private void DoOutsourcReturn() { this.ultraGrid1.UpdateData(); IQueryable checkMagRows = this.ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'"); if (checkMagRows.Count() == 0) { MessageUtil.ShowTips("请勾选需要回报的委外信息!"); return; } ArrayList parm2 = new ArrayList(); foreach (UltraGridRow row in checkMagRows) { if (!row.Cells["EntrustedLog"].Text.ToString().Equals("审批通过")) { MessageUtil.ShowTips("选中的委外单不是审批通过状态,不能委外回报!"); return; } //if (row.Cells["EntrustedLog"].Text.ToString().Equals("回报完毕")) //{ // MessageUtil.ShowTips("选中的委外单已回报,不能重复委外回报!"); // return; //} if (row.Cells["SubcontractcompleteNum"].Value.ToString().Equals("0")) { MessageUtil.ShowTips("请输入委外回报支数!"); return; } if (row.Cells["SubcontractcompleteWt"].Value.ToString().Equals("0")) { MessageUtil.ShowTips("请输入委外回报重量!"); return; } ArrayList parm = new ArrayList(); parm.Add(row.Cells["SubcontractcompleteNum"].Value.ToString()); parm.Add(row.Cells["SubcontractcompleteWt"].Value.ToString()); parm.Add(row.Cells["HbFpNum"].Text.ToString()); parm.Add(row.Cells["HbFpWt"].Text.ToString()); parm.Add(row.Cells["EntrustedNo"].Text.ToString()); parm2.Add(parm); } if (MessageUtil.ShowYesNoAndQuestion("是否确认委外回报?") == DialogResult.No) return; CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.mes.mcp.coup.FrmWeiTuo"; ccp.MethodName = "doOutsourcReturn"; ccp.ServerParams = new object[] { parm2,this.UserInfo.GetUserName() }; ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { MessageUtil.ShowTips(ccp.ReturnInfo); if (ccp.ReturnInfo.Equals("委外回报成功!")) { QuerySinglePlan(); } } } private void ultraGrid1_CellChange(object sender, CellEventArgs e) { UltraGridRow row=ultraGrid1.ActiveRow; if(row==null)return; //委外回报合格支 if (e.Cell.Column.Key.Equals("SubcontractcompleteNum")) { if (e.Cell.Row.Cells["SubcontractcompleteNum"].Value == null) { e.Cell.Row.Cells["SubcontractcompleteNum"].Value = "0"; } else { ultraGrid1.UpdateData(); string hbConNum = e.Cell.Row.Cells["SubcontractcompleteNum"].Value.ToString(); if (!StringUtil.IsInt(hbConNum) || hbConNum == "0") { e.Cell.Row.Cells["SubcontractcompleteNum"].Value = "0"; } if (int.Parse(e.Cell.Row.Cells["SubcontractcompleteNum"].Value.ToString()) > int.Parse(e.Cell.Row.Cells["EntrustedNum1"].Value.ToString())) { if (!row.Cells["StationCode"].Text.ToString().Equals("700301")) { e.Cell.Row.Cells["SubcontractcompleteNum"].Value = "0"; } } if (!row.Cells["StationCode"].Text.ToString().Equals("700301")) { e.Cell.Row.Cells["SubcontractcompleteWt"].Value = ((double.Parse(e.Cell.Row.Cells["EntrustedWt1"].Value.ToString()) / int.Parse(e.Cell.Row.Cells["EntrustedNum1"].Value.ToString())) * int.Parse(e.Cell.Row.Cells["SubcontractcompleteNum"].Value.ToString())).ToString("f3"); e.Cell.Row.Cells["HbFpNum"].Value = (int.Parse(e.Cell.Row.Cells["EntrustedNum1"].Value.ToString()) - int.Parse(e.Cell.Row.Cells["SubcontractcompleteNum"].Value.ToString())).ToString(); e.Cell.Row.Cells["HbFpWt"].Value = (double.Parse(e.Cell.Row.Cells["EntrustedWt1"].Value.ToString()) - double.Parse(e.Cell.Row.Cells["SubcontractcompleteWt"].Value.ToString())).ToString("f3"); } } } //委外回报合格吨 if (e.Cell.Column.Key.Equals("SubcontractcompleteWt")) { if (e.Cell.Row.Cells["SubcontractcompleteWt"].Value == null) { e.Cell.Row.Cells["SubcontractcompleteWt"].Value = "0"; } else { ultraGrid1.UpdateData(); string hbConWt = e.Cell.Row.Cells["SubcontractcompleteWt"].Value.ToString(); if (!StringUtil.IsFloat(hbConWt) || hbConWt == "0") { e.Cell.Row.Cells["SubcontractcompleteWt"].Value = "0"; } if (double.Parse(e.Cell.Row.Cells["SubcontractcompleteWt"].Value.ToString()) > double.Parse(e.Cell.Row.Cells["EntrustedWt1"].Text.ToString())) { if (!row.Cells["StationCode"].Text.ToString().Equals("700301")) { e.Cell.Row.Cells["SubcontractcompleteWt"].Value = "0"; } } if (!row.Cells["StationCode"].Text.ToString().Equals("700301")) { e.Cell.Row.Cells["HbFpWt"].Value = (double.Parse(e.Cell.Row.Cells["EntrustedWt1"].Text.ToString()) - double.Parse(e.Cell.Row.Cells["SubcontractcompleteWt"].Value.ToString())).ToString("f3"); } } } //委外回报废品个 if (e.Cell.Column.Key.Equals("HbFpNum")) { if (e.Cell.Row.Cells["HbFpNum"].Value == null) { e.Cell.Row.Cells["HbFpNum"].Value = "0"; } else { ultraGrid1.UpdateData(); string hbConWt = e.Cell.Row.Cells["HbFpNum"].Value.ToString(); if (!StringUtil.IsFloat(hbConWt) || hbConWt == "0") { e.Cell.Row.Cells["HbFpNum"].Value = "0"; } } } //委外回报废品吨 if (e.Cell.Column.Key.Equals("HbFpWt")) { if (e.Cell.Row.Cells["HbFpWt"].Value == null) { e.Cell.Row.Cells["HbFpWt"].Value = "0"; } else { ultraGrid1.UpdateData(); string hbConWt = e.Cell.Row.Cells["HbFpWt"].Value.ToString(); if (!StringUtil.IsFloat(hbConWt) || hbConWt == "0") { e.Cell.Row.Cells["HbFpWt"].Value = "0"; } } } } } }