FrmMscStationSelect.cs 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. using Core.Mes.Client.Comm.Control;
  2. using Core.Mes.Client.Comm.Server;
  3. using Core.Mes.Client.Comm.Tool;
  4. using CoreFS.CA06;
  5. using Infragistics.Win.UltraWinGrid;
  6. using System;
  7. using System.Collections;
  8. using System.Data;
  9. using System.Windows.Forms;
  10. namespace Core.StlMes.Client.Qcm
  11. {
  12. public partial class FrmPscStationSelect : FrmBase
  13. {
  14. private FrmProPSCMSC2 _frm = null;
  15. private UltraGridRow _row = null;
  16. private FrmPscStationSelect()
  17. {
  18. InitializeComponent();
  19. ExceptionHelper.RegistException();
  20. }
  21. public FrmPscStationSelect(FrmProPSCMSC2 frm, UltraGridRow row) : this()
  22. {
  23. _frm = frm;
  24. _row = row;
  25. LoadStationData();
  26. }
  27. private void LoadStationData()
  28. {
  29. DataTable dt = null;
  30. ArrayList list = new ArrayList();
  31. list.Add(_row.Cells["PROCESS_CODE"].Value.ToString());
  32. list.Add(_row.GetValue("PROCESS_CODE_C"));
  33. try
  34. {
  35. dt = ServerHelper.GetData("com.steering.pss.qcm.CoreFrmProPSCMSC2.queryBaseStation",
  36. new object[] { list }, _frm.ob);
  37. }
  38. catch
  39. {
  40. return;
  41. }
  42. AddBaseStationDataWithCount(dt);
  43. //foreach (UltraGridRow row in ultraGridSta.Rows)
  44. //{
  45. // if (row.GetValue("CHOOSE") == "True")
  46. // {
  47. // row.SetValue("UCCHOOSE", "True");
  48. // }
  49. //}
  50. if (_frm.UltraGrid4.ActiveRow != null)
  51. {
  52. if (_frm._dicMscStation.ContainsKey(_row.Cells["PROCESS_CODE"].Value.ToString()))
  53. {
  54. AddMscStationData(_frm._dicMscStation[_row.Cells["PROCESS_CODE"].Value.ToString()]);
  55. ultraGridSta.UpdateData();
  56. return;
  57. }
  58. DataTable dt2 = null;
  59. ArrayList list2 = new ArrayList();
  60. list2.Add(_frm.UltraGrid4.ActiveRow.Cells["MSC"].Value.ToString());
  61. list2.Add(_frm.UltraGrid4.ActiveRow.Cells["MSC_PLINE"].Value.ToString());
  62. list2.Add(_row.Cells["PROCESS_CODE"].Value.ToString());
  63. try
  64. {
  65. dt2 = ServerHelper.GetData("com.steering.pss.qcm.CoreFrmProPSCMSC2.queryMscStation",
  66. new object[] { list2 }, _frm.ob);
  67. }
  68. catch
  69. {
  70. return;
  71. }
  72. AddMscStationData(dt2);
  73. }
  74. if (_frm._dicMscStation.ContainsKey(_row.Cells["PROCESS_CODE"].Value.ToString()))
  75. {
  76. AddMscStationData(_frm._dicMscStation[_row.Cells["PROCESS_CODE"].Value.ToString()]);
  77. ultraGridSta.UpdateData();
  78. return;
  79. }
  80. COM_MSC_STATION.AcceptChanges();
  81. ultraGridSta.UpdateData();
  82. //GridHelper.RefreshAndAutoSize(ultraGridSta);
  83. }
  84. /// <summary>
  85. /// 根据工序的循环次数在客户端自动生成对应的行数。
  86. /// </summary>
  87. /// <param name="dt"></param>
  88. private void AddBaseStationDataWithCount(DataTable dt)
  89. {
  90. int count = int.Parse(_row.Cells["ICOUNT"].Value.ToString() == ""
  91. ? "1" : _row.Cells["ICOUNT"].Value.ToString());
  92. //GridHelper.CopyDataToDatatable(ref dt, ref COM_MSC_STATION, true);
  93. for (int i = 0; i < count; i++)
  94. {
  95. foreach (DataRow drOld in dt.Rows)
  96. {
  97. DataRow drNew = COM_MSC_STATION.NewRow();
  98. foreach (DataColumn dcOld in dt.Columns)
  99. {
  100. if (COM_MSC_STATION.Columns.Contains(dcOld.ColumnName))
  101. {
  102. drNew[dcOld.ColumnName] = drOld[dcOld.ColumnName].ToString();
  103. }
  104. }
  105. drNew["PROCESS_SEQ"] = (i + 1).ToString();
  106. COM_MSC_STATION.Rows.Add(drNew);
  107. }
  108. }
  109. }
  110. private void AddMscStationData(DataTable dt)
  111. {
  112. foreach (DataRow dr in dt.Rows)
  113. {
  114. UltraGridRow[] rows = GridHelper.GetRowsWithKey(ultraGridSta,
  115. new string[] { "STATION_CODE", "PROCESS_SEQ" },
  116. new string[] { dr["STATION_CODE"].ToString(), dr["PROCESS_SEQ"].ToString() });
  117. if (rows.Length == 0) continue;
  118. rows[0].Cells["MSC"].Value = dr["MSC"].ToString();
  119. rows[0].Cells["MSC_PLINE"].Value = dr["MSC_PLINE"].ToString();
  120. rows[0].Cells["COST"].Value = dr["COST"].ToString();
  121. rows[0].Cells["CHOOSE"].Value = dr["CHOOSE"].ToString();
  122. rows[0].Cells["RETURN_RESULT"].Value = dr["RETURN_RESULT"].ToString();
  123. rows[0].Cells["SEND_CHECKPLAN"].Value = dr["SEND_CHECKPLAN"].ToString();
  124. //rows[0].Cells["GROUP_SEQ"].Value = dr["GROUP_SEQ"].ToString();
  125. rows[0].Cells["MEMO"].Value = dr["MEMO"].ToString();
  126. rows[0].Cells["UCCHOOSE"].Value = true;
  127. }
  128. }
  129. private void AddMscStationData(UltraGrid grid)
  130. {
  131. UltraGridRow[] rows = GridHelper.GetRowsWithKey(grid, new string[] { "UCCHOOSE" }, new string[] { "True" });
  132. foreach (UltraGridRow row in rows)
  133. {
  134. string stationCode = row.Cells["STATION_CODE"].Value.ToString();
  135. string processSeq = row.Cells["PROCESS_SEQ"].Value.ToString();
  136. UltraGridRow[] rowsSta = GridHelper.GetRowsWithKey(ultraGridSta,
  137. new string[] { "STATION_CODE", "PROCESS_SEQ" },
  138. new string[] { stationCode, processSeq });
  139. if (rowsSta.Length == 0) continue;
  140. rowsSta[0].Cells["COST"].Value = row.Cells["COST"].Value;
  141. rowsSta[0].Cells["CHOOSE"].Value = row.Cells["CHOOSE"].Value.ToString() == "True" ? true : false;
  142. rowsSta[0].Cells["RETURN_RESULT"].Value = row.Cells["RETURN_RESULT"].Value.ToString() == "True" ? true : false;
  143. rowsSta[0].Cells["SEND_CHECKPLAN"].Value = row.Cells["SEND_CHECKPLAN"].Value.ToString() == "True" ? true : false;
  144. rowsSta[0].Cells["MEMO"].Value = row.Cells["MEMO"].Value;
  145. rowsSta[0].Cells["UCCHOOSE"].Value = row.Cells["UCCHOOSE"].Value.ToString() == "True" ? true : false;
  146. }
  147. }
  148. private void InitCheckState()
  149. {
  150. UltraGridRow[] rows = GridHelper.GetRowsWithKey(ultraGridSta,
  151. new string[] { "MSC" }, new string[] { "" });
  152. foreach (UltraGridRow row in rows)
  153. {
  154. row.Cells["UCCHOOSE"].Value = true;
  155. }
  156. }
  157. private void button1_Click(object sender, EventArgs e)
  158. {
  159. this.ultraGridSta.UpdateData();
  160. foreach (UltraGridRow row in ultraGridSta.Rows)
  161. {
  162. if (row.GetValue("UCCHOOSE") == "False") continue;
  163. if (row.GetValue("COST") != "" && row.GetValue("COST").TryParseDecimal() == false)
  164. {
  165. MessageUtil.ShowWarning("标准成本不是有效的数字!");
  166. row.SetCellActive("COST");
  167. return;
  168. }
  169. }
  170. this.DialogResult = DialogResult.OK;
  171. }
  172. private void button2_Click(object sender, EventArgs e)
  173. {
  174. this.DialogResult = DialogResult.Cancel;
  175. }
  176. private void ultraGridSta_CellChange(object sender, CellEventArgs e)
  177. {
  178. ultraGridSta.UpdateData();
  179. }
  180. private void ultraGridSta_InitializeRow(object sender, InitializeRowEventArgs e)
  181. {
  182. // CHOOSE UCCHOOSE
  183. }
  184. private void MustCheck(bool isCheck)
  185. {
  186. foreach (UltraGridRow row in ultraGridSta.Rows)
  187. {
  188. if (bool.Parse(row.GetValue("CHOOSE")))
  189. {
  190. row.SetValue("UCCHOOSE", isCheck.ToString());
  191. }
  192. }
  193. ultraGridSta.UpdateData();
  194. }
  195. private void labelCheckBox1_CheckBox_CheckedChanged(object sender, EventArgs e)
  196. {
  197. MustCheck(labelCheckBox1.Checked);
  198. }
  199. }
  200. }