frmBaseProcesscostC.cs 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585
  1. using Core.Mes.Client.Comm.Format;
  2. using Core.Mes.Client.Comm.Server;
  3. using Core.Mes.Client.Comm.Tool;
  4. using Core.StlMes.Client.PnCost.Models;
  5. using CoreFS.CA06;
  6. using Infragistics.Win.UltraWinGrid;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.ComponentModel;
  10. using System.Data;
  11. using System.Drawing;
  12. using System.Linq;
  13. using System.Text;
  14. using System.Windows.Forms;
  15. namespace Core.StlMes.Client.PnCost
  16. {
  17. public partial class frmBaseProcesscostC : FrmBase
  18. {
  19. #region 定义变量
  20. public frmBaseProcesscostC()
  21. {
  22. InitializeComponent();
  23. }
  24. private DataTable dtpline;
  25. #endregion
  26. #region 初始化
  27. private void frmBaseProcesscostC_Load(object sender, EventArgs e)
  28. {
  29. EntityHelper.ShowGridCaption<CostBaseProcesscostCEntity>(ultraGrid1.DisplayLayout.Bands[0]);
  30. dtpline = ServerHelper.GetData("com.steering.pss.pncost.base.ComBaseProcesscostC.queryPliao",
  31. new object[] { }, ob);
  32. ultraComboEditor1.DisplayMember = "PLINE_NAME";
  33. ultraComboEditor1.ValueMember = "PLINE_CODE";
  34. ultraComboEditor1.DataSource = dtpline;
  35. ultraComboEditor2.DisplayMember = "PLINE_NAME";
  36. ultraComboEditor2.ValueMember = "PLINE_CODE";
  37. ultraComboEditor2.DataSource = dtpline;
  38. ultraCheckEditor1.Checked = false;//模糊
  39. ultraTextEditor1.Enabled = false;//模糊
  40. ultraCheckEditor3.Checked = false;
  41. ultraComboEditor2.Enabled = false;
  42. Query();
  43. }
  44. #endregion
  45. #region 方法
  46. public override void ToolBar_Click(object sender, string ToolbarKey)
  47. {
  48. base.ToolBar_Click(sender, ToolbarKey);
  49. switch (ToolbarKey)
  50. {
  51. case "Query":
  52. Query();
  53. break;
  54. case "Update":
  55. Save();
  56. break;
  57. case "Delete":
  58. Delete();
  59. break;
  60. case "Resume":
  61. Resume();
  62. break;
  63. case "Close":
  64. this.Close();
  65. break;
  66. }
  67. }
  68. /// 查询方法
  69. /// <summary>
  70. /// 查询方法
  71. /// </summary>
  72. private void Query()
  73. {
  74. #region 条件验证
  75. //产线
  76. string strPei = "";
  77. if (ultraCheckEditor1.Checked)//产线是否选择
  78. {
  79. if (ultraTextEditor1.Text == "")//产线是否输入
  80. {
  81. MessageUtil.ShowWarning("请输入产线!");
  82. return;
  83. }
  84. else
  85. {
  86. strPei = ultraTextEditor1.Text.Trim();//产线
  87. }
  88. }
  89. //产线
  90. if (ultraCheckEditor3.Checked)//产线是否选择
  91. {
  92. strPei = ultraComboEditor2.Text;//产线
  93. }
  94. #endregion
  95. List<CostBaseProcesscostCEntity> data = EntityHelper.GetData<CostBaseProcesscostCEntity>(
  96. "com.steering.pss.pncost.base.ComBaseProcesscostC.query", new object[] { strPei }, ob);
  97. costBaseProcesscostCEntityBindingSource.DataSource = data;
  98. if (ultraGrid1.Rows.Count == 0)
  99. {
  100. return;
  101. }
  102. for (int i = 0; i < ultraGrid1.Rows.Count; i++)
  103. {
  104. if (ultraGrid1.Rows[i].Cells["VALIDFLAG"].Value.ToString() == "无效")
  105. {
  106. ultraGrid1.Rows[i].Appearance.ForeColor = Color.Red;
  107. }
  108. ultraGrid1.Rows[i].Cells["PLINENAMENEW"].Value = ultraGrid1.Rows[i].Cells["PLINENAME"].Value;
  109. ultraGrid1.Rows[i].Cells["SCHEDULEMINNEW"].Value = ultraGrid1.Rows[i].Cells["SCHEDULEMIN"].Value;
  110. ultraGrid1.Rows[i].Cells["SCHEDULEMAXNEW"].Value = ultraGrid1.Rows[i].Cells["SCHEDULEMAX"].Value;
  111. ultraGrid1.Rows[i].Cells["CHK"].Value = false;
  112. GridEdite(ultraGrid1.Rows[i]);
  113. }
  114. ultraGrid1.UpdateData();
  115. ultraGrid1.ActiveRow = ultraGrid1.Rows[0];
  116. }
  117. /// 保存方法
  118. /// <summary>
  119. /// 保存方法
  120. /// </summary>
  121. private void Save()
  122. {
  123. string stringnew = "";
  124. string min = "";
  125. string max = "";
  126. string xuanze = "false";
  127. try
  128. {
  129. #region 验证信息
  130. ultraGrid1.UpdateData();
  131. for (int i = 0; i < ultraGrid1.Rows.Count; i++)
  132. {
  133. if (ultraGrid1.Rows[i].Cells["CHK"].Value.ToString() == "True")
  134. {
  135. if (ultraGrid1.Rows[i].Cells["PLINENAME"].Value.ToString2() == "")
  136. {
  137. MessageUtil.ShowWarning("产线不能为空!请选择产线");
  138. return;
  139. }
  140. if (ultraGrid1.Rows[i].Cells["SCHEDULEMIN"].Value.ToString2() == "")
  141. {
  142. MessageUtil.ShowWarning("排产量下限不能为空!请重新输入");
  143. return;
  144. }
  145. if (ultraGrid1.Rows[i].Cells["SCHEDULEMAX"].Value.ToString2() == "")
  146. {
  147. MessageUtil.ShowWarning("排产量上限不能为空!请重新输入");
  148. return;
  149. }
  150. if (Convert.ToDecimal(ultraGrid1.Rows[i].Cells["SCHEDULEMAX"].Value.ToString3()) <=
  151. Convert.ToDecimal(ultraGrid1.Rows[i].Cells["SCHEDULEMIN"].Value.ToString3()))
  152. {
  153. MessageUtil.ShowWarning("排产量上限<=下限!请重新输入");
  154. return;
  155. }
  156. if (ultraGrid1.Rows[i].Cells["COSTPRICE"].Value.ToString2() == "")
  157. {
  158. MessageUtil.ShowWarning("吨加工费不能为空!请重新输入");
  159. return;
  160. }
  161. if (ultraGrid1.Rows[i].Cells["CREATENAME"].Value.ToString2() == "")//判断是新增还是修改的保存
  162. {
  163. stringnew = ultraGrid1.Rows[i].Cells["PLINENAME"].Text.ToString2();
  164. min = ultraGrid1.Rows[i].Cells["SCHEDULEMIN"].Value.ToString3();
  165. max = ultraGrid1.Rows[i].Cells["SCHEDULEMAX"].Value.ToString3();
  166. DataTable dt = ServerHelper.GetData("com.steering.pss.pncost.base.ComBaseProcesscostC.queryNum", new Object[] { stringnew, min, max }, ob);
  167. if (Convert.ToInt32(dt.Rows[0][0].ToString()) > 0)
  168. {
  169. MessageUtil.ShowWarning("排产量上下限范围有重合!,请重新输入");
  170. return;
  171. }
  172. for (int index = 0; index < ultraGrid1.Rows.Count; index++)
  173. {
  174. if (ultraGrid1.Rows[index].Cells["CHK"].Value.ToString() == "True" && i != index &&
  175. ultraGrid1.Rows[index].Cells["PLINENAME"].Text.ToString() == stringnew)
  176. {
  177. if (Convert.ToDecimal(ultraGrid1.Rows[index].Cells["SCHEDULEMIN"].Value.ToString()) < Convert.ToDecimal(min) &&
  178. Convert.ToDecimal(ultraGrid1.Rows[index].Cells["SCHEDULEMAX"].Value.ToString()) > Convert.ToDecimal(min))
  179. {
  180. MessageUtil.ShowWarning("排产量上下限范围有重合!,请重新输入");
  181. return;
  182. }
  183. if (Convert.ToDecimal(ultraGrid1.Rows[index].Cells["SCHEDULEMIN"].Value.ToString()) < Convert.ToDecimal(max) &&
  184. Convert.ToDecimal(ultraGrid1.Rows[index].Cells["SCHEDULEMAX"].Value.ToString()) > Convert.ToDecimal(max))
  185. {
  186. MessageUtil.ShowWarning("排产量上下限范围有重合!,请重新输入");
  187. return;
  188. }
  189. if (Convert.ToDecimal(ultraGrid1.Rows[index].Cells["SCHEDULEMIN"].Value.ToString()) > Convert.ToDecimal(min) &&
  190. Convert.ToDecimal(ultraGrid1.Rows[index].Cells["SCHEDULEMAX"].Value.ToString()) < Convert.ToDecimal(max))
  191. {
  192. MessageUtil.ShowWarning("排产量上下限范围有重合!,请重新输入");
  193. return;
  194. }
  195. }
  196. }
  197. }
  198. else //修改
  199. {
  200. stringnew = ultraGrid1.Rows[i].Cells["PLINENAME"].Text.ToString2();
  201. min = ultraGrid1.Rows[i].Cells["SCHEDULEMIN"].Value.ToString3();
  202. max = ultraGrid1.Rows[i].Cells["SCHEDULEMAX"].Value.ToString3();
  203. if (ultraGrid1.Rows[i].Cells["PLINENAME"].Value.ToString2() != ultraGrid1.Rows[i].Cells["PLINENAMENEW"].Value.ToString2() ||
  204. ultraGrid1.Rows[i].Cells["SCHEDULEMIN"].Value.ToString2() != ultraGrid1.Rows[i].Cells["SCHEDULEMINNEW"].Value.ToString2() ||
  205. ultraGrid1.Rows[i].Cells["SCHEDULEMAX"].Value.ToString2() != ultraGrid1.Rows[i].Cells["SCHEDULEMAXNEW"].Value.ToString2())
  206. {
  207. //DataTable dt = ServerHelper.GetData("com.steering.pss.pncost.base.ComBaseProcesscostC.queryNum", new Object[] { stringnew, min, max }, ob);
  208. //DataTable dtnew = ServerHelper.GetData("com.steering.pss.pncost.base.ComBaseProcesscostC.queryshangxia", new Object[] { stringnew, min, max }, ob);
  209. //if (Convert.ToInt32(dt.Rows[0][0].ToString()) > 0)
  210. //{
  211. // for (int j = 0; j < dtnew.Rows.Count; j++)//修改的时候 要剔除本身那条数据
  212. // {
  213. // if (!(dtnew.Rows[j]["PLINE_NAME"].ToString2() == ultraGrid1.Rows[i].Cells["PLINENAMENEW"].Text.ToString2() &&
  214. // dtnew.Rows[j]["SCHEDULE_MIN"].ToString2() == ultraGrid1.Rows[i].Cells["SCHEDULEMINNEW"].Text.ToString2() &&
  215. // dtnew.Rows[j]["SCHEDULE_MAX"].ToString2() == ultraGrid1.Rows[i].Cells["SCHEDULEMAXNEW"].Text.ToString2()))
  216. // {
  217. // MessageUtil.ShowWarning("排产量上下限范围有重合!,请重新输入");
  218. // return;
  219. // }
  220. // }
  221. //}
  222. for (int index = 0; index < ultraGrid1.Rows.Count; index++)
  223. {
  224. if ( i != index &&
  225. ultraGrid1.Rows[index].Cells["PLINENAME"].Text.ToString() == stringnew)
  226. {
  227. if (Convert.ToDecimal(ultraGrid1.Rows[index].Cells["SCHEDULEMIN"].Value.ToString()) < Convert.ToDecimal(min) &&
  228. Convert.ToDecimal(ultraGrid1.Rows[index].Cells["SCHEDULEMAX"].Value.ToString()) > Convert.ToDecimal(min))
  229. {
  230. MessageUtil.ShowWarning("排产量上下限范围有重合!,请重新输入");
  231. return;
  232. }
  233. if (Convert.ToDecimal(ultraGrid1.Rows[index].Cells["SCHEDULEMIN"].Value.ToString()) < Convert.ToDecimal(max) &&
  234. Convert.ToDecimal(ultraGrid1.Rows[index].Cells["SCHEDULEMAX"].Value.ToString()) > Convert.ToDecimal(max))
  235. {
  236. MessageUtil.ShowWarning("排产量上下限范围有重合!,请重新输入");
  237. return;
  238. }
  239. if (Convert.ToDecimal(ultraGrid1.Rows[index].Cells["SCHEDULEMIN"].Value.ToString()) > Convert.ToDecimal(min) &&
  240. Convert.ToDecimal(ultraGrid1.Rows[index].Cells["SCHEDULEMAX"].Value.ToString()) < Convert.ToDecimal(max))
  241. {
  242. MessageUtil.ShowWarning("排产量上下限范围有重合!,请重新输入");
  243. return;
  244. }
  245. }
  246. }
  247. }
  248. }
  249. xuanze = "true";
  250. }
  251. }
  252. if (xuanze == "false")
  253. {
  254. MessageUtil.ShowWarning("请选择你要保存的记录!");
  255. return;
  256. }
  257. if (MessageUtil.ShowYesNoAndQuestion("是否确认保存?") == System.Windows.Forms.DialogResult.No)
  258. {
  259. return;
  260. }
  261. #endregion
  262. for (int i = 0; i < ultraGrid1.Rows.Count; i++)
  263. {
  264. if (ultraGrid1.Rows[i].Cells["CHK"].Value.ToString() == "True")
  265. {
  266. CostBaseProcesscostCEntity parm = new CostBaseProcesscostCEntity();
  267. parm.PlineName = ultraGrid1.Rows[i].Cells["PLINENAME"].Text.ToString();
  268. parm.ProcessCode = ultraGrid1.Rows[i].Cells["PROCESSCODE"].Value.ToString();
  269. parm.ProcessDesc = ultraGrid1.Rows[i].Cells["PROCESSDESC"].Value.ToString();
  270. parm.ScheduleMax = Convert.ToDecimal(ultraGrid1.Rows[i].Cells["SCHEDULEMAX"].Value.ToString3());
  271. parm.ScheduleMin = Convert.ToDecimal(ultraGrid1.Rows[i].Cells["SCHEDULEMIN"].Value.ToString3());
  272. parm.CostPrice = Convert.ToDecimal(ultraGrid1.Rows[i].Cells["COSTPRICE"].Value.ToString3());
  273. parm.Memo = ultraGrid1.Rows[i].Cells["MEMO"].Value.ToString();
  274. if (ultraGrid1.Rows[i].Cells["CREATENAME"].Value.ToString() == "")//判断是新增还是修改的保存
  275. {
  276. parm.PlineCode = ultraGrid1.Rows[i].Cells["PLINENAME"].Value.ToString2();
  277. parm.CreateName = this.UserInfo.GetUserName();//新增保存
  278. string JsonStr = JSONFormat.Format(parm);
  279. ServerHelper.SetData("com.steering.pss.pncost.base.ComBaseProcesscostC.isave", new object[] { JsonStr }, ob);
  280. }
  281. else
  282. {
  283. if (ultraGrid1.Rows[i].Cells["PLINENAME"].Text.ToString2() != ultraGrid1.Rows[i].Cells["PLINENAMENEW"].Value.ToString2())
  284. {
  285. parm.PlineCode = ultraGrid1.Rows[i].Cells["PLINENAME"].Value.ToString();
  286. }
  287. else
  288. {
  289. parm.PlineCode = ultraGrid1.Rows[i].Cells["PLINECODE"].Value.ToString();
  290. }
  291. parm.UpdateName = this.UserInfo.GetUserName();//修改保存
  292. string JsonStr = JSONFormat.Format(parm);
  293. string plinenamenew = "";
  294. min = ultraGrid1.Rows[i].Cells["SCHEDULEMINNEW"].Value.ToString3();
  295. max = ultraGrid1.Rows[i].Cells["SCHEDULEMAXNEW"].Value.ToString3();
  296. plinenamenew = ultraGrid1.Rows[i].Cells["PLINENAMENEW"].Value.ToString();
  297. ServerHelper.SetData("com.steering.pss.pncost.base.ComBaseProcesscostC.usave", new object[] { JsonStr, plinenamenew, min, max }, ob);
  298. }
  299. }
  300. }
  301. }
  302. catch (Exception ex)
  303. {
  304. MessageUtil.ShowError("保存失败!'" + ex.Message + "'");
  305. return;
  306. }
  307. MessageUtil.ShowTips("保存成功!");
  308. Query();
  309. for (int i = 0; i < ultraGrid1.Rows.Count; i++)
  310. {
  311. if (ultraGrid1.Rows[i].Cells["PLINENAME"].Text.ToString() == stringnew)
  312. {
  313. ultraGrid1.Rows[i].Activate();
  314. }
  315. }
  316. }
  317. /// 删除方法
  318. /// <summary>
  319. /// 删除方法
  320. /// </summary>
  321. private void Delete()
  322. {
  323. string stringnew = "";
  324. string xuanze = "false";
  325. try
  326. {
  327. #region 验证信息
  328. ultraGrid1.UpdateData();
  329. for (int i = 0; i < ultraGrid1.Rows.Count; i++)
  330. {
  331. if (ultraGrid1.Rows[i].Cells["CHK"].Value.ToString() == "True")
  332. {
  333. //是否已经是无效方案
  334. if (ultraGrid1.Rows[i].Cells["VALIDFLAG"].Value.ToString() != "有效")
  335. {
  336. MessageUtil.ShowWarning("选择了已经作废的数据!");
  337. return;
  338. }
  339. xuanze = "true";
  340. }
  341. }
  342. if (xuanze == "false")
  343. {
  344. MessageUtil.ShowWarning("请选择你要删除的记录!");
  345. return;
  346. }
  347. if (MessageUtil.ShowYesNoAndQuestion("是否确认删除?") == System.Windows.Forms.DialogResult.No)
  348. {
  349. return;
  350. }
  351. #endregion
  352. for (int i = 0; i < ultraGrid1.Rows.Count; i++)
  353. {
  354. if (ultraGrid1.Rows[i].Cells["CHK"].Value.ToString() == "True")
  355. {
  356. stringnew = ultraGrid1.Rows[i].Cells["PLINENAME"].Text.ToString();
  357. CostBaseProcesscostCEntity parm = new CostBaseProcesscostCEntity();
  358. parm.PlineCode = ultraGrid1.Rows[i].Cells["PLINECODE"].Value.ToString();
  359. parm.ScheduleMax = Convert.ToDecimal(ultraGrid1.Rows[i].Cells["SCHEDULEMAX"].Value.ToString3());
  360. parm.ScheduleMin = Convert.ToDecimal(ultraGrid1.Rows[i].Cells["SCHEDULEMIN"].Value.ToString3());
  361. parm.CostPrice = Convert.ToDecimal(ultraGrid1.Rows[i].Cells["COSTPRICE"].Value.ToString3());
  362. parm.UpdateName = this.UserInfo.GetUserName();
  363. parm.DeleteName = this.UserInfo.GetUserName();
  364. string JsonStr = JSONFormat.Format(parm);
  365. ServerHelper.SetData("com.steering.pss.pncost.base.ComBaseProcesscostC.delete", new object[] { JsonStr }, ob);
  366. }
  367. }
  368. }
  369. catch (Exception ex)
  370. {
  371. MessageUtil.ShowError("删除失败!'" + ex.Message + "'");
  372. return;
  373. }
  374. MessageUtil.ShowTips("删除成功!");
  375. Query();
  376. for (int i = 0; i < ultraGrid1.Rows.Count; i++)
  377. {
  378. if (ultraGrid1.Rows[i].Cells["PLINENAME"].Text.ToString() == stringnew)
  379. {
  380. ultraGrid1.Rows[i].Activate();
  381. }
  382. }
  383. }
  384. /// 恢复方法
  385. /// <summary>
  386. /// 恢复方法
  387. /// </summary>
  388. private void Resume()
  389. {
  390. string stringnew = "";
  391. string min = "";
  392. string max = "";
  393. string xuanze = "false";
  394. try
  395. {
  396. #region 验证信息
  397. ultraGrid1.UpdateData();
  398. for (int i = 0; i < ultraGrid1.Rows.Count; i++)
  399. {
  400. if (ultraGrid1.Rows[i].Cells["CHK"].Value.ToString() == "True")
  401. {
  402. stringnew = ultraGrid1.Rows[i].Cells["PLINENAME"].Text.ToString2();
  403. min = ultraGrid1.Rows[i].Cells["SCHEDULEMIN"].Value.ToString3();
  404. max = ultraGrid1.Rows[i].Cells["SCHEDULEMAX"].Value.ToString3();
  405. DataTable dt = ServerHelper.GetData("com.steering.pss.pncost.base.ComBaseProcesscostC.queryNum", new Object[] { stringnew, min, max }, ob);
  406. if (Convert.ToInt32(dt.Rows[0][0].ToString()) > 0)
  407. {
  408. MessageUtil.ShowWarning("排产量上下限范围有重合!,不允许恢复");
  409. return;
  410. }
  411. //是否是无效方案
  412. if (ultraGrid1.Rows[i].Cells["VALIDFLAG"].Value.ToString() != "无效")
  413. {
  414. MessageUtil.ShowWarning("选择了没有作废的数据!");
  415. return;
  416. }
  417. xuanze = "true";
  418. }
  419. }
  420. if (xuanze == "false")
  421. {
  422. MessageUtil.ShowWarning("请选择你要恢复的记录!");
  423. return;
  424. }
  425. if (MessageUtil.ShowYesNoAndQuestion("是否确认恢复?") == System.Windows.Forms.DialogResult.No)
  426. {
  427. return;
  428. }
  429. #endregion
  430. for (int i = 0; i < ultraGrid1.Rows.Count; i++)
  431. {
  432. if (ultraGrid1.Rows[i].Cells["CHK"].Value.ToString() == "True")
  433. {
  434. stringnew = ultraGrid1.Rows[i].Cells["PLINENAME"].Text.ToString();
  435. CostBaseProcesscostCEntity parm = new CostBaseProcesscostCEntity();
  436. parm.PlineCode = ultraGrid1.Rows[i].Cells["PLINECODE"].Value.ToString();
  437. parm.ScheduleMax = Convert.ToDecimal(ultraGrid1.Rows[i].Cells["SCHEDULEMAX"].Value.ToString3());
  438. parm.ScheduleMin = Convert.ToDecimal(ultraGrid1.Rows[i].Cells["SCHEDULEMIN"].Value.ToString3());
  439. parm.CostPrice = Convert.ToDecimal(ultraGrid1.Rows[i].Cells["COSTPRICE"].Value.ToString3());
  440. parm.UpdateName = this.UserInfo.GetUserName();
  441. string JsonStr = JSONFormat.Format(parm);
  442. ServerHelper.SetData("com.steering.pss.pncost.base.ComBaseProcesscostC.resume", new object[] { JsonStr }, ob);
  443. }
  444. }
  445. }
  446. catch (Exception ex)
  447. {
  448. MessageUtil.ShowError("恢复失败!'" + ex.Message + "'");
  449. return;
  450. }
  451. MessageUtil.ShowTips("恢复成功!");
  452. Query();
  453. for (int i = 0; i < ultraGrid1.Rows.Count; i++)
  454. {
  455. if (ultraGrid1.Rows[i].Cells["PLINENAME"].Text.ToString() == stringnew)
  456. {
  457. ultraGrid1.Rows[i].Activate();
  458. }
  459. }
  460. }
  461. #endregion
  462. #region 事件
  463. /// 选择事件
  464. /// <summary>
  465. /// 选择事件
  466. /// </summary>
  467. private void ultraGrid1_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
  468. {
  469. ultraGrid1.UpdateData();
  470. if (e.Cell.Column.Key == "CHK")
  471. {
  472. GridEdite(e.Cell.Row);
  473. }
  474. if (e.Cell.Column.Key == "PlineName")
  475. {
  476. for (int i = 0; i < dtpline.Rows.Count; i++)
  477. {
  478. if (e.Cell.Row.GetText("PlineName").ToString2() == dtpline.Rows[i]["PLINE_NAME"].ToString2())
  479. {
  480. ultraGrid1.ActiveRow.Cells["PROCESSCODE"].Value = dtpline.Rows[i]["PROCESS_CODE"].ToString2();
  481. ultraGrid1.ActiveRow.Cells["PROCESSDESC"].Value = dtpline.Rows[i]["PROCESS_DESC"].ToString2();
  482. }
  483. }
  484. }
  485. }
  486. /// 选择判断
  487. /// <summary>
  488. /// 选择判断
  489. /// </summary>
  490. private void GridEdite(UltraGridRow row)
  491. {
  492. if (row.GetValue("CHK") == "True")
  493. {
  494. foreach (UltraGridCell cell in row.Cells)
  495. {
  496. if (cell.Column.CellActivation == Activation.AllowEdit)
  497. {
  498. cell.Activation = Activation.AllowEdit;
  499. }
  500. }
  501. }
  502. else
  503. {
  504. foreach (UltraGridCell cell in row.Cells)
  505. {
  506. if (cell.Column.Key == "CHK") continue;
  507. if (cell.Column.CellActivation == Activation.AllowEdit)
  508. {
  509. cell.Activation = Activation.ActivateOnly;
  510. }
  511. }
  512. }
  513. }
  514. /// 新增行事件
  515. /// <summary>
  516. /// 新增行事件
  517. /// </summary>
  518. private void ultraGrid1_InitializeTemplateAddRow(object sender, InitializeTemplateAddRowEventArgs e)
  519. {
  520. e.TemplateAddRow.Cells["CHK"].Value = false;
  521. foreach (UltraGridCell cell in e.TemplateAddRow.Cells)
  522. {
  523. if (cell.Column.CellActivation == Activation.AllowEdit)
  524. {
  525. cell.Activation = Activation.ActivateOnly;
  526. }
  527. }
  528. e.TemplateAddRow.Cells["CHK"].Activation = Activation.AllowEdit;
  529. //GridEdite(e.TemplateAddRow);
  530. }
  531. /// 模糊查询事件
  532. /// <summary>
  533. /// 模糊查询事件
  534. /// </summary>
  535. private void ultraCheckEditor1_CheckedChanged(object sender, EventArgs e)
  536. {
  537. if (ultraCheckEditor1.Checked == false)
  538. {
  539. ultraTextEditor1.Enabled = this.ultraCheckEditor1.Checked;
  540. }
  541. else {
  542. ultraTextEditor1.Enabled = this.ultraCheckEditor1.Checked;
  543. if (ultraCheckEditor3.Checked==true)
  544. {
  545. ultraCheckEditor3.Checked = ultraComboEditor2.Enabled = false;
  546. }
  547. }
  548. }
  549. /// 新增行事件
  550. /// <summary>
  551. /// 新增行事件
  552. /// </summary>
  553. private void ultraCheckEditor3_CheckedChanged(object sender, EventArgs e)
  554. {
  555. if (ultraCheckEditor3.Checked == false)
  556. {
  557. ultraComboEditor2.Enabled = this.ultraCheckEditor3.Checked;
  558. }
  559. else
  560. {
  561. ultraComboEditor2.Enabled = this.ultraCheckEditor3.Checked;
  562. if (ultraCheckEditor1.Checked == true)
  563. {
  564. ultraCheckEditor1.Checked = ultraTextEditor1.Enabled = false;
  565. }
  566. }
  567. }
  568. #endregion
  569. }
  570. }