using System; using System.Collections.Generic; using System.Data; using System.Drawing; using System.Linq; using System.Windows.Forms; using Core.Mes.Client.Comm.Server; using Core.StlMes.Client.Mcp.Control.Entity; using CoreFS.CA06; using Infragistics.Win; using Infragistics.Win.UltraWinEditors; using Infragistics.Win.UltraWinGrid; namespace Core.StlMes.Client.Mcp.Control.Machining { public partial class MchControlBase : UserControl { public MchControlBase() { InitializeComponent(); ScrappedList = new List(); SuspiciousList = new List(); } protected string _plineCode = ""; protected List Names = new List(); protected OpeBase ob; public OpeBase Ob { get { return ob; } set { ob = value; } } public void DisableFiltering() { ultraGrid1.DisplayLayout.Override.AllowRowFiltering = DefaultableBoolean.False; ultraGrid1.DisplayLayout.Override.HeaderClickAction = HeaderClickAction.Default; } public void SetFont(Font f1) { ultraGrid1.Font = f1; foreach (UltraGridColumn UltraGridColumn in ultraGrid1.DisplayLayout.Bands[0].Columns) { UltraGridColumn.Header.Appearance.FontData.Bold = f1.Bold ? DefaultableBoolean.True : DefaultableBoolean.False; UltraGridColumn.Header.Appearance.FontData.Name = f1.Name; UltraGridColumn.Header.Appearance.FontData.SizeInPoints = f1.SizeInPoints; } if (ultraGrid1.DisplayLayout.Bands[0].Groups != null && ultraGrid1.DisplayLayout.Bands[0].Groups.Count>0) foreach (var group in ultraGrid1.DisplayLayout.Bands[0].Groups) { group.Header.Appearance.FontData.Bold = f1.Bold ? DefaultableBoolean.True : DefaultableBoolean.False; group.Header.Appearance.FontData.Name = f1.Name; group.Header.Appearance.FontData.SizeInPoints = f1.SizeInPoints; } } public List PortHttBatchSampleResultEntitys { get; set; } public string gx { get; set; } protected virtual string ScrapCode { get { return "701501"; } } protected virtual string SuspiciousCode { get { return "7016"; } } /// /// 废品 /// public List ScrappedList { get; protected set; } /// /// 可疑 /// public List SuspiciousList { get; protected set; } private PlnZyJgxCEntity _plnZyJgxCEntity = null; /// /// 炉计划 /// public PlnZyJgxCEntity PlnZyJgxCEntity { get { return _plnZyJgxCEntity; } set { if (ob == null) return; if(_plnZyJgxCEntity==null || (value!=null && _plnZyJgxCEntity.PlineCode != value.PlineCode)) { DataTable ds = ServerHelper.GetData("com.steering.mes.mcp.Mch.MchComm.GetGx", new object[] { value.PlineCode }, ob); if (ds.Rows.Count > 0) { ProductionOrder = ds.Rows[0]["STATION_CODES"].ToString2(); } else { ProductionOrder = "701301;701311"; } } _plnZyJgxCEntity = value; }} private string ProductionOrder = ""; public List OkPort { get { return PortHttBatchSampleResultEntitys==null? new List() : PortHttBatchSampleResultEntitys.Where( p => ((p.MatStatus == "00") || (p.MatStatus == "合格")) || CheckGx2(p.OpProcessCode, gx)).ToList(); } } public List OkPort2 { get { return PortHttBatchSampleResultEntitys == null ? new List() : PortHttBatchSampleResultEntitys.Where( p => ((p.MatStatus == "00") || (p.MatStatus == "合格")) || CheckGx(p.OpProcessCode, gx)).ToList(); } } public bool CheckGx(string code1, string code2) { return ProductionOrder.IndexOf(code1, StringComparison.Ordinal) > ProductionOrder.IndexOf(code2, StringComparison.Ordinal); } public bool CheckGx2(string code1, string code2) { return ProductionOrder.IndexOf(code1, StringComparison.Ordinal) >= ProductionOrder.IndexOf(code2, StringComparison.Ordinal); } protected virtual void ultraGrid1_CellChange(object sender, CellEventArgs e) { try { ultraGrid1.UpdateData(); if (e.Cell.Column.Key.Equals("ProTime") || e.Cell.Column.Key.Equals("ProEndTime")) { if(e.Cell.Text.Contains("_")) return; } if (e.Cell.Column.Key.Equals("ProNum")) { if ("701312" == gx) { e.Cell.Row.Cells["ProWt"].Value = comm.GetWeight1(PortHttBatchSampleResultEntitys, gx, int.Parse(e.Cell.Value.ToString3()), int.Parse(PlnZyJgxCEntity.ProCount.ToString3())); } else { e.Cell.Row.Cells["ProWt"].Value = comm.GetWeight(PortHttBatchSampleResultEntitys, gx, int.Parse(e.Cell.Value.ToString3()), int.Parse(PlnZyJgxCEntity.ProCount.ToString3())); } if (ultraGrid1.DisplayLayout.Bands[0].Columns.Exists("QualifiedNum")) { e.Cell.Row.Cells["QualifiedNum"].Value = e.Cell.Value; e.Cell.Row.Cells["QualifiedWt"].Value = e.Cell.Row.Cells["ProWt"].Value; } if (ultraGrid1.DisplayLayout.Bands[0].Columns.Exists("FinalQualifiedNum")) { e.Cell.Row.Cells["FinalQualifiedNum"].Value = e.Cell.Value; e.Cell.Row.Cells["FinalQualifiedWt"].Value = e.Cell.Row.Cells["ProWt"].Value; } } if (e.Cell.Column.Key.Equals("FinalQualifiedNum")) { e.Cell.Row.Cells["FinalQualifiedWt"].Value = comm.GetWeight(PortHttBatchSampleResultEntitys, gx, int.Parse(e.Cell.Value.ToString3()), int.Parse(PlnZyJgxCEntity.ProCount.ToString3())); } if (e.Cell.Column.Key.Equals("QualifiedNum")) { e.Cell.Row.Cells["QualifiedWt"].Value = comm.GetWeight(PortHttBatchSampleResultEntitys, gx, int.Parse(e.Cell.Value.ToString3()), int.Parse(PlnZyJgxCEntity.ProCount.ToString3())); } if (e.Cell.Column.Key.Equals("ReProNum")) { e.Cell.Row.Cells["ReProWt"].Value = comm.GetWeight(PortHttBatchSampleResultEntitys, gx, int.Parse(e.Cell.Value.ToString3()), int.Parse(PlnZyJgxCEntity.ProCount.ToString3())); } if (e.Cell.Column.Key.Equals("ProGroup") && e.Cell.Value != null) { name.DataSource = Names.Where(p => p.ColGroup == e.Cell.Value.ToString2()).ToList(); } if (e.Cell.Column.Key.Equals("ProUser") && e.Cell.Value != null && e.Cell.Row.Cells.Exists("Responsible")) { var list = Names.Where( p => p.ColGroup == e.Cell.Row.Cells["ProGroup"].Value.ToString2() && p.UserName == e.Cell.Value.ToString2()) .ToList(); if (list.Any()) e.Cell.Row.Cells["Responsible"].Value = list[0].Responsible; } if (e.Cell.Row.Cells.Exists("FinalQualifiedNum") && e.Cell.Row.Cells.Exists("QualifiedNum") && e.Cell.Row.Cells.Exists("ReProNum")) { e.Cell.Row.Cells["FinalQualifiedNum"].Value = decimal.Parse(e.Cell.Row.Cells["QualifiedNum"].Value.ToString3()) + decimal.Parse(e.Cell.Row.Cells["ReProNum"].Value.ToString3()); } /* if (e.Cell.Row.Cells.Exists("QualifiedNum") && e.Cell.Row.Cells.Exists("ProNum")) { e.Cell.Row.Cells["QualifiedNum"].Value = decimal.Parse(e.Cell.Row.Cells["ProNum"].Value.ToString3()) - decimal.Parse(e.Cell.Row.Cells["FailNum"].Value.ToString3()); }*/ ultraGrid1.Refresh(); } catch (Exception ex) { } } private void uteScrapped_EditorButtonClick(object sender, EditorButtonEventArgs e) { if (PlnZyJgxCEntity==null) return; if (PlnZyJgxCEntity.HeatPlanNo == null) return; if (PlnZyJgxCEntity.PlineCode == null) return; var matfrm = new FrmScrapMchNew(Ob, ScrappedList, PlnZyJgxCEntity.HeatPlanNo, ScrapCode, PlnZyJgxCEntity.BatchNo, PlnZyJgxCEntity.BatchGroudNo, gx == "701303"){Text = "废品原因"}; matfrm.ShowDialog(); if (matfrm.DialogResult == DialogResult.OK) { ScrappedList = matfrm.dataList; EditScrapped(); ultraGrid1_CellChange(ultraGrid1, new CellEventArgs(ultraGrid1.ActiveCell)); } // Value.DubiousNum = Value.DubiousNum ?? 0; ultraGrid1.PerformAction(UltraGridAction.ExitEditMode); ultraGrid1.UpdateData(); } /// /// 录入废品成功后 /// protected virtual void EditScrapped() { } private void uteSuspicious_EditorButtonClick(object sender, EditorButtonEventArgs e) { if (PlnZyJgxCEntity == null) return; if (PlnZyJgxCEntity.HeatPlanNo == null) return; if (PlnZyJgxCEntity.PlineCode == null) return; var matfrm = new FrmScrapMchNew(Ob, SuspiciousList, PlnZyJgxCEntity.HeatPlanNo, SuspiciousCode, PlnZyJgxCEntity.BatchNo, PlnZyJgxCEntity.BatchGroudNo,false,false) { Text = "可疑原因" }; ; matfrm.ShowDialog(); // Value.DubiousNum = Value.DubiousNum ?? 0; ultraGrid1.PerformAction(UltraGridAction.ExitEditMode); ultraGrid1.UpdateData(); if (matfrm.DialogResult == DialogResult.OK) { SuspiciousList = matfrm.dataList; EditSuspicious(); } ultraGrid1.PerformAction(UltraGridAction.ExitEditMode); ultraGrid1.UpdateData(); } /// /// 录入可疑成功后 /// protected virtual void EditSuspicious() { } } }