using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Data; using System.Linq; using System.Text; using System.Windows.Forms; using Infragistics.Win.UltraWinGrid; using com.steering.mes.mcp.entity; using Core.Mes.Client.Comm.Server; using CoreFS.CA06; using Core.Mes.Client.Comm.Tool; using Core.StlMes.Client.Mcp.Control.Entity; using Infragistics.Win; namespace Core.StlMes.Client.Mcp.Control { public partial class HttInstructionCardControl : UserControl { private OpeBase ob; public OpeBase Ob { get { return ob; } set { ob = value; } } private string _plineCode = ""; public void DisableFiltering() { ultraGrid1.DisplayLayout.Override.AllowRowFiltering = DefaultableBoolean.False; } public List PortHttBatchSampleResultEntitys { get; set; } List Names = new List(); /// /// 废品 /// public List ScrappedList { get; private set; } public HttLoadingResultEntity Value { get { List list = httLoadingResultEntityBindingSource.DataSource as List; return list==null || !list.Any()?new HttLoadingResultEntity(): list.FirstOrDefault(); } set { if (value == null) { httLoadingResultEntityBindingSource.DataSource = new List() { new HttLoadingResultEntity() }; ScrappedList = new List(); } else { httLoadingResultEntityBindingSource.DataSource = new List() {value.Clone()}; if (ob == null || ob.MainUrl == "") return; if (_plineCode != Value.PlineCode) { Names = EntityHelper.GetData( "com.steering.mes.mcp.heatTreatment.FrmHttCrackDetectResult.getHttSign", new object[] {Value.PlineCode, "0"}, Ob); name.DataSource = Names.Where(p => p.ColGroup == value.LoadGroup).ToList(); name.DisplayMember = "UserName"; name.ValueMember = "UserName"; YdmBaseClass.SetComboItemHeight(name); _plineCode = Value.PlineCode; } if (!string.IsNullOrEmpty(value.ResultNo) && value.FailNum > 0 && value.FailNum != ScrappedList.Count) { ScrappedList = EntityHelper.GetData( "com.steering.mes.mcp.heatTreatment.FrmHttBugD.doQueryScrapNum", new object[] {"", value.ResultNo}, Ob); } if (value.FailNum == 0) { ScrappedList = new List(); } } } } /// /// 上料炉号 /// public string FeedStoveNo { get; set; } public decimal ActCount { get; set; } public string BatchNo { get; set; } public string GroupNo { get; set; } public string JudgeNo { get; set; } 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; } } public HttInstructionCardControl() { ScrappedList = new DataSourceList(); InitializeComponent(); EntityHelper.ShowGridCaption(ultraGrid1.DisplayLayout.Bands[0]); } public void ShowPro(bool isPro) { ultraGrid1.DisplayLayout.Bands[0].Columns["Producer"].CellActivation = isPro? Activation.AllowEdit:Activation.ActivateOnly; ultraGrid1.DisplayLayout.Bands[0].Columns["ProducerTime"].CellActivation =isPro? Activation.AllowEdit : Activation.ActivateOnly; } private void ultraGrid1_CellChange(object sender, CellEventArgs e) { ultraGrid1.UpdateData(); if (e.Cell.Column.Key.Equals("ProNum") && Value.ProNum != null && Value.ProcessSeq != null) { DataTable dt = ServerHelper.GetData("com.steering.mes.mcp.heatTreatment.HttLoadingService.getQueryWeight", new object[] { Value.ProNum.ToString2(),Value.HeatPlanNo, BatchNo, GroupNo }, this.Ob); if (dt.Rows.Count > 0) { decimal weigt; decimal.TryParse(dt.Rows[0]["ACT_WEIGHT"].ToString(), out weigt); Value.ProWt = weigt; } } if (e.Cell.Column.Key.Equals("LoadGroup") && Value.LoadGroup != null) { name.DataSource = Names.Where(p => p.ColGroup == Value.LoadGroup).ToList(); } if (e.Cell.Column.Key.Equals("ProcessSeq") && Value.ProNum != null && Value.ProcessSeq != null) { if (Value.ProcessSeq == 1) { Value.ProNum = ActCount; DataTable dt = ServerHelper.GetData("com.steering.mes.mcp.heatTreatment.HttLoadingService.getQueryWeight", new object[] { Value.ProNum.ToString2(), FeedStoveNo, BatchNo, GroupNo }, this.Ob); if (dt.Rows.Count > 0) { decimal weigt; decimal.TryParse(dt.Rows[0]["ACT_WEIGHT"].ToString(), out weigt); Value.ProWt = weigt; } } else { Value.ProNum = PortHttBatchSampleResultEntitys.Count( p => (p.ProcessSeq == Value.ProcessSeq - 1) && (p.MatStatus == "00" || p.MatStatus == "合格")); Value.ProWt = PortHttBatchSampleResultEntitys.Where( p => p.ProcessSeq == Value.ProcessSeq - 1 && (p.MatStatus == "00" || p.MatStatus == "合格")) .Take(int.Parse(Value.ProNum.ToString3())).Sum(p => p.ActWeight); } } ultraGrid1.Refresh(); } private void craftImg_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e) { if(Value.HeatPlanNo==null) { return; } if (Value.PlineCode == null) { return; } List PortHttBatch = EntityHelper.GetData( "com.steering.mes.mcp.heatTreatment.ScrapHelper.doQueryLoadHttPort", new object[] { Value.HeatPlanNo, BatchNo, GroupNo,JudgeNo}, ob); FrmScrapHttNew matfrm = new FrmScrapHttNew(this.ob, null, ScrappedList, false, Value.HeatPlanNo, int.Parse(Value.ProcessSeq.ToString3()), "600401", "", BatchNo, PortHttBatch); matfrm.ShowDialog(); if (matfrm.DialogResult == DialogResult.OK) { ScrappedList = matfrm.ScrappedList; Value.FailNum = ScrappedList.Sum(p=>p.DefFillNum); } Value.FailNum = Value.FailNum ?? 0; ultraGrid1.PerformAction(UltraGridAction.ExitEditMode); this.ultraGrid1.UpdateData(); } } }