BlankPredictionSelect.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Drawing;
  4. using System.Linq;
  5. using System.Windows.Forms;
  6. using Core.Mes.Client.Comm.Tool;
  7. using Core.StlMes.Client.LgResMgt.Mcms.entity;
  8. using CoreFS.CA06;
  9. using Infragistics.Win.UltraWinGrid;
  10. namespace Core.StlMes.Client.LgResMgt.Mcms
  11. {
  12. public partial class BlankPredictionSelect : FrmBase
  13. {
  14. private List<CmmBlankPredictionEntityEdit> currentTotal;
  15. private readonly List<CmmBlankPredictionEntityEdit> totals;
  16. private CmmWeightRecordEntityFull _defaultData = null;
  17. public BlankPredictionSelect(OpeBase _ob, CmmWeightRecordEntityFull defaultData)
  18. {
  19. InitializeComponent();
  20. ob = _ob;
  21. EntityHelper.ShowGridCaption<CmmBlankPredictionEntityEdit>(CrackDetectGrid.DisplayLayout.Bands[0]);
  22. CrackDetectGrid.DisplayLayout.Bands[0].Columns["PoundNum"].Header.Caption = "已过磅";
  23. CrackDetectGrid.DisplayLayout.Bands[0].Columns["SingleLen"].Header.Caption = "单倍长";
  24. Dictionary<string,object> dic = new Dictionary<string, object>();
  25. dic.Add("validflag",new List<string> { "1" });
  26. if (defaultData != null && defaultData.MatInfos != null && defaultData.MatInfos.Any(p=>!string.IsNullOrWhiteSpace(p.DocumentNo)))
  27. {
  28. dic.Add("documentNo", defaultData.MatInfos.Where(p => !string.IsNullOrWhiteSpace(p.DocumentNo)).Select(p => p.DocumentNo).Distinct().ToList());
  29. }
  30. totals = EntityHelper.GetData<CmmBlankPredictionEntityEdit>(
  31. "com.steering.Mcms.BlankPredictionServer.doQuery",
  32. new object[] { dic },
  33. ob);
  34. if (totals.Any())
  35. totals = totals.OrderBy(p => p.ShippersName).ThenBy(p => p.OrderNo).ThenBy(p => p.JudgeStoveNo).ToList();
  36. uceQueryShipperName.DataSource = totals.Select(p => p.ShippersName).Distinct().ToList();
  37. _defaultData = defaultData;
  38. }
  39. public string ShipperName { get; private set; }
  40. public string Memo { get; private set; }
  41. public List<CmmWeightMatEntity> ListMatNo
  42. {
  43. get
  44. {
  45. return
  46. cmmWeightMatEntityBindingSource.DataSource as List<CmmWeightMatEntity>;
  47. }
  48. }
  49. private void CrackDetectGrid_CellChange(object sender, CellEventArgs e)
  50. {
  51. var data = cmmWeightMatEntityBindingSource.DataSource as List<CmmWeightMatEntity>;
  52. if (data == null) data = new List<CmmWeightMatEntity>();
  53. var entity = e.Cell.Row.ListObject as CmmBlankPredictionEntityEdit;
  54. if (e.Cell.Column.Key != "Chk")
  55. {
  56. decimal? actCount = null;
  57. if (!string.IsNullOrWhiteSpace(e.Cell.Row.Cells["EditNum"].Text.Replace("_", "")))
  58. actCount = decimal.Parse(e.Cell.Row.Cells["EditNum"].Text.Replace("_", ""));
  59. string len = e.Cell.Row.Cells["ActLen"].Text;
  60. if ((bool) e.Cell.Row.Cells["Chk"].Value)
  61. {
  62. data.Where(p => p.DocumentNo == e.Cell.Row.Cells["PredictionId"].Value.ToString2())
  63. .ToList()
  64. .ForEach(p =>
  65. {
  66. p.ActCount = actCount;
  67. p.ActLenTemp = len;
  68. });
  69. }
  70. else
  71. {
  72. data.Add(new CmmWeightMatEntity
  73. {
  74. ProOrderNo = entity.OrderNo,
  75. JudgeStoveNoOld = entity.JudgeStoveNo,
  76. Steelcode = entity.Gradecode,
  77. Steelname = entity.Gradename,
  78. ActDimater = entity.ActDimater,
  79. ActLenTemp =len,
  80. ActCount = actCount,
  81. DocumentNo = entity.PredictionId,
  82. OrderNo = entity.OrderNo,
  83. OrderSeq = entity.OrderSqe,
  84. OrdNoPk = entity.OrdNoPk
  85. });
  86. e.Cell.Row.Cells["Chk"].Value = true;
  87. e.Cell.Row.Cells["Chk"].Appearance.BackColor = Color.LightGreen;
  88. }
  89. }
  90. else
  91. {
  92. CrackDetectGrid.UpdateData();
  93. if (!(bool) e.Cell.Row.Cells["Chk"].Value) e.Cell.Row.Cells["Chk"].Appearance.Reset();
  94. if ((bool) e.Cell.Value)
  95. data.Add(new CmmWeightMatEntity
  96. {
  97. ProOrderNo = entity.OrderNo,
  98. JudgeStoveNoOld = entity.JudgeStoveNo,
  99. Steelcode = entity.Gradecode,
  100. Steelname = entity.Gradename,
  101. ActDimater = entity.ActDimater,
  102. ActLenTemp = entity.ActLen.ToString2(),
  103. ActCount = entity.EditNum,
  104. DocumentNo = entity.PredictionId,
  105. OrderNo = entity.OrderNo,
  106. OrderSeq = entity.OrderSqe,
  107. OrdNoPk = entity.OrdNoPk
  108. });
  109. else
  110. {
  111. if (
  112. data.Any(
  113. p => !string.IsNullOrWhiteSpace(p.InstockNum) && int.Parse(p.InstockNum) > 0 && p.DocumentNo == entity.PredictionId))
  114. {
  115. MessageBox.Show("该炉已经入库,不允许取消!");
  116. e.Cell.Row.Cells["Chk"].Value = true;
  117. return;
  118. }
  119. data.RemoveAll(q => q.DocumentNo == entity.PredictionId);
  120. }
  121. }
  122. cmmWeightMatEntityBindingSource.DataSource = data;
  123. cmmWeightMatEntityBindingSource.ResetBindings(false);
  124. Comm.RefreshAndAutoSize(matGrid);
  125. }
  126. private void uceQueryShipperName_ValueChanged(object sender, EventArgs e)
  127. {
  128. cmmBlankPredictionEntityBindingSource.Clear();
  129. cmmWeightMatEntityBindingSource.Clear();
  130. txtJudgeStove.Text = "";
  131. if (uceQueryShipperName.Text != "")
  132. {
  133. currentTotal =
  134. totals.Where(p => p.ShippersName == uceQueryShipperName.Text)
  135. .ToList();
  136. var data = new List<CmmWeightMatEntity>();
  137. if (_defaultData != null && _defaultData.MatInfos!=null)
  138. foreach (var cmmWeightMatEntity in _defaultData.MatInfos)
  139. {
  140. var ent = currentTotal.Where(p => p.PredictionId == cmmWeightMatEntity.DocumentNo).ToList();
  141. if (ent.Any())
  142. {
  143. ent.ForEach(q =>
  144. {
  145. q.Chk = true;
  146. q.EditNum = cmmWeightMatEntity.ActCount;
  147. q.ActLen = cmmWeightMatEntity.ActLenTemp;
  148. });
  149. data.Add(EntityHelper.CopyEntity<CmmWeightMatEntity>(cmmWeightMatEntity));
  150. }
  151. }
  152. cmmBlankPredictionEntityBindingSource.DataSource = currentTotal;
  153. cmmWeightMatEntityBindingSource.DataSource = data;
  154. Comm.RefreshAndAutoSize(matGrid);
  155. Comm.RefreshAndAutoSize(CrackDetectGrid);
  156. }
  157. }
  158. private void utnOk_Click(object sender, EventArgs e)
  159. {
  160. ShipperName = uceQueryShipperName.Text;
  161. CrackDetectGrid.UpdateData();
  162. if (currentTotal != null)
  163. {
  164. List<CmmBlankPredictionEntityEdit> temp = currentTotal.Where(p => p.Chk).ToList();
  165. Memo = temp.Any(p => p.TypeFlag == "1")
  166. ? "双经销合同坯料"
  167. : "";
  168. }
  169. DialogResult = DialogResult.OK;
  170. }
  171. private void BlankPredictionSelect_Shown(object sender, EventArgs e)
  172. {
  173. Font = new Font("宋体", 12F);
  174. CrackDetectGrid.DisplayLayout.Override.HeaderAppearance.FontData.SizeInPoints = 12;
  175. CrackDetectGrid.Font = Font;
  176. matGrid.DisplayLayout.Override.HeaderAppearance.FontData.SizeInPoints = 12;
  177. matGrid.Font = Font;
  178. this.Location = new Point(Location.X -140,Location.Y-100);
  179. if (_defaultData != null)
  180. {
  181. uceQueryShipperName.Value = _defaultData.ShippersName;
  182. }
  183. }
  184. private void txtJudgeStove_KeyUp(object sender, KeyEventArgs e)
  185. {
  186. if (currentTotal == null) return;
  187. if (uceQueryShipperName.SelectedIndex<0) return;
  188. List<CmmBlankPredictionEntityEdit> data = string.IsNullOrWhiteSpace(txtJudgeStove.Text.Trim())
  189. ? currentTotal
  190. : currentTotal.Where(p => p.JudgeStoveNo.IndexOf(txtJudgeStove.Text.Trim(), StringComparison.Ordinal) >= 0)
  191. .ToList();
  192. cmmBlankPredictionEntityBindingSource.DataSource = data;
  193. // txtJudgeStove.ButtonsRight["find"].Visible = !data.Any();
  194. cmmBlankPredictionEntityBindingSource.ResetBindings(false);
  195. }
  196. private void CrackDetectGrid_InitializeRow(object sender, InitializeRowEventArgs e)
  197. {
  198. if ((bool) e.Row.Cells["Chk"].Value) e.Row.Cells["Chk"].Appearance.BackColor = Color.LightGreen;
  199. }
  200. private void BlankPredictionSelect_Load(object sender, EventArgs e)
  201. {
  202. }
  203. private void txtJudgeStove_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
  204. {
  205. if (string.IsNullOrWhiteSpace(txtJudgeStove.Text))
  206. {
  207. return;
  208. }
  209. Dictionary<string, object> dic = new Dictionary<string, object>();
  210. dic.Add("validflag", new List<string> { "1","2","3" });
  211. dic.Add("judgeStoveNoD",txtJudgeStove.Text);
  212. dic.Add("shippersNameD", uceQueryShipperName.Text);
  213. List < CmmBlankPredictionEntityEdit> add = EntityHelper.GetData<CmmBlankPredictionEntityEdit>(
  214. "com.steering.Mcms.BlankPredictionServer.doQuery",
  215. new object[] { dic },
  216. ob);
  217. add = add.Where(p => !currentTotal.Any(q => q.PredictionId == p.PredictionId)).ToList();
  218. if (add != null && add.Any())
  219. {
  220. currentTotal.AddRange(add);
  221. totals.AddRange(add);
  222. txtJudgeStove_KeyUp(null, null);
  223. }
  224. }
  225. }
  226. }