FrmProcessParameters.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445
  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.Drawing;
  10. using System.Windows.Forms;
  11. namespace Core.StlMes.Client.Qcm
  12. {
  13. public partial class FrmProcessParameters : FrmBase
  14. {
  15. public FrmProcessParameters()
  16. {
  17. InitializeComponent();
  18. }
  19. private void FrmProcessParameters_Load(object sender, EventArgs e)
  20. {
  21. BindCmbParamType();
  22. cmbParamType.SelectedIndex = 0;
  23. cmbStyleName.SelectedIndex = 0;
  24. //doQuery();
  25. }
  26. /// <summary>
  27. /// 获取工艺参数最大值
  28. /// </summary>
  29. /// <returns></returns>
  30. private string GetMaxCode()
  31. {
  32. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreProcessParameters.GetMaxCode", null, this.ob);
  33. string maxCode = "";
  34. if (dt.Rows.Count > 0)
  35. {
  36. if (!"".Equals(dt.Rows[0][0].ToString()))
  37. {
  38. maxCode = dt.Rows[0][0].ToString();
  39. }
  40. else
  41. {
  42. maxCode = "C000";
  43. }
  44. }
  45. return maxCode;
  46. }
  47. /// <summary>
  48. /// 绑定工艺参数类别数据源
  49. /// </summary>
  50. private void BindCmbParamType()
  51. {
  52. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreProcessParameters.GetType", null, this.ob); ;
  53. cmbParamType.DataSource = dt;
  54. cmbParamType.DisplayMember = "BASENAME";
  55. cmbParamType.ValueMember = "BASECODE";
  56. DataTable dtProcess = ServerHelper.GetData("com.steering.pss.qcm.CoreControlPointBasics.GetProcess", null, this.ob);
  57. ultraComboEditor1.DataSource = dtProcess;
  58. ultraComboEditor1.DisplayMember = "PROCESS_DESC";
  59. ultraComboEditor1.ValueMember = "PROCESS_CODE";
  60. }
  61. /// <summary>
  62. /// 重写基类方法
  63. /// </summary>
  64. /// <param name="sender"></param>
  65. /// <param name="ToolbarKey"></param>
  66. public override void ToolBar_Click(object sender, string ToolbarKey)
  67. {
  68. switch (ToolbarKey)
  69. {
  70. case "doQuery":
  71. doQuery();
  72. break;
  73. case "doAdd":
  74. doAdd();
  75. break;
  76. case "doModify":
  77. doModify();
  78. break;
  79. case "doDelete":
  80. this.doDeleteOrResume(true);
  81. break;
  82. case "doResume":
  83. this.doDeleteOrResume(false);
  84. break;
  85. case "Refresh":
  86. {
  87. BindCmbParamType();
  88. cmbParamType.SelectedIndex = 0;
  89. cmbStyleName.SelectedIndex = 0;
  90. break;
  91. }
  92. case "Close":
  93. this.Close();
  94. break;
  95. }
  96. }
  97. /// <summary>
  98. /// 用于验证修改时,描述是否已存在
  99. /// </summary>
  100. private static string VName = "";
  101. /// <summary>
  102. /// 验证非空项
  103. /// </summary>
  104. /// <returns></returns>
  105. private bool ValidInput()
  106. {
  107. if (string.IsNullOrEmpty(txtName.Text.Trim()))
  108. {
  109. MessageBox.Show("请输入工艺参数描述!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  110. return false;
  111. }
  112. return true;
  113. }
  114. /// <summary>
  115. /// 验证描述是否重复。
  116. /// </summary>
  117. /// <param name="name"></param>
  118. /// <returns></returns>
  119. private bool isRepeatName(string name)
  120. {
  121. DataTable dt = new DataTable();
  122. dt = ServerHelper.GetData("com.steering.pss.qcm.CoreProcessParameters.GetName", new Object[] { name }, this.ob);
  123. if (dt.Rows.Count > 0)
  124. {
  125. return true;
  126. }
  127. else
  128. {
  129. return false;
  130. }
  131. }
  132. /// <summary>
  133. /// 新增
  134. /// </summary>
  135. private void doAdd()
  136. {
  137. if (ValidInput())
  138. {
  139. //验证描述不允许重复。
  140. string name = txtName.Text.Trim();
  141. if (isRepeatName(name))
  142. {
  143. MessageBox.Show("工艺参数描述\"" + name + "\"已存在,请重新输入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  144. return;
  145. }
  146. if (MessageBox.Show("是否确认新增!", "提示", MessageBoxButtons.YesNo) == DialogResult.No)
  147. {
  148. return;
  149. }
  150. try
  151. {
  152. ArrayList parm = new ArrayList();
  153. //自动生成编号信息。
  154. //string chenCode = GridHelper.AutoCode(this.dataTable1);
  155. //获取数据库中CRAFT_CODE的最大值。
  156. //GetMaxCode();
  157. //string chenCode = StringUtil.SequenceIncrease(dataTable1.Compute("max(CRAFT_CODE)", "").ToString());
  158. string chenCode = StringUtil.SequenceIncrease(GetMaxCode());
  159. parm.Add(chenCode);
  160. parm.Add(name);
  161. parm.Add(cmbParamType.Text);
  162. parm.Add(cmbStyleName.Value);
  163. parm.Add(this.UserInfo.GetUserName());
  164. parm.Add(txtMemo.Text);
  165. parm.Add(ultraComboEditor1.Value.ToString2());
  166. CoreClientParam ccp = new CoreClientParam();
  167. ccp.ServerName = "com.steering.pss.qcm.CoreProcessParameters";
  168. ccp.MethodName = "doAdd";
  169. ccp.ServerParams = new object[] { parm };
  170. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  171. if (ccp.ReturnCode == -1) return;
  172. doQuery();
  173. //高亮显示新增的数据
  174. Infragistics.Win.UltraWinGrid.UltraGridRow row = null;
  175. for (int i = 0; i < ultraGrid1.Rows.Count; i++)
  176. {
  177. row = ultraGrid1.Rows[i];
  178. if (row.Cells["CRAFT_CODE"].Value.ToString().Equals(chenCode))
  179. {
  180. row.Activate();
  181. break;
  182. }
  183. }
  184. }
  185. catch (Exception ex)
  186. {
  187. MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  188. }
  189. }
  190. }
  191. /// <summary>
  192. /// 修改
  193. /// </summary>
  194. private void doModify()
  195. {
  196. if (ultraGrid1.ActiveRow == null)
  197. {
  198. MessageBox.Show("请选择需要修改的数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  199. return;
  200. }
  201. string validflagStr = ultraGrid1.ActiveRow.Cells["VALIDFLAG"].Value.ToString();
  202. //无效数据不允许修改
  203. if ("0".Equals(validflagStr))
  204. {
  205. MessageBox.Show("无效数据不支持修改操作。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  206. return;
  207. }
  208. if (ValidInput())
  209. {
  210. //验证描述不允许重复。
  211. string name = txtName.Text.Trim();
  212. if (!VName.Equals(name))
  213. {
  214. if (isRepeatName(name))
  215. {
  216. MessageBox.Show("工艺参数描述\"" + name + "\"已存在,请重新输入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  217. return;
  218. }
  219. }
  220. //确认修改吗?
  221. if (MessageBox.Show("是否确认修改选中的数据!", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
  222. {
  223. return;
  224. }
  225. ArrayList parm = new ArrayList();
  226. string chenCode = ultraGrid1.ActiveRow.Cells["CRAFT_CODE"].Value.ToString();
  227. parm.Add(txtName.Text);
  228. parm.Add(cmbParamType.Text);
  229. parm.Add(cmbStyleName.Value);
  230. parm.Add(this.UserInfo.GetUserName());
  231. parm.Add(txtMemo.Text);
  232. parm.Add(ultraComboEditor1.Value.ToString2());
  233. parm.Add(chenCode);
  234. CoreClientParam ccp = new CoreClientParam();
  235. ccp.ServerName = "com.steering.pss.qcm.CoreProcessParameters";
  236. ccp.MethodName = "doModify";
  237. ccp.ServerParams = new object[] { parm };
  238. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  239. if (ccp.ReturnCode == -1) return;
  240. doQuery();
  241. //高亮显示新增的数据
  242. Infragistics.Win.UltraWinGrid.UltraGridRow row = null;
  243. for (int i = 0; i < ultraGrid1.Rows.Count; i++)
  244. {
  245. row = ultraGrid1.Rows[i];
  246. if (row.Cells["CRAFT_CODE"].Value.ToString().Equals(chenCode))
  247. {
  248. row.Activate();
  249. break;
  250. }
  251. }
  252. }
  253. }
  254. /// <summary>
  255. /// 查询
  256. /// </summary>
  257. private void doQuery()
  258. {
  259. bool validFlag = chkValid.Checked;
  260. string titleName = "";
  261. if (ultraCheckEditor1.Checked)
  262. {
  263. titleName = txtTitleName.Text.Trim();
  264. }
  265. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreProcessParameters.getLineList", new Object[] { validFlag, titleName }, this.ob);
  266. GridHelper.CopyDataToDatatable(ref dt, ref this.dataTable1, true);
  267. //不同颜色区分是否有效数据
  268. Infragistics.Win.UltraWinGrid.UltraGridRow row = null;
  269. for (int i = 0; i < ultraGrid1.Rows.Count; i++)
  270. {
  271. row = ultraGrid1.Rows[i];
  272. if (!row.Cells["VALIDFLAG"].Value.ToString().Equals("1"))
  273. {
  274. row.Appearance.ForeColor = Color.Red;
  275. }
  276. else
  277. {
  278. row.Appearance.ForeColor = Color.Black;
  279. }
  280. }
  281. GridHelper.RefreshAndAutoSizeExceptRows(ultraGrid1, new UltraGridColumn[] {
  282. ultraGrid1.DisplayLayout.Bands[0].Columns["MEMO"]
  283. });
  284. }
  285. /// <summary>
  286. /// GRID ROW激活时信息带至编辑区
  287. /// </summary>
  288. /// <param name="sender"></param>
  289. /// <param name="e"></param>
  290. private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
  291. {
  292. Infragistics.Win.UltraWinGrid.UltraGridRow row = ultraGrid1.ActiveRow;
  293. if (row != null)
  294. {
  295. //CRAFT_CODE,CRAFTITEM_DESC,CRAFTITEM_TYPE,CRAFTITEM_LV
  296. txtName.Text = row.Cells["CRAFTITEM_DESC"].Value.ToString();
  297. VName = txtName.Text.Trim();
  298. cmbParamType.Text = row.Cells["CRAFTITEM_TYPE"].Value.ToString();
  299. cmbStyleName.Value = row.Cells["CRAFTITEM_LV"].Value.ToString();
  300. txtMemo.Text = row.Cells["MEMO"].Value.ToString();
  301. ultraComboEditor1.Value = row.Cells["PROCESS_CODE"].Value.ToString();
  302. }
  303. }
  304. /// <summary>
  305. /// 作废或恢复
  306. /// </summary>
  307. /// <param name="isDelete">true作废 false恢复</param>
  308. private void doDeleteOrResume(bool isDelete)
  309. {
  310. ultraGrid1.UpdateData();
  311. if (ultraGrid1.ActiveRow == null)
  312. {
  313. MessageBox.Show("请选择需要" + (isDelete ? "作废" : "恢复") + "的数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  314. return;
  315. }
  316. string validflagStr = ultraGrid1.ActiveRow.Cells["VALIDFLAG"].Value.ToString();
  317. //无效数据不允许作废
  318. if ("0".Equals(validflagStr))
  319. {
  320. if (isDelete)
  321. {
  322. MessageBox.Show("无效数据不支持作废操作。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  323. return;
  324. }
  325. }
  326. else
  327. {
  328. //有效数据不允许恢复
  329. if (!isDelete)
  330. {
  331. MessageBox.Show("有效数据不支持恢复操作。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  332. return;
  333. }
  334. }
  335. if (MessageBox.Show("是否确认" + (isDelete ? "作废" : "恢复") + "选中的数据!", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
  336. {
  337. try
  338. {
  339. ArrayList param = new ArrayList();
  340. string craftCode = ultraGrid1.ActiveRow.Cells["CRAFT_CODE"].Value.ToString();
  341. param.Add(craftCode);
  342. int count = ServerHelper.SetData("com.steering.pss.qcm.CoreProcessParameters.deleteLineInfo", new Object[] { param, UserInfo.GetUserName(), isDelete }, this.ob);
  343. if (count > 0)
  344. {
  345. doQuery();
  346. Infragistics.Win.UltraWinGrid.UltraGridRow rowD = null;
  347. for (int i = 0; i < ultraGrid1.Rows.Count; i++)
  348. {
  349. rowD = ultraGrid1.Rows[i];
  350. if (rowD.Cells["CRAFT_CODE"].Value.ToString().Equals(craftCode))
  351. {
  352. rowD.Activate();
  353. break;
  354. }
  355. }
  356. }
  357. }
  358. catch (Exception ex)
  359. {
  360. MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  361. }
  362. }
  363. }
  364. private void ultraCheckEditor1_CheckedChanged(object sender, EventArgs e)
  365. {
  366. if (ultraCheckEditor1.Checked)
  367. {
  368. txtTitleName.ReadOnly = false;
  369. }
  370. else
  371. {
  372. txtTitleName.ReadOnly = true;
  373. }
  374. }
  375. }
  376. }