FrmPurCicpPrice.cs 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using com.hnshituo.pur.vo;
  10. using Infragistics.Win.UltraWinEditors;
  11. using CoreFS.CA06;using Pur.Entity;
  12. using Core.Mes.Client.Comm.Control;
  13. using Pur.require_plan;
  14. using Pur.Pop_upWindow;
  15. using Pur.Entity;
  16. namespace Pur.Balance
  17. {
  18. public partial class FrmPurCicpPrice : FrmPmsBase
  19. {
  20. public FrmPurCicpPrice()
  21. {
  22. InitializeComponent();
  23. }
  24. private void FrmPurCicpPrice_Load(object sender, EventArgs e)
  25. {
  26. clearEdtArea();
  27. QureyCicpPriceM();
  28. }
  29. #region toolbar工具栏
  30. //toolbar工具栏加载
  31. public override void ToolBar_Click(object sender, string ToolBarKey)
  32. {
  33. switch (ToolBarKey)
  34. {
  35. case "Query"://查询基价标准主表数据
  36. QureyCicpPriceM();
  37. //GetQueryPhysicWH();
  38. break;
  39. case "Add"://增加基价标准主表
  40. AddCicpPriceM();
  41. break;
  42. case "Update"://修改基价标准主表
  43. EditCicpPriceM();
  44. break;
  45. case "Delete"://删除基价标准主表
  46. DeleteCicpPriceM();
  47. break;
  48. case "AddCicpPriceC": //新增基价标准明细表
  49. AddCicpPriceC();
  50. break;
  51. case "UpdateCicpPriceC"://修改基价标准明细表
  52. EditCicpPriceC();
  53. break;
  54. case "DeleteCicpPriceC"://删除基价标准明细表
  55. DeleteCicpPriceC();
  56. break;
  57. case "Close"://关闭窗口
  58. this.Close();
  59. break;
  60. }
  61. }
  62. #endregion
  63. #region toolbar事件
  64. /// <summary>
  65. /// 删除一条明细
  66. /// </summary>
  67. private void DeleteCicpPriceC()
  68. {
  69. try
  70. {
  71. //判断是否获取到焦点
  72. if (ultraGrid2.ActiveRow != null)
  73. {
  74. string oldstrid = ultraGrid2.ActiveRow.Cells["id"].Value.ToString().Trim();
  75. string oldstrstandid = ultraGrid2.ActiveRow.Cells["standId"].Value.ToString().Trim();
  76. string oldchemcode = ultraGrid2.ActiveRow.Cells["chemCode"].Value.ToString().Trim(); ;
  77. //提示是否需要修改
  78. if (MessageBox.Show("将修改明细表ID为[" + oldstrid + "]的信息?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
  79. {
  80. //构建实体类
  81. BalanceCicpriceC pc = new BalanceCicpriceC();
  82. pc.Validflag = "0";
  83. pc.Id = oldstrid;
  84. pc.ChemCode = oldchemcode;
  85. pc.DeleteName = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName();
  86. pc.DeleteTime = DateTime.Now;
  87. pc.DeleteUserid = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserID();
  88. //调用服务接口
  89. CoreResult re = this.execute<CoreResult>("com.hnshituo.pur.balance.service.BalanceCicpriceCService", "doUpdateCicpPriceC", new object[] { pc });
  90. if (re.Resultcode == 0)
  91. {
  92. //DataTable tempData = (DataTable)re.Resultdata;
  93. //GridHelper.CopyDataToDatatable(ref re.Resultdata, ref dataTable1, true);
  94. MessageBox.Show("删除成功", "提示");
  95. QureyCicpPriceM();
  96. BalanceClassCommon.doActiveSelRow(ultraGrid1, "id", oldstrstandid);
  97. }
  98. else
  99. {
  100. MessageBox.Show("操作失败:" + re.Resultmsg, "提示");
  101. return;
  102. }
  103. }
  104. }
  105. else
  106. {
  107. MessageBox.Show("操作失败:请选择需修改的成分计价标准行", "提示");
  108. return;
  109. }
  110. }
  111. catch (Exception ex)
  112. {
  113. MessageBox.Show("操作失败:" + ex.Message, "提示");
  114. }
  115. }
  116. private void EditCicpPriceC()
  117. {
  118. try
  119. {
  120. //判断是否获取到焦点
  121. if (ultraGrid2.ActiveRow != null)
  122. {
  123. string strid = ultraGrid2.ActiveRow.Cells["id"].Value.ToString().Trim();
  124. string strstandid = ultraGrid2.ActiveRow.Cells["standId"].Value.ToString().Trim();
  125. //获取编辑框信息
  126. // string strid = edtIdC.Text.ToString().Trim();
  127. string strchemCode = edtChemCode.Text.ToString().Trim();
  128. string strremark = edtRemarkC.Text.ToString().Trim();
  129. double dbaddSubtValue = (double)edtAddSubtValue.Value;
  130. //构建实体类
  131. BalanceCicpriceC pc = new BalanceCicpriceC();
  132. //校验编辑框信息
  133. if (edtup.Checked)
  134. {
  135. if (edtmaxVal.Value == null || edtMaxSign.Value==null)
  136. {
  137. MessageBox.Show("上限符号和上限值不能为空","提升");
  138. edtmaxVal.Focus();
  139. return;
  140. }
  141. else
  142. {
  143. pc.MaxVal = (double)edtmaxVal.Value;
  144. pc.MaxSign = edtMaxSign.Text;
  145. }
  146. }
  147. if (edtdown.Checked)
  148. {
  149. if(edtMinVal.Value==null||edtMinSign.Value==null)
  150. {
  151. MessageBox.Show("下限符号和下限值不能为空","提升");
  152. edtMinVal.Focus();
  153. return;
  154. }
  155. else
  156. {
  157. pc.MinVal = (double)edtMinVal.Value;
  158. pc.MinSign = edtMinSign.Text;
  159. }
  160. }
  161. if (edtup.Checked && edtdown.Checked)
  162. {
  163. double ii = (double)edtMinVal.Value;
  164. double jj = (double)edtmaxVal.Value;
  165. if (ii > jj)
  166. {
  167. MessageBox.Show("上限不能小于下限", "提示");
  168. edtmaxVal.Focus();
  169. return;
  170. }
  171. }
  172. if (string.IsNullOrEmpty(strid))
  173. {
  174. MessageBox.Show("操作失败:ID不能为空", "提示");
  175. edtId.Focus();
  176. return;
  177. }
  178. if (string.IsNullOrEmpty(strstandid))
  179. {
  180. MessageBox.Show("操作失败:标准号为空", "提示");
  181. edtStandId.Focus();
  182. return;
  183. }
  184. if (string.IsNullOrEmpty(strchemCode))
  185. {
  186. MessageBox.Show("操作失败:元素编号为空", "提示");
  187. edtChemCode.Focus();
  188. return;
  189. }
  190. if (edtAddSubtValue.Value == null || edtAddSubtValue.Value.ToString()=="")
  191. {
  192. MessageBox.Show("操作失败:请输入加减额度", "提示");
  193. edtAddSubtValue.Focus();
  194. return;
  195. }
  196. //提示是否需要修改
  197. if (MessageBox.Show("将修改明细表ID为[" + strid + "]的信息?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
  198. {
  199. pc.Id = strid;
  200. pc.StandId=strstandid;
  201. pc.Remark = strremark;
  202. pc.Validflag = "1";
  203. pc.ChemCode = strchemCode;
  204. pc.AddSubtValue = dbaddSubtValue;
  205. pc.UpdateName = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName();
  206. pc.UpdateTime = DateTime.Now;
  207. pc.UpdateUserid = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserID();
  208. //调用服务接口
  209. CoreResult re = this.execute<CoreResult>("com.hnshituo.pur.balance.service.BalanceCicpriceCService", "doUpdateCicpPriceC", new object[] { pc });
  210. if (re.Resultcode == 0)
  211. {
  212. //DataTable tempData = (DataTable)re.Resultdata;
  213. //GridHelper.CopyDataToDatatable(ref re.Resultdata, ref dataTable1, true);
  214. MessageBox.Show("修改成功", "提示");
  215. QureyCicpPriceM();
  216. BalanceClassCommon.doActiveSelRow(ultraGrid1, "id", strstandid);
  217. BalanceClassCommon.doActiveSelRow(ultraGrid2, "id", strid);
  218. }
  219. else
  220. {
  221. MessageBox.Show("操作失败:" + re.Resultmsg, "提示");
  222. return;
  223. }
  224. }
  225. }
  226. else
  227. {
  228. MessageBox.Show("操作失败:请选择需修改的基价标准明细行", "提示");
  229. return;
  230. }
  231. }
  232. catch (Exception ex)
  233. {
  234. MessageBox.Show("操作失败:" + ex.Message, "提示");
  235. }
  236. }
  237. private void AddCicpPriceC()
  238. {
  239. try
  240. {
  241. //判断是否获取到焦点
  242. if (ultraGrid1.ActiveRow != null)
  243. {
  244. string strstandid = ultraGrid1.ActiveRow.Cells["id"].Value.ToString().Trim();
  245. //获取编辑框信息
  246. string strchemCode = edtChemCode.Text.ToString().Trim();
  247. string strchemname=edtChemName.Text.ToString().Trim();
  248. string strremark = edtRemarkC.Text.ToString().Trim();
  249. double dbaddSubtValue = (double)edtAddSubtValue.Value;
  250. //构建实体类
  251. BalanceCicpriceC pc = new BalanceCicpriceC();
  252. //校验编辑框信息
  253. if (edtup.Checked)
  254. {
  255. if (edtmaxVal.Value == null || edtMaxSign.Value==null)
  256. {
  257. MessageBox.Show("上限符号和上限值不能为空","提升");
  258. edtmaxVal.Focus();
  259. return;
  260. }
  261. else
  262. {
  263. pc.MaxVal = (double)edtmaxVal.Value;
  264. pc.MaxSign = edtMaxSign.Text;
  265. }
  266. }
  267. if (edtdown.Checked)
  268. {
  269. if(edtMinVal.Value==null||edtMinSign.Value==null)
  270. {
  271. MessageBox.Show("下限符号和下限值不能为空","提升");
  272. edtMinVal.Focus();
  273. return;
  274. }
  275. else
  276. {
  277. pc.MinVal = (double)edtMinVal.Value;
  278. pc.MinSign = edtMinSign.Text;
  279. }
  280. }
  281. if (edtup.Checked && edtdown.Checked)
  282. {
  283. if ((double)edtMinVal.Value > (double)edtmaxVal.Value)
  284. {
  285. MessageBox.Show("上限不能小于下限", "提示");
  286. edtmaxVal.Focus();
  287. return;
  288. }
  289. }
  290. if (string.IsNullOrEmpty(strstandid))
  291. {
  292. MessageBox.Show("操作失败:标准号为空", "提示");
  293. edtStandId.Focus();
  294. return;
  295. }
  296. if (string.IsNullOrEmpty(strchemCode))
  297. {
  298. MessageBox.Show("操作失败:元素编号为空", "提示");
  299. edtChemCode.Focus();
  300. return;
  301. }
  302. if (edtAddSubtValue.Value == null || edtAddSubtValue.Value.ToString()=="")
  303. {
  304. MessageBox.Show("操作失败:请输入加减额度", "提示");
  305. edtAddSubtValue.Focus();
  306. return;
  307. }
  308. //提示是否需要修改
  309. if (MessageBox.Show("将新增元素为[" + strchemname + "]的一条明细信息?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
  310. {
  311. pc.StandId = strstandid;
  312. pc.Remark = strremark;
  313. pc.Validflag = "1";
  314. pc.ChemCode = strchemCode;
  315. pc.AddSubtValue = dbaddSubtValue;
  316. pc.CreateName = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName();
  317. pc.CreateTime = DateTime.Now;
  318. pc.CreateUserid = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserID();
  319. //调用服务接口
  320. CoreResult re = this.execute<CoreResult>("com.hnshituo.pur.balance.service.BalanceCicpriceCService", "doAddCicpPriceC", new object[] { pc });
  321. if (re.Resultcode == 0)
  322. {
  323. //DataTable tempData = (DataTable)re.Resultdata;
  324. //GridHelper.CopyDataToDatatable(ref re.Resultdata, ref dataTable1, true);
  325. MessageBox.Show("新增成功", "提示");
  326. QureyCicpPriceM();
  327. BalanceClassCommon.doActiveSelRow(ultraGrid1, "id", strstandid);
  328. BalanceClassCommon.doActiveSelRow(ultraGrid2, "chemCode", strchemCode);
  329. }
  330. else
  331. {
  332. MessageBox.Show("操作失败:" + re.Resultmsg, "提示");
  333. return;
  334. }
  335. }
  336. }
  337. else
  338. {
  339. MessageBox.Show("操作失败:请选择需新增的基价标准行", "提示");
  340. return;
  341. }
  342. }
  343. catch (Exception ex)
  344. {
  345. MessageBox.Show("操作失败:" + ex.Message, "提示");
  346. }
  347. }
  348. /// <summary>
  349. /// 删除一条成分计价标准主表行信息
  350. /// </summary>
  351. private void DeleteCicpPriceM()
  352. {
  353. try
  354. {
  355. //判断是否获取到焦点
  356. if (ultraGrid1.ActiveRow != null)
  357. {
  358. string strId = ultraGrid1.ActiveRow.Cells["Id"].Value.ToString().Trim();
  359. string strname = ultraGrid1.ActiveRow.Cells["name"].Value.ToString().Trim();
  360. string stritemcode = ultraGrid1.ActiveRow.Cells["itemCode"].Value.ToString().Trim();
  361. //提示是否需要修改
  362. if (MessageBox.Show("将删除名称为[" + strname + "]的成分计价标准信息?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
  363. {
  364. //构建实体类
  365. BalanceCicpriceM pm = new BalanceCicpriceM();
  366. pm.Validflag = "0";
  367. pm.Id = strId;
  368. pm.ItemCode = stritemcode;
  369. pm.DeleteName = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName();
  370. pm.DeleteTime = DateTime.Now;
  371. pm.DeleteUserid = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserID();
  372. //调用服务接口
  373. CoreResult re = this.execute<CoreResult>("com.hnshituo.pur.balance.service.BalanceCicpriceMService", "doUpdateCicpPriceM", new object[] { pm });
  374. if (re.Resultcode == 0)
  375. {
  376. //DataTable tempData = (DataTable)re.Resultdata;
  377. //GridHelper.CopyDataToDatatable(ref re.Resultdata, ref dataTable1, true);
  378. MessageBox.Show("删除成功", "提示");
  379. QureyCicpPriceM();
  380. }
  381. else
  382. {
  383. MessageBox.Show("操作失败:" + re.Resultmsg, "提示");
  384. return;
  385. }
  386. }
  387. }
  388. else
  389. {
  390. MessageBox.Show("操作失败:请选择需删除的成分计价标准行", "提示");
  391. return;
  392. }
  393. }
  394. catch (Exception ex)
  395. {
  396. MessageBox.Show("操作失败:" + ex.Message, "提示");
  397. }
  398. }
  399. /// <summary>
  400. /// 编辑成分计价标准行信息
  401. /// </summary>
  402. private void EditCicpPriceM()
  403. {
  404. try
  405. {
  406. //判断是否获取到焦点
  407. if (ultraGrid1.ActiveRow != null)
  408. {
  409. string oldstrid = ultraGrid1.ActiveRow.Cells["id"].Value.ToString().Trim();
  410. string oldstrname = ultraGrid1.ActiveRow.Cells["name"].Value.ToString().Trim();
  411. //获取编辑框信息
  412. string strname = edtName.Text.ToString().Trim();
  413. string stritemCode = edtItemCode.Text.ToString().Trim();
  414. string strremark = edtRemark.Text.ToString().Trim();
  415. string stritemattrId = edtItemAttrId.Text.ToString().Trim();
  416. //校验编辑框信息
  417. if (string.IsNullOrEmpty(oldstrid))
  418. {
  419. MessageBox.Show("操作失败:ID不能为空", "提示");
  420. edtId.Focus();
  421. return;
  422. }
  423. if (string.IsNullOrEmpty(strname))
  424. {
  425. MessageBox.Show("操作失败:名称不能为空", "提示");
  426. edtName.Focus();
  427. return;
  428. }
  429. if (string.IsNullOrEmpty(stritemCode))
  430. {
  431. MessageBox.Show("操作失败:请选择物料", "提示");
  432. edtItemCode.Focus();
  433. return;
  434. }
  435. //提示是否需要修改
  436. if (MessageBox.Show("将修改名称为[" + oldstrname + "]的成分计价标准信息?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
  437. {
  438. //构建实体类
  439. BalanceCicpriceM pm = new BalanceCicpriceM();
  440. pm.Id = oldstrid;
  441. pm.Name = strname;
  442. pm.ItemCode = stritemCode;
  443. pm.ItemAttrId = stritemattrId;
  444. pm.Remark = strremark;
  445. pm.Validflag = "1";
  446. pm.UpdateName = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName();
  447. pm.UpdateTime = DateTime.Now;
  448. pm.UpdateUserid = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserID();
  449. //调用服务接口
  450. CoreResult re = this.execute<CoreResult>("com.hnshituo.pur.balance.service.BalanceCicpriceMService", "doUpdateCicpPriceM", new object[] { pm });
  451. if (re.Resultcode == 0)
  452. {
  453. //DataTable tempData = (DataTable)re.Resultdata;
  454. //GridHelper.CopyDataToDatatable(ref re.Resultdata, ref dataTable1, true);
  455. MessageBox.Show("修改成功", "提示");
  456. QureyCicpPriceM();
  457. BalanceClassCommon.doActiveSelRow(ultraGrid1, "id", oldstrid);
  458. }
  459. else
  460. {
  461. MessageBox.Show("操作失败:" + re.Resultmsg, "提示");
  462. return;
  463. }
  464. }
  465. }
  466. else
  467. {
  468. MessageBox.Show("操作失败:请选择需修改的成分计价标准行", "提示");
  469. return;
  470. }
  471. }
  472. catch (Exception ex)
  473. {
  474. MessageBox.Show("操作失败" + ex.Message, "提示");
  475. }
  476. }
  477. /// <summary>
  478. /// 新增一条基价标准主表行信息
  479. /// </summary>
  480. private void AddCicpPriceM()
  481. {
  482. try
  483. {
  484. //获取编辑框信息
  485. string strname = edtName.Text.ToString().Trim();
  486. string stritemCode = edtItemCode.Text.ToString().Trim();
  487. string strremark = edtRemark.Text.ToString().Trim();
  488. string stritemattrId = edtItemAttrId.Text.ToString().Trim();
  489. //校验编辑框信息
  490. if (string.IsNullOrEmpty(strname))
  491. {
  492. MessageBox.Show("操作失败:名称不能为空", "提示");
  493. edtName.Focus();
  494. return;
  495. }
  496. if (string.IsNullOrEmpty(stritemCode))
  497. {
  498. MessageBox.Show("操作失败:请选择物料", "提示");
  499. edtItemCode.Focus();
  500. return;
  501. }
  502. //构建实体类
  503. BalanceCicpriceM pm = new BalanceCicpriceM();
  504. pm.Name = strname;
  505. pm.ItemCode = stritemCode;
  506. pm.ItemAttrId=stritemattrId;
  507. pm.Remark = strremark;
  508. pm.Validflag = "1";
  509. pm.CreateName = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName();
  510. pm.CreateTime = DateTime.Now;
  511. pm.CreateUserid = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserID();
  512. //调用服务接口
  513. CoreResult re = this.execute<CoreResult>("com.hnshituo.pur.balance.service.BalanceCicpriceMService", "doAddCicpPriceM", new object[] { pm });
  514. if (re.Resultcode == 0)
  515. {
  516. //DataTable tempData = (DataTable)re.Resultdata;
  517. //GridHelper.CopyDataToDatatable(ref re.Resultdata, ref dataTable1, true);
  518. MessageBox.Show("新增成功", "提示");
  519. QureyCicpPriceM();
  520. BalanceClassCommon.doActiveSelRow(ultraGrid1, "name", strname);
  521. }
  522. else
  523. {
  524. MessageBox.Show("操作失败:" + re.Resultmsg, "提示");
  525. return;
  526. }
  527. }
  528. catch (Exception ex)
  529. {
  530. MessageBox.Show("操作失败:" + ex.Message, "提示");
  531. }
  532. }
  533. /// <summary>
  534. /// 查询主表数据
  535. /// </summary>
  536. private void QureyCicpPriceM()
  537. {
  538. try
  539. {
  540. //获取查询框数据
  541. string strid = QId.Text.ToString().Trim();
  542. string strname = Qname.Text.ToString().Trim();
  543. //构建查询实体类
  544. BalanceCicpriceM pm = new BalanceCicpriceM();
  545. pm.Id = strid;
  546. pm.ItemName = strname;
  547. //调用服务器查询API进行查询
  548. DataTable re = this.execute<DataTable>("com.hnshituo.pur.balance.service.BalanceCicpriceMService", "doQureyCicpPriceM", new object[] { pm });
  549. GridHelper.CopyDataToDatatable(ref re, ref dataTable1, true);
  550. }
  551. catch (Exception ex)
  552. {
  553. MessageBox.Show("操作失败:" + ex.Message, "提示");
  554. }
  555. }
  556. #endregion
  557. #region 页面点击事件
  558. private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
  559. {
  560. try
  561. {
  562. //加载数据到编辑区
  563. string strid = ultraGrid1.ActiveRow.Cells["id"].Value.ToString().Trim();
  564. string strname = ultraGrid1.ActiveRow.Cells["name"].Value.ToString().Trim();
  565. string stritemCode = ultraGrid1.ActiveRow.Cells["itemCode"].Value.ToString().Trim();
  566. string stritemName = ultraGrid1.ActiveRow.Cells["itemName"].Value.ToString().Trim();
  567. string strremark = ultraGrid1.ActiveRow.Cells["remark"].Value.ToString().Trim();
  568. string stritemAttr = ultraGrid1.ActiveRow.Cells["itemAttr"].Value.ToString().Trim();
  569. string stritemAttrId = ultraGrid1.ActiveRow.Cells["itemAttrId"].Value.ToString().Trim();
  570. edtId.Text = strid;
  571. edtName.Text = strname;
  572. edtItemCode.Text = stritemCode;
  573. edtItemName.Text = stritemName;
  574. edtRemark.Text = strremark;
  575. edtItemAttr.Text = stritemAttr;
  576. edtItemAttrId.Text = stritemAttrId;
  577. //获取页面点击行的ID
  578. if (string.IsNullOrEmpty(strid))
  579. {
  580. MessageBox.Show("操作失败:获取的ID为空", "提示");
  581. }
  582. //构建实体类
  583. BalanceCicpriceC pc = new BalanceCicpriceC();
  584. pc.StandId = strid;
  585. pc.Validflag = "1";
  586. //调用服务器查询API进行查询
  587. DataTable re = this.execute<DataTable>("com.hnshituo.pur.balance.service.BalanceCicpriceCService", "doQureyCicpPriceC", new object[] { pc });
  588. GridHelper.CopyDataToDatatable(ref re, ref dataTable2, true);
  589. }
  590. catch (Exception ex)
  591. {
  592. MessageBox.Show("操作失败:" + ex.Message, "提示");
  593. }
  594. }
  595. private void ultraGrid2_AfterRowActivate(object sender, EventArgs e)
  596. {
  597. try
  598. {
  599. //加载数据到编辑区
  600. string strid = ultraGrid2.ActiveRow.Cells["id"].Value.ToString().Trim();
  601. string strremark = ultraGrid2.ActiveRow.Cells["remark"].Value.ToString().Trim();
  602. string strstandId = ultraGrid2.ActiveRow.Cells["standId"].Value.ToString().Trim();
  603. string strmaxsign = ultraGrid2.ActiveRow.Cells["maxSign"].Value.ToString().Trim();
  604. string strminsign = ultraGrid2.ActiveRow.Cells["minSign"].Value.ToString().Trim();
  605. if (ultraGrid2.ActiveRow.Cells["minVal"].Value == null)
  606. {
  607. edtMinVal.Value = null;
  608. }
  609. else
  610. {
  611. edtMinVal.Value =ultraGrid2.ActiveRow.Cells["minVal"].Value;
  612. }
  613. if(ultraGrid2.ActiveRow.Cells["maxVal"].Value == null)
  614. {
  615. edtmaxVal.Value = null;
  616. }
  617. else
  618. {
  619. edtmaxVal.Value = ultraGrid2.ActiveRow.Cells["maxVal"].Value;
  620. }
  621. if(ultraGrid2.ActiveRow.Cells["addSubtValue"].Value!=null)
  622. {
  623. edtAddSubtValue.Value=ultraGrid2.ActiveRow.Cells["addSubtValue"].Value;
  624. }
  625. else{
  626. MessageBox.Show("数据异常:明细表ID为"+strid+"的加减额度为空","提示");
  627. return;
  628. }
  629. string strchemCode = ultraGrid2.ActiveRow.Cells["chemCode"].Value.ToString().Trim();
  630. string strchemName = ultraGrid2.ActiveRow.Cells["chemName"].Value.ToString().Trim();
  631. edtIdC.Text = strid;
  632. edtRemarkC.Text = strremark;
  633. edtStandId.Text = strstandId;
  634. edtMaxSign.Text = strmaxsign;
  635. edtMinSign.Text = strminsign;
  636. edtChemCode.Text = strchemCode;
  637. edtChemName.Text = strchemName;
  638. //上限和下限是否可以判断
  639. if (strmaxsign == "" || strmaxsign == null)
  640. {
  641. edtup.Checked = false;
  642. }
  643. else
  644. {
  645. edtup.Checked = true;
  646. }
  647. if (strminsign == "" || strminsign == null)
  648. {
  649. edtdown.Checked = false;
  650. }
  651. else
  652. {
  653. edtdown.Checked = true;
  654. }
  655. }
  656. catch (Exception ex)
  657. {
  658. MessageBox.Show("操作失败:" + ex.Message, "提示");
  659. }
  660. }
  661. private void clearEdtArea()
  662. {
  663. foreach (Control ctr in ultraExpandableGroupBox1.Controls)
  664. {
  665. if (ctr is Label)
  666. { continue; }
  667. if (ctr is UltraCheckEditor)
  668. {
  669. UltraCheckEditor ultcmb = (UltraCheckEditor)ctr;
  670. ultcmb.Checked = false;
  671. }
  672. if (ctr is UltraComboEditor)
  673. {
  674. UltraComboEditor ultcmb = (UltraComboEditor)ctr;
  675. ultcmb.Text = "";
  676. ultcmb.Enabled = false;
  677. }
  678. if (ctr is CheckBox)
  679. {
  680. CheckBox cb = (CheckBox)ctr;
  681. cb.Checked = false;
  682. }
  683. ctr.Text = null;
  684. edtmaxVal.Enabled = false;
  685. edtMaxSign.Enabled = false;
  686. edtmaxVal.Value = null;
  687. edtMaxSign.Text = "";
  688. edtMinVal.Enabled = false;
  689. edtMinSign.Enabled = false;
  690. edtMinVal.Value = null;
  691. edtMinSign.Text = "";
  692. }
  693. }
  694. private void edtup_CheckedChanged(object sender, EventArgs e)
  695. {
  696. if (edtup.Checked)
  697. {
  698. edtmaxVal.Enabled = true;
  699. edtMaxSign.Enabled = true;
  700. }
  701. else
  702. {
  703. edtmaxVal.Enabled = false;
  704. edtMaxSign.Enabled = false;
  705. edtmaxVal.Value = null;
  706. edtMaxSign.Text = "";
  707. }
  708. }
  709. private void edtdown_CheckedChanged(object sender, EventArgs e)
  710. {
  711. if (edtdown.Checked)
  712. {
  713. edtMinVal.Enabled = true;
  714. edtMinSign.Enabled = true;
  715. }
  716. else
  717. {
  718. edtMinVal.Enabled = false;
  719. edtMinSign.Enabled = false;
  720. edtMinVal.Value = null;
  721. edtMinSign.Text = "";
  722. }
  723. }
  724. private void edtItemName_EditorButtonClick(object sender, EditorButtonEventArgs e)
  725. {
  726. FrmPurPlanMat matfrm = new FrmPurPlanMat(this.ob);
  727. matfrm.ShowDialog();
  728. string strmatcode = matfrm.getItemCode();
  729. string strmatname = matfrm.getItemName();
  730. string stritemAttr = matfrm.ItemAttr;
  731. string stritemAttrId = matfrm.ItemAttrId;
  732. edtItemCode.Text = strmatcode;
  733. edtItemName.Text = strmatname;
  734. edtItemAttr.Text = stritemAttr;
  735. edtItemAttrId.Text = stritemAttrId;
  736. }
  737. private void edtChemName_EditorButtonClick(object sender, EditorButtonEventArgs e)
  738. {
  739. FrmPop_upChem chemfrm = new FrmPop_upChem(this.ob);
  740. chemfrm.ShowDialog();
  741. string strchemcode = chemfrm.ChemCode;
  742. string strchemname = chemfrm.ChemName;
  743. edtChemCode.Text = strchemcode;
  744. edtChemName.Text = strchemname;
  745. }
  746. private void ultraGrid1_AfterCellActivate(object sender, EventArgs e)
  747. {
  748. ultraTabControl1.SelectedTab = ultraTabControl1.Tabs[0];
  749. }
  750. private void ultraGrid2_AfterCellActivate(object sender, EventArgs e)
  751. {
  752. ultraTabControl1.SelectedTab = ultraTabControl1.Tabs[1];
  753. }
  754. #endregion
  755. }
  756. }