frmBaseMaterialPl.cs 47 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099
  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 CoreFS.CA06;
  10. using Core.Mes.Client.Comm.Tool;
  11. using System.Collections;
  12. using Infragistics.Win.UltraWinGrid;
  13. using Core.Mes.Client.Comm.Format;
  14. using Core.Mes.Client.Comm.Server;
  15. using Core.Mes.Client.Comm.Control;
  16. using Core.StlMes.Client.Qcm;
  17. namespace Core.StlMes.Client.SaleOrder.ReviewForm
  18. {
  19. public partial class frmBaseMaterialPl : FrmBase
  20. {
  21. private DataSourceList<SlmBaseMaterialEntity> _materialEntityList = new DataSourceList<SlmBaseMaterialEntity>();
  22. private DataSourceList<SlmBaseMaterialAPlEntity> _materialAPlEntityList = new DataSourceList<SlmBaseMaterialAPlEntity>();
  23. private DataSourceList<SlmBaseMaterialBPlEntity> _materialBPlEntityList = new DataSourceList<SlmBaseMaterialBPlEntity>();
  24. private DataSourceList<SlmBaseMaterialCPlEntity> _materialCPlEntityList = new DataSourceList<SlmBaseMaterialCPlEntity>();
  25. private DataSourceList<SlmBaseMaterialDPlEntity> _materialDPlEntityList = new DataSourceList<SlmBaseMaterialDPlEntity>();
  26. private DataSourceList<SlmBaseMaterialEPlEntity> _materialEPlEntityList = new DataSourceList<SlmBaseMaterialEPlEntity>();
  27. private DataSourceList<SlmBaseMaterialFPlEntity> _materialFPlEntityList = new DataSourceList<SlmBaseMaterialFPlEntity>();
  28. private DataSourceList<SlmBaseMaterialJPlEntity> _materialJPlEntityList = new DataSourceList<SlmBaseMaterialJPlEntity>();
  29. private DataSourceList<SlmBaseMaterialIPlEntity> _materialIPlEntityList = new DataSourceList<SlmBaseMaterialIPlEntity>();
  30. Boolean flag = false;
  31. private string[] _plines = new string[0];
  32. public frmBaseMaterialPl()
  33. {
  34. InitializeComponent();
  35. this.IsLoadUserView = true;
  36. }
  37. private void frmBaseMaterialPl_Load(object sender, EventArgs e)
  38. {
  39. EntityHelper.ShowGridCaption<SlmBaseMaterialAPlEntity>(ultraGrid1.DisplayLayout.Bands[0]);
  40. EntityHelper.ShowGridCaption<SlmBaseMaterialBPlEntity>(ultraGrid2.DisplayLayout.Bands[0]);
  41. EntityHelper.ShowGridCaption<SlmBaseMaterialCPlEntity>(ultraGrid3.DisplayLayout.Bands[0]);
  42. EntityHelper.ShowGridCaption<SlmBaseMaterialDPlEntity>(ultraGrid4.DisplayLayout.Bands[0]);
  43. EntityHelper.ShowGridCaption<SlmBaseMaterialEPlEntity>(ultraGrid5.DisplayLayout.Bands[0]);
  44. EntityHelper.ShowGridCaption<SlmBaseMaterialFPlEntity>(ultraGrid6.DisplayLayout.Bands[0]);
  45. EntityHelper.ShowGridCaption<SlmBaseMaterialJPlEntity>(ultraGrid7.DisplayLayout.Bands[0]);
  46. EntityHelper.ShowGridCaption<SlmBaseMaterialIPlEntity>(ultraGrid8.DisplayLayout.Bands[0]);
  47. EntityHelper.ShowGridCaption<SlmBaseMaterialEntity>(ultraGrid9.DisplayLayout.Bands[0]);
  48. GetPagePermission();
  49. _plines = getPlinePermission();
  50. flag = true;
  51. }
  52. private void QueryMaterial()
  53. {
  54. try
  55. {
  56. this.Cursor = Cursors.WaitCursor;
  57. if (IsExitEdit())
  58. {
  59. if (ultraTabControl1.ActiveTab.Key == "1")
  60. {
  61. QueryMaterialAPl();
  62. }
  63. else if (ultraTabControl1.ActiveTab.Key == "2")
  64. {
  65. QueryMaterialBPl();
  66. }
  67. else if (ultraTabControl1.ActiveTab.Key == "3")
  68. {
  69. QueryMaterialCPl();
  70. }
  71. else if (ultraTabControl1.ActiveTab.Key == "4")
  72. {
  73. QueryMaterialDPl();
  74. }
  75. else if (ultraTabControl1.ActiveTab.Key == "5")
  76. {
  77. QueryMaterialEPl();
  78. }
  79. else if (ultraTabControl1.ActiveTab.Key == "6")
  80. {
  81. QueryMaterialFPl();
  82. }
  83. else if (ultraTabControl1.ActiveTab.Key == "7")
  84. {
  85. QueryMaterialHPl();
  86. }
  87. else if (ultraTabControl1.ActiveTab.Key == "8")
  88. {
  89. QueryMaterialIPl();
  90. }
  91. else if (ultraTabControl1.ActiveTab.Key == "9")
  92. {
  93. QueryBaseMaterial();
  94. }
  95. }
  96. }
  97. finally
  98. {
  99. this.Cursor = Cursors.Default;
  100. }
  101. }
  102. /// <summary>
  103. /// 查询基础物料编码
  104. /// </summary>
  105. private void QueryBaseMaterial()
  106. {
  107. _materialEntityList = EntityHelper.GetData<SlmBaseMaterialEntity>(
  108. "com.steering.pss.sale.order.CoreBaseMaterialPl.getBaseMaterial", new object[] { }, ob);
  109. _materialEntityList.AcceptChanges();
  110. slmBaseMaterialEntityBindingSource.DataSource = _materialEntityList;
  111. }
  112. /// <summary>
  113. /// 通过主键查询基础物料码
  114. /// </summary>
  115. /// <returns></returns>
  116. private DataRow QueryBaseMaterialByPk(string materialNo)
  117. {
  118. DataTable dt = ServerHelper.GetData("com.steering.pss.sale.order.CoreBaseMaterialPl.getBaseMaterialByPk",
  119. new object[] { materialNo }, ob);
  120. if (dt.Rows.Count > 0)
  121. {
  122. return dt.Rows[0];
  123. }
  124. else
  125. {
  126. return null;
  127. }
  128. }
  129. /// <summary>
  130. /// 查询电炉
  131. /// </summary>
  132. private void QueryMaterialAPl()
  133. {
  134. _materialAPlEntityList = EntityHelper.GetData<SlmBaseMaterialAPlEntity>(
  135. "com.steering.pss.sale.order.CoreBaseMaterialPl.getBaseMaterialAPl", new object[] { _plines }, ob);
  136. _materialAPlEntityList.AcceptChanges();
  137. slmBaseMaterialAPlEntityBindingSource.DataSource = _materialAPlEntityList;
  138. }
  139. /// <summary>
  140. /// 查询铸造
  141. /// </summary>
  142. private void QueryMaterialBPl()
  143. {
  144. _materialBPlEntityList = EntityHelper.GetData<SlmBaseMaterialBPlEntity>(
  145. "com.steering.pss.sale.order.CoreBaseMaterialPl.getBaseMaterialBPl", new object[] { _plines }, ob);
  146. _materialBPlEntityList.AcceptChanges();
  147. slmBaseMaterialBPlEntityBindingSource.DataSource = _materialBPlEntityList;
  148. }
  149. /// <summary>
  150. /// 查询锻造
  151. /// </summary>
  152. private void QueryMaterialCPl()
  153. {
  154. _materialCPlEntityList = EntityHelper.GetData<SlmBaseMaterialCPlEntity>(
  155. "com.steering.pss.sale.order.CoreBaseMaterialPl.getBaseMaterialCPl", new object[] { _plines }, ob);
  156. _materialCPlEntityList.AcceptChanges();
  157. slmBaseMaterialCPlEntityBindingSource.DataSource = _materialCPlEntityList;
  158. }
  159. /// <summary>
  160. /// 查询轧制
  161. /// </summary>
  162. private void QueryMaterialDPl()
  163. {
  164. _materialDPlEntityList = EntityHelper.GetData<SlmBaseMaterialDPlEntity>(
  165. "com.steering.pss.sale.order.CoreBaseMaterialPl.getBaseMaterialDPl", new object[] { _plines }, ob);
  166. _materialDPlEntityList.AcceptChanges();
  167. slmBaseMaterialDPlEntityBindingSource.DataSource = _materialDPlEntityList;
  168. }
  169. /// <summary>
  170. /// 查询墩拔扩
  171. /// </summary>
  172. private void QueryMaterialEPl()
  173. {
  174. _materialEPlEntityList = EntityHelper.GetData<SlmBaseMaterialEPlEntity>(
  175. "com.steering.pss.sale.order.CoreBaseMaterialPl.getBaseMaterialEPl", new object[] { _plines }, ob);
  176. _materialEPlEntityList.AcceptChanges();
  177. slmBaseMaterialEPlEntityBindingSource.DataSource = _materialEPlEntityList;
  178. }
  179. /// <summary>
  180. /// 查询热处理
  181. /// </summary>
  182. private void QueryMaterialFPl()
  183. {
  184. _materialFPlEntityList = EntityHelper.GetData<SlmBaseMaterialFPlEntity>(
  185. "com.steering.pss.sale.order.CoreBaseMaterialPl.getBaseMaterialFPl", new object[] { _plines }, ob);
  186. _materialFPlEntityList.AcceptChanges();
  187. slmBaseMaterialFPlEntityBindingSource.DataSource = _materialFPlEntityList;
  188. }
  189. /// <summary>
  190. /// 查询接箍
  191. /// </summary>
  192. private void QueryMaterialHPl()
  193. {
  194. _materialJPlEntityList = EntityHelper.GetData<SlmBaseMaterialJPlEntity>(
  195. "com.steering.pss.sale.order.CoreBaseMaterialPl.getBaseMaterialHPl", new object[] { _plines }, ob);
  196. _materialJPlEntityList.AcceptChanges();
  197. slmBaseMaterialJPlEntityBindingSource.DataSource = _materialJPlEntityList;
  198. }
  199. /// <summary>
  200. /// 查询加工
  201. /// </summary>
  202. private void QueryMaterialIPl()
  203. {
  204. _materialIPlEntityList = EntityHelper.GetData<SlmBaseMaterialIPlEntity>(
  205. "com.steering.pss.sale.order.CoreBaseMaterialPl.getBaseMaterialIPl", new object[] { _plines }, ob);
  206. _materialIPlEntityList.AcceptChanges();
  207. slmBaseMaterialIPlEntityBindingSource.DataSource = _materialIPlEntityList;
  208. }
  209. public override void ToolBar_Click(object sender, string ToolbarKey)
  210. {
  211. base.ToolBar_Click(sender, ToolbarKey);
  212. switch (ToolbarKey)
  213. {
  214. case "doQuery":
  215. QueryMaterial();
  216. break;
  217. case "doUpdate":
  218. UpdateMaterialAPl();
  219. break;
  220. case "doDelete":
  221. DeleteMaterialAPl();
  222. break;
  223. case "Export":
  224. DoExport();
  225. break;
  226. case "doClose":
  227. this.Close();
  228. break;
  229. }
  230. }
  231. private void DoExport()
  232. {
  233. if (ultraTabControl1.ActiveTab.Key == "1")
  234. {
  235. GridHelper.ulGridToExcel(ultraGrid1, "电炉产线能力");
  236. }
  237. else if (ultraTabControl1.ActiveTab.Key == "2")
  238. {
  239. GridHelper.ulGridToExcel(ultraGrid2, "铸造产线能力");
  240. }
  241. else if (ultraTabControl1.ActiveTab.Key == "3")
  242. {
  243. GridHelper.ulGridToExcel(ultraGrid3, "锻造产线能力");
  244. }
  245. else if (ultraTabControl1.ActiveTab.Key == "4")
  246. {
  247. GridHelper.ulGridToExcel(ultraGrid4, "轧制产线能力");
  248. }
  249. else if (ultraTabControl1.ActiveTab.Key == "5")
  250. {
  251. GridHelper.ulGridToExcel(ultraGrid5, "镦拔扩产线能力");
  252. }
  253. else if (ultraTabControl1.ActiveTab.Key == "6")
  254. {
  255. GridHelper.ulGridToExcel(ultraGrid6, "热处理产线能力");
  256. }
  257. else if (ultraTabControl1.ActiveTab.Key == "7")
  258. {
  259. GridHelper.ulGridToExcel(ultraGrid7, "接箍加工产线能力");
  260. }
  261. else if (ultraTabControl1.ActiveTab.Key == "8")
  262. {
  263. GridHelper.ulGridToExcel(ultraGrid8, "加工产线能力");
  264. }
  265. else if (ultraTabControl1.ActiveTab.Key == "9")
  266. {
  267. GridHelper.ulGridToExcel(ultraGrid9, "产成品物料");
  268. }
  269. }
  270. /// <summary>
  271. /// 修改电炉产线能力
  272. /// </summary>
  273. private void UpdateMaterialAPl()
  274. {
  275. ultraGrid1.UpdateData();
  276. ultraGrid2.UpdateData();
  277. ultraGrid3.UpdateData();
  278. ultraGrid4.UpdateData();
  279. ultraGrid5.UpdateData();
  280. ultraGrid6.UpdateData();
  281. ultraGrid7.UpdateData();
  282. ultraGrid8.UpdateData();
  283. ultraGrid9.UpdateData();
  284. var ultraGrid9Rows = ultraGrid9.Rows.Where(a=>a.GetValue("Chk") == "True");
  285. IQueryable<UltraGridRow> ultraGrid1ChkRows = ultraGrid1.Rows.AsQueryable().Where("CHK = 'True'");
  286. IQueryable<UltraGridRow> ultraGrid2ChkRows = ultraGrid2.Rows.AsQueryable().Where("CHK = 'True'");
  287. IQueryable<UltraGridRow> ultraGrid3ChkRows = ultraGrid3.Rows.AsQueryable().Where("CHK = 'True'");
  288. IQueryable<UltraGridRow> ultraGrid4ChkRows = ultraGrid4.Rows.AsQueryable().Where("CHK = 'True'");
  289. IQueryable<UltraGridRow> ultraGrid5ChkRows = ultraGrid5.Rows.AsQueryable().Where("CHK = 'True'");
  290. IQueryable<UltraGridRow> ultraGrid6ChkRows = ultraGrid6.Rows.AsQueryable().Where("CHK = 'True'");
  291. IQueryable<UltraGridRow> ultraGrid7ChkRows = ultraGrid7.Rows.AsQueryable().Where("CHK = 'True'");
  292. IQueryable<UltraGridRow> ultraGrid8ChkRows = ultraGrid8.Rows.AsQueryable().Where("CHK = 'True'");
  293. int chkCnt = ultraGrid1ChkRows.Count() + ultraGrid2ChkRows.Count() + ultraGrid3ChkRows.Count()
  294. + ultraGrid4ChkRows.Count() + ultraGrid5ChkRows.Count() + ultraGrid6ChkRows.Count()
  295. + ultraGrid7ChkRows.Count() + ultraGrid8ChkRows.Count() + ultraGrid9Rows.Count();
  296. if (chkCnt == 0)
  297. {
  298. MessageUtil.ShowWarning("请选择记录");
  299. return;
  300. }
  301. ArrayList list = new ArrayList();
  302. ArrayList list1 = new ArrayList();
  303. ArrayList list2 = new ArrayList();
  304. ArrayList list3 = new ArrayList();
  305. ArrayList list4 = new ArrayList();
  306. ArrayList list5 = new ArrayList();
  307. ArrayList list6 = new ArrayList();
  308. ArrayList list7 = new ArrayList();
  309. ArrayList list8 = new ArrayList();
  310. ArrayList list9 = new ArrayList();
  311. string msg = "";
  312. string fieldName = "";
  313. foreach (UltraGridRow ugr in ultraGrid1ChkRows)
  314. {
  315. SlmBaseMaterialAPlEntity baseMaterialAPl = EntityHelper.CopyEntity<SlmBaseMaterialAPlEntity>(ugr.ListObject);
  316. baseMaterialAPl.UpdateName = UserInfo.GetUserName();
  317. if (EntityHelper.CheckEntity(baseMaterialAPl, out msg, out fieldName) == false)
  318. {
  319. MessageUtil.ShowWarning(msg);
  320. return;
  321. }
  322. string strJSON = JSONFormat.Format(baseMaterialAPl);
  323. list1.Add(strJSON);
  324. }
  325. foreach (UltraGridRow ugr in ultraGrid2ChkRows)
  326. {
  327. SlmBaseMaterialBPlEntity baseMaterialBPl = EntityHelper.CopyEntity<SlmBaseMaterialBPlEntity>(ugr.ListObject);
  328. baseMaterialBPl.UpdateName = UserInfo.GetUserName();
  329. string strJSON = JSONFormat.Format(baseMaterialBPl);
  330. list2.Add(strJSON);
  331. }
  332. foreach (UltraGridRow ugr in ultraGrid3ChkRows)
  333. {
  334. SlmBaseMaterialCPlEntity baseMaterialCPl = EntityHelper.CopyEntity<SlmBaseMaterialCPlEntity>(ugr.ListObject);
  335. baseMaterialCPl.UpdateName = UserInfo.GetUserName();
  336. string strJSON = JSONFormat.Format(baseMaterialCPl);
  337. list3.Add(strJSON);
  338. }
  339. IQueryable<SlmBaseMaterialDPlEntity> querableMaterialD = ultraGrid4ChkRows.Select(a => (SlmBaseMaterialDPlEntity)a.ListObject);
  340. if (CheckMaterialDIsSame(querableMaterialD, out msg))
  341. {
  342. MessageUtil.ShowWarning(msg);
  343. return;
  344. }
  345. foreach (UltraGridRow ugr in ultraGrid4ChkRows)
  346. {
  347. SlmBaseMaterialDPlEntity baseMaterialDPl = EntityHelper.CopyEntity<SlmBaseMaterialDPlEntity>(ugr.ListObject);
  348. baseMaterialDPl.UpdateName = this.UserInfo.GetUserName();
  349. string strJSON = JSONFormat.Format(baseMaterialDPl);
  350. list4.Add(strJSON);
  351. }
  352. foreach (UltraGridRow ugr in ultraGrid4ChkRows)
  353. {
  354. SlmBaseMaterialDPlEntity baseMaterialDPl = EntityHelper.CopyEntity<SlmBaseMaterialDPlEntity>(ugr.ListObject);
  355. if (CheckMaterialD(baseMaterialDPl, list4, out msg))
  356. {
  357. MessageUtil.ShowWarning(msg);
  358. return;
  359. }
  360. }
  361. //if (CheckMaterialD(list4, out msg))
  362. //{
  363. // MessageUtil.ShowWarning(msg);
  364. // return;
  365. //}
  366. foreach (UltraGridRow ugr in ultraGrid5ChkRows)
  367. {
  368. SlmBaseMaterialEPlEntity baseMaterialEPl = EntityHelper.CopyEntity<SlmBaseMaterialEPlEntity>(ugr.ListObject);
  369. baseMaterialEPl.UpdateName = this.UserInfo.GetUserName();
  370. string strJSON = JSONFormat.Format(baseMaterialEPl);
  371. list5.Add(strJSON);
  372. }
  373. foreach (UltraGridRow ugr in ultraGrid6ChkRows)
  374. {
  375. SlmBaseMaterialFPlEntity baseMaterialFPl = EntityHelper.CopyEntity<SlmBaseMaterialFPlEntity>(ugr.ListObject);
  376. baseMaterialFPl.UpdateName = this.UserInfo.GetUserName();
  377. string strJSON = JSONFormat.Format(baseMaterialFPl);
  378. list6.Add(strJSON);
  379. }
  380. foreach (UltraGridRow ugr in ultraGrid7ChkRows)
  381. {
  382. SlmBaseMaterialJPlEntity baseMaterialJPl = EntityHelper.CopyEntity<SlmBaseMaterialJPlEntity>(ugr.ListObject);
  383. baseMaterialJPl.UpdateName = this.UserInfo.GetUserName();
  384. string strJSON = JSONFormat.Format(baseMaterialJPl);
  385. list7.Add(strJSON);
  386. }
  387. foreach (UltraGridRow ugr in ultraGrid8ChkRows)
  388. {
  389. SlmBaseMaterialIPlEntity baseMaterialIPl = EntityHelper.CopyEntity<SlmBaseMaterialIPlEntity>(ugr.ListObject);
  390. baseMaterialIPl.UpdateName = this.UserInfo.GetUserName();
  391. string strJSON = JSONFormat.Format(baseMaterialIPl);
  392. list8.Add(strJSON);
  393. }
  394. foreach (var row in ultraGrid9Rows)
  395. {
  396. SlmBaseMaterialEntity baseMaterial = EntityHelper.CopyEntity<SlmBaseMaterialEntity>(row.ListObject);
  397. DataRow rowBaseMaterial = QueryBaseMaterialByPk(baseMaterial.MaterialNo.ToString());
  398. if (rowBaseMaterial != null && rowBaseMaterial["FIRST_PRDC"].ToString() == "1")
  399. {
  400. if (baseMaterial.AutoCraft == "True")
  401. {
  402. MessageUtil.ShowWarning("该物料为首次生产,不能设置自动生成工艺文件!");
  403. row.SetCellActive("AutoCraft");
  404. return;
  405. }
  406. }
  407. baseMaterial.UpdateName = this.UserInfo.GetUserName();
  408. string strJSON = JSONFormat.Format(baseMaterial);
  409. list9.Add(strJSON);
  410. }
  411. list.Add(list1);
  412. list.Add(list2);
  413. list.Add(list3);
  414. list.Add(list4);
  415. list.Add(list5);
  416. list.Add(list6);
  417. list.Add(list7);
  418. list.Add(list8);
  419. list.Add(list9);
  420. if (MessageUtil.ShowYesNoAndQuestion("是否修改?") == DialogResult.No)
  421. {
  422. return;
  423. }
  424. ServerHelper.SetData("com.steering.pss.sale.order.CoreBaseMaterialPl.updateBaseMaterial", new object[] { list}, ob);
  425. _materialAPlEntityList.AcceptChanges();
  426. _materialBPlEntityList.AcceptChanges();
  427. _materialCPlEntityList.AcceptChanges();
  428. _materialDPlEntityList.AcceptChanges();
  429. _materialEPlEntityList.AcceptChanges();
  430. _materialFPlEntityList.AcceptChanges();
  431. _materialIPlEntityList.AcceptChanges();
  432. _materialJPlEntityList.AcceptChanges();
  433. _materialEntityList.AcceptChanges();
  434. MessageUtil.ShowTips("修改成功!");
  435. //QueryMaterialAPl();
  436. }
  437. private bool CheckMaterialDIsSame(IQueryable<SlmBaseMaterialDPlEntity> querableMaterialD, out string msg)
  438. {
  439. msg = "";
  440. var varList = querableMaterialD.GroupBy(a =>
  441. new
  442. {
  443. a.OutMaterialNo, a.InMaterialNo
  444. });
  445. foreach (var var in varList)
  446. {
  447. IQueryable<SlmBaseMaterialDPlEntity> groupList = querableMaterialD.Where(
  448. a => a.InMaterialNo == var.Key.InMaterialNo && a.OutMaterialNo == var.Key.OutMaterialNo);
  449. int cnt = groupList.Select(a => a.PlineLevel).Distinct().Count();
  450. if (cnt != groupList.Count())
  451. {
  452. msg = "保存的数据中优先级存在重复项!\r\n投入物料[" + groupList.First().InMaterialDesc + "]-产出物料["
  453. + groupList.First().OutMaterialDesc +"]";
  454. return true;
  455. }
  456. }
  457. return false;
  458. }
  459. private bool CheckMaterialD(SlmBaseMaterialDPlEntity baseMaterialDPl, ArrayList list, out string msg)
  460. {
  461. msg = "";
  462. DataTable dt = ServerHelper.GetData("com.steering.pss.sale.order.CoreBaseMaterialPl.queryMaterialDLvCnt",
  463. new object[] { JSONFormat.Format(baseMaterialDPl), list }, ob);
  464. if (dt.Rows.Count > 0)
  465. {
  466. msg = "系统中存在相同的优先级[" + dt.Rows[0]["PLINE_LEVEL"] + "]\r\n投入物料["
  467. + baseMaterialDPl.InMaterialDesc + "]-产出物料["+ baseMaterialDPl.OutMaterialDesc +"]";
  468. return true;
  469. }
  470. return false;
  471. }
  472. //private void InitColumn()
  473. //{
  474. // ///电炉
  475. // setColumnReadOnly(ultraGrid1, new String[] { "InMaterialNo", "OutMaterialNo", "PlineCode", "PlineName", "InMaterialDesc", "OutMaterialDesc" });
  476. // setColumnBackColor(ultraGrid1, new String[] { "HrCapcty", "PrdRate", "DisableFl" });
  477. // ///铸造
  478. // setColumnReadOnly(ultraGrid2, new String[] { "InMaterialNo", "OutMaterialNo", "PlineCode", "PlineName" });
  479. // setColumnBackColor(ultraGrid2, new String[] { "HrCapcty", "PrdRate", "DisableFl" });
  480. // ///锻造
  481. // setColumnReadOnly(ultraGrid3, new String[] { "InMaterialNo", "OutMaterialNo", "PlineCode", "PlineName" });
  482. // setColumnBackColor(ultraGrid3, new String[] { "HrCapcty", "PrdRate", "DisableFl" });
  483. // ///轧管
  484. // setColumnReadOnly(ultraGrid4, new String[] { "InMaterialNo", "OutMaterialNo", "PlineCode", "PlineName" });
  485. // setColumnBackColor(ultraGrid4, new String[] { "HrCapcty", "PrdRate", "DisableFl", "RolLenMin", "RolLenMax", "CropEnd", "MandrelSize", "DisableFl", "DblLenMax" }); ;
  486. // ///墩拔扩
  487. // setColumnReadOnly(ultraGrid5, new String[] { "InMaterialNo", "OutMaterialNo", "PlineCode", "PlineName" });
  488. // setColumnBackColor(ultraGrid5, new String[] { "HrCapcty", "PrdRate", "DisableFl" });
  489. // ///热处理
  490. // setColumnReadOnly(ultraGrid6, new String[] { "InMaterialNo", "OutMaterialNo", "PlineCode", "PlineName" });
  491. // setColumnBackColor(ultraGrid6, new String[] { "HrCapcty", "PrdRate", "DisableFl" });
  492. // ///接箍
  493. // setColumnReadOnly(ultraGrid7, new String[] { "InMaterialNo", "OutMaterialNo", "PlineCode", "PlineName" });
  494. // setColumnBackColor(ultraGrid7, new String[] { "HrCapcty", "PrdRate", "DisableFl" });
  495. //}
  496. ///// <summary>
  497. ///// 设置列背景颜色
  498. ///// </summary>
  499. ///// <param name="ugr">UltraGrid</param>
  500. ///// <param name="columns">列数组</param>
  501. //private void setColumnBackColor(UltraGrid ugr, String[] columns)
  502. //{
  503. // for (int i = 0; i < columns.Length; i++)
  504. // {
  505. // ugr.DisplayLayout.Bands[0].Columns[columns[i]].CellAppearance.BackColor = Color.FromArgb(255, 255, 128);
  506. // }
  507. //}
  508. ///// <summary>
  509. ///// 设置列只可读
  510. ///// </summary>
  511. ///// <param name="ugr">UltraGrid</param>
  512. ///// <param name="columns">列数组</param>
  513. //private void setColumnReadOnly(UltraGrid ugr, String[] columns)
  514. //{
  515. // for (int i = 0; i < columns.Length; i++)
  516. // {
  517. // ugr.DisplayLayout.Bands[0].Columns[columns[i]].CellActivation = Activation.ActivateOnly;
  518. // }
  519. //}
  520. /// <summary>
  521. /// 判断实体类列数据是否为数字
  522. /// </summary>
  523. /// <param name="obj"></param>
  524. /// <param name="columns"></param>
  525. /// <returns></returns>
  526. private Boolean checkIsNumber(Object obj, List<String> columns)
  527. {
  528. System.Reflection.PropertyInfo[] properties = obj.GetType().GetProperties(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public);
  529. foreach (System.Reflection.PropertyInfo item in properties)
  530. {
  531. string name = item.Name;
  532. string value = item.GetValue(obj, null).ToString();
  533. if (columns.Contains(name))
  534. {
  535. if (!value.Equals("") && !StringUtil.IsNumber(value))
  536. {
  537. return false;
  538. }
  539. }
  540. }
  541. return true;
  542. }
  543. private void ControlCellEdit(UltraGridRow row)
  544. {
  545. foreach (UltraGridCell cell in row.Cells)
  546. {
  547. if (cell.Column.CellAppearance.BackColor == Color.FromArgb(255, 255, 128))
  548. {
  549. if (row.Cells["CHK"].Value.ToString() == "True") cell.Activation = Activation.AllowEdit;
  550. else cell.Activation = Activation.ActivateOnly;
  551. }
  552. }
  553. }
  554. private void ultraGrid1_InitializeRow(object sender, InitializeRowEventArgs e)
  555. {
  556. ControlCellEdit(e.Row);
  557. }
  558. private void ultraGrid2_InitializeRow(object sender, InitializeRowEventArgs e)
  559. {
  560. ControlCellEdit(e.Row);
  561. }
  562. private void ultraGrid3_InitializeRow(object sender, InitializeRowEventArgs e)
  563. {
  564. ControlCellEdit(e.Row);
  565. }
  566. private void ultraGrid4_InitializeRow(object sender, InitializeRowEventArgs e)
  567. {
  568. ControlCellEdit(e.Row);
  569. }
  570. private void ultraGrid5_InitializeRow(object sender, InitializeRowEventArgs e)
  571. {
  572. ControlCellEdit(e.Row);
  573. }
  574. private void ultraGrid6_InitializeRow(object sender, InitializeRowEventArgs e)
  575. {
  576. ControlCellEdit(e.Row);
  577. }
  578. private void ultraGrid7_InitializeRow(object sender, InitializeRowEventArgs e)
  579. {
  580. ControlCellEdit(e.Row);
  581. }
  582. private void ultraGrid8_InitializeRow(object sender, InitializeRowEventArgs e)
  583. {
  584. ControlCellEdit(e.Row);
  585. }
  586. private void ultraGrid1_CellChange(object sender, CellEventArgs e)
  587. {
  588. ultraGrid1.UpdateData();
  589. SlmBaseMaterialAPlEntity materialAPlEntity = (SlmBaseMaterialAPlEntity)e.Cell.Row.ListObject;
  590. _materialAPlEntityList.Change(materialAPlEntity);
  591. }
  592. private void ultraGrid2_CellChange(object sender, CellEventArgs e)
  593. {
  594. e.Cell.Row.Update();
  595. SlmBaseMaterialBPlEntity materialBPlEntity = (SlmBaseMaterialBPlEntity)e.Cell.Row.ListObject;
  596. _materialBPlEntityList.Change(materialBPlEntity);
  597. }
  598. private void ultraGrid3_CellChange(object sender, CellEventArgs e)
  599. {
  600. e.Cell.Row.Update();
  601. SlmBaseMaterialCPlEntity materialCPlEntity = (SlmBaseMaterialCPlEntity)e.Cell.Row.ListObject;
  602. _materialCPlEntityList.Change(materialCPlEntity);
  603. }
  604. private void ultraGrid4_CellChange(object sender, CellEventArgs e)
  605. {
  606. e.Cell.Row.Update();
  607. SlmBaseMaterialDPlEntity materialDPlEntity = (SlmBaseMaterialDPlEntity)e.Cell.Row.ListObject;
  608. _materialDPlEntityList.Change(materialDPlEntity);
  609. }
  610. private void ultraGrid5_CellChange(object sender, CellEventArgs e)
  611. {
  612. e.Cell.Row.Update();
  613. SlmBaseMaterialEPlEntity materialEPlEntity = (SlmBaseMaterialEPlEntity)e.Cell.Row.ListObject;
  614. _materialEPlEntityList.Change(materialEPlEntity);
  615. }
  616. private void ultraGrid6_CellChange(object sender, CellEventArgs e)
  617. {
  618. e.Cell.Row.Update();
  619. SlmBaseMaterialFPlEntity materialFPlEntity = (SlmBaseMaterialFPlEntity)e.Cell.Row.ListObject;
  620. _materialFPlEntityList.Change(materialFPlEntity);
  621. }
  622. private void ultraGrid7_CellChange(object sender, CellEventArgs e)
  623. {
  624. e.Cell.Row.Update();
  625. SlmBaseMaterialJPlEntity materialJPlEntity = (SlmBaseMaterialJPlEntity)e.Cell.Row.ListObject;
  626. _materialJPlEntityList.Change(materialJPlEntity);
  627. }
  628. private void ultraGrid8_CellChange(object sender, CellEventArgs e)
  629. {
  630. e.Cell.Row.Update();
  631. SlmBaseMaterialIPlEntity materialIPlEntity = (SlmBaseMaterialIPlEntity)e.Cell.Row.ListObject;
  632. _materialIPlEntityList.Change(materialIPlEntity);
  633. }
  634. private bool IsExitEdit()
  635. {
  636. if(_materialAPlEntityList.IsChanged || _materialBPlEntityList.IsChanged || _materialCPlEntityList.IsChanged
  637. || _materialDPlEntityList.IsChanged || _materialEPlEntityList.IsChanged || _materialFPlEntityList.IsChanged
  638. || _materialIPlEntityList.IsChanged || _materialJPlEntityList.IsChanged || _materialEntityList.IsChanged)
  639. {
  640. if (MessageUtil.ShowYesNoAndQuestion("系统检测到有数据修改,是否放弃编辑?") == DialogResult.Yes)
  641. {
  642. _materialAPlEntityList.IsChanged = false;
  643. _materialBPlEntityList.IsChanged = false;
  644. _materialCPlEntityList.IsChanged = false;
  645. _materialDPlEntityList.IsChanged = false;
  646. _materialEPlEntityList.IsChanged = false;
  647. _materialFPlEntityList.IsChanged = false;
  648. _materialIPlEntityList.IsChanged = false;
  649. _materialJPlEntityList.IsChanged = false;
  650. _materialEntityList.IsChanged = false;
  651. return true;
  652. }
  653. else
  654. {
  655. return false;
  656. }
  657. }
  658. return true;
  659. }
  660. private void ultraTabControl1_ActiveTabChanging(object sender, Infragistics.Win.UltraWinTabControl.ActiveTabChangingEventArgs e)
  661. {
  662. if (IsExitEdit() == false)
  663. {
  664. e.Cancel = true;
  665. }
  666. }
  667. /// <summary>
  668. /// 获取TAB页面权限
  669. /// </summary>
  670. /// <param name="deptCode"></param>
  671. /// <returns></returns>
  672. public void GetPagePermission()
  673. {
  674. for (int i = 0; i < ultraTabControl1.Tabs.Count; i++)
  675. {
  676. ultraTabControl1.Tabs[i].Visible = false;
  677. }
  678. DataTable dt = ServerHelper.GetData("com.steering.pss.sale.order.CoreBaseMaterialPl.GetPagePermission", new object[] { this.ValidDataPurviewIds }, this.ob);
  679. ArrayList proCodeList = new ArrayList();
  680. if (dt != null && dt.Rows.Count > 0)
  681. {
  682. foreach(DataRow dr in dt.Rows){
  683. proCodeList.Add(dr[0]);
  684. }
  685. }
  686. ultraTabControl1.Tabs[8].Visible = true;
  687. if (proCodeList != null && proCodeList.Count > 0)
  688. {
  689. if (proCodeList.Contains("A"))
  690. {
  691. ultraTabControl1.Tabs[0].Visible = true;
  692. }
  693. if (proCodeList.Contains("B"))
  694. {
  695. ultraTabControl1.Tabs[1].Visible = true;
  696. }
  697. if (proCodeList.Contains("C"))
  698. {
  699. ultraTabControl1.Tabs[2].Visible = true;
  700. }
  701. if (proCodeList.Contains("D"))
  702. {
  703. ultraTabControl1.Tabs[3].Visible = true;
  704. }
  705. if (proCodeList.Contains("E"))
  706. {
  707. ultraTabControl1.Tabs[4].Visible = true;
  708. }
  709. if (proCodeList.Contains("F"))
  710. {
  711. ultraTabControl1.Tabs[5].Visible = true;
  712. }
  713. if (proCodeList.Contains("H"))
  714. {
  715. ultraTabControl1.Tabs[6].Visible = true;
  716. }
  717. if (proCodeList.Contains("G"))
  718. {
  719. ultraTabControl1.Tabs[7].Visible = true;
  720. }
  721. }
  722. }
  723. /// <summary>
  724. /// 产线权限
  725. /// </summary>
  726. /// <returns></returns>
  727. public string[] getPlinePermission()
  728. {
  729. DataTable dt = ServerHelper.GetData("com.steering.pss.sale.order.CoreBaseMaterialPl.getPlinePermission", new object[] { this.ValidDataPurviewIds }, this.ob);
  730. string[] plines=new string[0];
  731. if (dt != null && dt.Rows.Count > 0)
  732. {
  733. plines = new string[dt.Rows.Count];
  734. for (int i=0;i< dt.Rows.Count;i++)
  735. {
  736. plines[i] = dt.Rows[i][0].ToString();
  737. }
  738. }
  739. return plines;
  740. }
  741. private void ultraTabControl1_SelectedTabChanged(object sender, Infragistics.Win.UltraWinTabControl.SelectedTabChangedEventArgs e)
  742. {
  743. if (!flag)
  744. {
  745. return;
  746. }
  747. try
  748. {
  749. this.Cursor = Cursors.WaitCursor;
  750. QueryMaterial();
  751. }
  752. finally
  753. {
  754. this.Cursor = Cursors.Default;
  755. }
  756. }
  757. public void DeleteMaterialAPl()
  758. {
  759. ultraGrid1.UpdateData();
  760. ultraGrid2.UpdateData();
  761. ultraGrid3.UpdateData();
  762. ultraGrid4.UpdateData();
  763. ultraGrid5.UpdateData();
  764. ultraGrid6.UpdateData();
  765. ultraGrid7.UpdateData();
  766. ultraGrid8.UpdateData();
  767. ultraGrid9.UpdateData();
  768. IQueryable<UltraGridRow> ultraGrid1ChkRows = ultraGrid1.Rows.AsQueryable().Where("CHK = 'True'");
  769. IQueryable<UltraGridRow> ultraGrid2ChkRows = ultraGrid2.Rows.AsQueryable().Where("CHK = 'True'");
  770. IQueryable<UltraGridRow> ultraGrid3ChkRows = ultraGrid3.Rows.AsQueryable().Where("CHK = 'True'");
  771. IQueryable<UltraGridRow> ultraGrid4ChkRows = ultraGrid4.Rows.AsQueryable().Where("CHK = 'True'");
  772. IQueryable<UltraGridRow> ultraGrid5ChkRows = ultraGrid5.Rows.AsQueryable().Where("CHK = 'True'");
  773. IQueryable<UltraGridRow> ultraGrid6ChkRows = ultraGrid6.Rows.AsQueryable().Where("CHK = 'True'");
  774. IQueryable<UltraGridRow> ultraGrid7ChkRows = ultraGrid7.Rows.AsQueryable().Where("CHK = 'True'");
  775. IQueryable<UltraGridRow> ultraGrid8ChkRows = ultraGrid8.Rows.AsQueryable().Where("CHK = 'True'");
  776. var ultraGrid9Rows = ultraGrid9.Rows.Where(a=>a.GetValue("Chk") == "True");
  777. int chkCnt = ultraGrid1ChkRows.Count() + ultraGrid2ChkRows.Count() + ultraGrid3ChkRows.Count()
  778. + ultraGrid4ChkRows.Count() + ultraGrid5ChkRows.Count() + ultraGrid6ChkRows.Count()
  779. + ultraGrid7ChkRows.Count() + ultraGrid8ChkRows.Count() + ultraGrid9Rows.Count();
  780. if (chkCnt == 0)
  781. {
  782. MessageUtil.ShowWarning("请选择需要删除的记录!");
  783. return;
  784. }
  785. ArrayList list = new ArrayList();
  786. ArrayList list1 = new ArrayList();
  787. ArrayList list2 = new ArrayList();
  788. ArrayList list3 = new ArrayList();
  789. ArrayList list4 = new ArrayList();
  790. ArrayList list5 = new ArrayList();
  791. ArrayList list6 = new ArrayList();
  792. ArrayList list7 = new ArrayList();
  793. ArrayList list8 = new ArrayList();
  794. ArrayList list9 = new ArrayList();
  795. string msg = "";
  796. string fieldName = "";
  797. foreach (UltraGridRow ugr in ultraGrid1ChkRows)
  798. {
  799. SlmBaseMaterialAPlEntity baseMaterialAPl = EntityHelper.CopyEntity<SlmBaseMaterialAPlEntity>(ugr.ListObject);
  800. baseMaterialAPl.UpdateName = UserInfo.GetUserName();
  801. if (EntityHelper.CheckEntity(baseMaterialAPl, out msg, out fieldName) == false)
  802. {
  803. MessageUtil.ShowWarning(msg);
  804. return;
  805. }
  806. string strJSON = JSONFormat.Format(baseMaterialAPl);
  807. list1.Add(strJSON);
  808. }
  809. foreach (UltraGridRow ugr in ultraGrid2ChkRows)
  810. {
  811. SlmBaseMaterialBPlEntity baseMaterialBPl = EntityHelper.CopyEntity<SlmBaseMaterialBPlEntity>(ugr.ListObject);
  812. baseMaterialBPl.UpdateName = UserInfo.GetUserName();
  813. string strJSON = JSONFormat.Format(baseMaterialBPl);
  814. list2.Add(strJSON);
  815. }
  816. foreach (UltraGridRow ugr in ultraGrid3ChkRows)
  817. {
  818. SlmBaseMaterialCPlEntity baseMaterialCPl = EntityHelper.CopyEntity<SlmBaseMaterialCPlEntity>(ugr.ListObject);
  819. baseMaterialCPl.UpdateName = UserInfo.GetUserName();
  820. string strJSON = JSONFormat.Format(baseMaterialCPl);
  821. list3.Add(strJSON);
  822. }
  823. IQueryable<SlmBaseMaterialDPlEntity> querableMaterialD = ultraGrid4ChkRows.Select(a => (SlmBaseMaterialDPlEntity)a.ListObject);
  824. if (CheckMaterialDIsSame(querableMaterialD, out msg))
  825. {
  826. MessageUtil.ShowWarning(msg);
  827. return;
  828. }
  829. foreach (UltraGridRow ugr in ultraGrid4ChkRows)
  830. {
  831. SlmBaseMaterialDPlEntity baseMaterialDPl = EntityHelper.CopyEntity<SlmBaseMaterialDPlEntity>(ugr.ListObject);
  832. baseMaterialDPl.UpdateName = this.UserInfo.GetUserName();
  833. string strJSON = JSONFormat.Format(baseMaterialDPl);
  834. list4.Add(strJSON);
  835. }
  836. foreach (UltraGridRow ugr in ultraGrid4ChkRows)
  837. {
  838. SlmBaseMaterialDPlEntity baseMaterialDPl = EntityHelper.CopyEntity<SlmBaseMaterialDPlEntity>(ugr.ListObject);
  839. if (CheckMaterialD(baseMaterialDPl, list4, out msg))
  840. {
  841. MessageUtil.ShowWarning(msg);
  842. return;
  843. }
  844. }
  845. foreach (UltraGridRow ugr in ultraGrid5ChkRows)
  846. {
  847. SlmBaseMaterialEPlEntity baseMaterialEPl = EntityHelper.CopyEntity<SlmBaseMaterialEPlEntity>(ugr.ListObject);
  848. baseMaterialEPl.UpdateName = this.UserInfo.GetUserName();
  849. string strJSON = JSONFormat.Format(baseMaterialEPl);
  850. list5.Add(strJSON);
  851. }
  852. foreach (UltraGridRow ugr in ultraGrid6ChkRows)
  853. {
  854. SlmBaseMaterialFPlEntity baseMaterialFPl = EntityHelper.CopyEntity<SlmBaseMaterialFPlEntity>(ugr.ListObject);
  855. baseMaterialFPl.UpdateName = this.UserInfo.GetUserName();
  856. string strJSON = JSONFormat.Format(baseMaterialFPl);
  857. list6.Add(strJSON);
  858. }
  859. foreach (UltraGridRow ugr in ultraGrid7ChkRows)
  860. {
  861. SlmBaseMaterialJPlEntity baseMaterialJPl = EntityHelper.CopyEntity<SlmBaseMaterialJPlEntity>(ugr.ListObject);
  862. baseMaterialJPl.UpdateName = this.UserInfo.GetUserName();
  863. string strJSON = JSONFormat.Format(baseMaterialJPl);
  864. list7.Add(strJSON);
  865. }
  866. foreach (UltraGridRow ugr in ultraGrid8ChkRows)
  867. {
  868. SlmBaseMaterialIPlEntity baseMaterialIPl = EntityHelper.CopyEntity<SlmBaseMaterialIPlEntity>(ugr.ListObject);
  869. baseMaterialIPl.UpdateName = this.UserInfo.GetUserName();
  870. string strJSON = JSONFormat.Format(baseMaterialIPl);
  871. list8.Add(strJSON);
  872. }
  873. foreach (var row in ultraGrid9Rows)
  874. {
  875. SlmBaseMaterialEntity baseMaterial = EntityHelper.CopyEntity<SlmBaseMaterialEntity>(row.ListObject);
  876. baseMaterial.UpdateName = this.UserInfo.GetUserName();
  877. string strJSON = JSONFormat.Format(baseMaterial);
  878. list9.Add(strJSON);
  879. }
  880. list.Add(list1);
  881. list.Add(list2);
  882. list.Add(list3);
  883. list.Add(list4);
  884. list.Add(list5);
  885. list.Add(list6);
  886. list.Add(list7);
  887. list.Add(list8);
  888. list.Add(list9);
  889. if (MessageUtil.ShowYesNoAndQuestion("此删除操作不可恢复,确认是否继续?") == DialogResult.No)
  890. {
  891. return;
  892. }
  893. ServerHelper.SetData("com.steering.pss.sale.order.CoreBaseMaterialPl.deleteBaseMaterial", new object[] { list }, ob);
  894. QueryMaterial();
  895. MessageUtil.ShowTips("删除成功!");
  896. }
  897. private void ultraTextEditor1_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
  898. {
  899. var row = ultraGrid9.ActiveRow;
  900. switch (ultraGrid9.ActiveCell.Column.Key)
  901. {
  902. case "MaterialTypeMaxDesc":
  903. DataTable dtMax = ClsBaseInfo.GetComBaseInfo("4088", ob);
  904. dtMax.Columns["BASENAME"].Caption = "物料大类";
  905. BaseInfoPopup baseInfoMax = new BaseInfoPopup(dtMax, "BASENAME", "BASECODE");
  906. foreach (var column in baseInfoMax.UltraGrid1.DisplayLayout.Bands[0].Columns)
  907. {
  908. if (column.Key != "BASENAME")
  909. {
  910. column.Hidden = true;
  911. }
  912. }
  913. if (baseInfoMax.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  914. {
  915. ultraGrid9.ActiveRow.SetValue("MaterialTypeMaxDesc", baseInfoMax.ChoicedRow.GetValue("BASENAME"));
  916. ultraGrid9.ActiveRow.SetValue("MaterialTypeMax", baseInfoMax.ChoicedRow.GetValue("BASECODE"));
  917. }
  918. break;
  919. case "MaterialTypeMidDesc":
  920. if (row.GetValue("MaterialTypeMax") == "")
  921. {
  922. MessageUtil.ShowWarning("请选择物料大类!");
  923. return;
  924. }
  925. DataTable dtMid = ClsBaseInfo.GetComBaseInfo(row.GetValue("MaterialTypeMax"), ob);
  926. dtMid.Columns["BASENAME"].Caption = "物料中类";
  927. BaseInfoPopup baseInfoMid = new BaseInfoPopup(dtMid, "BASENAME", "BASECODE");
  928. foreach (var column in baseInfoMid.UltraGrid1.DisplayLayout.Bands[0].Columns)
  929. {
  930. if (column.Key != "BASENAME")
  931. {
  932. column.Hidden = true;
  933. }
  934. }
  935. if (baseInfoMid.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  936. {
  937. ultraGrid9.ActiveRow.SetValue("MaterialTypeMidDesc", baseInfoMid.ChoicedRow.GetValue("BASENAME"));
  938. ultraGrid9.ActiveRow.SetValue("MaterialTypeMid", baseInfoMid.ChoicedRow.GetValue("BASECODE"));
  939. }
  940. break;
  941. case "MaterialTypeMinDesc":
  942. if (row.GetValue("MaterialTypeMid") == "")
  943. {
  944. MessageUtil.ShowWarning("请选择物料中类!");
  945. return;
  946. }
  947. DataTable dtMin = ClsBaseInfo.GetComBaseInfo(row.GetValue("MaterialTypeMid"), ob);
  948. dtMin.Columns["BASENAME"].Caption = "物料小类";
  949. BaseInfoPopup baseInfoMin = new BaseInfoPopup(dtMin, "BASENAME", "BASECODE");
  950. foreach (var column in baseInfoMin.UltraGrid1.DisplayLayout.Bands[0].Columns)
  951. {
  952. if (column.Key != "BASENAME")
  953. {
  954. column.Hidden = true;
  955. }
  956. }
  957. if (baseInfoMin.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  958. {
  959. ultraGrid9.ActiveRow.SetValue("MaterialTypeMinDesc", baseInfoMin.ChoicedRow.GetValue("BASENAME"));
  960. ultraGrid9.ActiveRow.SetValue("MaterialTypeMin", baseInfoMin.ChoicedRow.GetValue("BASECODE"));
  961. }
  962. break;
  963. case "PropertyType1Desc":
  964. DataTable dtProperty1 = ClsBaseInfo.GetComBaseInfo("4089", ob);
  965. dtProperty1.Columns["BASENAME"].Caption = "属性分类1";
  966. BaseInfoPopup baseInfoProperty1 = new BaseInfoPopup(dtProperty1, "BASENAME", "BASECODE");
  967. foreach (var column in baseInfoProperty1.UltraGrid1.DisplayLayout.Bands[0].Columns)
  968. {
  969. if (column.Key != "BASENAME")
  970. {
  971. column.Hidden = true;
  972. }
  973. }
  974. if (baseInfoProperty1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  975. {
  976. ultraGrid9.ActiveRow.SetValue("PropertyType1Desc", baseInfoProperty1.ChoicedRow.GetValue("BASENAME"));
  977. ultraGrid9.ActiveRow.SetValue("PropertyType1", baseInfoProperty1.ChoicedRow.GetValue("BASECODE"));
  978. }
  979. break;
  980. case "PropertyType2Desc":
  981. DataTable dtProperty2 = ClsBaseInfo.GetComBaseInfo("4089", ob);
  982. dtProperty2.Columns["BASENAME"].Caption = "属性分类2";
  983. BaseInfoPopup baseInfoProperty2 = new BaseInfoPopup(dtProperty2, "BASENAME", "BASECODE");
  984. foreach (var column in baseInfoProperty2.UltraGrid1.DisplayLayout.Bands[0].Columns)
  985. {
  986. if (column.Key != "BASENAME")
  987. {
  988. column.Hidden = true;
  989. }
  990. }
  991. if (baseInfoProperty2.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  992. {
  993. ultraGrid9.ActiveRow.SetValue("PropertyType2Desc", baseInfoProperty2.ChoicedRow.GetValue("BASENAME"));
  994. ultraGrid9.ActiveRow.SetValue("PropertyType2", baseInfoProperty2.ChoicedRow.GetValue("BASECODE"));
  995. }
  996. break;
  997. }
  998. }
  999. private void ultraGrid9_CellChange(object sender, CellEventArgs e)
  1000. {
  1001. e.Cell.Row.Update();
  1002. SlmBaseMaterialEntity materialEntity = (SlmBaseMaterialEntity)e.Cell.Row.ListObject;
  1003. _materialEntityList.Change(materialEntity);
  1004. }
  1005. private void ultraGrid_MouseUp(object sender, MouseEventArgs e)
  1006. {
  1007. UltraGrid grid = (UltraGrid)sender;
  1008. foreach (UltraGridRow row in grid.Rows)
  1009. {
  1010. if (row.Selected)
  1011. {
  1012. row.Cells["CHK"].Value = true;
  1013. }
  1014. }
  1015. grid.UpdateData();
  1016. }
  1017. }
  1018. }