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 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.Mes.Client.Comm.Format; using Core.StlMes.Client.Mcp.Control.Entity; using HttOfflineResultDentity = com.steering.mes.mcp.entity.HttOfflineResultDentity; namespace Core.StlMes.Client.Mcp.Treatment { public partial class FrmScrapNumHigh : FrmBase { private ArrayList list = null; private string plineCode = ""; private string SLGx = ""; private string heatPlanNo = ""; private string resultNo = ""; public string reslNo = ""; public string groudno = ""; public string cutnum = ""; private string StorageNo = ""; private string save = "0"; private string Linenum = ""; private string PlineName = ""; private int ProcessSeq = 1; HttHheatResultEntity result1 = new HttHheatResultEntity();//高温炉 public FrmScrapNumHigh(HttHheatResultEntity result, string heatNo, string slgx, string batchgroudno, string outnumcut, string storageNo, string pline_Code, string ResultNo, string linenum, string plineName, OpeBase ob) { InitializeComponent(); //list = arr; this.ob = ob; plineCode = pline_Code; SLGx = slgx; groudno = batchgroudno; cutnum = outnumcut; StorageNo = storageNo; heatPlanNo = heatNo; resultNo = ResultNo; result1 = result; Linenum = linenum; PlineName = plineName; } public FrmScrapNumHigh(HttHheatResultEntity result, string heatNo, string slgx, string batchgroudno, string outnumcut, string storageNo, string pline_Code, string ResultNo, string linenum, string plineName, int processSeq,OpeBase ob) { InitializeComponent(); //list = arr; this.ob = ob; plineCode = pline_Code; SLGx = slgx; groudno = batchgroudno; cutnum = outnumcut; StorageNo = storageNo; heatPlanNo = heatNo; resultNo = ResultNo; result1 = result; Linenum = linenum; PlineName = plineName; ProcessSeq = processSeq; } /// /// 查询所有合格管序号 /// //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 "Close": CloseFrm(); break; } } int alarmTotalNum = 0;//可疑总支数 int scarpTotalNum = 0;//废品总支数 int offlineTotalNum = 0;//下线总支数 private void CloseFrm() { alamNum = alarmTotalNum.ToString(); scrapNum = scarpTotalNum.ToString(); testOfflineNum = offlineTotalNum.ToString(); this.DialogResult = System.Windows.Forms.DialogResult.OK; this.Close(); } /// /// 保存离线 /// private void Save() { this.ultraGridDetailDes1.UpdateData(); alarmTotalNum = 0; scarpTotalNum = 0; offlineTotalNum = 0; IQueryable checkAlarmRows = this.ultraGridDetailDes1.Rows.AsQueryable().Where(" CHK = 'True'"); // IQueryable checkOffineRow = this.ultraGridDetailDes3.Rows.AsQueryable().Where(" CHK = 'True'"); List alarmlist = new List(); ArrayList scraplist = new ArrayList(); //foreach (UltraGridRow uRow in checkAlarmRows) //{ // ArrayList list1 = new ArrayList(); // if (uRow.Cells["FAIL_TYPE_NAME"].Value.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; // } // 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); //} //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("保存成功!")) // { // 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); // } //} //MchUtResultEntity result = this.crackDetectControl1.Value; //foreach (UltraGridRow uRow in checkAlarmRows) //{ // ArrayList list1 = new ArrayList(); // if (uRow.Cells["FAIL_TYPE_NAME"].Value.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; // } int num = 0; foreach (UltraGridRow urrg in ultraGridDetailDes1.Rows) { num = num + int.Parse(urrg.Cells["OFFLINE_NUM"].Text.ToString()); } string time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); ArrayList list = new ArrayList(); list.Add(heatPlanNo); list.Add(SLGx); list.Add(""); list.Add(this.UserInfo.GetUserName()); list.Add(time); list.Add(this.UserInfo.GetUserOrder()); list.Add(this.UserInfo.GetUserGroup()); list.Add(num.ToString()); if (MessageUtil.ShowYesNoAndQuestion("是否离线?") == DialogResult.No) return; foreach (UltraGridRow uRow in checkAlarmRows) { ArrayList list1 = new ArrayList(); if (uRow.Cells["GOWHERE_NAME"].Value.ToString() == "") { MessageUtil.ShowTips("去向不能为空,请选择!"); return; } if (uRow.Cells["OFFLINE_NUM"].Value.ToString() == "" || uRow.Cells["OFFLINE_NUM"].Value.ToString() == "0") { MessageUtil.ShowTips("支数不能为空或者为零支,请输入!"); return; } if (!uRow.Cells["OFFLINE_NUM"].Value.ToString().TryParseInt()) { MessageUtil.ShowTips("支数请输入整数!"); return; } //if(Convert.ToInt32(Linenum)<=Convert.ToInt32(uRow.Cells["OFFLINE_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); HttOfflineResultDentity resultD = getRowData(uRow); resultD.ResultNo = uRow.Cells["FAIL_BILL"].Value.ToString(); resultD.GowhereName = uRow.Cells["GOWHERE_NAME"].Text.ToString().Trim(); resultD.OfflineNum = uRow.Cells["OFFLINE_NUM"].Value.ToString().Trim(); alarmlist.Add(JSONFormat.Format(resultD)); } 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.heatTreatment.HeatTreatmentService"; ccp.MethodName = "offLineExpandResult1"; ccp.ServerParams = new Object[] { alarmlist, JSONFormat.Format(result1), list, plineCode, StorageNo, groudno, ProcessSeq }; 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) { MessageUtil.ShowTips(ccp.ReturnInfo); if (ccp.ReturnInfo.Equals("离线成功!")) { save = "1"; alamNum = alarmTotalNum.ToString(); scrapNum = scarpTotalNum.ToString(); this.DialogResult = System.Windows.Forms.DialogResult.OK; } } } public HttOfflineResultDentity getRowData(UltraGridRow checkrow) { HttOfflineResultDentity resultD = new HttOfflineResultDentity(); resultD.GowhereName = checkrow.Cells["GOWHERE_NAME"].Value.ToString().Trim(); resultD.OfflineNum = checkrow.Cells["OFFLINE_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(); } /// /// 查询离线去向 /// public void doQuery() { dataTable1.Clear(); dataTable2.Clear(); dataTable3.Clear(); ////下拉选离线去向 //DataTable dt2 = ServerHelper.GetData("com.steering.mes.mcp.Mch.FrmCrackDetectResult.getQuerydirect", new object[] { "G", "002001006" }, this.ob); ////comm.FilComboboxAdd(standard, dt2, "BASECODE", "BASENAME", "validflag NOT in ('0')", false, "全部", ""); //kreason.DataSource = dt2; //kreason.DisplayMember = "PLINE_NAME"; //kreason.ValueMember = "PLINE_CODE"; //YdmBaseClass.SetComboItemHeight(kreason); //下拉选离线去向 DataTable dt2 = ServerHelper.GetData("com.steering.mes.mcp.Mch.FrmCrackDetectResult.getQuerydirectOffline", new object[] { plineCode }, this.ob); //comm.FilComboboxAdd(standard, dt2, "BASECODE", "BASENAME", "validflag NOT in ('0')", false, "全部", ""); kreason.DataSource = dt2; kreason.DisplayMember = "OFFLINE_PLACE"; kreason.ValueMember = "OFFLINE_PLACE"; YdmBaseClass.SetComboItemHeight(kreason); foreach (UltraGridRow urg in ultraGridDetailDes1.Rows) { GridEdite(urg); } } private void ultraGridDetailDes1_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e) { UltraGrid ug = (UltraGrid)sender; this.ultraGridDetailDes1.UpdateData(); GridEdite(e.Cell.Row); 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 ultraGridDetailDes2_CellChange(object sender, CellEventArgs e) { UltraGrid ug = (UltraGrid)sender; 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 = ""; } } } private void FrmScrapNum_FormClosing(object sender, FormClosingEventArgs e) { /* UltraGridRow urg = ultraGridDetailDes1.ActiveRow; if (urg != null) { if (Convert.ToBoolean(urg.Cells["CHK"].Text) == true && urg.Cells["GOWHERE_NAME"].Text != "") { if (save == "0") { MessageUtil.ShowTips("请点保存按钮!"); e.Cancel = true; } } }*/ } /// /// /// 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(); } private void ultraGridDetailDes1_AfterRowInsert(object sender, RowEventArgs e) { this.ultraGridDetailDes1.UpdateData(); DataTable dt = kreason.DataSource as DataTable; if (dt != null && dt.Rows.Count > 0) { e.Row.Cells["GOWHERE_NAME"].Value = dt.Rows[0]["OFFLINE_PLACE"].ToString(); } GridEdite(e.Row); } } }