MchControlBase.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. 
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Windows.Forms;
  8. using Core.Mes.Client.Comm.Server;
  9. using Core.StlMes.Client.Mcp.Control.Entity;
  10. using CoreFS.CA06;
  11. using Infragistics.Win;
  12. using Infragistics.Win.UltraWinEditors;
  13. using Infragistics.Win.UltraWinGrid;
  14. namespace Core.StlMes.Client.Mcp.Control.Machining
  15. {
  16. public partial class MchControlBase : UserControl
  17. {
  18. public MchControlBase()
  19. {
  20. InitializeComponent();
  21. ScrappedList = new List<MchBugDEntity>();
  22. SuspiciousList = new List<MchBugDEntity>();
  23. }
  24. protected string _plineCode = "";
  25. protected List<HttSignatureEntity> Names = new List<HttSignatureEntity>();
  26. protected OpeBase ob;
  27. public OpeBase Ob
  28. {
  29. get { return ob; }
  30. set { ob = value; }
  31. }
  32. public void DisableFiltering()
  33. {
  34. ultraGrid1.DisplayLayout.Override.AllowRowFiltering = DefaultableBoolean.False;
  35. ultraGrid1.DisplayLayout.Override.HeaderClickAction = HeaderClickAction.Default;
  36. }
  37. public void SetFont(Font f1)
  38. {
  39. ultraGrid1.Font = f1;
  40. foreach (UltraGridColumn UltraGridColumn in ultraGrid1.DisplayLayout.Bands[0].Columns)
  41. {
  42. UltraGridColumn.Header.Appearance.FontData.Bold = f1.Bold ? DefaultableBoolean.True : DefaultableBoolean.False;
  43. UltraGridColumn.Header.Appearance.FontData.Name = f1.Name;
  44. UltraGridColumn.Header.Appearance.FontData.SizeInPoints = f1.SizeInPoints;
  45. }
  46. if (ultraGrid1.DisplayLayout.Bands[0].Groups != null && ultraGrid1.DisplayLayout.Bands[0].Groups.Count>0)
  47. foreach (var group in ultraGrid1.DisplayLayout.Bands[0].Groups)
  48. {
  49. group.Header.Appearance.FontData.Bold = f1.Bold ? DefaultableBoolean.True : DefaultableBoolean.False;
  50. group.Header.Appearance.FontData.Name = f1.Name;
  51. group.Header.Appearance.FontData.SizeInPoints = f1.SizeInPoints;
  52. }
  53. }
  54. public List<PortMchBatchSampleResultEntity> PortHttBatchSampleResultEntitys { get; set; }
  55. public string gx { get; set; }
  56. protected virtual string ScrapCode
  57. {
  58. get { return "701501"; }
  59. }
  60. protected virtual string SuspiciousCode
  61. {
  62. get { return "7016"; }
  63. }
  64. /// <summary>
  65. /// 废品
  66. /// </summary>
  67. public List<MchBugDEntity> ScrappedList { get; protected set; }
  68. /// <summary>
  69. /// 可疑
  70. /// </summary>
  71. public List<MchBugDEntity> SuspiciousList { get; protected set; }
  72. private PlnZyJgxCEntity _plnZyJgxCEntity = null;
  73. /// <summary>
  74. /// 炉计划
  75. /// </summary>
  76. public PlnZyJgxCEntity PlnZyJgxCEntity { get { return _plnZyJgxCEntity; }
  77. set
  78. {
  79. if (ob == null) return;
  80. if(_plnZyJgxCEntity==null || (value!=null && _plnZyJgxCEntity.PlineCode != value.PlineCode))
  81. {
  82. DataTable ds = ServerHelper.GetData("com.steering.mes.mcp.Mch.MchComm.GetGx", new object[] { value.PlineCode }, ob);
  83. if (ds.Rows.Count > 0)
  84. {
  85. ProductionOrder = ds.Rows[0]["STATION_CODES"].ToString2();
  86. }
  87. else
  88. {
  89. ProductionOrder = "701301;701311";
  90. }
  91. }
  92. _plnZyJgxCEntity = value;
  93. }}
  94. private string ProductionOrder = "";
  95. public List<PortMchBatchSampleResultEntity> OkPort
  96. {
  97. get
  98. {
  99. return PortHttBatchSampleResultEntitys==null? new List<PortMchBatchSampleResultEntity>() :
  100. PortHttBatchSampleResultEntitys.Where(
  101. p =>
  102. ((p.MatStatus == "00") || (p.MatStatus == "合格")) || CheckGx2(p.OpProcessCode, gx)).ToList();
  103. }
  104. }
  105. public List<PortMchBatchSampleResultEntity> OkPort2
  106. {
  107. get
  108. {
  109. return PortHttBatchSampleResultEntitys == null ? new List<PortMchBatchSampleResultEntity>() :
  110. PortHttBatchSampleResultEntitys.Where(
  111. p =>
  112. ((p.MatStatus == "00") || (p.MatStatus == "合格")) || CheckGx(p.OpProcessCode, gx)).ToList();
  113. }
  114. }
  115. public bool CheckGx(string code1, string code2)
  116. {
  117. return ProductionOrder.IndexOf(code1, StringComparison.Ordinal) >
  118. ProductionOrder.IndexOf(code2, StringComparison.Ordinal);
  119. }
  120. public bool CheckGx2(string code1, string code2)
  121. {
  122. return ProductionOrder.IndexOf(code1, StringComparison.Ordinal) >=
  123. ProductionOrder.IndexOf(code2, StringComparison.Ordinal);
  124. }
  125. protected virtual void ultraGrid1_CellChange(object sender, CellEventArgs e)
  126. {
  127. try
  128. {
  129. ultraGrid1.UpdateData();
  130. if (e.Cell.Column.Key.Equals("ProTime") || e.Cell.Column.Key.Equals("ProEndTime"))
  131. {
  132. if(e.Cell.Text.Contains("_")) return;
  133. }
  134. if (e.Cell.Column.Key.Equals("ProNum"))
  135. {
  136. if ("701312" == gx)
  137. {
  138. e.Cell.Row.Cells["ProWt"].Value = comm.GetWeight1(PortHttBatchSampleResultEntitys, gx,
  139. int.Parse(e.Cell.Value.ToString3()),
  140. int.Parse(PlnZyJgxCEntity.ProCount.ToString3()));
  141. }
  142. else
  143. {
  144. e.Cell.Row.Cells["ProWt"].Value = comm.GetWeight(PortHttBatchSampleResultEntitys, gx,
  145. int.Parse(e.Cell.Value.ToString3()),
  146. int.Parse(PlnZyJgxCEntity.ProCount.ToString3()));
  147. }
  148. if (ultraGrid1.DisplayLayout.Bands[0].Columns.Exists("QualifiedNum"))
  149. {
  150. e.Cell.Row.Cells["QualifiedNum"].Value = e.Cell.Value;
  151. e.Cell.Row.Cells["QualifiedWt"].Value = e.Cell.Row.Cells["ProWt"].Value;
  152. }
  153. if (ultraGrid1.DisplayLayout.Bands[0].Columns.Exists("FinalQualifiedNum"))
  154. {
  155. e.Cell.Row.Cells["FinalQualifiedNum"].Value = e.Cell.Value;
  156. e.Cell.Row.Cells["FinalQualifiedWt"].Value = e.Cell.Row.Cells["ProWt"].Value;
  157. }
  158. }
  159. if (e.Cell.Column.Key.Equals("FinalQualifiedNum"))
  160. {
  161. e.Cell.Row.Cells["FinalQualifiedWt"].Value = comm.GetWeight(PortHttBatchSampleResultEntitys, gx,
  162. int.Parse(e.Cell.Value.ToString3()),
  163. int.Parse(PlnZyJgxCEntity.ProCount.ToString3()));
  164. }
  165. if (e.Cell.Column.Key.Equals("QualifiedNum"))
  166. {
  167. e.Cell.Row.Cells["QualifiedWt"].Value = comm.GetWeight(PortHttBatchSampleResultEntitys, gx,
  168. int.Parse(e.Cell.Value.ToString3()),
  169. int.Parse(PlnZyJgxCEntity.ProCount.ToString3()));
  170. }
  171. if (e.Cell.Column.Key.Equals("ReProNum"))
  172. {
  173. e.Cell.Row.Cells["ReProWt"].Value = comm.GetWeight(PortHttBatchSampleResultEntitys, gx,
  174. int.Parse(e.Cell.Value.ToString3()),
  175. int.Parse(PlnZyJgxCEntity.ProCount.ToString3()));
  176. }
  177. if (e.Cell.Column.Key.Equals("ProGroup") && e.Cell.Value != null)
  178. {
  179. name.DataSource = Names.Where(p => p.ColGroup == e.Cell.Value.ToString2()).ToList();
  180. }
  181. if (e.Cell.Column.Key.Equals("ProUser") && e.Cell.Value != null && e.Cell.Row.Cells.Exists("Responsible"))
  182. {
  183. var list =
  184. Names.Where(
  185. p => p.ColGroup == e.Cell.Row.Cells["ProGroup"].Value.ToString2() && p.UserName == e.Cell.Value.ToString2())
  186. .ToList();
  187. if (list.Any()) e.Cell.Row.Cells["Responsible"].Value = list[0].Responsible;
  188. }
  189. if (e.Cell.Row.Cells.Exists("FinalQualifiedNum") && e.Cell.Row.Cells.Exists("QualifiedNum") && e.Cell.Row.Cells.Exists("ReProNum"))
  190. {
  191. e.Cell.Row.Cells["FinalQualifiedNum"].Value =
  192. decimal.Parse(e.Cell.Row.Cells["QualifiedNum"].Value.ToString3()) +
  193. decimal.Parse(e.Cell.Row.Cells["ReProNum"].Value.ToString3());
  194. }
  195. /* if (e.Cell.Row.Cells.Exists("QualifiedNum") && e.Cell.Row.Cells.Exists("ProNum"))
  196. {
  197. e.Cell.Row.Cells["QualifiedNum"].Value =
  198. decimal.Parse(e.Cell.Row.Cells["ProNum"].Value.ToString3()) -
  199. decimal.Parse(e.Cell.Row.Cells["FailNum"].Value.ToString3());
  200. }*/
  201. ultraGrid1.Refresh();
  202. }
  203. catch (Exception ex)
  204. {
  205. }
  206. }
  207. private void uteScrapped_EditorButtonClick(object sender, EditorButtonEventArgs e)
  208. {
  209. if (PlnZyJgxCEntity==null) return;
  210. if (PlnZyJgxCEntity.HeatPlanNo == null)
  211. return;
  212. if (PlnZyJgxCEntity.PlineCode == null)
  213. return;
  214. var matfrm = new FrmScrapMchNew(Ob, ScrappedList, PlnZyJgxCEntity.HeatPlanNo, ScrapCode, PlnZyJgxCEntity.BatchNo, PlnZyJgxCEntity.BatchGroudNo, gx == "701303"){Text = "废品原因"};
  215. matfrm.ShowDialog();
  216. if (matfrm.DialogResult == DialogResult.OK)
  217. {
  218. ScrappedList = matfrm.dataList;
  219. EditScrapped();
  220. ultraGrid1_CellChange(ultraGrid1, new CellEventArgs(ultraGrid1.ActiveCell));
  221. }
  222. // Value.DubiousNum = Value.DubiousNum ?? 0;
  223. ultraGrid1.PerformAction(UltraGridAction.ExitEditMode);
  224. ultraGrid1.UpdateData();
  225. }
  226. /// <summary>
  227. /// 录入废品成功后
  228. /// </summary>
  229. protected virtual void EditScrapped()
  230. {
  231. }
  232. private void uteSuspicious_EditorButtonClick(object sender, EditorButtonEventArgs e)
  233. {
  234. if (PlnZyJgxCEntity == null) return;
  235. if (PlnZyJgxCEntity.HeatPlanNo == null)
  236. return;
  237. if (PlnZyJgxCEntity.PlineCode == null)
  238. return;
  239. var matfrm = new FrmScrapMchNew(Ob, SuspiciousList, PlnZyJgxCEntity.HeatPlanNo, SuspiciousCode, PlnZyJgxCEntity.BatchNo, PlnZyJgxCEntity.BatchGroudNo,false,false) { Text = "可疑原因" }; ;
  240. matfrm.ShowDialog();
  241. // Value.DubiousNum = Value.DubiousNum ?? 0;
  242. ultraGrid1.PerformAction(UltraGridAction.ExitEditMode);
  243. ultraGrid1.UpdateData();
  244. if (matfrm.DialogResult == DialogResult.OK)
  245. {
  246. SuspiciousList = matfrm.dataList;
  247. EditSuspicious();
  248. }
  249. ultraGrid1.PerformAction(UltraGridAction.ExitEditMode);
  250. ultraGrid1.UpdateData();
  251. }
  252. /// <summary>
  253. /// 录入可疑成功后
  254. /// </summary>
  255. protected virtual void EditSuspicious()
  256. {
  257. }
  258. }
  259. }