using com.steering.mes.mcp.entity; using Core.Mes.Client.Comm.Control; using Core.Mes.Client.Comm.Server; using Core.Mes.Client.Comm.Tool; using Core.StlMes.Client.Mcp.Control; //using Core.StlMes.Client.ZGMil.Result; 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.Windows.Forms; using Core.StlMes.Client.Mcp.Control.Entity; namespace Core.StlMes.Client.Mcp.Control { public partial class FrmScrap : FrmBase { private ArrayList list = null; private string plineCode; private string SLGx = ""; private string heatPlanNo = ""; private string resultNo = ""; public string reslNo = ""; public string Open = ""; private string save = "0"; private string Fenum = ""; public FrmScrap(string heatNo,string slgx,string pline_Code,string ResultNo,string open,string fenum,OpeBase ob) { InitializeComponent(); //list = arr; this.ob = ob; plineCode = pline_Code; SLGx = slgx; heatPlanNo = heatNo; resultNo = ResultNo; Open = open; Fenum = fenum; } /// /// 查询所有合格管序号 /// //private void QuerySeq(ArrayList list) //{ // DataTable ds = ServerHelper.GetData("com.steering.mes.zgmil.coup.EddyCurrentTestingResult.doQuerySeq", new object[] { list }, ob); // GridHelper.CopyDataToDatatable(ref ds, ref dataTable4, true); //} public string alamNum = ""; public string scrapNum = ""; public string testOfflineNum = ""; private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e) { switch (e.Tool.Key) { case "Save": Save(); break; case "Update": Update(); break; case "Delete": Delete(); break; case "Close": CloseFrm(); break; } } int alarmTotalNum = 0;//可疑总支数 int scarpTotalNum = 0;//废品总支数 int offlineTotalNum = 0;//下线总支数 public static ArrayList dName = null;//怀疑 public static ArrayList fName = null;//废品 private void CloseFrm() { alamNum = alarmTotalNum.ToString(); scrapNum = scarpTotalNum.ToString(); testOfflineNum = offlineTotalNum.ToString(); this.DialogResult = System.Windows.Forms.DialogResult.OK; this.Close(); } //修改可疑、废品 private void Update() { this.ultraGridDetailDes1.UpdateData(); this.ultraGridDetailDes2.UpdateData(); IQueryable checkAlarmRows = this.ultraGridDetailDes1.Rows.AsQueryable().Where(" CHK = 'True'"); IQueryable checkScrapRows = this.ultraGridDetailDes2.Rows.AsQueryable().Where(" CHK = 'True'"); ArrayList alarmlist = new ArrayList(); ArrayList scraplist = new ArrayList(); foreach (UltraGridRow uRow in checkAlarmRows) { MchBugDEntity resultD = getRowData(uRow); resultD.ResultNo = uRow.Cells["RESULT_NO"].Text.ToString(); resultD.FailBill = uRow.Cells["FAIL_BILL"].Text.ToString(); resultD.FailBillSqe = uRow.Cells["FAIL_BILL_SQE"].Text.ToString(); alarmlist.Add(resultD); alarmTotalNum = alarmTotalNum + int.Parse(uRow.Cells["FAIL_NUM"].Value.ToString3()); } foreach (UltraGridRow uRow in checkScrapRows) { MchBugDEntity resultD = getRowData(uRow); resultD.ResultNo = uRow.Cells["RESULT_NO"].Text.ToString(); resultD.FailBill = uRow.Cells["FAIL_BILL"].Text.ToString(); resultD.FailBillSqe = uRow.Cells["FAIL_BILL_SQE"].Text.ToString(); scraplist.Add(resultD); scarpTotalNum = scarpTotalNum + int.Parse(uRow.Cells["FAIL_NUM"].Value.ToString3()); } CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.mes.mcp.Mch.FrmMchBugD"; ccp.MethodName = "UpdateFail"; ccp.ServerParams = new object[] { alarmlist, scraplist, SLGx, plineCode, heatPlanNo }; ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { MessageUtil.ShowTips(ccp.ReturnInfo); if (ccp.ReturnInfo.Equals("修改成功!")) { doQuery(); alamNum = alarmTotalNum.ToString(); scrapNum = scarpTotalNum.ToString(); this.DialogResult = System.Windows.Forms.DialogResult.OK; } else { MessageUtil.ShowTips(ccp.ReturnInfo); } } } //删除可疑、废品 private void Delete() { this.ultraGridDetailDes1.UpdateData(); this.ultraGridDetailDes2.UpdateData(); IQueryable checkAlarmRows = this.ultraGridDetailDes1.Rows.AsQueryable().Where(" CHK = 'True'"); IQueryable checkScrapRows = this.ultraGridDetailDes2.Rows.AsQueryable().Where(" CHK = 'True'"); ArrayList alarmlist = new ArrayList(); ArrayList scraplist = new ArrayList(); foreach (UltraGridRow uRow in checkAlarmRows) { MchBugDEntity resultD = getRowData(uRow); resultD.ResultNo = uRow.Cells["RESULT_NO"].Text.ToString(); resultD.FailBill = uRow.Cells["FAIL_BILL"].Text.ToString(); resultD.FailBillSqe = uRow.Cells["FAIL_BILL_SQE"].Text.ToString(); alarmlist.Add(resultD); } foreach (UltraGridRow uRow in checkScrapRows) { MchBugDEntity resultD = getRowData(uRow); resultD.ResultNo = uRow.Cells["RESULT_NO"].Text.ToString(); resultD.FailBill = uRow.Cells["FAIL_BILL"].Text.ToString(); resultD.FailBillSqe = uRow.Cells["FAIL_BILL_SQE"].Text.ToString(); scraplist.Add(resultD); } CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.mes.mcp.Mch.FrmMchBugD"; ccp.MethodName = "deleteFail"; ccp.ServerParams = new object[] { alarmlist, scraplist, SLGx, plineCode, heatPlanNo }; ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { MessageUtil.ShowTips(ccp.ReturnInfo); if (ccp.ReturnInfo.Equals("删除成功!")) { doQuery(); this.DialogResult = System.Windows.Forms.DialogResult.OK; } else { MessageUtil.ShowTips(ccp.ReturnInfo); } } } /// /// 保存可疑、剔除品 /// private void Save() { this.ultraGridDetailDes1.UpdateData(); this.ultraGridDetailDes2.UpdateData(); // this.ultraGridDetailDes3.UpdateData(); // string strInbound = "800707";//入库类型 //string strInMemo = ""; alarmTotalNum = 0; scarpTotalNum = 0; offlineTotalNum = 0; IQueryable checkAlarmRows = this.ultraGridDetailDes1.Rows.AsQueryable().Where(" CHK = 'True'"); IQueryable checkScrapRows = this.ultraGridDetailDes2.Rows.AsQueryable().Where(" CHK = 'True'"); // IQueryable checkOffineRow = this.ultraGridDetailDes3.Rows.AsQueryable().Where(" CHK = 'True'"); ArrayList alarmlist = new ArrayList(); ArrayList scraplist = new ArrayList(); //ArrayList offlinelist = new ArrayList(); foreach (UltraGridRow uRow in checkAlarmRows) { ArrayList list1 = new ArrayList(); if (uRow.Cells["FAIL_TYPE_NAME"].Text.ToString() == "") { MessageUtil.ShowTips("可疑支数原因不能为空,请选择!"); return; } if (uRow.Cells["FAIL_NUM"].Value.ToString() == "" || uRow.Cells["FAIL_NUM"].Value.ToString() == "0") { MessageUtil.ShowTips("可疑支数不能为空或者为零支,请输入!"); return; } if (!uRow.Cells["FAIL_NUM"].Value.ToString().TryParseInt()) { MessageUtil.ShowTips("可疑支数请输入整数!"); return; } //if (Convert.ToInt32(Fenum) < Convert.ToInt32(uRow.Cells["FAIL_NUM"].Value.ToString())) //{ // MessageUtil.ShowTips("可疑支数不能大于加工剩余支数!"); // return; //} alarmTotalNum = alarmTotalNum + int.Parse(uRow.Cells["FAIL_NUM"].Value.ToString3()); //list1.Add(uRow.Cells["FAIL_TYPE_NAME"].Text.Trim()); //list1.Add(uRow.Cells["FAIL_NUM"].Value.ToString3()); //list1.Add(alarmTotalNum.ToString()); //alarmlist.Add(list1); MchBugDEntity resultD = getRowData(uRow); resultD.ResultNo = uRow.Cells["FAIL_BILL"].Value.ToString(); alarmlist.Add(resultD); } dName = alarmlist; //int n = 0; //foreach (UltraGridRow ugr in checkScrapRows) //{ // //string alarmReason = ugr.Cells["REASON1"].Text.Trim(); // int num = 0; // foreach (UltraGridRow ugr1 in checkAlarmRows) // { // if (ugr1.Cells["FAIL_TYPE_NAME"].Text.Trim().Equals(alarmReason)) // { // num = num + int.Parse(ugr1.Cells["FAIL_NUM"].Value.ToString3()); // } // } // if (num < int.Parse(ugr.Cells["FAIL_NUM"].Value.ToString3())) // { // n = n + 1; // } //} //if (n > 0) //{ // MessageUtil.ShowTips("废品支数不能超出对应的报警原因下的支数!"); // return; //} foreach (UltraGridRow row in checkScrapRows) { ArrayList list2 = new ArrayList(); //if (row.Cells["REASON1"].Value.ToString2() == "") //{ // MessageUtil.ShowTips("报警原因不能为空,请选择!"); // return; //} if (row.Cells["FAIL_TYPE_NAME"].Text.ToString() == "") { MessageUtil.ShowTips("废品原因不能为空,请选择!"); return; } if (row.Cells["FAIL_NUM"].Value.ToString() == "" || row.Cells["FAIL_NUM"].Value.ToString() == "0") { MessageUtil.ShowTips("废品支数不能为空或者为零支,请输入!"); return; } if (!row.Cells["FAIL_NUM"].Value.ToString().TryParseInt()) { MessageUtil.ShowTips("废品支数请输入整数!"); return; } //if (Convert.ToInt32(Fenum) < Convert.ToInt32(row.Cells["FAIL_NUM"].Value.ToString())) //{ // MessageUtil.ShowTips("废品支数不能大于加工剩余支数!"); // return; //} scarpTotalNum = scarpTotalNum + int.Parse(row.Cells["FAIL_NUM"].Value.ToString3()); //list2.Add(row.Cells["FAIL_TYPE_NAME"].Text.Trim()); //list2.Add(row.Cells["FAIL_NUM"].Value.ToString3()); //list2.Add(scarpTotalNum.ToString()); ////list2.Add(row.Cells["REASON1"].Text.Trim()); //scraplist.Add(list2); MchBugDEntity resultD = getRowData(row); resultD.ResultNo = row.Cells["FAIL_BILL"].Value.ToString(); scraplist.Add(resultD); } fName = scraplist; if (dName.Count != 0 || fName.Count != 0) { MessageUtil.ShowTips("添加成功!"); save = "1"; alamNum = alarmTotalNum.ToString(); scrapNum = scarpTotalNum.ToString(); this.DialogResult = System.Windows.Forms.DialogResult.OK; } //CoreClientParam ccp = new CoreClientParam(); //ccp.ServerName = "com.steering.mes.mcp.Mch.FrmMchBugD"; //ccp.MethodName = "addPerson"; //ccp.ServerParams = new object[] { alarmlist, scraplist, SLGx, plineCode, heatPlanNo }; //ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal); //if (ccp.ReturnCode != -1) //{ // MessageUtil.ShowTips(ccp.ReturnInfo); // if (ccp.ReturnInfo.Equals("保存成功!")) // { // save = "1"; // alamNum = alarmTotalNum.ToString(); // scrapNum = scarpTotalNum.ToString(); // //testOfflineNum = offlineTotalNum.ToString(); // //UltraGridRow urg = ultraGridDetailDes2.ActiveRow; // //if(urg!=null) // //{ // // reslNo = urg.Cells["RESULT_NO"].Value.ToString(); // //} // this.DialogResult = System.Windows.Forms.DialogResult.OK; // } // else // { // MessageUtil.ShowTips(ccp.ReturnInfo); // } //} } public MchBugDEntity getRowData(UltraGridRow checkrow) { MchBugDEntity resultD = new MchBugDEntity(); resultD.FailTypeName = checkrow.Cells["FAIL_TYPE_NAME"].Text.ToString().Trim(); resultD.FailDirect = checkrow.Cells["FAIL_DIRECT"].Text.ToString().Trim(); resultD.FailNum =decimal.Parse(checkrow.Cells["FAIL_NUM"].Value.ToString().Trim()); return resultD; } /// /// 查询仓库信息 /// /// /// private DataTable getStoreNo(string plineCode) { DataTable ds = ServerHelper.GetData("com.steering.mes.signature.FrmInOnlineStore.doQueryStoreNo", new object[] { plineCode }, ob); if (ds.Rows.Count > 0) { return ds; } else { return null; } } private void FrmScrap_Load(object sender, EventArgs e) { doQuery(); if (Open == "0") { ultraGroupBox2.Hide(); } //QuerySeq(list); } /// /// 查询可疑品、剔除品 /// public void doQuery() { dataTable1.Clear(); dataTable2.Clear(); dataTable3.Clear(); //查询可疑支数 //DataTable dt = ServerHelper.GetData("com.steering.mes.mcp.Mch.FrmMchBugD.doQueryAlarmNum", new object[] { heatPlanNo,resultNo }, ob); //GridHelper.CopyDataToDatatable(ref dt,ref dataTable1,true); //查询废品支数 //DataTable ds = ServerHelper.GetData("com.steering.mes.mcp.Mch.FrmMchBugD.doQueryScrapNum", new object[] { heatPlanNo, resultNo }, ob); //GridHelper.CopyDataToDatatable(ref ds, ref dataTable2, true); //DataTable dd = ServerHelper.GetData("com.steering.mes.zgmil.coup.EddyCurrentTestingResult.doQueryOffineNum", new object[] { list }, ob); //GridHelper.CopyDataToDatatable(ref dd, ref dataTable3, true); //下拉选探伤废品原因 DataTable dt2 = ServerHelper.GetData("com.steering.mes.mcp.Mch.FrmCrackDetectResult.getQuerybase", new object[] { "7004" }, this.ob); //comm.FilComboboxAdd(standard, dt2, "BASECODE", "BASENAME", "validflag NOT in ('0')", false, "全部", ""); kreason.DataSource = dt2; kreason.DisplayMember = "BASENAME"; kreason.ValueMember = "BASECODE"; YdmBaseClass.SetComboItemHeight(kreason); reason.DataSource = dt2; reason.DisplayMember = "BASENAME"; reason.ValueMember = "BASECODE"; YdmBaseClass.SetComboItemHeight(reason); foreach (UltraGridRow urg in ultraGridDetailDes1.Rows) { GridEdite(urg); } foreach (UltraGridRow urg in ultraGridDetailDes2.Rows) { GridEdite(urg); } if(resultNo==null) { resultNo = ""; } DataTable dt = ServerHelper.GetData("com.steering.mes.mcp.Mch.FrmMchBugD.QueryFailData", new object[] { heatPlanNo, SLGx, resultNo, plineCode }, ob); GridHelper.CopyDataToDatatable(ref dt, ref dataTable2, true); DataTable dt1 = ServerHelper.GetData("com.steering.mes.mcp.Mch.FrmMchBugD.QueryKeyiFailData", new object[] { heatPlanNo, SLGx, resultNo, plineCode }, ob); GridHelper.CopyDataToDatatable(ref dt1, ref dataTable1, true); } private void ultraGridDetailDes1_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e) { this.ultraGridDetailDes1.UpdateData(); GridEdite(e.Cell.Row); //UltraGrid ug = (UltraGrid)sender; //this.ultraGridDetailDes1.UpdateData(); //if (e.Cell.Column.Key == "REASON") //{ // if (e.Cell.Value == "") // { // MessageBox.Show("您未选择任何选项,请重新选择", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning); // return; // } // int temp = 0; // for (int i = 0; i < ug.Rows.Count(); i++) // { // UltraGridRow ugr = ug.Rows[i]; // if (e.Cell.Value.ToString().Equals(ugr.Cells["REASON"].Value.ToString())) // { // temp = temp + 1; // } // } // if (temp > 1) // { // MessageBox.Show(e.Cell.Value.ToString() + "选项已被选取,请重新选择", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning); // e.Cell.Row.Cells["REASON"].Value = ""; // } //} //if(e.Cell.Column.Key == "ACT_COUNT") //{ // int total = 0; // foreach(UltraGridRow row in this.ultraGridDetailDes1.Rows) // { // if (Convert.ToBoolean(row.Cells["CHK"].Text) == true) // { // total = total + int.Parse(row.Cells["ACT_COUNT"].Value.ToString3()); // } // } // ultraGrid1.BeginUpdate(); // foreach (UltraGridRow uRow in this.ultraGrid1.Rows) // { // if (total >= uRow.Index + 1) // { // uRow.Cells["CHK1"].Value = true; // } // else // { // uRow.Cells["CHK1"].Value = false; // } // } // ultraGrid1.EndUpdate(); //} } private void ultraGridDetailDes2_CellChange(object sender, CellEventArgs e) { this.ultraGridDetailDes2.UpdateData(); GridEdite(e.Cell.Row); //UltraGrid ug = (UltraGrid)sender; //this.ultraGridDetailDes2.UpdateData(); //if (e.Cell.Column.Key == "REASON") //{ // if (e.Cell.Value == "") // { // MessageBox.Show("您未选择任何选项,请重新选择", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning); // return; // } // int temp = 0; // for (int i = 0; i < ug.Rows.Count(); i++) // { // UltraGridRow ugr = ug.Rows[i]; // if (e.Cell.Value.ToString().Equals(ugr.Cells["REASON"].Value.ToString()) && e.Cell.Row.Cells["REASON1"].Value.ToString2().Equals(ugr.Cells["REASON1"].Value.ToString2())) // { // temp = temp + 1; // } // } // if (temp > 1) // { // MessageBox.Show(e.Cell.Value.ToString() + "选项已被选取,请重新选择", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning); // e.Cell.Row.Cells["REASON"].Value = ""; // } //} //if (e.Cell.Column.Key == "REASON1") //{ // if (e.Cell.Value == "") // { // MessageBox.Show("您未选择任何选项,请重新选择", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning); // return; // } // int temp1 = 0; // for (int i = 0; i < ug.Rows.Count(); i++) // { // UltraGridRow ugr = ug.Rows[i]; // if (e.Cell.Value.ToString().Equals(ugr.Cells["REASON1"].Value.ToString()) && e.Cell.Row.Cells["REASON"].Value.ToString2().Equals(ugr.Cells["REASON"].Value.ToString2())) // { // temp1 = temp1 + 1; // } // } // if (temp1 > 1) // { // MessageBox.Show(e.Cell.Value.ToString() + "选项已被选取,请重新选择", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning); // e.Cell.Row.Cells["REASON"].Value = ""; // } //} //if (e.Cell.Column.Key == "ACT_COUNT") //{ // int total = 0; // foreach (UltraGridRow row in this.ultraGridDetailDes2.Rows) // { // if (Convert.ToBoolean(row.Cells["CHK"].Text) == true) // { // total = total + int.Parse(row.Cells["ACT_COUNT"].Value.ToString3()); // } // } // ultraGrid1.BeginUpdate(); // IQueryable checkAlarmRows = this.ultraGrid1.Rows.AsQueryable().Where(" CHK1 = 'True' and CHK3 = 'False' ORDER BY TO_NUMBER(SEQ) ASC"); // if (checkAlarmRows.Count() < total) // { // MessageUtil.ShowTips("废品总支数不能大于报警总支数"); // return; // } // else // { // int i = 1; // foreach (UltraGridRow uRow in checkAlarmRows) // { // uRow.Cells["CHK2"].Value = false; // if (i <= total) // { // uRow.Cells["CHK2"].Value = true; // } // i++; // } // } // ultraGrid1.EndUpdate(); //} } private void FrmScrap_FormClosing(object sender, FormClosingEventArgs e) { UltraGridRow urg = ultraGridDetailDes2.ActiveRow; if (urg != null) { if (urg.Cells["CHK"].Text != "") { if (Convert.ToBoolean(urg.Cells["CHK"].Text) == true && urg.Cells["FAIL_TYPE_NAME"].Text != "") { if (save == "0") { MessageUtil.ShowTips("请点保存按钮!"); e.Cancel = true; } } } } } private void ultraGridDetailDes1_AfterRowInsert(object sender, RowEventArgs e) { this.ultraGridDetailDes1.UpdateData(); GridEdite(e.Row); } private void ultraGridDetailDes2_AfterRowInsert(object sender, RowEventArgs e) { this.ultraGridDetailDes2.UpdateData(); GridEdite(e.Row); } /// /// /// ulltragrid控件受勾影响(打钩可编辑,不打勾不能编辑)** /// /// private void GridEdite(UltraGridRow row) { if (row.GetValue("CHK") == "True") { foreach (UltraGridCell cell in row.Cells) { if (cell.Column.CellActivation == Activation.AllowEdit) { cell.Activation = Activation.AllowEdit; } } } else { foreach (UltraGridCell cell in row.Cells) { if (cell.Column.Key.Contains("CHK")) continue; if (cell.Column.CellActivation == Activation.AllowEdit) { cell.Activation = Activation.ActivateOnly; } } } ultraGridDetailDes1.UpdateData(); ultraGridDetailDes2.UpdateData(); } //private void ultraGridDetailDes3_CellChange(object sender, CellEventArgs e) //{ // UltraGrid ug = (UltraGrid)sender; // this.ultraGridDetailDes3.UpdateData(); // if (e.Cell.Column.Key == "REASON") // { // if (e.Cell.Value == "") // { // MessageBox.Show("您未选择任何选项,请重新选择", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning); // return; // } // int temp = 0; // for (int i = 0; i < ug.Rows.Count(); i++) // { // UltraGridRow ugr = ug.Rows[i]; // if (e.Cell.Value.ToString().Equals(ugr.Cells["REASON"].Value.ToString())) // { // temp = temp + 1; // } // } // if (temp > 1) // { // MessageBox.Show(e.Cell.Value.ToString() + "选项已被选取,请重新选择", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning); // e.Cell.Row.Cells["REASON"].Value = ""; // } // } //} //private void FrmScrap_Leave(object sender, EventArgs e) //{ // FrmTestingResult frmTestingResult = new FrmTestingResult(); // frmTestingResult.ETResultSave(); //} } }