using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using CoreFS.CA06; using Core.StlMes.Client.YdmStuffManage.Entity; using Core.Mes.Client.Comm.Tool; using System.Collections; using Infragistics.Win.UltraWinEditors; using Core.StlMes.Client.YdmBase; using Infragistics.Win.UltraWinGrid; using Core.Mes.Client.Comm.Format; using Infragistics.Win; using Core.Mes.Client.Comm.Server; namespace Core.StlMes.Client.YdmStuffManage { public partial class FrmStuffSurfaceInspection : FrmBase { public FrmStuffSurfaceInspection() { InitializeComponent(); } private void FrmStuffSurfaceInspection_Load(object sender, EventArgs e) { DateTime now = DateTime.Now; DateTime dt1 = new DateTime(now.Year, now.Month, 1);//当月第一天 DateTime dt2 = dt1.AddMonths(1).AddDays(-1);//当月最后一天 RegStartTime.Value = DateTime.Parse(dt1.ToString("yyyy-MM-dd") + " 00:00:00"); RegEndTime.Value = DateTime.Parse(dt2.ToString("yyyy-MM-dd") + " 23:59:59"); EntityHelper.ShowGridCaption(ultraGrid2.DisplayLayout.Bands[0]); EntityHelper.ShowGridCaption(ultraGrid2.DisplayLayout.Bands[1]); EntityHelper.ShowGridCaption(ultraGrid1.DisplayLayout.Bands[0]); EntityHelper.ShowGridCaption(ultraGrid1.DisplayLayout.Bands[1]); BaseMethod.InitCellPosition(ultraGrid2, new string[] {"ActCount", "ActLenMax", "ActLenMin", "ActTheoryWeight", "ActHeight", "ActDimater", "CuttingNum", "ActLen", "ActFixNum", "ActFixLen" }); BaseMethod.InitCellPosition(ultraGrid2, new string[] { "ActCount", "ActTheoryWeight", "ActLen", "CheckLen", "ActDimater", "CheckDimater" }, 1); BaseMethod.InitCellPosition(ultraGrid1, new string[] { "ActCount", "ActLenMax", "ActLenMin", "ActTheoryWeight", "ActDimater", "ActLen", "ActFixNum", "ActFixLen", "Quantity", "Eligiblequty"}); BaseMethod.InitCellPosition(ultraGrid1, new string[] { "ActCount", "ActTheoryWeight", "ActLen", "CheckLen", "ActDimater", "CheckDimater" }, 1); InitBaseBug(); } UltraComboEditor bugLocation = new UltraComboEditor(); UltraComboEditor bugName1 = new UltraComboEditor(); UltraComboEditor bugName2 = new UltraComboEditor(); UltraComboEditor bugName3 = new UltraComboEditor(); UltraComboEditor bugName4 = new UltraComboEditor(); UltraComboEditor bugName5 = new UltraComboEditor(); /// /// 加载缺陷 /// private void InitBaseBug() { ClsBaseInfo.FillComBaseInfo(bugLocation, "4082", ob, true); //YdmBaseClass.InitComboEditor(bugLocation, "com.steering.pss.ydm.Stuffmanage.FrmStuffSurfaceInspection.getBugLocation", "BASECODE", this.ob, true); YdmBaseClass.BindColumn(bugLocation, "BugPosName", this.Controls, this.ultraGrid2, 1); YdmBaseClass.InitComboEditor(bugName1, "com.steering.pss.ydm.Stuffmanage.FrmStuffSurfaceInspection.getBugName", "BASECODE", this.ob, true); YdmBaseClass.BindColumn(bugName1, "BugName1", this.Controls, this.ultraGrid2, 1); YdmBaseClass.InitComboEditor(bugName2, "com.steering.pss.ydm.Stuffmanage.FrmStuffSurfaceInspection.getBugName", "BASECODE", this.ob, true); YdmBaseClass.BindColumn(bugName2, "BugName2", this.Controls, this.ultraGrid2, 1); YdmBaseClass.InitComboEditor(bugName3, "com.steering.pss.ydm.Stuffmanage.FrmStuffSurfaceInspection.getBugName", "BASECODE", this.ob, true); YdmBaseClass.BindColumn(bugName3, "BugName3", this.Controls, this.ultraGrid2, 1); YdmBaseClass.InitComboEditor(bugName4, "com.steering.pss.ydm.Stuffmanage.FrmStuffSurfaceInspection.getBugName", "BASECODE", this.ob, true); YdmBaseClass.BindColumn(bugName4, "BugName4", this.Controls, this.ultraGrid2, 1); YdmBaseClass.InitComboEditor(bugName5, "com.steering.pss.ydm.Stuffmanage.FrmStuffSurfaceInspection.getBugName", "BASECODE", this.ob, true); YdmBaseClass.BindColumn(bugName5, "BugName5", this.Controls, this.ultraGrid2, 1); } /// /// 重写基类方法 /// /// /// public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey) { case "Query": doQueryData(); break; case"QuerySurFace": doQuerySurFace(); break; case"Ensure": EnsureData(); break; case "Close": this.Close(); break; } } /// /// 查询检验结果 /// private void doQuerySurFace() { string regStartTim = ""; string regEndTim = ""; string heatNo = ""; if (this.chkRegTime.Checked) { regStartTim = RegStartTime.Value.ToString(); regEndTim = RegEndTime.Value.ToString(); } if (this.chkFurnace.Checked) { heatNo = this.txtFurnace.Text.Trim(); } ArrayList parm = new ArrayList(); parm.Add(heatNo); List listSource = EntityHelper.GetData( "com.steering.pss.ydm.Stuffmanage.FrmStuffSurfaceInspection.doQuerySurFace", new object[] { parm, regStartTim, regEndTim }, this.ob); List listSource2 = EntityHelper.GetData( "com.steering.pss.ydm.Stuffmanage.FrmStuffSurfaceInspection.doQuerySurFaceC", new object[] {regStartTim, regEndTim }, this.ob); EntityHelper.AddEntityRelation(listSource, listSource2, "bugNo","bugNo"); QcmLgSurfaceMEntitybindingSource.DataSource = listSource; } /// /// 查询收料信息 /// private void doQueryData() { string regStartTim = ""; string regEndTim = ""; string heatNo = ""; string[] L1 = new string[] { "GroudNo", "JudgeStoveNo", "FaceResultCode" }; string[] L2 = new string[] { "GroudNo", "JudgeStoveNo", "FaceResultCode" }; if (this.chkRegTime.Checked) { regStartTim = RegStartTime.Value.ToString(); regEndTim = RegEndTime.Value.ToString(); } if (this.chkFurnace.Checked) { heatNo = this.txtFurnace.Text.Trim(); } ArrayList parm = new ArrayList(); parm.Add(heatNo); List listSource = EntityHelper.GetData( "com.steering.pss.ydm.Stuffmanage.FrmStuffSurfaceInspection.doQueryMat", new object[] { parm, regStartTim, regEndTim }, this.ob); List listSource2 = EntityHelper.GetData( "com.steering.pss.ydm.Stuffmanage.FrmStuffSurfaceInspection.doQueryMatC", new object[] { parm, regStartTim, regEndTim }, this.ob); EntityHelper.AddEntityRelation(listSource, listSource2, L1, L2); MatGpMEntity1bindingSource.DataSource = listSource; this.chkAll.Checked = false; } /// /// 确认缺陷 /// private void EnsureData() { this.ultraGrid2.UpdateData(); int m = 0; QcmLgSurfaceCEntity qcmEntity = null; QcmLgSurfaceCEntity _qcmEntity = null; string qcmTity = ""; string _qcmTity = ""; IQueryable checkMagRows = this.ultraGrid2.Rows.AsQueryable().Where(" CHK = 'True'"); if (checkMagRows.Count() == 0) { MessageUtil.ShowTips("请选择需要确认缺陷的主信息!"); return; } ArrayList parm = new ArrayList(); ArrayList list = new ArrayList(); ArrayList list1 = new ArrayList(); foreach (UltraGridRow uRow in checkMagRows) { if (!((int.Parse(uRow.Cells["QualifiedCount"].Text) + int.Parse(uRow.Cells["NoQualifiedCount"].Text)).ToString()).Equals(uRow.Cells["ActCount"].Text)) { MessageUtil.ShowTips("输入的合格支数/不合格支数有误,请重新输入!"); return; } MatGpMEntity1 matGpEntity = (MatGpMEntity1)uRow.ListObject; string matTity = JSONFormat.Format(matGpEntity); parm.Add(matTity); foreach (UltraGridRow row in uRow.ChildBands[0].Rows) { if (row.Cells["CHK"].Value.ToString() == "True") { if (row.Cells["CheckDimater"].Text.ToString() != "") { if (!StringUtil.IsInt(row.Cells["CheckDimater"].Value.ToString())) { MessageUtil.ShowTips("输入的检验规格需为整数!"); return; } } if (row.Cells["CheckLen"].Text.ToString() != "") { if (!StringUtil.IsInt(row.Cells["CheckLen"].Value.ToString())) { MessageUtil.ShowTips("输入的检验长度需为整数!"); return; } } if (row.Cells["BugPosName"].Value.ToString() == "" && row.Cells["BugName1"].Value.ToString() == "" && row.Cells["BugName2"].Value.ToString() == "" && row.Cells["BugName3"].Value.ToString()=="" && row.Cells["BugName4"].Value.ToString() == "" && row.Cells["BugName5"].Value.ToString() == "") { m = m + 1; } if (row.Cells["BugPosName"].Value.ToString() != "" || row.Cells["BugName1"].Value.ToString() != "" && row.Cells["BugName2"].Value.ToString() != "" && row.Cells["BugName3"].Value.ToString() != "" && row.Cells["BugName4"].Value.ToString() != "" && row.Cells["BugName5"].Value.ToString() != "") { qcmEntity = EntityHelper.CopyEntity(row.ListObject); qcmEntity.BugCode1 = row.Cells["BugName1"].Value.ToString(); qcmEntity.BugCode2 = row.Cells["BugName2"].Value.ToString(); qcmEntity.BugCode3 = row.Cells["BugName3"].Value.ToString(); qcmEntity.BugCode4 = row.Cells["BugName4"].Value.ToString(); qcmEntity.BugCode5 = row.Cells["BugName5"].Value.ToString(); qcmEntity.BugPosCode = row.Cells["BugPosName"].Value.ToString(); qcmTity = JSONFormat.Format(qcmEntity); list.Add(qcmTity); } else { _qcmEntity = (QcmLgSurfaceCEntity)row.ListObject; _qcmTity = JSONFormat.Format(_qcmEntity); list1.Add(_qcmTity); } } } if (!m.ToString().Equals(uRow.Cells["QualifiedCount"].Text)) { MessageUtil.ShowTips("输入合格支数与登记合格支数不相符,请确认数据的正确性!"); return; } } if (MessageUtil.ShowYesNoAndQuestion("是否确认缺陷?") == DialogResult.No) { return; } CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.pss.ydm.Stuffmanage.FrmStuffSurfaceInspection"; ccp.MethodName = "ensureBug"; ccp.ServerParams = new object[] {parm,list,list1,this.UserInfo.GetUserName(),"C009"}; ccp = ob.ExecuteNonQuery(ccp,CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { if (ccp.ReturnInfo.Equals("确认检验结果成功!")) { doQueryData(); MessageUtil.ShowTips(ccp.ReturnInfo); } } else { MessageUtil.ShowTips(ccp.ReturnInfo); } } private void chkFurnace_CheckedChanged(object sender, EventArgs e) { this.txtFurnace.Enabled = this.chkFurnace.Checked; } private void ultraGrid2_CellChange(object sender, CellEventArgs e) { if (e.Cell.Row.HasParent()) { this.ultraGrid2.UpdateData(); if (e.Cell.Column.Key.Equals("CHK")) { if (e.Cell.Row.Cells["CHK"].Value.ToString() == "True") { e.Cell.Row.ParentRow.Cells["Quantity"].Value = (int.Parse(e.Cell.Row.ParentRow.Cells["Quantity"].Value.ToString()) + 1).ToString();//检验支数 } else { e.Cell.Row.ParentRow.Cells["Quantity"].Value = (int.Parse(e.Cell.Row.ParentRow.Cells["Quantity"].Value.ToString())- 1).ToString();//检验支数 } //if (e.Cell.Row.HasChild()) //{ // for (int i = 0; i < e.Cell.Row.ChildBands[0].Rows.Count; i++) // { // e.Cell.Row.ChildBands[0].Rows[i].Cells["CHK1"].Value = "true"; // } //} } if (e.Cell.Column.Key.Equals("BugName1")) { if (e.Cell.Row.Cells["BugName1"].Value.ToString() != "") { if (e.Cell.Row.Cells["BugName1"].Value.ToString().Equals(e.Cell.Row.Cells["BugName2"].Value.ToString()) || e.Cell.Row.Cells["BugName1"].Value.ToString().Equals(e.Cell.Row.Cells["BugName3"].Value.ToString()) || e.Cell.Row.Cells["BugName1"].Value.ToString().Equals(e.Cell.Row.Cells["BugName4"].Value.ToString()) || e.Cell.Row.Cells["BugName1"].Value.ToString().Equals(e.Cell.Row.Cells["BugName5"].Value.ToString())) { MessageUtil.ShowTips("此缺陷【" + e.Cell.Row.Cells["BugName1"].Text.ToString() + "】已被选择,不允许重复选择!"); return; } } } if (e.Cell.Column.Key.Equals("BugName2")) { if (e.Cell.Row.Cells["BugName2"].Value.ToString() != "") { if (e.Cell.Row.Cells["BugName2"].Value.ToString().Equals(e.Cell.Row.Cells["BugName1"].Value.ToString()) || e.Cell.Row.Cells["BugName2"].Value.ToString().Equals(e.Cell.Row.Cells["BugName3"].Value.ToString()) || e.Cell.Row.Cells["BugName2"].Value.ToString().Equals(e.Cell.Row.Cells["BugName4"].Value.ToString()) || e.Cell.Row.Cells["BugName2"].Value.ToString().Equals(e.Cell.Row.Cells["BugName5"].Value.ToString())) { MessageUtil.ShowTips("此缺陷【" + e.Cell.Row.Cells["BugName2"].Text.ToString() + "】已被选择,不允许重复选择!"); e.Cell.Row.Cells["BugName2"].Value = ""; return; } } } if (e.Cell.Column.Key.Equals("BugName3")) { if (e.Cell.Row.Cells["BugName3"].Value.ToString() != "") { if (e.Cell.Row.Cells["BugName3"].Value.ToString().Equals(e.Cell.Row.Cells["BugName1"].Value.ToString()) || e.Cell.Row.Cells["BugName3"].Value.ToString().Equals(e.Cell.Row.Cells["BugName2"].Value.ToString()) || e.Cell.Row.Cells["BugName3"].Value.ToString().Equals(e.Cell.Row.Cells["BugName4"].Value.ToString()) || e.Cell.Row.Cells["BugName3"].Value.ToString().Equals(e.Cell.Row.Cells["BugName5"].Value.ToString())) { MessageUtil.ShowTips("此缺陷【" + e.Cell.Row.Cells["BugName3"].Text.ToString() + "】已被选择,不允许重复选择!"); e.Cell.Row.Cells["BugName3"].Value = ""; return; } } } if (e.Cell.Column.Key.Equals("BugName4")) { if (e.Cell.Row.Cells["BugName4"].Value.ToString() != "") { if (e.Cell.Row.Cells["BugName4"].Value.ToString().Equals(e.Cell.Row.Cells["BugName1"].Value.ToString()) || e.Cell.Row.Cells["BugName4"].Value.ToString().Equals(e.Cell.Row.Cells["BugName2"].Value.ToString()) || e.Cell.Row.Cells["BugName4"].Value.ToString().Equals(e.Cell.Row.Cells["BugName3"].Value.ToString()) || e.Cell.Row.Cells["BugName4"].Value.ToString().Equals(e.Cell.Row.Cells["BugName5"].Value.ToString())) { MessageUtil.ShowTips("此缺陷【" + e.Cell.Row.Cells["BugName4"].Text.ToString() + "】已被选择,不允许重复选择!"); e.Cell.Row.Cells["BugName4"].Value = ""; return; } } } if (e.Cell.Column.Key.Equals("BugName5")) { if (e.Cell.Row.Cells["BugName5"].Value.ToString() != "") { if (e.Cell.Row.Cells["BugName5"].Value.ToString().Equals(e.Cell.Row.Cells["BugName1"].Value.ToString()) || e.Cell.Row.Cells["BugName5"].Value.ToString().Equals(e.Cell.Row.Cells["BugName2"].Value.ToString()) || e.Cell.Row.Cells["BugName5"].Value.ToString().Equals(e.Cell.Row.Cells["BugName3"].Value.ToString()) || e.Cell.Row.Cells["BugName5"].Value.ToString().Equals(e.Cell.Row.Cells["BugName4"].Value.ToString())) { MessageUtil.ShowTips("此缺陷【" + e.Cell.Row.Cells["BugName5"].Text.ToString() + "】已被选择,不允许重复选择!"); e.Cell.Row.Cells["BugName5"].Value = ""; return; } } } } } private void FrmStuffSurfaceInspection_Shown(object sender, EventArgs e) { if (toolMenu == null) return; if (toolMenu.Toolbars[0].Tools.Exists("QuerySurFace")) { toolMenu.Toolbars[0].Tools["QuerySurFace"].InstanceProps.Visible = DefaultableBoolean.False; } } private void ultraTabControl1_SelectedTabChanged(object sender, Infragistics.Win.UltraWinTabControl.SelectedTabChangedEventArgs e) { if (toolMenu == null) return; if (ultraTabControl1.SelectedTab.Key == "0") { if (toolMenu.Toolbars[0].Tools.Exists("Query")) { toolMenu.Toolbars[0].Tools["Query"].InstanceProps.Visible = DefaultableBoolean.True; } if (toolMenu.Toolbars[0].Tools.Exists("Ensure")) { toolMenu.Toolbars[0].Tools["Ensure"].InstanceProps.Visible = DefaultableBoolean.True; } if (toolMenu.Toolbars[0].Tools.Exists("QuerySurFace")) { toolMenu.Toolbars[0].Tools["QuerySurFace"].InstanceProps.Visible = DefaultableBoolean.False; } this.chkRegTime.Text = "收料时间"; } else { if (toolMenu.Toolbars[0].Tools.Exists("Query")) { toolMenu.Toolbars[0].Tools["Query"].InstanceProps.Visible = DefaultableBoolean.False; } if (toolMenu.Toolbars[0].Tools.Exists("Ensure")) { toolMenu.Toolbars[0].Tools["Ensure"].InstanceProps.Visible = DefaultableBoolean.False; } if (toolMenu.Toolbars[0].Tools.Exists("QuerySurFace")) { toolMenu.Toolbars[0].Tools["QuerySurFace"].InstanceProps.Visible = DefaultableBoolean.True; } this.chkRegTime.Text = "检验时间"; } } private void chkRegTime_CheckedChanged(object sender, EventArgs e) { this.RegStartTime.Enabled = this.chkRegTime.Checked; this.RegEndTime.Enabled = this.chkRegTime.Checked; } private void chkAll_CheckedChanged(object sender, EventArgs e) { if (chkAll.Checked) { foreach (UltraGridRow row in ultraGrid2.Rows) { if (row.Cells["CHK"].Text == "True") { foreach (UltraGridRow uRow in row.ChildBands[0].Rows) { //if (uRow.Cells["CXSTUPP"].Value.ToString().Equals("")) //{ // chkint += 1; // if (chkint > 50) return; uRow.Cells["CHK"].Value = true; row.Cells["Quantity"].Value = (int.Parse(row.Cells["Quantity"].Value.ToString()) + 1).ToString();//检验支数 //} } } } } else { foreach (UltraGridRow row in ultraGrid2.Rows) { if (row.Cells["CHK"].Text == "True") { foreach (UltraGridRow uRow in row.ChildBands[0].Rows) { //if (uRow.Cells["CXSTUPP"].Value.ToString().Equals("")) //{ // chkint += 1; // if (chkint > 50) return; uRow.Cells["CHK"].Value = false; row.Cells["Quantity"].Value = (int.Parse(row.Cells["Quantity"].Value.ToString()) - 1).ToString();//检验支数 //} } } } } } } }