| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275 |
- 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<CmmBlankPredictionEntityEdit> currentTotal;
- private readonly List<CmmBlankPredictionEntityEdit> totals;
- private CmmWeightRecordEntityFull _defaultData = null;
- public BlankPredictionSelect(OpeBase _ob, CmmWeightRecordEntityFull defaultData)
- {
- InitializeComponent();
- ob = _ob;
- EntityHelper.ShowGridCaption<CmmBlankPredictionEntityEdit>(CrackDetectGrid.DisplayLayout.Bands[0]);
- CrackDetectGrid.DisplayLayout.Bands[0].Columns["PoundNum"].Header.Caption = "已过磅";
- CrackDetectGrid.DisplayLayout.Bands[0].Columns["SingleLen"].Header.Caption = "单倍长";
- Dictionary<string,object> dic = new Dictionary<string, object>();
- dic.Add("validflag",new List<string> { "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<CmmBlankPredictionEntityEdit>(
- "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<CmmWeightMatEntity> ListMatNo
- {
- get
- {
- return
- cmmWeightMatEntityBindingSource.DataSource as List<CmmWeightMatEntity>;
-
- }
- }
- private void CrackDetectGrid_CellChange(object sender, CellEventArgs e)
- {
- var data = cmmWeightMatEntityBindingSource.DataSource as List<CmmWeightMatEntity>;
- if (data == null) data = new List<CmmWeightMatEntity>();
- 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<CmmWeightMatEntity>();
- 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>(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<CmmBlankPredictionEntityEdit> 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<CmmBlankPredictionEntityEdit> 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<string, object> dic = new Dictionary<string, object>();
- dic.Add("validflag", new List<string> { "1","2","3" });
- dic.Add("judgeStoveNoD",txtJudgeStove.Text);
- dic.Add("shippersNameD", uceQueryShipperName.Text);
- List < CmmBlankPredictionEntityEdit> add = EntityHelper.GetData<CmmBlankPredictionEntityEdit>(
- "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);
- }
- }
- }
- }
|