FrmProcessParametersD.cs 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. using Core.Mes.Client.Comm.Control;
  2. using Core.Mes.Client.Comm.Server;
  3. using CoreFS.CA06;
  4. using Infragistics.Win.UltraWinGrid;
  5. using System;
  6. using System.Collections;
  7. using System.Data;
  8. using System.Windows.Forms;
  9. namespace Core.StlMes.Client.Qcm
  10. {
  11. public partial class FrmProcessParametersD : FrmBase
  12. {
  13. public FrmProcessParametersD()
  14. {
  15. InitializeComponent();
  16. }
  17. private void FrmProcessParametersD_Load(object sender, EventArgs e)
  18. {
  19. }
  20. /// <summary>
  21. /// 重写基类方法
  22. /// </summary>
  23. /// <param name="sender"></param>
  24. /// <param name="ToolbarKey"></param>
  25. public override void ToolBar_Click(object sender, string ToolbarKey)
  26. {
  27. switch (ToolbarKey)
  28. {
  29. case "doQuery":
  30. doQuery();
  31. break;
  32. case "doSave":
  33. this.doSave();
  34. break;
  35. case "Close":
  36. this.Close();
  37. break;
  38. }
  39. }
  40. /// <summary>
  41. /// 查询功能实现
  42. /// </summary>
  43. private void doQuery()
  44. {
  45. BindProcessTable();
  46. //BindParametersTable();
  47. }
  48. /// <summary>
  49. /// 保存操作
  50. /// </summary>
  51. private void doSave()
  52. {
  53. ultraGrid2.UpdateData();
  54. //往工序点与工艺参数对应表中插入工序点编号和工艺参数编号。
  55. ArrayList Params = new ArrayList();
  56. string stationCode = ultraGrid1.ActiveRow.Cells["STATION_CODE"].Value.ToString();
  57. foreach (DataRow dr in this.parametersTable.Rows)
  58. {
  59. if ((Boolean)dr["CHK"])
  60. {
  61. ArrayList param = new ArrayList();
  62. //工序代码
  63. param.Add(ultraGrid1.ActiveRow.Cells["PROCESS_CODE"].Value.ToString());
  64. //工序描述
  65. param.Add(ultraGrid1.ActiveRow.Cells["PROCESS_DESC"].Value.ToString());
  66. //工序点代码
  67. param.Add(stationCode);
  68. //工序点描述
  69. param.Add(ultraGrid1.ActiveRow.Cells["STATION_DESC"].Value.ToString());
  70. //工艺参数代码
  71. param.Add(dr["CRAFT_CODE"].ToString());
  72. //工艺参数描述
  73. param.Add(dr["CRAFTITEM_DESC"].ToString());
  74. //单个参数维护个数
  75. string allowCount = dr["ALLOW_COUNT"].ToString();
  76. if ("".Equals(allowCount))
  77. {
  78. MessageBox.Show("单个参数维护个数不允许为空。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  79. return;
  80. }
  81. param.Add(allowCount);
  82. Params.Add(param);
  83. }
  84. }
  85. //确定保存吗?
  86. if (MessageBox.Show("是否确认保存?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
  87. {
  88. return;
  89. }
  90. //将Params作为参数传递到服务端,执行插入工作。
  91. CoreClientParam ccp = new CoreClientParam();
  92. //服务端的包名+类名
  93. ccp.ServerName = "com.steering.pss.qcm.CoreProcessParametersD";
  94. //类里的方法名
  95. ccp.MethodName = "doSave";
  96. ccp.ServerParams = new object[] { Params, stationCode };
  97. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  98. if (ccp.ReturnCode == -1)
  99. {
  100. return;
  101. }
  102. else
  103. {
  104. MessageBox.Show("保存成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  105. BindProcessTable();
  106. foreach (UltraGridRow row in ultraGrid1.Rows)
  107. {
  108. if (stationCode.Equals(row.Cells["STATION_CODE"].Value.ToString()))
  109. {
  110. row.Activate();
  111. }
  112. }
  113. }
  114. }
  115. /// <summary>
  116. /// 绑定右侧数据源,工艺参数与对应表两表联查
  117. /// </summary>
  118. private void BindParametersTable(string processCode)
  119. {
  120. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreProcessParametersD.getLineList", new Object[] { processCode }, this.ob);
  121. GridHelper.CopyDataToDatatable(ref dt, ref this.parametersTable, true);
  122. GridHelper.RefreshAndAutoSizeExceptColumns(ultraGrid2, new UltraGridColumn[] {
  123. ultraGrid2.DisplayLayout.Bands[0].Columns["CHK"]
  124. });
  125. }
  126. /// <summary>
  127. /// 绑定工序点数据源
  128. /// </summary>
  129. private void BindProcessTable()
  130. {
  131. //DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreControlPointBasics.getLineList", new Object[] { true, "" }, this.ob);
  132. //GridHelper.CopyDataToDatatable(ref dt, ref this.processTable, true);
  133. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreProcessParametersD.GetProcessGL", null, this.ob);
  134. GridHelper.CopyDataToDatatable(ref dt, ref this.processTable, true);
  135. GridHelper.RefreshAndAutoSizeExceptColumns(ultraGrid1, new UltraGridColumn[] {
  136. });
  137. }
  138. private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
  139. {
  140. //select 工艺参数 from 对应表 where 工序点 = 当前选中工序点编号
  141. string processCode = ultraGrid1.ActiveRow.Cells["STATION_CODE"].Value.ToString();
  142. BindParametersTable(processCode);
  143. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreProcessParametersD.GetParameters", new Object[] { processCode }, this.ob);
  144. //将界面上所有复选框重置为false。
  145. if (parametersTable.Rows.Count > 0)
  146. {
  147. foreach (DataRow dr in parametersTable.Rows)
  148. {
  149. dr["CHK"] = false;
  150. }
  151. }
  152. //判断是否有勾选项。
  153. if (dt.Rows.Count > 0)
  154. {
  155. foreach (DataRow dr in parametersTable.Rows)
  156. {
  157. for (int i = 0; i < dt.Rows.Count; i++)
  158. {
  159. if (dr["CRAFT_CODE"].ToString().Equals(dt.Rows[i]["CRAFTITEM_CODE"].ToString()))
  160. {
  161. dr["CHK"] = true;
  162. break;
  163. }
  164. }
  165. }
  166. }
  167. //未勾选不允许编辑数据。
  168. for (int i = 0; i < ultraGrid2.Rows.Count; i++)
  169. {
  170. for (int j = 0; j < ultraGrid2.Rows[i].Cells.Count; j++)
  171. {
  172. if (j != 4)
  173. {
  174. ultraGrid2.Rows[i].Cells[j].Activation = Infragistics.Win.UltraWinGrid.Activation.NoEdit;
  175. }
  176. }
  177. //如果已经选中,则单个参数可维护个数允许编辑。
  178. if ((Boolean)ultraGrid2.Rows[i].Cells[4].Value)
  179. {
  180. ultraGrid2.Rows[i].Cells[5].Activation = Infragistics.Win.UltraWinGrid.Activation.AllowEdit;
  181. }
  182. }
  183. }
  184. /// <summary>
  185. /// 勾选时,让单个参数维护个数可编辑
  186. /// </summary>
  187. /// <param name="sender"></param>
  188. /// <param name="e"></param>
  189. private void ultraGrid2_CellChange(object sender, CellEventArgs e)
  190. {
  191. ultraGrid2.UpdateData();
  192. if (e.Cell.Column.Key.Equals("CHK"))
  193. {
  194. if ((Boolean)e.Cell.Value)
  195. {
  196. for (int i = 0; i < e.Cell.Row.Cells.Count; i++)
  197. {
  198. //16 17 18 19 20 21 24
  199. if (i != 0 && i != 1 && i != 2 && i != 3)
  200. {
  201. e.Cell.Row.Cells[i].Activation = Infragistics.Win.UltraWinGrid.Activation.AllowEdit;
  202. }
  203. }
  204. }
  205. else
  206. {
  207. for (int i = 0; i < e.Cell.Row.Cells.Count; i++)
  208. {
  209. if (i != 4)
  210. {
  211. e.Cell.Row.Cells[i].Activation = Infragistics.Win.UltraWinGrid.Activation.NoEdit;
  212. }
  213. }
  214. }
  215. }
  216. }
  217. private void ultraGrid2_AfterCellUpdate(object sender, CellEventArgs e)
  218. {
  219. }
  220. }
  221. }