FrmControlPointBasics.cs 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851
  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 FrmControlPointBasics : FrmBase
  14. {
  15. //查询条件
  16. private string _stationType = "";
  17. public string StationType
  18. {
  19. get { return _stationType; }
  20. set { _stationType = value; }
  21. }
  22. public FrmControlPointBasics()
  23. {
  24. InitializeComponent();
  25. ExceptionHelper.RegistException();
  26. this.IsLoadUserView = true; //平台F1功能
  27. }
  28. public void PopupLoad(OpeBase ob)
  29. {
  30. this.ob = ob;
  31. this.OnLoad(EventArgs.Empty);
  32. }
  33. private void FrmControlPointBasics_Load(object sender, EventArgs e)
  34. {
  35. Init();
  36. }
  37. private void Init()
  38. {
  39. //绑定工序点类型数据源
  40. BindCmbPointType();
  41. //绑定工序数据源
  42. BindCmbProcess();
  43. //绑定监视级别数据源
  44. BindCmbMonitorLv();
  45. cmbPointType.SelectedIndex = 0;
  46. cmbProcess.SelectedIndex = 0;
  47. cmbMonitorLv.SelectedIndex = 0;
  48. }
  49. /// <summary>
  50. /// 绑定监视级别数据源
  51. /// </summary>
  52. private void BindCmbMonitorLv()
  53. {
  54. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreControlPointBasics.GetMonitorLv", null, this.ob);
  55. cmbMonitorLv.DataSource = dt;
  56. cmbMonitorLv.DisplayMember = "BASENAME";
  57. cmbMonitorLv.ValueMember = "BASECODE";
  58. }
  59. /// <summary>
  60. /// 获取工序数据源
  61. /// </summary>
  62. private void BindCmbProcess()
  63. {
  64. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreControlPointBasics.GetProcess", null, this.ob);
  65. cmbProcess.DataSource = dt;
  66. cmbProcess.DisplayMember = "PROCESS_DESC";
  67. cmbProcess.ValueMember = "PROCESS_CODE";
  68. }
  69. /// <summary>
  70. /// 绑定工序点类型数据源
  71. /// </summary>
  72. private void BindCmbPointType()
  73. {
  74. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreControlPointBasics.GetPointType", null, this.ob);
  75. cmbPointType.DataSource = dt;
  76. cmbPointType.DisplayMember = "BASENAME";
  77. cmbPointType.ValueMember = "BASECODE";
  78. }
  79. /// <summary>
  80. /// 重写基类方法
  81. /// </summary>
  82. /// <param name="sender"></param>
  83. /// <param name="ToolbarKey"></param>
  84. public override void ToolBar_Click(object sender, string ToolbarKey)
  85. {
  86. switch (ToolbarKey)
  87. {
  88. case "doQuery":
  89. doQuery();
  90. break;
  91. case "doAdd":
  92. doAdd();
  93. break;
  94. case "doModify":
  95. doModify();
  96. break;
  97. case "doGrouping":
  98. doGrouping();
  99. break;
  100. case "doDelete":
  101. this.doDeleteOrResume(true);
  102. break;
  103. case "doResume":
  104. this.doDeleteOrResume(false);
  105. break;
  106. case "Refresh":
  107. Init();
  108. break;
  109. case "Cancel":
  110. CancelGroup();
  111. break;
  112. case "Export":
  113. Export();
  114. break;
  115. case "Close":
  116. this.Close();
  117. break;
  118. }
  119. }
  120. private void Export()
  121. {
  122. GridHelper.ulGridToExcel(ultraGrid2, "工序点管理");
  123. }
  124. /// <summary>
  125. /// 取消分组
  126. /// </summary>
  127. private void CancelGroup()
  128. {
  129. ultraGrid2.UpdateData();
  130. int isselect = 0;
  131. string _code = ""; //用于定位
  132. ArrayList list = new ArrayList();
  133. foreach (UltraGridRow ugr in ultraGrid2.Rows)
  134. {
  135. if (ugr.Cells["CHK"].Value.ToString() == "True")
  136. {
  137. if (!ugr.Cells["VALIDFLAG"].Value.Equals("1"))
  138. {
  139. MessageUtil.ShowWarning("无效数据,不能进行此操作!");
  140. return;
  141. }
  142. if (ugr.Cells["MONITOR_LV2"].Value.ToString() == "")
  143. {
  144. MessageUtil.ShowWarning("未分组数据,不能取消分组!");
  145. return;
  146. }
  147. string code = ugr.Cells["STATION_CODE"].Value.ToString();
  148. isselect += 1;
  149. list.Add(code);
  150. _code = code;
  151. }
  152. }
  153. if (isselect == 0)
  154. {
  155. MessageUtil.ShowWarning("请选择你要取消分组的记录 !");
  156. return;
  157. }
  158. if (MessageBox.Show("是否确认对选择记录取消分组?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
  159. {
  160. return;
  161. }
  162. int count = ServerHelper.SetData("com.steering.pss.qcm.CoreControlPointBasics.cancelGroup", new object[] { list }, this.ob);
  163. if (count > 0)
  164. {
  165. MessageUtil.ShowTips("取消分组成功!");
  166. doQuery();
  167. Infragistics.Win.UltraWinGrid.UltraGridRow row = null;
  168. for (int i = 0; i < ultraGrid2.Rows.Count; i++)
  169. {
  170. row = ultraGrid2.Rows[i];
  171. if (row.Cells["STATION_CODE"].Value.ToString().Equals(_code))
  172. {
  173. row.Activate();
  174. break;
  175. }
  176. }
  177. }
  178. }
  179. /// <summary>
  180. /// 分组功能实现
  181. /// </summary>
  182. private void doGrouping()
  183. {
  184. //从数据库中获取最大分组索引号+1
  185. int GroupId = GetMaxGrouping();
  186. //将勾选项索引号改成最大索引号。
  187. UpdateGrouping(GroupId);
  188. }
  189. /// <summary>
  190. /// 将勾选项索引号改成最大索引号。
  191. /// </summary>
  192. private void UpdateGrouping(int GroupId)
  193. {
  194. //更新数据源。
  195. ultraGrid2.UpdateData();
  196. //判断是否有勾选项,没有则提示。
  197. int chkbool = 0;
  198. for (int i = 0; i < this.ultraGrid2.Rows.Count; i++)
  199. {
  200. Infragistics.Win.UltraWinGrid.UltraGridRow dr = ultraGrid2.Rows[i];
  201. if ((Boolean)dr.Cells["CHK"].Value)
  202. {
  203. chkbool += 1;
  204. }
  205. }
  206. if (chkbool <= 0)
  207. {
  208. MessageBox.Show("请先勾选您要分组的记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  209. return;
  210. }
  211. if (MessageBox.Show("是否确认分组?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
  212. {
  213. return;
  214. }
  215. ArrayList groupingParams = new ArrayList();
  216. for (int i = 0; i < this.ultraGrid2.Rows.Count; i++)
  217. {
  218. Infragistics.Win.UltraWinGrid.UltraGridRow row = ultraGrid2.Rows[i];
  219. if ((Boolean)row.Cells["CHK"].Value)
  220. {
  221. ArrayList parm = new ArrayList();
  222. parm.Add(GroupId);
  223. //工序点代码
  224. parm.Add(row.Cells["STATION_CODE"].Value);
  225. groupingParams.Add(parm);
  226. }
  227. }
  228. CoreClientParam ccp = new CoreClientParam();
  229. ccp.ServerName = "com.steering.pss.qcm.CoreControlPointBasics";
  230. //类里的方法名
  231. ccp.MethodName = "doGrouping";
  232. ccp.ServerParams = new object[] { groupingParams };
  233. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  234. if (ccp.ReturnCode == -1)
  235. {
  236. return;
  237. }
  238. else
  239. {
  240. MessageBox.Show("分组成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  241. doQuery();
  242. //聚焦
  243. Infragistics.Win.UltraWinGrid.UltraGridRow row = null;
  244. for (int i = 0; i < ultraGrid2.Rows.Count; i++)
  245. {
  246. row = ultraGrid2.Rows[i];
  247. if (!row.Cells["MONITOR_LV2"].Value.ToString().Equals(""))
  248. {
  249. if (Convert.ToInt32(row.Cells["MONITOR_LV2"].Value) == GroupId)
  250. {
  251. row.Activate();
  252. break;
  253. }
  254. }
  255. }
  256. }
  257. }
  258. /// <summary>
  259. /// 获取最大分组索引号
  260. /// </summary>
  261. private int GetMaxGrouping()
  262. {
  263. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreControlPointBasics.GetMaxGrouping", null, this.ob);
  264. int maxCode = 1;
  265. if (dt.Rows.Count > 0)
  266. {
  267. if (!"".Equals(dt.Rows[0][0].ToString()))
  268. {
  269. maxCode = Convert.ToInt32(dt.Rows[0][0]) + 1;
  270. }
  271. }
  272. return maxCode;
  273. }
  274. /// <summary>
  275. /// 非空项验证
  276. /// </summary>
  277. /// <returns></returns>
  278. private bool ValidInput(string actionType)
  279. {
  280. if (string.IsNullOrEmpty(txtStationDesc.Text.Trim()))
  281. {
  282. MessageBox.Show("请输入工序点名称!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  283. return false;
  284. }
  285. if (cmbPointType.SelectedItem == null)
  286. {
  287. MessageUtil.ShowWarning("请选择工序点类型");
  288. cmbPointType.Focus();
  289. return false;
  290. }
  291. string stationCode = txtStationCode.Text.Trim();
  292. if (txtStationCode.Text.Trim().Length < 6 && txtStationCode.Text.Trim() != "")
  293. {
  294. stationCode = txtStationCode.Text.Trim();
  295. stationCode = stationCode.PadLeft(5, '0');
  296. txtStationCode.Text = stationCode;
  297. }
  298. if (IsExistStationCode(actionType) == true)
  299. {
  300. MessageUtil.ShowWarning("已存在此工序点代码!");
  301. txtStationCode.Focus();
  302. return false;
  303. }
  304. if (cmbProcess.Value == null)
  305. {
  306. MessageUtil.ShowWarning("请选择二级工序!");
  307. cmbProcess.Focus();
  308. return false;
  309. }
  310. return true;
  311. }
  312. private bool IsExistStationCode(string actionType)
  313. {
  314. string oldStationCode = "";
  315. if (ultraGrid2.ActiveRow != null)
  316. {
  317. oldStationCode = ultraGrid2.ActiveRow.Cells["STATION_CODE"].Value.ToString();
  318. }
  319. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreControlPointBasics.isExistStationCode",
  320. new object[] { oldStationCode, txtStationCode.Text.Trim(), actionType }, ob);
  321. if (dt != null)
  322. {
  323. if (dt.Rows[0][0].ToString() != "0")
  324. {
  325. return true;
  326. }
  327. }
  328. return false;
  329. }
  330. /// <summary>
  331. /// 获取工序点顺序号最大值
  332. /// </summary>
  333. /// <returns></returns>
  334. private int GetMaxStation()
  335. {
  336. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreControlPointBasics.GetMaxStation", null, this.ob);
  337. int maxCode = 1;
  338. if (dt.Rows.Count > 0)
  339. {
  340. if (!"".Equals(dt.Rows[0][0].ToString()))
  341. {
  342. maxCode = Convert.ToInt32(dt.Rows[0][0]) + 1;
  343. }
  344. }
  345. return maxCode;
  346. }
  347. /// <summary>
  348. /// 获取工序点代码最大值
  349. /// </summary>
  350. /// <returns></returns>
  351. private string GetMaxCode()
  352. {
  353. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreControlPointBasics.GetMaxCode", null, this.ob);
  354. string maxCode = "";
  355. if (dt.Rows.Count > 0)
  356. {
  357. if (!"".Equals(dt.Rows[0][0].ToString()))
  358. {
  359. maxCode = dt.Rows[0][0].ToString();
  360. }
  361. else
  362. {
  363. maxCode = "C000";
  364. }
  365. }
  366. return maxCode;
  367. }
  368. /// <summary>
  369. /// 验证描述是否重复。
  370. /// </summary>
  371. /// <param name="name"></param>
  372. /// <returns></returns>
  373. private bool isRepeatName(string name)
  374. {
  375. DataTable dt = new DataTable();
  376. dt = ServerHelper.GetData("com.steering.pss.qcm.CoreControlPointBasics.GetName", new Object[] { name }, this.ob);
  377. if (dt.Rows.Count > 0)
  378. {
  379. return true;
  380. }
  381. else
  382. {
  383. return false;
  384. }
  385. }
  386. /// <summary>
  387. /// 新增
  388. /// </summary>
  389. private void doAdd()
  390. {
  391. if (ValidInput("Insert"))
  392. {
  393. //判断名称是否重复
  394. string name = txtStationDesc.Text.Trim();
  395. if (isRepeatName(name))
  396. {
  397. MessageBox.Show("工序点名称\"" + name + "\"已存在,请重新输入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  398. txtStationDesc.Focus();
  399. return;
  400. }
  401. if (txtStationId.Text.Trim() != "")
  402. {
  403. if (IsExistStationId(txtStationId.Value.ToString()) == true)
  404. {
  405. MessageUtil.ShowWarning("系统已存在该工序点顺序号!");
  406. txtStationId.Focus();
  407. return;
  408. }
  409. }
  410. if (MessageUtil.ShowYesNoAndQuestion("是否新增记录?") == DialogResult.No)
  411. {
  412. return;
  413. }
  414. //txtStationCode,txtStationDesc,txtStationType,txtStationId,txtProcessCode,
  415. //txtProcessDesc,txtProcessCodeC,txtProcessDescC,txtCost,txtChoose,
  416. //txtReturnResult,txtSendCheckplan,txtMonitorLv
  417. ArrayList parm = new ArrayList();
  418. //编号自动生成
  419. //自动生成编号
  420. string stationCode = "";
  421. if (txtStationCode.Text.Trim() != "")
  422. {
  423. stationCode = txtStationCode.Text.Trim();
  424. }
  425. else
  426. {
  427. stationCode = StringUtil.SequenceIncrease(GetMaxCode());
  428. }
  429. parm.Add(stationCode);
  430. parm.Add(txtStationDesc.Text);
  431. parm.Add(cmbPointType.Value.ToString());
  432. parm.Add(cmbProcess.Value.ToString());
  433. parm.Add(cmbProcess.Text.ToString());
  434. //parm.Add(cmbProcessC.Value.ToString());
  435. //parm.Add(cmbProcessC.Text.ToString());
  436. parm.Add(txtCost.Text == "" ? "0" : txtCost.Value.ToString());
  437. //必经项,是否
  438. if (chkChoose.Checked)
  439. {
  440. parm.Add(1);
  441. }
  442. else
  443. {
  444. parm.Add(0);
  445. }
  446. //执行返回,是否
  447. if (chkReturnResult.Checked)
  448. {
  449. parm.Add(1);
  450. }
  451. else
  452. {
  453. parm.Add(0);
  454. }
  455. //是否发送检验计划
  456. if (chkSendCheckplan.Checked)
  457. {
  458. parm.Add(1);
  459. }
  460. else
  461. {
  462. parm.Add(0);
  463. }
  464. //监制级别
  465. parm.Add(cmbMonitorLv.Text.Trim());
  466. //顺序号STATION_ID,从数据库读取最大顺序号+1返回。
  467. int stationId = GetMaxStation();
  468. if (txtStationId.Text.ToString() == "")
  469. {
  470. parm.Add(stationId);
  471. }
  472. else
  473. {
  474. parm.Add(txtStationId.Text.Trim());
  475. }
  476. parm.Add(this.UserInfo.GetUserName());
  477. parm.Add(txtMemo.Text);
  478. parm.Add(che_COST_POINT.Checked?"1":"0");
  479. CoreClientParam ccp = new CoreClientParam();
  480. ccp.ServerName = "com.steering.pss.qcm.CoreControlPointBasics";
  481. ccp.MethodName = "doAdd";
  482. ccp.ServerParams = new object[] { parm };
  483. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  484. if (ccp.ReturnCode == -1)
  485. return;
  486. MessageUtil.ShowTips("新增成功!");
  487. doQuery();
  488. //高亮显示新增的数据
  489. Infragistics.Win.UltraWinGrid.UltraGridRow row = null;
  490. for (int i = 0; i < ultraGrid2.Rows.Count; i++)
  491. {
  492. row = ultraGrid2.Rows[i];
  493. if (row.Cells["STATION_CODE"].Value.ToString().Equals(stationCode))
  494. {
  495. row.Activate();
  496. break;
  497. }
  498. }
  499. }
  500. }
  501. private bool IsExistStationId(string strStationId)
  502. {
  503. ArrayList list = new ArrayList();
  504. list.Add(strStationId);
  505. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreControlPointBasics.isExistStationId",
  506. new object[] { list }, ob);
  507. if (dt != null)
  508. {
  509. if (dt.Rows[0][0].ToString() != "0")
  510. {
  511. return true;
  512. }
  513. }
  514. return false;
  515. }
  516. /// <summary>
  517. /// 修改
  518. /// </summary>
  519. private void doModify()
  520. {
  521. if (ultraGrid2.ActiveRow == null)
  522. {
  523. MessageBox.Show("请选择需要修改的数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  524. return;
  525. }
  526. string validflagStr = ultraGrid2.ActiveRow.Cells["VALIDFLAG"].Value.ToString();
  527. //无效数据不允许修改
  528. if ("0".Equals(validflagStr))
  529. {
  530. MessageBox.Show("无效数据不支持修改操作。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  531. return;
  532. }
  533. if (txtStationId.Text.Trim() != ultraGrid2.ActiveRow.Cells["STATION_ID"].Value.ToString())
  534. {
  535. if (IsExistStationId(txtStationId.Value.ToString()) == true)
  536. {
  537. MessageUtil.ShowWarning("系统已存在该工序点顺序号!");
  538. txtStationId.Focus();
  539. return;
  540. }
  541. }
  542. if (ValidInput("Update"))
  543. {
  544. //验证描述不允许重复。
  545. string name = txtStationDesc.Text.Trim();
  546. if (!name.Equals(ultraGrid2.ActiveRow.Cells["STATION_DESC"].Value.ToString()))
  547. {
  548. if (isRepeatName(name))
  549. {
  550. MessageBox.Show("工序点名称\"" + name + "\"已存在,请重新输入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  551. return;
  552. }
  553. }
  554. //确认修改吗?
  555. if (MessageBox.Show("是否确认修改选中的数据!", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
  556. {
  557. return;
  558. }
  559. ArrayList parm = new ArrayList();
  560. string stationCode = "";
  561. if (txtStationCode.Text.Trim() != "")
  562. {
  563. stationCode = txtStationCode.Text.Trim();
  564. }
  565. else
  566. {
  567. stationCode = ultraGrid2.ActiveRow.Cells["STATION_CODE"].Value.ToString();
  568. }
  569. parm.Add(stationCode);
  570. parm.Add(txtStationDesc.Text);
  571. parm.Add(cmbPointType.Value.ToString());
  572. parm.Add(cmbProcess.Value.ToString());
  573. parm.Add(cmbProcess.Text.ToString());
  574. parm.Add(txtCost.Value == null ? "0" : txtCost.Value.ToString());
  575. //必经项,是否
  576. if (chkChoose.Checked)
  577. {
  578. parm.Add(1);
  579. }
  580. else
  581. {
  582. parm.Add(0);
  583. }
  584. //执行返回,是否
  585. if (chkReturnResult.Checked)
  586. {
  587. parm.Add(1);
  588. }
  589. else
  590. {
  591. parm.Add(0);
  592. }
  593. //是否发送检验计划
  594. if (chkSendCheckplan.Checked)
  595. {
  596. parm.Add(1);
  597. }
  598. else
  599. {
  600. parm.Add(0);
  601. }
  602. parm.Add(cmbMonitorLv.Text.Trim());
  603. parm.Add(this.UserInfo.GetUserName());
  604. parm.Add(txtMemo.Text);
  605. parm.Add(txtStationId.Value == null ? ultraGrid2.ActiveRow.Cells["STATION_ID"].Value.ToString() : txtStationId.Value.ToString());
  606. parm.Add(che_COST_POINT.Checked ? "1" : "0");
  607. parm.Add(ultraGrid2.ActiveRow.Cells["STATION_CODE"].Value.ToString());
  608. CoreClientParam ccp = new CoreClientParam();
  609. ccp.ServerName = "com.steering.pss.qcm.CoreControlPointBasics";
  610. ccp.MethodName = "doModify";
  611. ccp.ServerParams = new object[] { parm };
  612. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  613. if (ccp.ReturnCode == -1) return;
  614. MessageUtil.ShowTips("修改成功!");
  615. doQuery();
  616. //高亮显示新增的数据
  617. Infragistics.Win.UltraWinGrid.UltraGridRow row = null;
  618. for (int i = 0; i < ultraGrid2.Rows.Count; i++)
  619. {
  620. row = ultraGrid2.Rows[i];
  621. if (row.Cells["STATION_CODE"].Value.ToString().Equals(stationCode))
  622. {
  623. row.Activate();
  624. break;
  625. }
  626. }
  627. }
  628. }
  629. /// <summary>
  630. /// 查询
  631. /// </summary>
  632. private void doQuery()
  633. {
  634. bool validFlag = chkValid.Checked;
  635. string titleName = "";
  636. if (ultraCheckEditor1.Checked)
  637. {
  638. titleName = txtTitleName.Text.Trim();
  639. }
  640. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreControlPointBasics.getLineList",
  641. new Object[] { validFlag, titleName, _stationType }, this.ob);
  642. GridHelper.CopyDataToDatatable(ref dt, ref this.dataTable1, true);
  643. //不同颜色区分是否有效数据
  644. Infragistics.Win.UltraWinGrid.UltraGridRow row = null;
  645. for (int i = 0; i < ultraGrid2.Rows.Count; i++)
  646. {
  647. row = ultraGrid2.Rows[i];
  648. if (!row.Cells["VALIDFLAG"].Value.ToString().Equals("1"))
  649. {
  650. row.Appearance.ForeColor = Color.Red;
  651. row.Cells["CHK"].Activation = Activation.Disabled;
  652. }
  653. else
  654. {
  655. row.Appearance.ForeColor = Color.Black;
  656. }
  657. }
  658. //列自适应
  659. GridHelper.RefreshAndAutoSizeExceptRows(ultraGrid2, new UltraGridColumn[] {
  660. ultraGrid2.DisplayLayout.Bands[0].Columns["MEMO"],
  661. ultraGrid2.DisplayLayout.Bands[0].Columns["CHK"]
  662. });
  663. }
  664. /// <summary>
  665. /// GRID ROW激活时信息带至编辑区
  666. /// </summary>
  667. /// <param name="sender"></param>
  668. /// <param name="e"></param>
  669. private void ultraGrid2_AfterRowActivate(object sender, EventArgs e)
  670. {
  671. Infragistics.Win.UltraWinGrid.UltraGridRow row = ultraGrid2.ActiveRow;
  672. if (row != null)
  673. {
  674. //STATION_CODE,STATION_DESC,STATION_TYPE ,STATION_ID
  675. //PROCESS_CODE,PROCESS_DESC,PROCESS_CODE_C,PROCESS_DESC_C
  676. // COST,CHOOSE,RETURN_RESULT,SEND_CHECKPLAN,MONITOR_LV
  677. //txtStationCode,txtStationDesc,txtStationType,txtStationId,txtProcessCode,
  678. //txtProcessDesc,txtProcessCodeC,txtProcessDescC,txtCost,txtChoose,
  679. //txtReturnResult,txtSendCheckplan,txtMonitorLv
  680. txtStationCode.Text = row.Cells["STATION_CODE"].Value.ToString();
  681. txtStationDesc.Text = row.Cells["STATION_DESC"].Value.ToString();
  682. cmbPointType.Text = row.Cells["STATION_TYPE"].Value.ToString();
  683. cmbProcess.Value = row.Cells["PROCESS_CODE"].Value.ToString();
  684. //cmbProcessC.Value = row.Cells["PROCESS_CODE_C"].Value.ToString();
  685. txtCost.Value = row.Cells["COST"].Value.ToString();
  686. if ("1".Equals(row.Cells["CHOOSE"].Value.ToString()))
  687. {
  688. chkChoose.Checked = true;
  689. }
  690. else
  691. {
  692. chkChoose.Checked = false;
  693. }
  694. if ("1".Equals(row.Cells["RETURN_RESULT"].Value.ToString()))
  695. {
  696. chkReturnResult.Checked = true;
  697. }
  698. else
  699. {
  700. chkReturnResult.Checked = false;
  701. }
  702. if ("1".Equals(row.Cells["SEND_CHECKPLAN"].Value.ToString()))
  703. {
  704. chkSendCheckplan.Checked = true;
  705. }
  706. else
  707. {
  708. chkSendCheckplan.Checked = false;
  709. }
  710. che_COST_POINT.Checked = row.Cells["COST_POINT"].Value.ToString2().Equals("是") ? true : false;
  711. cmbMonitorLv.Text = row.Cells["MONITOR_LV"].Value.ToString();
  712. txtMemo.Text = row.Cells["MEMO"].Value.ToString();
  713. txtStationId.Value = row.Cells["STATION_ID"].Value.ToString();
  714. }
  715. }
  716. /// <summary>
  717. /// 作废或恢复
  718. /// </summary>
  719. /// <param name="isDelete">true作废 false恢复</param>
  720. private void doDeleteOrResume(bool isDelete)
  721. {
  722. if (ultraGrid2.ActiveRow == null)
  723. {
  724. MessageBox.Show("请选择需要" + (isDelete ? "作废" : "恢复") + "的数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  725. return;
  726. }
  727. string validflagStr = ultraGrid2.ActiveRow.Cells["VALIDFLAG"].Value.ToString();
  728. //无效数据不允许作废
  729. if ("0".Equals(validflagStr))
  730. {
  731. if (isDelete)
  732. {
  733. MessageBox.Show("无效数据不支持作废操作。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  734. return;
  735. }
  736. }
  737. else
  738. {
  739. //有效数据不允许恢复
  740. if (!isDelete)
  741. {
  742. MessageBox.Show("有效数据不支持恢复操作。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  743. return;
  744. }
  745. }
  746. ArrayList param = new ArrayList();
  747. string stationCode = ultraGrid2.ActiveRow.Cells["STATION_CODE"].Value.ToString();
  748. param.Add(stationCode);
  749. if (param.Count > 0 && MessageBox.Show("是否确认" + (isDelete ? "作废" : "恢复") + "选中的数据!", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
  750. {
  751. int count = ServerHelper.SetData("com.steering.pss.qcm.CoreControlPointBasics.deleteLineInfo", new Object[] { param, UserInfo.GetUserName(), isDelete }, this.ob);
  752. if (count > 0)
  753. {
  754. doQuery();
  755. Infragistics.Win.UltraWinGrid.UltraGridRow rowD = null;
  756. for (int i = 0; i < ultraGrid2.Rows.Count; i++)
  757. {
  758. rowD = ultraGrid2.Rows[i];
  759. if (rowD.Cells["STATION_CODE"].Value.ToString().Equals(stationCode))
  760. {
  761. rowD.Activate();
  762. break;
  763. }
  764. }
  765. }
  766. }
  767. }
  768. private void ultraCheckEditor1_CheckedChanged(object sender, EventArgs e)
  769. {
  770. if (ultraCheckEditor1.Checked)
  771. {
  772. txtTitleName.ReadOnly = false;
  773. }
  774. else
  775. {
  776. txtTitleName.ReadOnly = true;
  777. }
  778. }
  779. }
  780. }