MeasureControl.cs 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. 
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Windows.Forms;
  6. using System.Windows.Forms.VisualStyles;
  7. using com.steering.mes.mcp.entity;
  8. using Core.Mes.Client.Comm.Tool;
  9. using Core.StlMes.Client.Mcp.Control.Entity;
  10. using Core.StlMes.Client.Mcp.Control.Machining;
  11. using Infragistics.Win;
  12. using Infragistics.Win.UltraWinGrid;
  13. namespace Core.StlMes.Client.Mcp.Control
  14. {
  15. public partial class MeasureControl : MchControlBase
  16. {
  17. private List<RtdMeasurePosdataEntity> UnMatchData = new List<RtdMeasurePosdataEntity>();
  18. public MeasureControl()
  19. {
  20. InitializeComponent();
  21. EntityHelper.ShowGridCaption<MchMeasureResultEntity>(ultraGrid1.DisplayLayout.Bands[0]);
  22. gx = "701310";
  23. Value = null;
  24. ValueList list = new ValueList();
  25. list.ValueListItems.Add(new ValueListItem("0", "否"));
  26. list.ValueListItems.Add(new ValueListItem("1", "是"));
  27. ultraGrid1.DisplayLayout.Bands[0].Columns["Flag"].ValueList = new ValueList();
  28. }
  29. protected override string ScrapCode { get { return "701510"; } }
  30. public void ResetM(bool ShowM)
  31. {
  32. if (ShowM)
  33. {
  34. ultraGrid1.DisplayLayout.Bands[0].Columns["ProNum"].EditorComponent = uteM;
  35. ultraGrid1.DisplayLayout.Bands[0].Columns["ProNum"].RowLayoutColumnInfo.PreferredCellSize =
  36. new System.Drawing.Size(150, 0);
  37. }
  38. else
  39. {
  40. ultraGrid1.DisplayLayout.Bands[0].Columns["ProNum"].EditorComponent = null;
  41. ultraGrid1.DisplayLayout.Bands[0].Columns["ProNum"].RowLayoutColumnInfo.PreferredCellSize =
  42. new System.Drawing.Size(50, 0);
  43. }
  44. }
  45. public MchMeasureResultEntity Value
  46. {
  47. get
  48. {
  49. var list =
  50. mchMeasureResultEntityBindingSource.DataSource as List<MchMeasureResultEntity>;
  51. return (list == null) || !list.Any() ? new MchMeasureResultEntity() : list.FirstOrDefault();
  52. }
  53. set
  54. {
  55. if (value == null)
  56. {
  57. mchMeasureResultEntityBindingSource.DataSource = new List<MchMeasureResultEntity>
  58. {
  59. new MchMeasureResultEntity()
  60. };
  61. ScrappedList = new List<MchBugDEntity>();
  62. }
  63. else
  64. {
  65. value.ProWt = comm.GetWeight(PortHttBatchSampleResultEntitys, gx, (int)(value.ProNum ?? 0),
  66. (int)(PlnZyJgxCEntity.ProCount ?? 0));
  67. UnMatchData = EntityHelper.GetData<RtdMeasurePosdataEntity>(
  68. "com.steering.mes.mcp.Mch.FrmMeasureResult.getUnmatchRtdMeasurePosdataEntity",
  69. new object[] { value.JudgeStoveNo, value.BatchNo, value.PlineCode }, Ob);
  70. if (UnMatchData.Any())
  71. {
  72. value.ProTime = UnMatchData[0].MsauerDate;
  73. int a = int.Parse(value.ProNum.ToString3());
  74. if (a > UnMatchData.Count) a = UnMatchData.Count;
  75. if (a == 0) a = 1;
  76. value.ProEndTime = UnMatchData[a-1].MsauerDate;
  77. }
  78. mchMeasureResultEntityBindingSource.DataSource = new List<MchMeasureResultEntity> { value.Clone() };
  79. if (_plineCode != Value.PlineCode)
  80. {
  81. Names = EntityHelper.GetData<HttSignatureEntity>(
  82. "com.steering.mes.mcp.heatTreatment.FrmHttCrackDetectResult.getHttSign",
  83. new object[] { Value.PlineCode, "9" }, Ob);
  84. name.DisplayMember = "UserName";
  85. name.ValueMember = "UserName";
  86. YdmBaseClass.SetComboItemHeight(name);
  87. _plineCode = Value.PlineCode;
  88. }
  89. name.DataSource = Names.Where(p => p.ColGroup == value.ProGroup).ToList();
  90. if (value.FailNum == 0)
  91. ScrappedList = new List<MchBugDEntity>();
  92. if (value.Flag == "0")
  93. {
  94. MeasureData= new List<MchLenWeightEntity>();
  95. }
  96. }
  97. }
  98. }
  99. public List<MchLenWeightEntity> MeasureData = new List<MchLenWeightEntity>();
  100. protected override void ultraGrid1_CellChange(object sender, CellEventArgs e)
  101. {
  102. base.ultraGrid1_CellChange(sender, e);
  103. if (e.Cell.Column.Key.Equals("ProNum"))
  104. {
  105. if (UnMatchData.Any())
  106. {
  107. e.Cell.Row.Cells["ProTime"].Value = UnMatchData[0].MsauerDate;
  108. int a = int.Parse( e.Cell.Row.Cells["ProNum"].Value.ToString3());
  109. if (a > UnMatchData.Count) a = UnMatchData.Count;
  110. e.Cell.Row.Cells["ProEndTime"].Value = UnMatchData[a-1].MsauerDate;
  111. }
  112. }
  113. }
  114. protected override void EditScrapped()
  115. {
  116. Value.FailNum = ScrappedList.Sum(p => p.FailNum);
  117. Value.FailWt = ScrappedList.Sum(p => p.FailWt);
  118. Value.ProNum = MeasureData.Any()
  119. ? (MeasureData.Sum(p => p.ActCount) - Value.FailNum)
  120. : (OkPort.Count(p => p.TrFlag != "1") - Value.FailNum);
  121. ultraGrid1.Refresh();
  122. }
  123. private void uteChangeLen_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
  124. {
  125. if (PlnZyJgxCEntity == null) return;
  126. if (PlnZyJgxCEntity.HeatPlanNo == null)
  127. return;
  128. if (PlnZyJgxCEntity.PlineCode == null)
  129. return;
  130. using (var matfrm = new MeasureData(MeasureData))
  131. {
  132. if (matfrm.ShowDialog() == DialogResult.OK)
  133. {
  134. MeasureData = matfrm.data;
  135. Value.Flag = MeasureData.Any()?"1":"0";
  136. Value.ProNum = MeasureData.Sum(p => p.ActCount);
  137. }
  138. ultraGrid1.PerformAction(UltraGridAction.ExitEditMode);
  139. ultraGrid1.UpdateData();
  140. }
  141. }
  142. private void UpdateData(MchMeasureResultEntity entity)
  143. {
  144. if (UnMatchData.Any())
  145. {
  146. entity.ProTime = UnMatchData[0].MsauerDate;
  147. int a = int.Parse(entity.ProNum.ToString3());
  148. if (a > UnMatchData.Count) a = UnMatchData.Count;
  149. entity.ProEndTime = UnMatchData[a].MsauerDate;
  150. }
  151. }
  152. }
  153. }