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; namespace Core.StlMes.Client.Mcp.Mch { public partial class FrmScrapNumThreadinspect : FrmBase { private ArrayList list = null; private string plineCode = ""; private string SLGx = ""; private string SLGxname = ""; 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 = ""; MchHreadResultEntity result1 = new MchHreadResultEntity();//螺纹检验 public FrmScrapNumThreadinspect(MchHreadResultEntity result, string heatNo, string slgx, string slgxname, 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; SLGxname = slgxname; groudno = batchgroudno; cutnum = outnumcut; StorageNo = storageNo; heatPlanNo = heatNo; resultNo = ResultNo; result1 = result; Linenum = linenum; PlineName = plineName; } 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'"); ArrayList alarmlist = new ArrayList(); ArrayList scraplist = new ArrayList(); int num = 0; foreach (UltraGridRow urrg in ultraGridDetailDes1.Rows) { num = num + int.Parse(urrg.Cells["OFFLINE_NUM"].Value.ToString()); } string time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); ArrayList list = new ArrayList(); list.Add(heatPlanNo); 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["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"].Text.ToString())) { MessageUtil.ShowTips("离线支数不允许大于加工支数!"); return; } MchOfflineResultDentity 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(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.Mch.FrmThreadInspectResult"; ccp.MethodName = "offLineExpandResult"; ccp.ServerParams = new Object[] { alarmlist,result1, list, plineCode, StorageNo, groudno, cutnum }; 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; } else { MessageUtil.ShowTips(ccp.ReturnInfo); } } } public MchOfflineResultDentity getRowData(UltraGridRow checkrow) { MchOfflineResultDentity resultD = new MchOfflineResultDentity(); resultD.GowhereName = checkrow.Cells["GOWHERE_NAME"].Value.ToString().Trim(); resultD.OfflineNum = checkrow.Cells["OFFLINE_NUM"].Value.ToString().Trim(); return resultD; } 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 = "PLINE_NAME"; kreason.ValueMember = "PLINE_CODE"; 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 FrmScrapNumThreadinspect_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(); GridEdite(e.Row); } } }