FrmPurMatClass.cs 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717
  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;using Pur.Entity;
  10. using Infragistics.Win;
  11. using Infragistics.Win.UltraWinGrid;
  12. using Pur.Entity.configureEntity;
  13. using Core.Mes.Client.Comm.Control;
  14. using Infragistics.Win.UltraWinTree;
  15. using Core.Mes.Client.Comm.Tool;
  16. using com.hnshituo.pur.vo;
  17. using Pur.configure;
  18. using Pur.Pop_upWindow;
  19. using System.Collections;
  20. namespace Pur
  21. {
  22. public partial class FrmPurMatClass : FrmPmsBase
  23. {
  24. PurmatclassEntity Q_mat = null;
  25. private bool QclickQueryCell = false;//是否点击查询按钮或grid1单元格
  26. public FrmPurMatClass()
  27. {
  28. InitializeComponent();
  29. ultraGrid1.DisplayLayout.Bands[0].Override.AllowUpdate = DefaultableBoolean.False;
  30. }
  31. //菜单按钮事件
  32. public override void ToolBar_Click(object sender, string ToolbarKey)
  33. {
  34. switch (ToolbarKey)
  35. {
  36. case "Query":
  37. ultraTree1.Nodes.Clear();
  38. getultree();// 获取物料分类树形结构
  39. GetPUR_MAT_CLASS(getEnSelContion(null));
  40. if (ultraGrid1.Rows.Count < 1)
  41. {
  42. if (ultraTree1.ActiveNode != null)
  43. {
  44. ultraTree1.ActiveNode.Expanded = true;
  45. }
  46. }
  47. else
  48. {
  49. QclickQueryCell = true;
  50. UltraTreeNode uttNode = ultraTree1.GetNodeByKey(ultraGrid1.Rows[0].Cells["BASECODE"].Value.ToString()).Parent;
  51. if (uttNode == ultraTree1.ActiveNode)
  52. {
  53. return;
  54. }
  55. ultraTree1.CollapseAll();
  56. if (uttNode == null)
  57. {
  58. ultraTree1.ActiveNode = ultraTree1.GetNodeByKey(ultraGrid1.Rows[0].Cells["BASECODE"].Value.ToString());
  59. }
  60. else
  61. {
  62. ultraTree1.ActiveNode = uttNode;
  63. uttNode.Expanded = true;
  64. while (uttNode.Parent != null)
  65. {
  66. uttNode = uttNode.Parent;
  67. uttNode.Expanded = true;
  68. }
  69. }
  70. }
  71. break;
  72. case "Add":
  73. AddPUR_MAT_CLASS();
  74. break;
  75. case "Update":
  76. UpdPUR_MAT_CLASS();
  77. break;
  78. case "Delete":
  79. DelPUR_MAT_CLASS();
  80. break;
  81. case "UpdClassName":
  82. UpdClassName();
  83. break;
  84. case "doExcel":
  85. doExcel();
  86. break;
  87. }
  88. }
  89. private void doExcel()
  90. {
  91. try
  92. {
  93. this.Cursor = Cursors.Default;
  94. if (ultraGrid1.Rows.Count <= 0)
  95. {
  96. MessageUtil.ShowTips("无可导出明细!");
  97. }
  98. ArrayList alUltraGrid = new ArrayList();
  99. alUltraGrid.Add(ultraGrid1);
  100. ArrayList alSheeft = new ArrayList();
  101. alSheeft.Add("物料分类");
  102. if (ultraGrid1.Rows.Count > 0)
  103. {
  104. GridHelper.ulGridToExcel(alUltraGrid, alSheeft, "物料分类表");//导出excel
  105. }
  106. else
  107. {
  108. MessageUtil.ShowTips("无可导出明细!");
  109. }
  110. }
  111. catch (Exception e)
  112. {
  113. MessageUtil.ShowTips("导出失败" + e.Message);
  114. }
  115. finally
  116. {
  117. this.Cursor = Cursors.Default;
  118. }
  119. }
  120. /// <summary>
  121. /// 修改分类的父类
  122. /// </summary>
  123. private void UpdClassName()
  124. {
  125. frmPopMatClass frm = new frmPopMatClass(this.ob);
  126. frm.ShowDialog();
  127. if(frm.Q_Ultnode!=null)
  128. {
  129. //string strNode=ultraTree1.ActiveNode.Key;
  130. string strBaseName= ultraGrid1.ActiveRow.Cells["BASENAME"].Value.ToString().Trim();
  131. string strBaseCode = ultraGrid1.ActiveRow.Cells["BASECODE"].Value.ToString().Trim();
  132. if (MessageUtil.ShowYesNoAndQuestion("确定要将分类【" + strBaseName + "】移动到分类【" + frm.Q_Ultnode.Text + "】下吗?").Equals(DialogResult.Yes))
  133. {
  134. PurmatclassEntity Purmatclass_Entity = new PurmatclassEntity();
  135. Purmatclass_Entity.Basecode = strBaseCode;
  136. Purmatclass_Entity.Parentcode = frm.Q_Ultnode.Key;
  137. Purmatclass_Entity.UpdateName = UserInfo.GetUserName();
  138. Purmatclass_Entity.UpdateUserid = UserInfo.GetUserID();
  139. CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.MatClassService", "doUpdate", new object[] { Purmatclass_Entity });
  140. if (crt.Resultcode != 0)
  141. {
  142. MessageUtil.ShowTips("修改失败 " + crt.Resultmsg);
  143. return;
  144. }
  145. MessageBox.Show("修改成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  146. if (ultraTree1.ActiveNode != null)
  147. {
  148. //查询物料分类
  149. ultraTree1.Nodes.Clear();
  150. getultree();// 获取物料分类树形结构
  151. PurmatclassEntity pmcE = new PurmatclassEntity();
  152. pmcE.Parentcode = frm.Q_Ultnode.Key;
  153. GetPUR_MAT_CLASS(pmcE);
  154. ConfigureClassCommon.doActiveSelRow(ultraGrid1, "BASECODE", Purmatclass_Entity.Basecode);//激活当前行
  155. ExpNode(Purmatclass_Entity.Basecode);
  156. }
  157. }
  158. }
  159. }
  160. /// <summary>
  161. /// 查询物料分类
  162. /// </summary>
  163. public void GetPUR_MAT_CLASS(PurmatclassEntity mat)
  164. {
  165. dataTable1.Clear();
  166. DataTable dt = this.execute<DataTable>("com.hnshituo.pur.configure.service.MatClassService", "getMatClass", new object[] { mat, 0, 0 });
  167. // GetJsonService().execute<DataTable>("com.hnshituo.pur.configure.service.MatClassService", "getMatClass", new object[] { mat, 0, 0 });
  168. //按创建时间降序
  169. if (dt.Rows.Count > 0)
  170. {
  171. dt.DefaultView.Sort = "CREATETIME DESC";
  172. dt = dt.DefaultView.ToTable();
  173. }
  174. GridHelper.CopyDataToDatatable(ref dt, ref dataTable1, true);//绑定物料分类表
  175. Q_mat = mat;
  176. }
  177. /// <summary>
  178. /// 添加
  179. /// </summary>
  180. public void AddPUR_MAT_CLASS()
  181. {
  182. try
  183. {
  184. if (txt_BASENAME.Text.Trim() == "")
  185. {
  186. MessageUtil.ShowTips("填写物料分类名称");
  187. return;
  188. }
  189. if (txt_BASECODE.Text.Trim() == "")
  190. {
  191. MessageUtil.ShowTips("填写物料分类编码");
  192. return;
  193. }
  194. PurmatclassEntity Purmatclass_Entity = new PurmatclassEntity();
  195. Purmatclass_Entity.Basecode = txt_BASECODE.Text;//分类编码
  196. if (isExsitRow("com.hnshituo.pur.configure.service.MatClassService", Purmatclass_Entity))//判断分类编码是否存在
  197. {
  198. MessageUtil.ShowTips("分类编码已存在,请重新输入");
  199. return;
  200. }
  201. Purmatclass_Entity.Basecode = null;
  202. Purmatclass_Entity.Basename = txt_BASENAME.Text;
  203. if (isExsitRow("com.hnshituo.pur.configure.service.MatClassService", Purmatclass_Entity))//判断分类名称是否存在
  204. {
  205. MessageUtil.ShowTips("数据库中已存在相同的分类名称,请重新输入");
  206. return;
  207. }
  208. if (ultraCheckEditor3.Checked)//添加物料大类
  209. {
  210. if (!IsCharacter(txt_BASECODE.Text))
  211. {
  212. MessageUtil.ShowTips("物料大类必须为单个大写英文字母,请重新输入");
  213. return;
  214. }
  215. Purmatclass_Entity.Parentcode = null;//如果添加大类,则分类编码null
  216. }
  217. else
  218. { Purmatclass_Entity.Parentcode = ultraTree1.ActiveNode.Key; }
  219. //else//添加物料小类
  220. //{
  221. // if (ultraTree1.ActiveNode == null)
  222. // {
  223. // MessageUtil.ShowTips("请选择左侧树形结构的节点");
  224. // return;
  225. // }
  226. // if (Q_mat.Parentcode == null)
  227. // {
  228. // MessageBox.Show("请选择父类节点或者勾“选添加物料大类”", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  229. // return;
  230. // }
  231. // Purmatclass_Entity.Basecode = getItemCodeClass(Q_mat.Parentcode);//分类编码
  232. // Purmatclass_Entity.Parentcode = ultraTree1.ActiveNode.Key;
  233. //}
  234. //判断分类名称是否存在
  235. //if (ultraGrid1.ActiveRow.Cells["BASENAME"].Value.ToString() != txt_BASENAME.Text)
  236. //{
  237. //Purmatclass_Entity.Basecode = null;
  238. //}
  239. Purmatclass_Entity.Parentcode = ultraTree1.ActiveNode.Key;
  240. Purmatclass_Entity.Basecode = txt_BASECODE.Text;//分类编码
  241. Purmatclass_Entity.Basename = txt_BASENAME.Text.Trim();//分类名称
  242. Purmatclass_Entity.CreateName = UserInfo.GetUserName();
  243. Purmatclass_Entity.CreateTime = System.DateTime.Now;//创建时间
  244. Purmatclass_Entity.CreateUserid = UserInfo.GetUserID();
  245. Purmatclass_Entity.Validflag = "1";
  246. CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.MatClassService", "doInsert", new object[] { Purmatclass_Entity });//添加操作
  247. if (crt.Resultcode != 0)
  248. {
  249. MessageUtil.ShowTips("添加失败 " + crt.Resultmsg);
  250. return;
  251. }
  252. MessageBox.Show("添加成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  253. if (ultraTree1.ActiveNode != null)
  254. {
  255. //查询物料分类
  256. PurmatclassEntity pmcE = new PurmatclassEntity();
  257. pmcE.Parentcode = ultraTree1.ActiveNode.Key;
  258. GetPUR_MAT_CLASS(pmcE);
  259. ConfigureClassCommon.doActiveSelRow(ultraGrid1, "BASECODE", Purmatclass_Entity.Basecode);//激活当前行
  260. //展开上次激活的节点
  261. if (ultraCheckEditor3.Checked)//添加根节点
  262. {
  263. ultraTree1.Nodes.Add(Purmatclass_Entity.Basecode, Purmatclass_Entity.Basename);
  264. }
  265. else
  266. {
  267. UltraTreeNode node = ultraTree1.ActiveNode;
  268. node.Nodes.Add(Purmatclass_Entity.Basecode, Purmatclass_Entity.Basename);
  269. }
  270. }
  271. }
  272. catch (Exception e)
  273. {
  274. MessageBox.Show(" 添加出现异常:" + e.Message, "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  275. return;
  276. }
  277. }
  278. /// <summary>
  279. /// 修改
  280. /// </summary>
  281. public void UpdPUR_MAT_CLASS()
  282. {
  283. try
  284. {
  285. if (MessageUtil.ShowYesNoAndQuestion("是否确定更新?") == DialogResult.No)
  286. {
  287. return;
  288. }
  289. if (ultraCheckEditor3.Checked)
  290. {
  291. MessageUtil.ShowTips("你已勾选“添加物料大类”复选框,不能进行修改操作");
  292. return;
  293. }
  294. if (txt_BASENAME.Text.Trim() == "")
  295. {
  296. MessageUtil.ShowTips("填写物料分类名称");
  297. return;
  298. }
  299. if (ultraGrid1.ActiveRow == null)
  300. {
  301. MessageBox.Show("请选择要修改的物料分类!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  302. return;
  303. }
  304. if (txt_BASECODE.Text.Trim() != ultraGrid1.ActiveRow.Cells["BASECODE"].Value.ToString().Trim())
  305. {
  306. MessageUtil.ShowTips("不能更新分类编码");
  307. //txt_BASECODE.Text = ultraGrid1.ActiveRow.Cells["BASECODE"].Value.ToString();
  308. return;
  309. }
  310. PurmatclassEntity Purmatclass_Entity = new PurmatclassEntity();
  311. if (txt_BASENAME.Text.Trim() != ultraGrid1.ActiveRow.Cells["BASENAME"].Value.ToString().Trim())
  312. {
  313. Purmatclass_Entity.Basename = txt_BASENAME.Text;
  314. if (isExsitRow("com.hnshituo.pur.configure.service.MatClassService", Purmatclass_Entity))//判断分类名称是否存在
  315. {
  316. MessageUtil.ShowTips("数据库中已存在相同的分类名称,请重新输入");
  317. return;
  318. }
  319. }
  320. Purmatclass_Entity.Basecode = ultraGrid1.ActiveRow.Cells["BASECODE"].Value.ToString();//分类编码
  321. Purmatclass_Entity.Basename = txt_BASENAME.Text;//分类名称
  322. Purmatclass_Entity.UpdateName = UserInfo.GetUserName();
  323. Purmatclass_Entity.UpdateUserid = UserInfo.GetUserID();
  324. Purmatclass_Entity.UpdateTime = System.DateTime.Now;//修改时间
  325. CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.MatClassService", "doUpdate", new object[] { Purmatclass_Entity });
  326. if (crt.Resultcode != 0)
  327. {
  328. MessageUtil.ShowTips("修改失败 " + crt.Resultmsg);
  329. return;
  330. }
  331. MessageBox.Show("修改成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  332. if (ultraTree1.ActiveNode != null)
  333. {
  334. //查询物料分类
  335. PurmatclassEntity pmcE = new PurmatclassEntity();
  336. pmcE.Parentcode = ultraTree1.ActiveNode.Key;
  337. GetPUR_MAT_CLASS(pmcE);
  338. ConfigureClassCommon.doActiveSelRow(ultraGrid1, "BASECODE", Purmatclass_Entity.Basecode);//激活当前行
  339. //展开上次激活的节点
  340. if (ultraTree1.ActiveNode.Parent != null)
  341. {
  342. UltraTreeNode node = ultraTree1.ActiveNode.Nodes[Purmatclass_Entity.Basecode];
  343. node.Text = Purmatclass_Entity.Basename;
  344. }
  345. else
  346. {
  347. ultraTree1.Nodes.Add(Purmatclass_Entity.Basecode, Purmatclass_Entity.Basename);
  348. }
  349. }
  350. }
  351. catch (Exception e)
  352. {
  353. MessageBox.Show("修改出现异常:" + e.Message, "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  354. return;
  355. }
  356. }
  357. /// <summary>
  358. /// 删除
  359. /// </summary>
  360. public void DelPUR_MAT_CLASS()
  361. {
  362. try
  363. {
  364. if (ultraGrid1.ActiveRow == null)
  365. {
  366. MessageBox.Show("请选择要删除的物料分类!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  367. return;
  368. }
  369. if (MessageUtil.ShowYesNoAndQuestion("确定要删除物料分类【" + ultraGrid1.ActiveRow.Cells["BASECODE"].Value.ToString() + "】?") == DialogResult.No)
  370. {
  371. return;
  372. }
  373. PurmatclassEntity Purmatclass_Entity = new PurmatclassEntity();
  374. Purmatclass_Entity.Parentcode = ultraGrid1.ActiveRow.Cells["BASECODE"].Value.ToString();//分类编码
  375. Purmatclass_Entity.Validflag = "1";
  376. if (this.execute<int>("com.hnshituo.pur.configure.service.MatClassService", "count", new object[] { Purmatclass_Entity }) > 0)
  377. {
  378. MessageUtil.ShowTips("分类编码【" + ultraGrid1.ActiveRow.Cells["BASECODE"].Value.ToString() + "】存在子节点,不能删除");
  379. return;
  380. }
  381. MatEntity mat = new MatEntity();
  382. mat.ArcCode = Purmatclass_Entity.Parentcode;
  383. mat.Validflag = "1";
  384. if (this.execute<int>("com.hnshituo.pur.configure.service.MatService", "count", new object[] { mat }) > 0)
  385. {
  386. MessageUtil.ShowTips("分类编码【" + ultraGrid1.ActiveRow.Cells["BASECODE"].Value.ToString() + "】存在物料,不能删除");
  387. return;
  388. }
  389. Purmatclass_Entity.Basecode = ultraGrid1.ActiveRow.Cells["BASECODE"].Value.ToString();//分类编码
  390. Purmatclass_Entity.DeleteName = UserInfo.GetUserName();
  391. Purmatclass_Entity.DeleteTime = System.DateTime.Now;//修改时间
  392. Purmatclass_Entity.DeleteUserid = UserInfo.GetUserID();//修改时间
  393. Purmatclass_Entity.Validflag = "0";
  394. CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.MatClassService", "doUpdate", new object[] { Purmatclass_Entity });
  395. if (crt.Resultcode != 0)
  396. {
  397. MessageUtil.ShowTips("删除失败 " + crt.Resultmsg);
  398. return;
  399. }
  400. if (Q_mat != null)
  401. {
  402. //查询物料分类
  403. PurmatclassEntity pmcE = new PurmatclassEntity();
  404. pmcE.Parentcode = ultraTree1.ActiveNode.Key;
  405. GetPUR_MAT_CLASS(pmcE);
  406. //展开上次激活的节点
  407. if (ultraTree1.ActiveNode != null)
  408. {
  409. UltraTreeNode node = ultraTree1.ActiveNode.Nodes[Purmatclass_Entity.Basecode];
  410. ultraTree1.ActiveNode.Nodes.Remove(node);
  411. }
  412. MessageBox.Show("删除成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  413. }
  414. }
  415. catch (Exception e)
  416. {
  417. MessageBox.Show("删除出现异常:" + e.Message, "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  418. return;
  419. }
  420. }
  421. /// <summary>
  422. /// 获取物料分类树形结构
  423. /// </summary>
  424. public void getultree()
  425. {
  426. PurmatclassEntity mat = new PurmatclassEntity();
  427. mat.Validflag = "1";
  428. DataTable dt = this.execute<DataTable>("com.hnshituo.pur.configure.service.MatClassService", "find", new object[] { mat, 0, 0 });
  429. if (dt == null || dt.Rows.Count < 1)
  430. {
  431. return;
  432. }
  433. DataTable dt_A = new DataTable();//物料分类
  434. //筛选出根节点
  435. DataRow[] rows = dt.Select("PARENTCODE='' or PARENTCODE is null");
  436. dt_A = dt.Clone(); //克隆A的结构
  437. foreach (DataRow row in rows)
  438. {
  439. dt_A.ImportRow(row);//复制行数据
  440. }
  441. dt_A.DefaultView.Sort = "basename";
  442. dt_A = dt_A.DefaultView.ToTable();
  443. //添加物料大类
  444. for (int j = 0; j < dt_A.Rows.Count; j++)
  445. {
  446. if (!ultraTree1.Nodes.Exists(dt_A.Rows[j]["BASECODE"].ToString()))
  447. {
  448. UltraTreeNode Ultnode = ultraTree1.Nodes.Add(dt_A.Rows[j]["BASECODE"].ToString(), dt_A.Rows[j]["BASENAME"].ToString());
  449. getChildNodes(Ultnode, dt);
  450. }
  451. }
  452. }
  453. /// <summary>
  454. /// 递归查询父节点下的所有子节点
  455. /// </summary>
  456. /// <param name="Tnode"></param>
  457. public void getChildNodes(UltraTreeNode Tnode, DataTable dt)
  458. {
  459. DataTable dt_A = dt.Clone();//物料分类
  460. DataRow[] rows = dt.Select("PARENTCODE='" + Tnode.Key + "'");
  461. foreach (DataRow row in rows)
  462. {
  463. dt_A.ImportRow(row);//复制行数据
  464. }
  465. //添加物料分类
  466. dt_A.DefaultView.Sort = "basename";
  467. dt_A = dt_A.DefaultView.ToTable();
  468. //添加物料分类
  469. for (int j = 0; j < dt_A.Rows.Count; j++)
  470. {
  471. UltraTreeNode Ultnode = Tnode.Nodes.Add(dt_A.Rows[j]["BASECODE"].ToString(), dt_A.Rows[j]["BASENAME"].ToString());
  472. getChildNodes(Ultnode, dt);//利用递归将当前节点的子节点添加进去
  473. }
  474. }
  475. /// <summary>
  476. /// 获取激活子节点
  477. /// </summary>
  478. /// <param name="Tnode"></param>
  479. public void ActiveChildNodes(UltraTreeNode Tnode)
  480. {
  481. Q_mat = new PurmatclassEntity();
  482. Q_mat.Validflag = "1";
  483. Q_mat.Parentcode = Tnode.Key;
  484. DataTable dt_A = this.execute<DataTable>("com.hnshituo.pur.configure.service.MatClassService", "find", new object[] { Q_mat, 0, 100 });
  485. for (int j = 0; j < dt_A.Rows.Count; j++)
  486. {
  487. UltraTreeNode Ultnode = Tnode.Nodes.Add(dt_A.Rows[j]["BASECODE"].ToString(), dt_A.Rows[j]["BASENAME"].ToString());
  488. ActiveChildNodes(Ultnode);//利用递归将当前节点的子节点添加进去
  489. }
  490. }
  491. //选中ultraGrid1激活行事件
  492. private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
  493. {
  494. txt_BASECODE.Text = ultraGrid1.ActiveRow.Cells["BASECODE"].Value.ToString();//分类编码
  495. txt_BASENAME.Text = ultraGrid1.ActiveRow.Cells["Basename"].Value.ToString();//分类名称
  496. //txt_BUYER_UNIT_CODE.Text = ultraGrid1.ActiveRow.Cells["BuyerUnitCode"].Value.ToString();//采购科室代码
  497. //txt_BUYER_POST.Text = ultraGrid1.ActiveRow.Cells["BuyerPost"].Value.ToString();//采购科室描叙
  498. }
  499. //选中 ultraTree1节点事件
  500. private void ultraTree1_AfterSelect(object sender, SelectEventArgs e)
  501. {
  502. ////清空
  503. //txt_BASECODE.Text = "";
  504. //txt_BASENAME.Text = "";
  505. //UltraTreeNode Ultnode = ultraTree1.ActiveNode;
  506. //GetPUR_MAT_CLASS(getEnSelContion(Ultnode.Key));
  507. }
  508. /// <summary>
  509. /// 筛选选中节点的子记录
  510. /// </summary>
  511. //public void getNodedt(UltraTreeNode Ultnode)
  512. //{
  513. // if (dt_Purmatclass != null && dt_Purmatclass.Rows.Count > 0)
  514. // {
  515. // DataTable dt_A = dt_Purmatclass.Clone();//物料分类
  516. // DataRow[] rows = dt_Purmatclass.Select("PARENTCODE='" + Ultnode.Key + "'");
  517. // foreach (DataRow row in rows)
  518. // {
  519. // dt_A.ImportRow(row);//复制行数据
  520. // }
  521. // dataTable1.Clear();
  522. // GridHelper.CopyDataToDatatable(ref dt_A, ref dataTable1, true);//绑定物料分类表
  523. // }
  524. //}
  525. //选中后自动展开
  526. private void ultraTree1_BeforeSelect(object sender, BeforeSelectEventArgs e)
  527. {
  528. //UltraTreeNode Ultnode = ultraTree1.ActiveNode;
  529. //Ultnode.Expanded = true;
  530. }
  531. /// <summary>
  532. /// 获取查询条件
  533. /// </summary>
  534. /// <returns></returns>
  535. private PurmatclassEntity getEnSelContion(string str)
  536. {
  537. PurmatclassEntity eMatClass = new PurmatclassEntity();
  538. if (str == null)
  539. {
  540. if (ultraTextEditor1.Text.Trim() != "")
  541. {
  542. eMatClass.Basecode = ultraTextEditor1.Text;
  543. }
  544. if (ultraTextEditor2.Text.Trim() != "")
  545. {
  546. eMatClass.Basename = ultraTextEditor2.Text;
  547. }
  548. }
  549. else
  550. {
  551. eMatClass.Parentcode = str;
  552. }
  553. eMatClass.Validflag = "1";
  554. return eMatClass;
  555. }
  556. /// <summary>
  557. /// 获取物料分类编码
  558. /// </summary>
  559. /// <param name="str"></param>
  560. /// <returns></returns>
  561. public string getItemCodeClass(string str)
  562. {
  563. string strChild = "";
  564. PurmatclassEntity mat = new PurmatclassEntity();
  565. mat.Parentcode = ultraTree1.ActiveNode.Key;
  566. int intChild = this.execute<int>("com.hnshituo.pur.configure.service.MatClassService", "count", new object[] { mat });
  567. intChild++;
  568. strChild = intChild.ToString();
  569. while (strChild.Length < 2)
  570. {
  571. strChild = "0" + strChild;
  572. }
  573. //判断编码是否存在
  574. PurmatclassEntity matIsExsitRow = new PurmatclassEntity();
  575. matIsExsitRow.Basecode = str + strChild;
  576. while (isExsitRow("com.hnshituo.pur.configure.service.MatClassService", matIsExsitRow))
  577. {
  578. intChild++;
  579. strChild = intChild.ToString();
  580. while (strChild.Length < 2)
  581. {
  582. strChild = "0" + strChild;
  583. }
  584. matIsExsitRow.Basecode = str + strChild;
  585. }
  586. return str + strChild;
  587. }
  588. /// <summary>
  589. /// 添加物料大类
  590. /// </summary>
  591. /// <param name="sender"></param>
  592. /// <param name="e"></param>
  593. private void ultraCheckEditor3_CheckedChanged(object sender, EventArgs e)
  594. {
  595. //txt_BASECODE.Enabled = ultraCheckEditor3.Checked;
  596. }
  597. private bool IsCharacter(string str)
  598. {
  599. if (str.Trim() != "" && str.Length == 1)
  600. {
  601. System.Text.ASCIIEncoding asciiEncoding = new System.Text.ASCIIEncoding();
  602. byte[] byteArray = asciiEncoding.GetBytes(str);
  603. if ((int)byteArray[0] >= 65 && (int)byteArray[0] <= 90)
  604. {
  605. return true;
  606. }
  607. }
  608. return false;
  609. }
  610. //判断物料中是否存在相同的列
  611. public bool isExsitRow(string strJavaPackName, object o)
  612. {
  613. DataTable dt = this.execute<DataTable>(strJavaPackName, "find", new object[] { o, 0, 0 });
  614. if (dt != null && dt.Rows.Count > 0)//存在相同的行
  615. {
  616. return true;
  617. }
  618. return false;
  619. }
  620. /// <summary>
  621. /// 单击grid行,自动展开左侧树形结构
  622. /// </summary>
  623. /// <param name="sender"></param>
  624. /// <param name="e"></param>
  625. private void ultraGrid1_ClickCell(object sender, ClickCellEventArgs e)
  626. {
  627. ExpNode(e.Cell.Row.Cells["BASECODE"].Value.ToString());
  628. }
  629. private void ExpNode(string strBASECODE)
  630. {
  631. UltraTreeNode uttNode = ultraTree1.GetNodeByKey(strBASECODE).Parent;
  632. if (uttNode == ultraTree1.ActiveNode)
  633. {
  634. return;
  635. }
  636. ultraTree1.CollapseAll();
  637. QclickQueryCell = true;
  638. if (uttNode == null)
  639. {
  640. ultraTree1.ActiveNode = ultraTree1.GetNodeByKey(strBASECODE);
  641. }
  642. else
  643. {
  644. ultraTree1.ActiveNode = uttNode;
  645. }
  646. ultraTree1.ActiveNode.Expanded = true;
  647. UltraTreeNode uttNodeExpand = ultraTree1.ActiveNode;
  648. while (uttNodeExpand.Parent != null)
  649. {
  650. uttNodeExpand = uttNodeExpand.Parent;
  651. uttNodeExpand.Expanded = true;
  652. }
  653. }
  654. /// <summary>
  655. /// 激活左侧树形结构
  656. /// </summary>
  657. /// <param name="sender"></param>
  658. /// <param name="e"></param>
  659. private void ultraTree1_AfterActivate(object sender, NodeEventArgs e)
  660. {
  661. //清空
  662. if (!QclickQueryCell)
  663. {
  664. txt_BASECODE.Text = "";
  665. txt_BASENAME.Text = "";
  666. UltraTreeNode Ultnode = ultraTree1.ActiveNode;
  667. Ultnode.Expanded = true;
  668. GetPUR_MAT_CLASS(getEnSelContion(Ultnode.Key));
  669. }
  670. QclickQueryCell = false;//设置未点击
  671. }
  672. private void ultraTree1_Click(object sender, EventArgs e)
  673. {
  674. }
  675. }
  676. }