using System; using System.Collections.Generic; using System.Drawing; using System.Linq; using System.Windows.Forms; using Core.Mes.Client.Comm.Tool; using Core.StlMes.Client.LgResMgt.Mcms.entity; using CoreFS.CA06; using Infragistics.Win.UltraWinGrid; namespace Core.StlMes.Client.LgResMgt.Mcms { public partial class BlankPredictionSelect : FrmBase { private List currentTotal; private readonly List totals; private CmmWeightRecordEntityFull _defaultData = null; public BlankPredictionSelect(OpeBase _ob, CmmWeightRecordEntityFull defaultData) { InitializeComponent(); ob = _ob; EntityHelper.ShowGridCaption(CrackDetectGrid.DisplayLayout.Bands[0]); CrackDetectGrid.DisplayLayout.Bands[0].Columns["PoundNum"].Header.Caption = "已过磅"; CrackDetectGrid.DisplayLayout.Bands[0].Columns["SingleLen"].Header.Caption = "单倍长"; Dictionary dic = new Dictionary(); dic.Add("validflag",new List { "1" }); if (defaultData != null && defaultData.MatInfos != null && defaultData.MatInfos.Any(p=>!string.IsNullOrWhiteSpace(p.DocumentNo))) { dic.Add("documentNo", defaultData.MatInfos.Where(p => !string.IsNullOrWhiteSpace(p.DocumentNo)).Select(p => p.DocumentNo).Distinct().ToList()); } totals = EntityHelper.GetData( "com.steering.Mcms.BlankPredictionServer.doQuery", new object[] { dic }, ob); if (totals.Any()) totals = totals.OrderBy(p => p.ShippersName).ThenBy(p => p.OrderNo).ThenBy(p => p.JudgeStoveNo).ToList(); uceQueryShipperName.DataSource = totals.Select(p => p.ShippersName).Distinct().ToList(); _defaultData = defaultData; } public string ShipperName { get; private set; } public string Memo { get; private set; } public List ListMatNo { get { return cmmWeightMatEntityBindingSource.DataSource as List; } } private void CrackDetectGrid_CellChange(object sender, CellEventArgs e) { var data = cmmWeightMatEntityBindingSource.DataSource as List; if (data == null) data = new List(); var entity = e.Cell.Row.ListObject as CmmBlankPredictionEntityEdit; if (e.Cell.Column.Key != "Chk") { decimal? actCount = null; if (!string.IsNullOrWhiteSpace(e.Cell.Row.Cells["EditNum"].Text.Replace("_", ""))) actCount = decimal.Parse(e.Cell.Row.Cells["EditNum"].Text.Replace("_", "")); string len = e.Cell.Row.Cells["ActLen"].Text; if ((bool) e.Cell.Row.Cells["Chk"].Value) { data.Where(p => p.DocumentNo == e.Cell.Row.Cells["PredictionId"].Value.ToString2()) .ToList() .ForEach(p => { p.ActCount = actCount; p.ActLenTemp = len; }); } else { data.Add(new CmmWeightMatEntity { ProOrderNo = entity.OrderNo, JudgeStoveNoOld = entity.JudgeStoveNo, Steelcode = entity.Gradecode, Steelname = entity.Gradename, ActDimater = entity.ActDimater, ActLenTemp =len, ActCount = actCount, DocumentNo = entity.PredictionId, OrderNo = entity.OrderNo, OrderSeq = entity.OrderSqe, OrdNoPk = entity.OrdNoPk }); e.Cell.Row.Cells["Chk"].Value = true; e.Cell.Row.Cells["Chk"].Appearance.BackColor = Color.LightGreen; } } else { CrackDetectGrid.UpdateData(); if (!(bool) e.Cell.Row.Cells["Chk"].Value) e.Cell.Row.Cells["Chk"].Appearance.Reset(); if ((bool) e.Cell.Value) data.Add(new CmmWeightMatEntity { ProOrderNo = entity.OrderNo, JudgeStoveNoOld = entity.JudgeStoveNo, Steelcode = entity.Gradecode, Steelname = entity.Gradename, ActDimater = entity.ActDimater, ActLenTemp = entity.ActLen.ToString2(), ActCount = entity.EditNum, DocumentNo = entity.PredictionId, OrderNo = entity.OrderNo, OrderSeq = entity.OrderSqe, OrdNoPk = entity.OrdNoPk }); else { if ( data.Any( p => !string.IsNullOrWhiteSpace(p.InstockNum) && int.Parse(p.InstockNum) > 0 && p.DocumentNo == entity.PredictionId)) { MessageBox.Show("该炉已经入库,不允许取消!"); e.Cell.Row.Cells["Chk"].Value = true; return; } data.RemoveAll(q => q.DocumentNo == entity.PredictionId); } } cmmWeightMatEntityBindingSource.DataSource = data; cmmWeightMatEntityBindingSource.ResetBindings(false); Comm.RefreshAndAutoSize(matGrid); } private void uceQueryShipperName_ValueChanged(object sender, EventArgs e) { cmmBlankPredictionEntityBindingSource.Clear(); cmmWeightMatEntityBindingSource.Clear(); txtJudgeStove.Text = ""; if (uceQueryShipperName.Text != "") { currentTotal = totals.Where(p => p.ShippersName == uceQueryShipperName.Text) .ToList(); var data = new List(); if (_defaultData != null && _defaultData.MatInfos!=null) foreach (var cmmWeightMatEntity in _defaultData.MatInfos) { var ent = currentTotal.Where(p => p.PredictionId == cmmWeightMatEntity.DocumentNo).ToList(); if (ent.Any()) { ent.ForEach(q => { q.Chk = true; q.EditNum = cmmWeightMatEntity.ActCount; q.ActLen = cmmWeightMatEntity.ActLenTemp; }); data.Add(EntityHelper.CopyEntity(cmmWeightMatEntity)); } } cmmBlankPredictionEntityBindingSource.DataSource = currentTotal; cmmWeightMatEntityBindingSource.DataSource = data; Comm.RefreshAndAutoSize(matGrid); Comm.RefreshAndAutoSize(CrackDetectGrid); } } private void utnOk_Click(object sender, EventArgs e) { ShipperName = uceQueryShipperName.Text; CrackDetectGrid.UpdateData(); if (currentTotal != null) { List temp = currentTotal.Where(p => p.Chk).ToList(); Memo = temp.Any(p => p.TypeFlag == "1") ? "双经销合同坯料" : ""; } DialogResult = DialogResult.OK; } private void BlankPredictionSelect_Shown(object sender, EventArgs e) { Font = new Font("宋体", 12F); CrackDetectGrid.DisplayLayout.Override.HeaderAppearance.FontData.SizeInPoints = 12; CrackDetectGrid.Font = Font; matGrid.DisplayLayout.Override.HeaderAppearance.FontData.SizeInPoints = 12; matGrid.Font = Font; this.Location = new Point(Location.X -140,Location.Y-100); if (_defaultData != null) { uceQueryShipperName.Value = _defaultData.ShippersName; } } private void txtJudgeStove_KeyUp(object sender, KeyEventArgs e) { if (currentTotal == null) return; if (uceQueryShipperName.SelectedIndex<0) return; List data = string.IsNullOrWhiteSpace(txtJudgeStove.Text.Trim()) ? currentTotal : currentTotal.Where(p => p.JudgeStoveNo.IndexOf(txtJudgeStove.Text.Trim(), StringComparison.Ordinal) >= 0) .ToList(); cmmBlankPredictionEntityBindingSource.DataSource = data; // txtJudgeStove.ButtonsRight["find"].Visible = !data.Any(); cmmBlankPredictionEntityBindingSource.ResetBindings(false); } private void CrackDetectGrid_InitializeRow(object sender, InitializeRowEventArgs e) { if ((bool) e.Row.Cells["Chk"].Value) e.Row.Cells["Chk"].Appearance.BackColor = Color.LightGreen; } private void BlankPredictionSelect_Load(object sender, EventArgs e) { } private void txtJudgeStove_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e) { if (string.IsNullOrWhiteSpace(txtJudgeStove.Text)) { return; } Dictionary dic = new Dictionary(); dic.Add("validflag", new List { "1","2","3" }); dic.Add("judgeStoveNoD",txtJudgeStove.Text); dic.Add("shippersNameD", uceQueryShipperName.Text); List < CmmBlankPredictionEntityEdit> add = EntityHelper.GetData( "com.steering.Mcms.BlankPredictionServer.doQuery", new object[] { dic }, ob); add = add.Where(p => !currentTotal.Any(q => q.PredictionId == p.PredictionId)).ToList(); if (add != null && add.Any()) { currentTotal.AddRange(add); totals.AddRange(add); txtJudgeStove_KeyUp(null, null); } } } }