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.StlMes.Client.Mcp.Control.Entity; namespace Core.StlMes.Client.Mcp.Mch { public partial class FrmScrapNumMeasureFail : FrmBase { private ArrayList list = null; private string[] plineCode; private string SLGx = ""; private string SLGxname = ""; private string resultNo = ""; public string reslNo = ""; public string groudno = ""; public string cutnum = ""; private string save = "0"; private string Linenum = ""; private string PlineName = ""; private string heartno = ""; public FrmScrapNumMeasureFail(string heartNo,string slgx, string slgxname, string batchgroudno, string outnumcut, string[] pline_Code, string ResultNo,string linenum,string plineName, OpeBase ob) { InitializeComponent(); this.ob = ob; plineCode = pline_Code; SLGx = slgx; SLGxname = slgxname; groudno = batchgroudno; cutnum = outnumcut; resultNo = ResultNo; Linenum = linenum; PlineName = plineName; heartno = heartNo; } private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e) { switch (e.Tool.Key) { case "Save": Save(); break; case "Close": CloseFrm(); break; } } public static ArrayList CrName= null;//超声701302 public static ArrayList CuName = null;//分切701303 public static ArrayList TrName = null;//车丝701304 public static ArrayList TsName = null;//螺纹检验701305 public static ArrayList CoName = null;//拧接701306 public static ArrayList DrName = null;//通径701307 public static ArrayList HyName = null;//水压701308 public static ArrayList ChName = null;//倒棱701309 public static ArrayList MeName = null;//测量701310 public static int CrNum = 0;//超声701302 public static int CuNum = 0;//分切701303 public static int TrNum = 0;//车丝701304 public static int TsNum = 0;//螺纹检验701305 public static int CoNum = 0;//拧接701306 public static int DrNum = 0;//通径701307 public static int HyNum = 0;//水压701308 public static int ChNum = 0;//倒棱701309 public static int MeNum = 0;//测量701310 private void CloseFrm() { this.DialogResult = System.Windows.Forms.DialogResult.OK; this.Close(); } /// /// 录入绝废 /// private void Save() { this.ultraGridDetailDes1.UpdateData(); IQueryable checkAlarmRows = this.ultraGridDetailDes1.Rows.AsQueryable().Where(" CHK = 'True'"); ArrayList alarmlist = new ArrayList(); ArrayList scraplist = new ArrayList(); int num = 0; foreach (UltraGridRow urrg in ultraGridDetailDes1.Rows) { num = num + int.Parse(urrg.Cells["FAIL_NUM"].Value.ToString()); } if (SLGx == "701302") { CrNum = num; }else if(SLGx == "701303") { CuNum = num; }else if(SLGx == "701304") { TrNum = num; }else if(SLGx == "701305") { TsNum = num; }else if(SLGx == "701306") { CoNum = num; }else if(SLGx == "701307") { DrNum = num; }else if (SLGx == "701308") { HyNum = num; }else if(SLGx == "701309") { ChNum = num; }else if(SLGx == "701310") { MeNum = num; } string time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); ArrayList list = new ArrayList(); list.Add(heartno); list.Add(SLGx); list.Add(SLGxname); 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["FAIL_DIRECT"].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; } //if (Convert.ToInt32(Linenum) <= Convert.ToInt32(uRow.Cells["FAIL_NUM"].Value.ToString())) //{ // MessageUtil.ShowTips("绝废支数不允许大于加工支数!"); // return; //} //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(); resultD.FailDirect = uRow.Cells["FAIL_DIRECT"].Text.ToString().Trim(); resultD.FailNum =decimal.Parse(uRow.Cells["FAIL_NUM"].Value.ToString().Trim()); resultD.FailTypeName = uRow.Cells["FAIL_TYPE_NAME"].Value.ToString().Trim(); alarmlist.Add(resultD); } if (SLGx == "701302") { CrName = alarmlist; if (CrName.Count != 0) { MessageUtil.ShowTips("添加成功!"); save = "1"; this.DialogResult = System.Windows.Forms.DialogResult.OK; } } else if (SLGx == "701303") { CuName = alarmlist; if (CuName.Count != 0) { MessageUtil.ShowTips("添加成功!"); save = "1"; ultraGridDetailDes1.UpdateData(); this.DialogResult = System.Windows.Forms.DialogResult.OK; } } else if (SLGx == "701304") { TrName = alarmlist; if (TrName.Count != 0) { MessageUtil.ShowTips("添加成功!"); save = "1"; this.DialogResult = System.Windows.Forms.DialogResult.OK; } } else if (SLGx == "701305") { TsName = alarmlist; if (TsName.Count != 0) { MessageUtil.ShowTips("添加成功!"); save = "1"; this.DialogResult = System.Windows.Forms.DialogResult.OK; } } else if (SLGx == "701306") { CoName = alarmlist; if (CoName.Count != 0) { MessageUtil.ShowTips("添加成功!"); save = "1"; this.DialogResult = System.Windows.Forms.DialogResult.OK; } } else if (SLGx == "701307") { DrName = alarmlist; if (DrName.Count != 0) { MessageUtil.ShowTips("添加成功!"); save = "1"; this.DialogResult = System.Windows.Forms.DialogResult.OK; } } else if (SLGx == "701308") { HyName = alarmlist; if (HyName.Count != 0) { MessageUtil.ShowTips("添加成功!"); save = "1"; this.DialogResult = System.Windows.Forms.DialogResult.OK; } } else if (SLGx == "701309") { ChName = alarmlist; if (ChName.Count != 0) { MessageUtil.ShowTips("添加成功!"); save = "1"; this.DialogResult = System.Windows.Forms.DialogResult.OK; } } else if (SLGx == "701310") { MeName = alarmlist; if (MeName.Count != 0) { MessageUtil.ShowTips("添加成功!"); save = "1"; this.DialogResult = System.Windows.Forms.DialogResult.OK; } } //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.Mch.FrmMeasureResult"; // ccp.MethodName = "FailExpandResult"; // ccp.ServerParams = new Object[] { alarmlist, result1, list, plineCode, groudno, cutnum, resultNo }; // 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("录入绝废成功!")) // { // Fname = // save = "1"; // this.DialogResult = System.Windows.Forms.DialogResult.OK; // } // else // { // MessageUtil.ShowTips(ccp.ReturnInfo); // } //} } public static void query(string heatNo) { CrNum = 0;//超声701302 CuNum = 0;//分切701303 TrNum = 0;//车丝701304 TsNum = 0;//螺纹检验701305 CoNum = 0;//拧接701306 DrNum = 0;//通径701307 HyNum = 0;//水压701308 ChNum = 0;//倒棱701309 MeNum = 0;//测量701310 } public MchBugDEntity getRowData(UltraGridRow checkrow) { MchBugDEntity resultD = new MchBugDEntity(); resultD.FailDirect = checkrow.Cells["FAIL_DIRECT"].Value.ToString().Trim(); resultD.FailNum =decimal.Parse(checkrow.Cells["FAIL_NUM"].Value.ToString().Trim()); resultD.FailTypeName = checkrow.Cells["FAIL_TYPE_NAME"].Value.ToString().Trim(); return resultD; } 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 FrmScrapNumMeasure_FormClosing(object sender, FormClosingEventArgs e) { UltraGridRow urg = ultraGridDetailDes1.ActiveRow; if (urg != null) { if (Convert.ToBoolean(urg.Cells["CHK"].Text) == true && urg.Cells["FAIL_DIRECT"].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(); GridEdite(e.Row); } } }