HttInstructionCardControl.cs 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Drawing;
  5. using System.Data;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using Infragistics.Win.UltraWinGrid;
  10. using com.steering.mes.mcp.entity;
  11. using Core.Mes.Client.Comm.Server;
  12. using CoreFS.CA06;
  13. using Core.Mes.Client.Comm.Tool;
  14. using Core.StlMes.Client.Mcp.Control.Entity;
  15. using Infragistics.Win;
  16. namespace Core.StlMes.Client.Mcp.Control
  17. {
  18. public partial class HttInstructionCardControl : UserControl
  19. {
  20. private OpeBase ob;
  21. public OpeBase Ob
  22. {
  23. get { return ob; }
  24. set { ob = value; }
  25. }
  26. private string _plineCode = "";
  27. public void DisableFiltering()
  28. {
  29. ultraGrid1.DisplayLayout.Override.AllowRowFiltering = DefaultableBoolean.False;
  30. }
  31. public List<PortHttBatchSampleResultEntity> PortHttBatchSampleResultEntitys { get; set; }
  32. List<HttSignatureEntity> Names = new List<HttSignatureEntity>();
  33. /// <summary>
  34. /// 废品
  35. /// </summary>
  36. public List<HttWasteResultEntity> ScrappedList { get; private set; }
  37. public HttLoadingResultEntity Value
  38. {
  39. get
  40. {
  41. List<HttLoadingResultEntity> list =
  42. httLoadingResultEntityBindingSource.DataSource as List<HttLoadingResultEntity>;
  43. return list==null || !list.Any()?new HttLoadingResultEntity(): list.FirstOrDefault();
  44. }
  45. set
  46. {
  47. if (value == null)
  48. {
  49. httLoadingResultEntityBindingSource.DataSource = new List<HttLoadingResultEntity>()
  50. {
  51. new HttLoadingResultEntity()
  52. };
  53. ScrappedList = new List<HttWasteResultEntity>();
  54. }
  55. else
  56. {
  57. httLoadingResultEntityBindingSource.DataSource = new List<HttLoadingResultEntity>() {value.Clone()};
  58. if (ob == null || ob.MainUrl == "") return;
  59. if (_plineCode != Value.PlineCode)
  60. {
  61. Names = EntityHelper.GetData<HttSignatureEntity>(
  62. "com.steering.mes.mcp.heatTreatment.FrmHttCrackDetectResult.getHttSign",
  63. new object[] {Value.PlineCode, "0"}, Ob);
  64. name.DataSource = Names.Where(p => p.ColGroup == value.LoadGroup).ToList();
  65. name.DisplayMember = "UserName";
  66. name.ValueMember = "UserName";
  67. YdmBaseClass.SetComboItemHeight(name);
  68. _plineCode = Value.PlineCode;
  69. }
  70. if (!string.IsNullOrEmpty(value.ResultNo) && value.FailNum > 0 &&
  71. value.FailNum != ScrappedList.Count)
  72. {
  73. ScrappedList = EntityHelper.GetData<HttWasteResultEntity>(
  74. "com.steering.mes.mcp.heatTreatment.FrmHttBugD.doQueryScrapNum",
  75. new object[] {"", value.ResultNo}, Ob);
  76. }
  77. if (value.FailNum == 0)
  78. {
  79. ScrappedList = new List<HttWasteResultEntity>();
  80. }
  81. }
  82. }
  83. }
  84. /// <summary>
  85. /// 上料炉号
  86. /// </summary>
  87. public string FeedStoveNo { get; set; }
  88. public decimal ActCount { get; set; }
  89. public string BatchNo { get; set; }
  90. public string GroupNo { get; set; }
  91. public string JudgeNo { get; set; }
  92. public void SetFont(Font f1)
  93. {
  94. ultraGrid1.Font = f1;
  95. foreach (UltraGridColumn UltraGridColumn in ultraGrid1.DisplayLayout.Bands[0].Columns)
  96. {
  97. UltraGridColumn.Header.Appearance.FontData.Bold = f1.Bold ? DefaultableBoolean.True : DefaultableBoolean.False;
  98. UltraGridColumn.Header.Appearance.FontData.Name = f1.Name;
  99. UltraGridColumn.Header.Appearance.FontData.SizeInPoints = f1.SizeInPoints;
  100. }
  101. }
  102. public HttInstructionCardControl()
  103. {
  104. ScrappedList = new DataSourceList<HttWasteResultEntity>();
  105. InitializeComponent();
  106. EntityHelper.ShowGridCaption<HttLoadingResultEntity>(ultraGrid1.DisplayLayout.Bands[0]);
  107. }
  108. public void ShowPro(bool isPro)
  109. {
  110. ultraGrid1.DisplayLayout.Bands[0].Columns["Producer"].CellActivation = isPro?
  111. Activation.AllowEdit:Activation.ActivateOnly;
  112. ultraGrid1.DisplayLayout.Bands[0].Columns["ProducerTime"].CellActivation =isPro?
  113. Activation.AllowEdit : Activation.ActivateOnly;
  114. }
  115. private void ultraGrid1_CellChange(object sender, CellEventArgs e)
  116. {
  117. ultraGrid1.UpdateData();
  118. if (e.Cell.Column.Key.Equals("ProNum") && Value.ProNum != null && Value.ProcessSeq != null)
  119. {
  120. DataTable dt =
  121. ServerHelper.GetData("com.steering.mes.mcp.heatTreatment.HttLoadingService.getQueryWeight",
  122. new object[]
  123. {
  124. Value.ProNum.ToString2(),Value.HeatPlanNo, BatchNo, GroupNo
  125. }, this.Ob);
  126. if (dt.Rows.Count > 0)
  127. {
  128. decimal weigt;
  129. decimal.TryParse(dt.Rows[0]["ACT_WEIGHT"].ToString(), out weigt);
  130. Value.ProWt = weigt;
  131. }
  132. }
  133. if (e.Cell.Column.Key.Equals("LoadGroup") && Value.LoadGroup != null)
  134. {
  135. name.DataSource = Names.Where(p => p.ColGroup == Value.LoadGroup).ToList();
  136. }
  137. if (e.Cell.Column.Key.Equals("ProcessSeq") && Value.ProNum != null && Value.ProcessSeq != null)
  138. {
  139. if (Value.ProcessSeq == 1)
  140. {
  141. Value.ProNum = ActCount;
  142. DataTable dt =
  143. ServerHelper.GetData("com.steering.mes.mcp.heatTreatment.HttLoadingService.getQueryWeight",
  144. new object[]
  145. {
  146. Value.ProNum.ToString2(), FeedStoveNo, BatchNo, GroupNo
  147. }, this.Ob);
  148. if (dt.Rows.Count > 0)
  149. {
  150. decimal weigt;
  151. decimal.TryParse(dt.Rows[0]["ACT_WEIGHT"].ToString(), out weigt);
  152. Value.ProWt = weigt;
  153. }
  154. }
  155. else
  156. {
  157. Value.ProNum =
  158. PortHttBatchSampleResultEntitys.Count(
  159. p =>
  160. (p.ProcessSeq == Value.ProcessSeq - 1) &&
  161. (p.MatStatus == "00" || p.MatStatus == "合格"));
  162. Value.ProWt = PortHttBatchSampleResultEntitys.Where(
  163. p =>
  164. p.ProcessSeq == Value.ProcessSeq - 1 &&
  165. (p.MatStatus == "00" || p.MatStatus == "合格"))
  166. .Take(int.Parse(Value.ProNum.ToString3())).Sum(p => p.ActWeight);
  167. }
  168. }
  169. ultraGrid1.Refresh();
  170. }
  171. private void craftImg_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
  172. {
  173. if(Value.HeatPlanNo==null)
  174. {
  175. return;
  176. }
  177. if (Value.PlineCode == null)
  178. {
  179. return;
  180. }
  181. List<PortHttBatchSampleResultEntityWithCheck> PortHttBatch =
  182. EntityHelper.GetData<PortHttBatchSampleResultEntityWithCheck>(
  183. "com.steering.mes.mcp.heatTreatment.ScrapHelper.doQueryLoadHttPort",
  184. new object[] { Value.HeatPlanNo, BatchNo, GroupNo,JudgeNo}, ob);
  185. FrmScrapHttNew matfrm = new FrmScrapHttNew(this.ob, null, ScrappedList, false, Value.HeatPlanNo,
  186. int.Parse(Value.ProcessSeq.ToString3()), "600401", "", BatchNo, PortHttBatch);
  187. matfrm.ShowDialog();
  188. if (matfrm.DialogResult == DialogResult.OK)
  189. {
  190. ScrappedList = matfrm.ScrappedList;
  191. Value.FailNum = ScrappedList.Sum(p=>p.DefFillNum);
  192. }
  193. Value.FailNum = Value.FailNum ?? 0;
  194. ultraGrid1.PerformAction(UltraGridAction.ExitEditMode);
  195. this.ultraGrid1.UpdateData();
  196. }
  197. }
  198. }