FrmMainTain.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424
  1. using com.hnshituo.pur.vo;
  2. using Core.Mes.Client.Comm.Control;
  3. using Core.Mes.Client.Comm.Tool;
  4. using Infragistics.Win.UltraWinGrid;
  5. using Pur.Entity;
  6. using Pur.Entity.configureEntity;
  7. using Pur.Pop_upWindow;
  8. using System;
  9. using System.Collections;
  10. using System.Collections.Generic;
  11. using System.ComponentModel;
  12. using System.Data;
  13. using System.Drawing;
  14. using System.Linq;
  15. using System.Text;
  16. using System.Windows.Forms;
  17. namespace Pur.configure
  18. {
  19. public partial class FrmMainTain : FrmPmsBase
  20. {
  21. public FrmMainTain()
  22. {
  23. InitializeComponent();
  24. }
  25. public override void ToolBar_Click(object sender, string ToolbarKey)
  26. {
  27. switch (ToolbarKey)
  28. {
  29. case "doQuery":
  30. getPurMainTain();
  31. break;
  32. case "doAdd":
  33. addPurMainTain();
  34. break;
  35. case "doDelete":
  36. delPurMainTain();
  37. break;
  38. case "Close":
  39. this.Close();
  40. break;
  41. }
  42. }
  43. /// <summary>
  44. /// 删除物料
  45. /// </summary>
  46. private void delPurMainTain()
  47. {
  48. UltraGridRow rug = ultraGrid3.ActiveRow;
  49. if (rug == null)
  50. {
  51. MessageUtil.ShowTips("请选择删除物料");
  52. return;
  53. }
  54. String strId = ultraGrid3.ActiveRow.Cells["ID"].Value.ToString();
  55. String strClassCode = ultraGrid3.ActiveRow.Cells["classCode"].Value.ToString();
  56. if (String.IsNullOrEmpty(strId))
  57. {
  58. MessageUtil.ShowTips("数据异常,物料编号为空");
  59. return;
  60. }
  61. if (MessageUtil.ShowYesNoAndQuestion("确定删除? 备注:若删除,该物料关联的属性将全部删除!")!= DialogResult.Yes)
  62. {
  63. return;
  64. }
  65. CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.ClassMatRelationService", "doDelete_Relation", new object[] { strId });
  66. if (crt.Resultcode != 0)
  67. {
  68. MessageUtil.ShowTips("删除失败");
  69. return;
  70. }
  71. MessageUtil.ShowTips("删除成功");
  72. doQueryMat(strClassCode);
  73. }
  74. /// <summary>
  75. /// 查询物料
  76. /// </summary>
  77. /// <param name="classCode"></param>
  78. private void doQueryMat(String classCode)
  79. {
  80. if(String.IsNullOrEmpty(classCode))
  81. {
  82. return;
  83. }
  84. PurClassMatRelationEntity purentity1 = new PurClassMatRelationEntity();
  85. purentity1.ClassCode = classCode;
  86. DataTable dt2 = this.execute<DataTable>("com.hnshituo.pur.configure.service.ClassMatRelationService", "find", new object[] { purentity1, 0, 0 });
  87. GridHelper.CopyDataToDatatable(dt2, dataTable3, true);
  88. GridHelper.RefreshAndAutoSize(ultraGrid3);
  89. }
  90. /// <summary>
  91. /// 查询属性
  92. /// </summary>
  93. /// <param name="itemCode"></param>
  94. private void doQueryAttr(String itemCode)
  95. {
  96. txt_AttrBZ.Text = "";
  97. textBox3.Text = "";
  98. if (String.IsNullOrEmpty(itemCode))
  99. {
  100. return;
  101. }
  102. PurClassMatAttrEntity purentity1 = new PurClassMatAttrEntity();
  103. purentity1.ItemCode = itemCode;
  104. DataTable dt2 = this.execute<DataTable>("com.hnshituo.pur.configure.service.ClassMatAttrService", "find", new object[] { purentity1, 0, 0 });
  105. GridHelper.CopyDataToDatatable(dt2, dataTable2, true);
  106. GridHelper.RefreshAndAutoSize(ultraGrid2);
  107. }
  108. private void addPurMainTain()
  109. {
  110. if (ultraGrid1.ActiveRow == null)
  111. {
  112. MessageUtil.ShowTips("请选择类型");
  113. return;
  114. }
  115. String strCLASSCODE = ultraGrid1.ActiveRow.GetCellValue("CLASSCODE").ToString().Trim();
  116. if (String.IsNullOrEmpty(strCLASSCODE))
  117. {
  118. MessageUtil.ShowTips("请选择类型编号为空");
  119. return;
  120. }
  121. ArrayList list=new ArrayList();
  122. frmPopMatSelect frm = new frmPopMatSelect(this.ob);
  123. frm.ShowDialog();
  124. if (frm.tips == "1")
  125. {
  126. for (int i = 0; i <frm.List_item.Count; i++)
  127. {
  128. PurClassMatRelationEntity purentity = new PurClassMatRelationEntity();
  129. purentity.ItemCode = ((MatEntity)frm.List_item[i]).ItemCode;
  130. purentity.ItemName = ((MatEntity)frm.List_item[i]).ItemName;
  131. purentity.ClassCode = strCLASSCODE;
  132. purentity.CreateName = UserInfo.GetUserName();
  133. purentity.CreateTime = DateTime.Now;
  134. purentity.CreateUserid = UserInfo.GetUserID();
  135. list.Add(purentity);
  136. }
  137. if (list.Count <= 0)
  138. {
  139. MessageUtil.ShowTips("未选择物料");
  140. return;
  141. }
  142. CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.ClassMatRelationService", "doInsert_Relation", new object[] { list, 0, 0 });
  143. if (crt.Resultcode != 0)
  144. {
  145. MessageUtil.ShowTips("绑定失败:" + crt.Resultmsg);
  146. }
  147. else {
  148. MessageUtil.ShowTips("操作成功");
  149. doQueryMat(strCLASSCODE);
  150. }
  151. }
  152. }
  153. /// <summary>
  154. /// 查询物料类型
  155. /// </summary>
  156. private void getPurMainTain()
  157. {
  158. dataTable1.Clear();
  159. dataTable2.Clear();
  160. dataTable3.Clear();
  161. textBox1.Text = "";
  162. txt_ClassBZ.Text = "";
  163. DataTable dt1 = this.execute<DataTable>("com.hnshituo.pur.configure.service.ClassMainService", "findAll", new object[] {});
  164. GridHelper.CopyDataToDatatable(dt1, dataTable1,true);
  165. GridHelper.RefreshAndAutoSize(ultraGrid1);
  166. }
  167. private void ultraButton6_Click(object sender, EventArgs e)
  168. {
  169. PurClassEntity purentity = new PurClassEntity();
  170. if (textBox1.Text != "")
  171. {
  172. purentity.ClassName = textBox1.Text.Trim();
  173. }
  174. else
  175. {
  176. MessageUtil.ShowTips("类型名称不能为空");
  177. return;
  178. }
  179. purentity.CreateName = UserInfo.GetUserName();
  180. purentity.CreateUserid = UserInfo.GetUserID();
  181. purentity.Remark = txt_ClassBZ.Text;
  182. if (MessageUtil.ShowYesNoAndQuestion("确定添加?") != DialogResult.Yes )
  183. {
  184. return;
  185. }
  186. CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.ClassMainService", "insert_id", new object[] { purentity });
  187. if (crt.Resultcode != 0)
  188. {
  189. MessageUtil.ShowTips("添加失败:"+crt.Resultmsg);
  190. return;
  191. }
  192. MessageUtil.ShowTips("添加成功");
  193. getPurMainTain();
  194. ConfigureClassCommon.doActiveSelRow(ultraGrid1, "CLASSNAME", purentity.ClassName);//激活当前行
  195. }
  196. private void ultraButton4_Click(object sender, EventArgs e)
  197. {
  198. PurClassEntity purentity = new PurClassEntity();
  199. UltraGridRow rug = ultraGrid1.ActiveRow;
  200. if (rug == null)
  201. {
  202. MessageUtil.ShowTips("请选中修改行");
  203. }
  204. if (textBox1.Text == "")
  205. {
  206. MessageUtil.ShowTips("修改内容不能为空");
  207. return;
  208. }
  209. if (textBox1.Text == ultraGrid1.ActiveRow.Cells["CLASSNAME"].Value.ToString())
  210. {
  211. MessageUtil.ShowTips("修改内容不能重复");
  212. return;
  213. }
  214. if (MessageUtil.ShowYesNoAndQuestion("是否确定修改?") == DialogResult.No)
  215. {
  216. return;
  217. }
  218. purentity.ClassCode = ultraGrid1.ActiveRow.Cells["CLASSCODE"].Value.ToString();
  219. purentity.ClassName = textBox1.Text.Trim();
  220. CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.ClassMainService", "doUpdate", new object[] { purentity, 0, 0 });
  221. if (crt.Resultcode != 0)
  222. {
  223. MessageUtil.ShowTips("修改失败");
  224. return;
  225. }
  226. MessageUtil.ShowTips("修改成功");
  227. getPurMainTain();
  228. ConfigureClassCommon.doActiveSelRow(ultraGrid1, "CLASSCODE", purentity.ClassCode);
  229. }
  230. private void ultraButton5_Click(object sender, EventArgs e)
  231. {
  232. if (ultraGrid1.ActiveRow != null)
  233. {
  234. String strClassCode = ultraGrid1.ActiveRow.Cells["CLASSCODE"].Value.ToString();
  235. if (String.IsNullOrEmpty(strClassCode))
  236. {
  237. MessageUtil.ShowTips("类型编号为空");
  238. return;
  239. }
  240. if (MessageUtil.ShowYesNoAndQuestion("是否确定删除类型【" + ultraGrid1.ActiveRow.Cells["CLASSNAME"].Value.ToString() + "】? 备注:若删除,其关联的物料和物料属性将同步删除") != DialogResult.Yes)
  241. {
  242. return;
  243. }
  244. CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.ClassMainService", "doDelete_id", new object[] { strClassCode });
  245. if (crt.Resultcode != 0)
  246. {
  247. MessageUtil.ShowTips("删除失败:" + crt.Resultmsg);
  248. }
  249. MessageUtil.ShowTips("删除成功");
  250. getPurMainTain();
  251. }
  252. }
  253. private void ultraButton1_Click(object sender, EventArgs e)
  254. {
  255. if (ultraGrid3.ActiveRow == null)
  256. {
  257. MessageUtil.ShowTips("请选择物料");
  258. return;
  259. }
  260. String strItemCode = ultraGrid3.ActiveRow.GetCellValue("itemCode").ToString().Trim();
  261. if (String.IsNullOrEmpty(strItemCode))
  262. {
  263. MessageUtil.ShowTips("选择的物料物料编号为空");
  264. return;
  265. }
  266. PurClassMatAttrEntity puren = new PurClassMatAttrEntity();
  267. if (textBox3.Text != "")
  268. {
  269. puren.AttrName = textBox3.Text.Trim();
  270. }
  271. else
  272. {
  273. MessageUtil.ShowTips("属性名称不能为空");
  274. return;
  275. }
  276. puren.CreateName = UserInfo.GetUserName();
  277. puren.CreateUserid = UserInfo.GetUserID();
  278. puren.CreateTime = DateTime.Now;
  279. puren.ItemCode = strItemCode;
  280. puren.Remark = txt_AttrBZ.Text;
  281. if (MessageUtil.ShowYesNoAndQuestion("确定添加?") != DialogResult.Yes)
  282. {
  283. return;
  284. }
  285. CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.ClassMatAttrService", "insert_id", new object[] { puren });
  286. if (crt.Resultcode != 0)
  287. {
  288. MessageUtil.ShowTips("添加失败:"+crt.Resultmsg);
  289. return;
  290. }
  291. MessageUtil.ShowTips("添加成功");
  292. doQueryAttr(strItemCode);
  293. ConfigureClassCommon.doActiveSelRow(ultraGrid2, "attrName", puren.AttrName);
  294. }
  295. private void FrmMainTain_Load(object sender, EventArgs e)
  296. {
  297. getPurMainTain();
  298. }
  299. private void ultraButton3_Click(object sender, EventArgs e)
  300. {
  301. PurClassMatAttrEntity puren = new PurClassMatAttrEntity();
  302. UltraGridRow rug = ultraGrid2.ActiveRow;
  303. puren.Id = ultraGrid2.ActiveRow.Cells["ID"].Value.ToString();
  304. if (rug == null)
  305. {
  306. MessageUtil.ShowTips("请选中修改行");
  307. }
  308. if (textBox3.Text != "")
  309. {
  310. puren.AttrName = textBox3.Text.Trim();
  311. }
  312. else
  313. {
  314. MessageUtil.ShowTips("属性名称不能为空");
  315. return;
  316. }
  317. //if (textBox3.Text == ultraGrid1.ActiveRow.Cells["ATTRNAME"].Value.ToString())
  318. //{
  319. // MessageUtil.ShowTips("属性名称不能重复");
  320. // return;
  321. //}
  322. if (MessageUtil.ShowYesNoAndQuestion("是否确定修改?") == DialogResult.No)
  323. {
  324. return;
  325. }
  326. CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.ClassMatAttrService", "doUpdate", new object[] { puren, 0, 0 });
  327. if (crt.Resultcode != 0)
  328. {
  329. MessageUtil.ShowTips("修改失败");
  330. return;
  331. }
  332. MessageUtil.ShowTips("修改成功");
  333. }
  334. private void ultraButton2_Click(object sender, EventArgs e)
  335. {
  336. UltraGridRow rug = ultraGrid2.ActiveRow;
  337. if (rug == null)
  338. {
  339. MessageUtil.ShowTips("请选择需删除的属性");
  340. return;
  341. }
  342. String strId = ultraGrid2.ActiveRow.Cells["ID"].Value.ToString();
  343. if(String.IsNullOrEmpty(strId))
  344. {
  345. MessageUtil.ShowTips("请选择需删除的属性编号为空");
  346. return;
  347. }
  348. if (MessageUtil.ShowYesNoAndQuestion("确定删除?") == DialogResult.No)
  349. {
  350. return;
  351. }
  352. CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.ClassMatAttrService", "doDelete", new object[] { strId });
  353. if (crt.Resultcode != 0)
  354. {
  355. MessageUtil.ShowTips("删除失败");
  356. return;
  357. }
  358. MessageUtil.ShowTips("删除成功");
  359. string strItemCode = ultraGrid3.ActiveRow.Cells["ItemCode"].Value.ToString();
  360. doQueryAttr(strItemCode);
  361. }
  362. private void ultraGrid3_AfterRowActivate(object sender, EventArgs e)
  363. {
  364. dataTable2.Clear();
  365. UltraGridRow uge = ultraGrid3.ActiveRow;
  366. if (uge == null)
  367. {
  368. return;
  369. }
  370. textBox3.Text = "";
  371. txt_AttrBZ.Text = "";
  372. String stritemCode = ultraGrid3.ActiveRow.GetCellValue("itemCode").ToString().Trim();
  373. doQueryAttr(stritemCode);
  374. }
  375. private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
  376. {
  377. dataTable2.Clear();
  378. dataTable3.Clear();
  379. UltraGridRow uge = ultraGrid1.ActiveRow;
  380. if (uge == null)
  381. {
  382. return;
  383. }
  384. String strClassCode = ultraGrid1.ActiveRow.GetCellValue("classCode").ToString().Trim();
  385. doQueryMat(strClassCode);
  386. }
  387. private void ultraGrid2_ClickCell(object sender, ClickCellEventArgs e)
  388. {
  389. textBox3.Text = e.Cell.Row.Cells["ATTRNAME"].Value.ToString();
  390. txt_AttrBZ.Text = e.Cell.Row.Cells["REMARK"].Value.ToString(); ;
  391. }
  392. private void ultraGrid1_ClickCell(object sender, ClickCellEventArgs e)
  393. {
  394. textBox1.Text = e.Cell.Row.Cells["classname"].Value.ToString();
  395. txt_ClassBZ.Text = e.Cell.Row.Cells["REMARK"].Value.ToString();
  396. }
  397. }
  398. }