FrmRegion.cs 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884
  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.Server;
  11. using Infragistics.Win.UltraWinGrid;
  12. using System.Collections;
  13. using Core.Mes.Client.Comm.Tool;
  14. using Core.Mes.Client.Comm.Control;
  15. namespace Core.StlMes.Client.SaleBase
  16. {
  17. public partial class FrmRegion : FrmBase
  18. {
  19. TreeNode tNode = new TreeNode();//保存上一次树点
  20. string strShift = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserOrder();
  21. string strTerm = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserGroup();
  22. string strOperator = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName();
  23. string regIonID = "";
  24. string nodeId = "";
  25. string region_no = "";
  26. DataTable isx = new DataTable();
  27. DataTable unLoad = new DataTable();
  28. protected override void OnLoad(EventArgs e)
  29. {
  30. try
  31. {
  32. base.OnLoad(e);
  33. ultraGridRegion.DisplayLayout.Override.FilterUIType = Infragistics.Win.UltraWinGrid.FilterUIType.FilterRow;
  34. ultraGridRegion.DisplayLayout.Override.FilterOperatorDefaultValue = Infragistics.Win.UltraWinGrid.FilterOperatorDefaultValue.Contains;
  35. //ultraGridRegion.DisplayLayout.Override.CellClickAction = Infragistics.Win.UltraWinGrid.CellClickAction.RowSelect;
  36. }
  37. catch (System.Exception ex)
  38. { }
  39. }
  40. public FrmRegion()
  41. {
  42. InitializeComponent();
  43. }
  44. /// <summary>
  45. /// 重写基类方法
  46. /// </summary>
  47. /// <param name="sender"></param>
  48. /// <param name="ToolbarKey"></param>
  49. public override void ToolBar_Click(object sender, string ToolbarKey)
  50. {
  51. switch (ToolbarKey)
  52. {
  53. case "doQuery":
  54. doQuery();
  55. break;
  56. case "doAdd":
  57. if (string.IsNullOrEmpty(txtName.Text))
  58. {
  59. MessageUtil.ShowTips("区域名称不允许为空!");
  60. return;
  61. }
  62. if (string.IsNullOrEmpty(ComboEdiRegPro.Text))
  63. {
  64. MessageUtil.ShowTips("区域属性不允许为空!");
  65. return;
  66. }
  67. if (string.IsNullOrEmpty(ComboEditorPro.Text))
  68. {
  69. MessageUtil.ShowTips("上级区域不允许为空!");
  70. return;
  71. }
  72. if (comboRegIon.SelectedItem == null || comboRegIon.Text.Equals(""))
  73. {
  74. MessageUtil.ShowWarning("请选择[行政片区]!");
  75. return ;
  76. }
  77. if (MessageUtil.ShowQuestion("是否新增数据?").ToString().ToLower().Equals("yes"))
  78. {
  79. string dosave = doSave();
  80. if (dosave.Equals("doAddTrue"))
  81. {
  82. MessageUtil.ShowTips("添加成功!");
  83. }
  84. else if (dosave.Equals("doAddFalse"))
  85. {
  86. MessageUtil.ShowTips("添加失败!");
  87. return;
  88. }
  89. else if (dosave.Equals("saveCoint"))
  90. {
  91. MessageUtil.ShowTips("已经维护!");
  92. return;
  93. }
  94. else if (dosave.Equals("updateTrue"))
  95. {
  96. MessageUtil.ShowTips("添加成功!");
  97. }
  98. else if (dosave.Equals("updateFalse"))
  99. {
  100. MessageUtil.ShowTips("添加失败!");
  101. return;
  102. }
  103. regIonCode();
  104. try {
  105. doQueryClick(ComboEditorPro.Value.ToString());
  106. }catch(Exception){}
  107. QueryTree();
  108. }
  109. break;
  110. case "doDelete":
  111. if (ultraGridRegion.ActiveRow == null)
  112. {
  113. MessageUtil.ShowTips("未找到需要操作的数据!");
  114. return;
  115. }
  116. if (string.IsNullOrEmpty(regIonID))
  117. {
  118. MessageUtil.ShowTips("请选择需要作废的数据!");
  119. return;
  120. }
  121. foreach (UltraGridRow ugr in this.ultraGridRegion.Rows)
  122. {
  123. if (ugr.Cells["REGION_NO"].Value.ToString().Equals(regIonID))
  124. {
  125. if (ugr.Cells["VALIDFLAG"].Value.ToString().Equals("无效"))
  126. {
  127. MessageUtil.ShowTips("数据无效不能重复操作!");
  128. return;
  129. }
  130. }
  131. }
  132. if (MessageUtil.ShowQuestion("是否作废数据?").ToString().ToLower().Equals("yes"))
  133. {
  134. if (doDelete())
  135. {
  136. MessageUtil.ShowTips("作废成功!");
  137. }
  138. else
  139. {
  140. MessageUtil.ShowTips("作废失败!");
  141. return;
  142. }
  143. regIonCode();
  144. try
  145. {
  146. doQueryClick(ComboEditorPro.Value.ToString());
  147. }catch( Exception){
  148. }
  149. QueryTree();
  150. //doQuery();
  151. }
  152. break;
  153. //case "doRecovery":
  154. // if (ultraGridRegion.ActiveRow == null)
  155. // {
  156. // MessageUtil.ShowTips("未找到需要操作的数据!");
  157. // return;
  158. // }
  159. // if (string.IsNullOrEmpty(regIonID))
  160. // {
  161. // MessageUtil.ShowTips("请选择需要恢复的数据!");
  162. // return;
  163. // }
  164. // foreach (UltraGridRow ugr in this.ultraGridRegion.Rows)
  165. // {
  166. // if (ugr.Cells["REGION_NO"].Value.ToString().Equals(regIonID))
  167. // {
  168. // if (ugr.Cells["VALIDFLAG"].Value.ToString().Equals("有效"))
  169. // {
  170. // MessageUtil.ShowTips("数据有效不能恢复!");
  171. // return;
  172. // }
  173. // }
  174. // }
  175. // if (MessageUtil.ShowQuestion("是否恢复数据?").ToString().ToLower().Equals("yes"))
  176. // {
  177. // if (doResume())
  178. // {
  179. // MessageUtil.ShowTips("恢复成功!");
  180. // }
  181. // else
  182. // {
  183. // MessageUtil.ShowTips("恢复失败!");
  184. // return;
  185. // }
  186. // doQueryClick(ComboEditorPro.Value == null ? "" : ComboEditorPro.Value.ToString());
  187. // }
  188. // break;
  189. case "doUpdate":
  190. if (ultraGridRegion.ActiveRow == null)
  191. {
  192. MessageUtil.ShowWarning("请选择一行您要修改的数据!");
  193. return ;
  194. }
  195. if (string.IsNullOrEmpty(txtName.Text))
  196. {
  197. MessageUtil.ShowTips("区域名称不允许为空!");
  198. return;
  199. }
  200. if (string.IsNullOrEmpty(ComboEdiRegPro.Text))
  201. {
  202. MessageUtil.ShowTips("区域属性不允许为空!");
  203. return;
  204. }
  205. if (string.IsNullOrEmpty(ComboEditorPro.Text))
  206. {
  207. MessageUtil.ShowTips("上级区域不允许为空!");
  208. return;
  209. }
  210. if (string.IsNullOrEmpty(comboRegIon.Text))
  211. {
  212. MessageUtil.ShowTips("行政片区不允许为空!");
  213. return;
  214. }
  215. if (string.IsNullOrEmpty(regIonID))
  216. {
  217. MessageUtil.ShowTips("请选择需要修改的数据!");
  218. return;
  219. }
  220. if (MessageUtil.ShowQuestion("是否修改数据?").ToString().ToLower().Equals("yes"))
  221. {
  222. if (doUpdate())
  223. {
  224. MessageUtil.ShowTips("修改成功!");
  225. }
  226. else
  227. {
  228. //MessageUtil.ShowTips("修改失败!");
  229. return;
  230. }
  231. regIonCode();
  232. try
  233. {
  234. doQueryClick(ComboEditorPro.Value.ToString());
  235. }
  236. catch (Exception)
  237. {
  238. }
  239. QueryTree();
  240. }
  241. break;
  242. case "doClose":
  243. this.Close();
  244. break;
  245. }
  246. }
  247. //查询
  248. public void doQuery()
  249. {
  250. QueryTree();
  251. //if (nodeId != "")
  252. //{
  253. // doQueryClick(nodeId);
  254. // return;
  255. //}
  256. DataTable dts = ServerHelper.GetData("com.steering.pss.sale.base.CoreRegion.GetQueryReg", new Object[] { }, this.ob);
  257. uldtsCoupling.Tables[0].Clear();
  258. foreach (DataRow dr in dts.Rows)
  259. {
  260. DataRow _dr = uldtsCoupling.Tables[0].NewRow();
  261. foreach (DataColumn dc in uldtsCoupling.Tables[0].Columns)
  262. {
  263. _dr[dc.ColumnName] = dr[dc.ColumnName];
  264. }
  265. uldtsCoupling.Tables[0].Rows.Add(_dr);
  266. }
  267. foreach (UltraGridRow ugr in this.ultraGridRegion.Rows)
  268. {
  269. if (ugr.Cells["VALIDFLAG"].Value.ToString().ToLower() == "0")
  270. {
  271. ugr.Cells["VALIDFLAG"].Value = "无效";
  272. this.ultraGridRegion.Rows[ugr.Index].CellAppearance.ForeColor = Color.Red;
  273. }
  274. if (ugr.Cells["VALIDFLAG"].Value.ToString().ToLower() == "1")
  275. {
  276. ugr.Cells["VALIDFLAG"].Value = "有效";
  277. }
  278. if (ugr.Cells["REGION_NM"].Value.ToString().Equals(region_no))
  279. {
  280. ugr.Activate();
  281. }
  282. else if (ugr.Cells["REGION_NO"].Value.ToString().Equals(region_no))
  283. {
  284. ugr.Activate();
  285. }
  286. }
  287. //内容自适应
  288. GridHelper.RefreshAndAutoSizeExceptRows(ultraGridRegion, new UltraGridColumn[] {
  289. ultraGridRegion.DisplayLayout.Bands[0].Columns["MEMO"]
  290. });
  291. }
  292. //单击树形视图查询
  293. public void doQueryClick(string regIon)
  294. {
  295. DataTable dts = ServerHelper.GetData("com.steering.pss.sale.base.CoreRegion.GetQueryRegIonCode", new Object[] { regIon }, this.ob);
  296. uldtsCoupling.Tables[0].Clear();
  297. foreach (DataRow dr in dts.Rows)
  298. {
  299. DataRow _dr = uldtsCoupling.Tables[0].NewRow();
  300. foreach (DataColumn dc in uldtsCoupling.Tables[0].Columns)
  301. {
  302. _dr[dc.ColumnName] = dr[dc.ColumnName];
  303. }
  304. uldtsCoupling.Tables[0].Rows.Add(_dr);
  305. }
  306. foreach (UltraGridRow ugr in this.ultraGridRegion.Rows)
  307. {
  308. if (ugr.Cells["VALIDFLAG"].Value.ToString().ToLower() == "0")
  309. {
  310. ugr.Cells["VALIDFLAG"].Value = "无效";
  311. this.ultraGridRegion.Rows[ugr.Index].CellAppearance.ForeColor = Color.Red;
  312. }
  313. if (ugr.Cells["VALIDFLAG"].Value.ToString().ToLower() == "1")
  314. {
  315. ugr.Cells["VALIDFLAG"].Value = "有效";
  316. }
  317. if (ugr.Cells["REGION_NM"].Value.ToString().Equals(region_no))
  318. {
  319. ugr.Activate();
  320. }
  321. else if (ugr.Cells["REGION_NO"].Value.ToString().Equals(region_no))
  322. {
  323. ugr.Activate();
  324. }
  325. }
  326. //内容自适应
  327. GridHelper.RefreshAndAutoSizeExceptRows(ultraGridRegion, new UltraGridColumn[] {
  328. ultraGridRegion.DisplayLayout.Bands[0].Columns["MEMO"]
  329. });
  330. }
  331. //保存
  332. public string doSave()
  333. {
  334. if (string.IsNullOrEmpty(ComboEditorPro.Text))
  335. {
  336. MessageUtil.ShowTips("请选择[上级区域],不允许为空!");
  337. return "xxx";
  338. }
  339. if (string.IsNullOrEmpty(ComboEdiRegPro.Text))
  340. {
  341. MessageUtil.ShowTips("请选择[区域属性],不允许为空!");
  342. return "xxx";
  343. }
  344. if (string.IsNullOrEmpty(txtName.Text))
  345. {
  346. MessageUtil.ShowTips("请选择[区域名称],不允许为空!");
  347. return "xxx";
  348. }
  349. if (txtName.Text.Equals("/"))
  350. {
  351. MessageUtil.ShowTips("请选择[区域名称],不允许填 / !");
  352. return "xxx";
  353. }
  354. //if (string.IsNullOrEmpty(comboRegIon.Text))
  355. //{
  356. // MessageUtil.ShowTips("行政片区不允许为空!");
  357. // return "xxx";
  358. //}
  359. //区域名称
  360. string regName = txtName.Text;
  361. //属性区域
  362. string regionno = ComboEdiRegPro.Text;
  363. string regionnm = ComboEdiRegPro.Value.ToString();
  364. //上级区域
  365. string pregionno = ComboEditorPro.Text == "" ? " " : ComboEditorPro.Text;
  366. string regiontype = ComboEditorPro.Value == null? " " : ComboEditorPro.Value.ToString();
  367. //行政片区
  368. string bigareaName = comboRegIon.Text == "" ? " " : comboRegIon.Text.ToString();
  369. string bigareaCode = comboRegIon.Value == null ? " " : comboRegIon.Value.ToString();
  370. //根据名称查找数据,如果有数据,而且是有效的,提示不允许新增。
  371. DataTable countDb = ServerHelper.GetData("com.steering.pss.sale.base.CoreRegion.saveQueryName", new Object[] { regName }, this.ob);
  372. if (countDb.Rows.Count > 0)
  373. {
  374. MessageUtil.ShowTips("请重新输入[区域名称],区域名称存在!");
  375. return "xxx";
  376. }
  377. DataTable dts = ServerHelper.GetData("com.steering.pss.sale.base.CoreRegion.GetSaveQuery", new Object[] { regName, regiontype }, this.ob);
  378. ArrayList parm = new ArrayList();
  379. CoreClientParam ccp = new CoreClientParam();
  380. if (dts.Rows.Count > 0)
  381. {
  382. if (dts.Rows[0]["VALIDFLAG"].ToString().Equals("1"))
  383. {
  384. return "saveCoint";
  385. }
  386. else if (dts.Rows[0]["VALIDFLAG"].ToString().Equals("0"))
  387. {
  388. parm = new ArrayList();
  389. parm.Add("1"); //0恢复
  390. parm.Add(dts.Rows[0]["REGION_NO"].ToString()); //ID
  391. ccp = new CoreClientParam();
  392. ccp.ServerName = "com.steering.pss.sale.base.CoreRegion";
  393. ccp.MethodName = "SetResumeIon";
  394. ccp.ServerParams = new object[] { parm };
  395. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  396. if (ccp.ReturnCode == -1)
  397. {
  398. return "updateFalse";
  399. }
  400. region_no = regName;
  401. return "updateTrue";
  402. }
  403. }
  404. parm = new ArrayList();
  405. parm.Add(regiontype); //如果是区域首次默认上级+01.
  406. parm.Add(regiontype); //如果是区域首次默认Where.
  407. parm.Add(regName); //区域名称
  408. parm.Add(regiontype); //上级区域代码
  409. parm.Add(regionnm);
  410. parm.Add(regiontype); //上级区域代码
  411. parm.Add(this.textBoxMemo.Text);
  412. parm.Add(strOperator);
  413. parm.Add(bigareaCode);//行政片区
  414. ccp = new CoreClientParam();
  415. ccp.ServerName = "com.steering.pss.sale.base.CoreRegion";
  416. ccp.MethodName = "SetAddRegion";
  417. ccp.ServerParams = new object[] { parm };
  418. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  419. if (ccp.ReturnCode == -1)
  420. {
  421. return "doAddFalse";
  422. }
  423. region_no = regName;
  424. return "doAddTrue";
  425. }
  426. //0删除,1恢复
  427. public bool doDelete()
  428. {
  429. if (string.IsNullOrEmpty(regIonID))
  430. {
  431. MessageUtil.ShowTips("请选择需要修改的数据!");
  432. return false;
  433. }
  434. ArrayList parm = new ArrayList();
  435. parm.Add("0"); //0删除
  436. parm.Add(strOperator);//删除人
  437. parm.Add(regIonID); //ID
  438. CoreClientParam ccp = new CoreClientParam();
  439. ccp.ServerName = "com.steering.pss.sale.base.CoreRegion";
  440. ccp.MethodName = "SetDleteRegion";
  441. ccp.ServerParams = new object[] { parm };
  442. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  443. if (ccp.ReturnCode == -1)
  444. {
  445. return false;
  446. }
  447. return true;
  448. }
  449. //恢复
  450. public bool doResume()
  451. {
  452. if (string.IsNullOrEmpty(regIonID))
  453. {
  454. MessageUtil.ShowTips("请选择需要修改的数据!");
  455. return false;
  456. }
  457. ArrayList parm = new ArrayList();
  458. parm.Add("1"); //0恢复
  459. parm.Add(regIonID); //ID
  460. CoreClientParam ccp = new CoreClientParam();
  461. ccp.ServerName = "com.steering.pss.sale.base.CoreRegion";
  462. ccp.MethodName = "SetResumeIon";
  463. ccp.ServerParams = new object[] { parm };
  464. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  465. if (ccp.ReturnCode == -1)
  466. {
  467. return false;
  468. }
  469. return true;
  470. }
  471. //修改
  472. public bool doUpdate()
  473. {
  474. if (string.IsNullOrEmpty(regIonID))
  475. {
  476. MessageUtil.ShowTips("请选择需要修改的数据!");
  477. return false;
  478. }
  479. if (string.IsNullOrEmpty(txtName.Text))
  480. {
  481. MessageUtil.ShowTips("区域名称不允许为空!");
  482. return false;
  483. }
  484. if (string.IsNullOrEmpty(ComboEdiRegPro.Text))
  485. {
  486. MessageUtil.ShowTips("属性区域不允许为空!");
  487. return false;
  488. }
  489. if (string.IsNullOrEmpty(ComboEditorPro.Text))
  490. {
  491. MessageUtil.ShowTips("上级区域不允许为空!");
  492. return false;
  493. }
  494. if (string.IsNullOrEmpty(comboRegIon.Text))
  495. {
  496. MessageUtil.ShowTips("行政区域不允许为空!");
  497. return false;
  498. }
  499. if (ultraGridRegion.ActiveRow != null && !ultraGridRegion.ActiveRow.Cells["REGION_NM"].Value.ToString().Equals(txtName.Text))
  500. {
  501. DataTable dts = ServerHelper.GetData("com.steering.pss.sale.base.CoreRegion.GetSaveQuery", new Object[] { txtName.Text, ComboEditorPro.Value }, this.ob);
  502. if (dts.Rows.Count > 0)
  503. {
  504. MessageUtil.ShowTips("城市名称已存在,不能修改!");
  505. return false;
  506. }
  507. }
  508. ArrayList parm = new ArrayList();
  509. parm.Add(txtName.Text); //0恢复
  510. parm.Add(ComboEdiRegPro.Value); //type
  511. parm.Add(textBoxMemo.Text);//备注
  512. parm.Add(strOperator);//修改人
  513. parm.Add(comboRegIon.Value == null ? " " : comboRegIon.Value.ToString());//行政片区
  514. parm.Add(ComboEditorPro.Value);
  515. parm.Add(regIonID);//ID
  516. CoreClientParam ccp = new CoreClientParam();
  517. ccp.ServerName = "com.steering.pss.sale.base.CoreRegion";
  518. ccp.MethodName = "SetUpdateIon";
  519. ccp.ServerParams = new object[] { parm };
  520. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  521. if (ccp.ReturnCode == -1)
  522. {
  523. return false;
  524. }
  525. region_no = regIonID;
  526. return true;
  527. }
  528. private void frmRegion_Load(object sender, EventArgs e)
  529. {
  530. regIonCode();
  531. //this.treeRegion.Parent.Font = new Font("宋体", 8F, System.Drawing.FontStyle.Bold);
  532. //this.treeRegion.BackColor = Color.Empty;
  533. QueryTree();//刷新树结构
  534. ClsBaseInfo.SetComboItemHeight(ComboEditorPro);
  535. ClsBaseInfo.SetComboItemHeight(ComboEdiRegPro);
  536. ClsBaseInfo.SetComboItemHeight(comboRegIon);
  537. }
  538. //加载区域和上级区域属性
  539. private void regIonCode()
  540. {
  541. unLoad = new DataTable();
  542. unLoad.Columns.Add("Name", typeof(System.String));
  543. unLoad.Columns.Add("Code", typeof(System.String));
  544. //查询区域属性
  545. isx = ServerHelper.GetData("com.steering.pss.sale.base.CoreRegion.GetRegIonCodeS", new Object[] { }, this.ob);
  546. for (int i = 0; i < isx.Rows.Count; i++)
  547. {
  548. unLoad.Rows.Add(isx.Rows[i]["REGION_TYPE_NM"].ToString(), isx.Rows[i]["REGION_TYPE_NO"].ToString());
  549. }
  550. ComboEdiRegPro.DataSource = unLoad;
  551. ComboEdiRegPro.DisplayMember = "Name";
  552. ComboEdiRegPro.ValueMember = "Code";
  553. //查询上级区域属性
  554. isx = new DataTable();
  555. unLoad = new DataTable();
  556. unLoad.Columns.Add("Name", typeof(System.String));
  557. unLoad.Columns.Add("Code", typeof(System.String));
  558. isx = ServerHelper.GetData("com.steering.pss.sale.base.CoreRegion.GetSelAdminRegion", new Object[] { }, this.ob);
  559. for (int i = 0; i < isx.Rows.Count; i++)
  560. {
  561. unLoad.Rows.Add(isx.Rows[i]["REGION_NM"].ToString(), isx.Rows[i]["REGION_NO"].ToString());
  562. }
  563. ComboEditorPro.DataSource = unLoad;
  564. ComboEditorPro.DisplayMember = "Name";
  565. ComboEditorPro.ValueMember = "Code";
  566. //行政片区
  567. isx = ServerHelper.GetData("com.steering.pss.sale.base.CoreBuyerOrder.GetQueryBaseInfo", new Object[] { "1007" }, this.ob);
  568. unLoad = new DataTable();
  569. unLoad.Columns.Add("BASENAME", typeof(System.String));
  570. unLoad.Columns.Add("BASECODE", typeof(System.String));
  571. for (int i = 0; i < isx.Rows.Count; i++)
  572. {
  573. unLoad.Rows.Add(isx.Rows[i]["BASENAME"].ToString(), isx.Rows[i]["BASECODE"].ToString());
  574. }
  575. DataRow dr = unLoad.NewRow();
  576. unLoad.Rows.Add(dr);
  577. comboRegIon.DataSource = unLoad;
  578. comboRegIon.DisplayMember = "BASENAME";
  579. comboRegIon.ValueMember = "BASECODE";
  580. }
  581. //刷新Tree
  582. public void QueryTree()
  583. {
  584. this.treeRegion.Nodes.Clear();
  585. DataTable dt = new DataTable();
  586. dt = ServerHelper.GetData("com.steering.pss.sale.base.CoreRegion.GetTivCode", new Object[] { }, this.ob);
  587. //树控件递归绑定方法。
  588. Bind_Tv(dt, treeRegion.Nodes, null, "REGION_NO", "P_REGION_NO", "REGION_NM");
  589. if (!string.IsNullOrEmpty(tNode.Name))
  590. {
  591. for (int e = 0; e < this.treeRegion.Nodes.Count; e++)
  592. {
  593. //展开一级节点
  594. //if (this.treeRegion.Nodes[e].Name.Equals(tNode.Name))
  595. //{
  596. // this.treeRegion.Nodes[e].Expand();
  597. // return;
  598. //}
  599. //展开二级节点
  600. for (int w = 0; w < this.treeRegion.Nodes[e].Nodes.Count; w++)
  601. {
  602. if (this.treeRegion.Nodes[e].Nodes[w].Name.Equals(tNode.Name))
  603. {
  604. this.treeRegion.Nodes[e].Expand();
  605. this.treeRegion.Nodes[e].Nodes[w].ExpandAll();
  606. return;
  607. }
  608. }
  609. //展开三级子节点
  610. for (int w = 0; w < this.treeRegion.Nodes[e].Nodes.Count; w++)
  611. {
  612. for (int r = 0; r < this.treeRegion.Nodes[e].Nodes[w].Nodes.Count; r++)
  613. {
  614. if (this.treeRegion.Nodes[e].Nodes[w].Nodes[r].Name.Equals(tNode.Name))
  615. {
  616. this.treeRegion.Nodes[e].Expand();
  617. this.treeRegion.Nodes[e].Nodes[w].Expand();
  618. this.treeRegion.Nodes[e].Nodes[w].Nodes[r].ExpandAll();
  619. return;
  620. }
  621. }
  622. }
  623. //展开四级子节点
  624. for (int w = 0; w < this.treeRegion.Nodes[e].Nodes.Count; w++)
  625. {
  626. for (int r = 0; r < this.treeRegion.Nodes[e].Nodes[w].Nodes.Count; r++)
  627. {
  628. for (int x = 0; x < this.treeRegion.Nodes[e].Nodes[w].Nodes[r].Nodes.Count; x++)
  629. {
  630. if (this.treeRegion.Nodes[e].Nodes[w].Nodes[r].Nodes[x].Name.Equals(tNode.Name))
  631. {
  632. this.treeRegion.Nodes[e].Expand();
  633. this.treeRegion.Nodes[e].Nodes[w].Expand();
  634. this.treeRegion.Nodes[e].Nodes[w].Nodes[r].Expand();
  635. this.treeRegion.Nodes[e].Nodes[w].Nodes[r].Nodes[x].ExpandAll();
  636. return;
  637. }
  638. }
  639. }
  640. }
  641. //展开五级子节点
  642. for (int w = 0; w < this.treeRegion.Nodes[e].Nodes.Count; w++)
  643. {
  644. for (int r = 0; r < this.treeRegion.Nodes[e].Nodes[w].Nodes.Count; r++)
  645. {
  646. for (int x = 0; x < this.treeRegion.Nodes[e].Nodes[w].Nodes[r].Nodes.Count; x++)
  647. {
  648. for (int j = 0; j < this.treeRegion.Nodes[e].Nodes[w].Nodes[r].Nodes[x].Nodes.Count; j++)
  649. {
  650. if (this.treeRegion.Nodes[e].Nodes[w].Nodes[r].Nodes[x].Nodes[j].Name.Equals(tNode.Name))
  651. {
  652. this.treeRegion.Nodes[e].Expand();
  653. this.treeRegion.Nodes[e].Nodes[w].Expand();
  654. this.treeRegion.Nodes[e].Nodes[w].Nodes[r].Expand();
  655. this.treeRegion.Nodes[e].Nodes[w].Nodes[r].Nodes[x].ExpandAll();
  656. this.treeRegion.Nodes[e].Nodes[w].Nodes[r].Nodes[j].ExpandAll();
  657. return;
  658. }
  659. }
  660. }
  661. }
  662. }
  663. }
  664. }
  665. }
  666. /// <summary>
  667. /// 绑定TreeView(利用TreeNodeCollection)
  668. /// </summary>
  669. /// <param name="tnc">TreeNodeCollection(TreeView的节点集合)</param>
  670. /// <param name="pid_val">父id的值</param>
  671. /// <param name="id">数据库 id 字段名</param>
  672. /// <param name="pid">数据库 父id 字段名</param>
  673. /// <param name="text">数据库 文本 字段值</param>
  674. private void Bind_Tv(DataTable dt, TreeNodeCollection tnc, string pid_val, string id, string pid, string text)
  675. {
  676. DataView dv = new DataView(dt);//将DataTable存到DataView中,以便于筛选数据
  677. TreeNode tn;//建立TreeView的节点(TreeNode),以便将取出的数据添加到节点中
  678. //以下为三元运算符,如果父id为空,则为构建“父id字段 is null”的查询条件,否则构建“父id字段=父id字段值”的查询条件
  679. string filter = string.IsNullOrEmpty(pid_val) ? pid + " is null" : string.Format(pid + "='{0}'", pid_val);
  680. dv.RowFilter = filter;//利用DataView将数据进行筛选,选出相同 父id值 的数据
  681. foreach (DataRowView drv in dv)
  682. {
  683. tn = new TreeNode();//建立一个新节点(学名叫:一个实例)
  684. tn.Tag = drv[id].ToString();//节点的Value值,一般为数据库的id值
  685. tn.Text = drv[text].ToString();//节点的Text,节点的文本显示
  686. tn.Name = drv["REGION_LVL_NO"].ToString();//区域属性代码
  687. tn.ImageKey = drv["REGION_LVL_NM"].ToString();
  688. if (!string.IsNullOrEmpty(drv["P_REGION_NO"].ToString()))
  689. {
  690. tn.ToolTipText = drv["P_REGION_NO"].ToString();
  691. }
  692. else
  693. {
  694. tn.ImageIndex = 0;
  695. }
  696. tnc.Add(tn);//将该节点加入到TreeNodeCollection(节点集合)中
  697. Bind_Tv(dt, tn.Nodes, tn.Tag.ToString(), id, pid, text);//递归(反复调用这个方法,直到把数据取完为止)
  698. }
  699. }
  700. private void treeRegion_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
  701. {
  702. //选择节点改变字体大小
  703. if (tNode.Text.Trim() != "")
  704. {
  705. tNode.NodeFont = new Font("宋体", 8F, System.Drawing.FontStyle.Bold);
  706. tNode.BackColor = Color.Empty;
  707. }
  708. e.Node.NodeFont = new Font("宋体", 9F, System.Drawing.FontStyle.Underline);
  709. e.Node.BackColor = Color.Empty;
  710. e.Node.BackColor = Color.LightBlue;
  711. tNode = e.Node;
  712. //查询上级区域属性
  713. isx = new DataTable();
  714. unLoad = new DataTable();
  715. unLoad.Columns.Add("Name", typeof(System.String));
  716. unLoad.Columns.Add("Code", typeof(System.String));
  717. isx = ServerHelper.GetData("com.steering.pss.sale.base.CoreRegion.GetSelAdminRegionFilter", new Object[] { tNode.Tag.ToString() }, this.ob);
  718. for (int i = 0; i < isx.Rows.Count; i++)
  719. {
  720. unLoad.Rows.Add(isx.Rows[i]["REGION_NM"].ToString(), isx.Rows[i]["REGION_NO"].ToString());
  721. }
  722. ComboEditorPro.DataSource = unLoad;
  723. ComboEditorPro.DisplayMember = "Name";
  724. ComboEditorPro.ValueMember = "Code";
  725. ////保存上一级区域属性信息
  726. //if (!string.IsNullOrEmpty(e.Node.ImageKey))
  727. //{
  728. // ComboEditorPro.Text = e.Node.ImageKey;
  729. // ComboEditorPro.Value = e.Node.ToolTipText;
  730. //}
  731. //保存上一级区域属性信息
  732. if (unLoad.Rows.Count > 0)
  733. {
  734. ComboEditorPro.Text = unLoad.Rows[0][0].ToString();
  735. ComboEditorPro.Value = unLoad.Rows[0][1].ToString();
  736. }
  737. //查询区域属性
  738. //string indexCode = "";
  739. //string indexName = e.Node.Text.Substring(0, e.Node.Text.IndexOf(" ")).Trim();
  740. //ComboEdiRegPro.Text = indexName;
  741. txtName.Text = e.Node.Text.Substring(e.Node.Text.IndexOf(" ")).Trim();
  742. DataTable countDb = ServerHelper.GetData("com.steering.pss.sale.base.CoreRegion.saveQueryName", new Object[] { txtName.Text }, this.ob);
  743. if (countDb.Rows.Count > 0)
  744. {
  745. comboRegIon.Value = countDb.Rows[0]["BIGAREA"].ToString();
  746. }
  747. doQueryClick(e.Node.Tag.ToString());
  748. nodeId = e.Node.Tag.ToString();
  749. }
  750. private void ultraGridRegion_Click(object sender, EventArgs e)
  751. {
  752. DataTable unLoad = new DataTable();
  753. unLoad.Columns.Add("Name", typeof(System.String));
  754. unLoad.Columns.Add("Code", typeof(System.String));
  755. if (this.ultraGridRegion.Rows.Count > 0)
  756. {
  757. //查询区域属性
  758. ComboEdiRegPro.Text = this.ultraGridRegion.DisplayLayout.ActiveRow.Cells["REGION_TYPE_NM"].Text.Trim();
  759. ComboEdiRegPro.Value = this.ultraGridRegion.DisplayLayout.ActiveRow.Cells["REGION_TYPE_NO"].Value.ToString();
  760. regIonID = this.ultraGridRegion.DisplayLayout.ActiveRow.Cells["REGION_NO"].Value.ToString(); //修改使用的id
  761. this.txtName.Text = this.ultraGridRegion.DisplayLayout.ActiveRow.Cells["REGION_NM"].Text.Trim();
  762. textBoxMemo.Text = this.ultraGridRegion.DisplayLayout.ActiveRow.Cells["MEMO"].Text.Trim();
  763. this.comboRegIon.Text = this.ultraGridRegion.DisplayLayout.ActiveRow.Cells["BIGAREA"].Text.Trim();
  764. //保存上一级区域属性信息
  765. if (!string.IsNullOrEmpty(this.ultraGridRegion.DisplayLayout.ActiveRow.Cells["P_REGION_NO"].Value.ToString()))
  766. {
  767. ComboEditorPro.Text = this.ultraGridRegion.DisplayLayout.ActiveRow.Cells["P_REGION_NM"].Value.ToString();
  768. ComboEditorPro.Value = this.ultraGridRegion.DisplayLayout.ActiveRow.Cells["P_REGION_NO"].Value.ToString();
  769. }
  770. }
  771. }
  772. private void ComboEditorPro_TextChanged(object sender, EventArgs e)
  773. {
  774. if (!string.IsNullOrEmpty(ComboEditorPro.Text))
  775. {
  776. DataTable unLoad = new DataTable();
  777. unLoad.Columns.Add("Name", typeof(System.String));
  778. unLoad.Columns.Add("Code", typeof(System.String));
  779. //查询区域属性
  780. isx = ServerHelper.GetData("com.steering.pss.sale.base.CoreRegion.GetRegIonCodeNo", new Object[] { ComboEditorPro.Value }, this.ob);
  781. for (int i = 0; i < isx.Rows.Count; i++)
  782. {
  783. unLoad.Rows.Add(isx.Rows[i]["REGION_TYPE_NM"].ToString(), isx.Rows[i]["REGION_TYPE_NO"].ToString());
  784. }
  785. ComboEdiRegPro.DataSource = unLoad;
  786. ComboEdiRegPro.DisplayMember = "Name";
  787. ComboEdiRegPro.ValueMember = "Code";
  788. }
  789. }
  790. private void txtName_TextChanged(object sender, EventArgs e)
  791. {
  792. if (this.txtName.Text.Length > 40)
  793. {
  794. MessageUtil.ShowTips("长度过长!");
  795. this.txtName.Text = this.txtName.Text.Substring(0,40);
  796. }
  797. }
  798. private void textBoxMemo_TextChanged(object sender, EventArgs e)
  799. {
  800. if (this.textBoxMemo.Text.Length > 180)
  801. {
  802. MessageUtil.ShowTips("长度过长!");
  803. this.textBoxMemo.Text = this.textBoxMemo.Text.Substring(0, 180);
  804. }
  805. }
  806. private void ultraGridRegion_AfterCellActivate(object sender, EventArgs e)
  807. {
  808. if (this.ultraGridRegion.ActiveRow!=null)
  809. {
  810. //查询区域属性
  811. ComboEdiRegPro.Text = this.ultraGridRegion.DisplayLayout.ActiveRow.Cells["REGION_TYPE_NM"].Text.Trim();
  812. ComboEdiRegPro.Value = this.ultraGridRegion.DisplayLayout.ActiveRow.Cells["REGION_TYPE_NO"].Value.ToString();
  813. regIonID = this.ultraGridRegion.DisplayLayout.ActiveRow.Cells["REGION_NO"].Value.ToString(); //修改使用的id
  814. this.txtName.Text = this.ultraGridRegion.DisplayLayout.ActiveRow.Cells["REGION_NM"].Text.Trim();
  815. textBoxMemo.Text = this.ultraGridRegion.DisplayLayout.ActiveRow.Cells["MEMO"].Text.Trim();
  816. this.comboRegIon.Text = this.ultraGridRegion.DisplayLayout.ActiveRow.Cells["BIGAREA"].Text.Trim();
  817. //保存上一级区域属性信息
  818. if (!string.IsNullOrEmpty(this.ultraGridRegion.DisplayLayout.ActiveRow.Cells["P_REGION_NO"].Value.ToString()))
  819. {
  820. ComboEditorPro.Text = this.ultraGridRegion.DisplayLayout.ActiveRow.Cells["P_REGION_NM"].Value.ToString();
  821. ComboEditorPro.Value = this.ultraGridRegion.DisplayLayout.ActiveRow.Cells["P_REGION_NO"].Value.ToString();
  822. }
  823. }
  824. }
  825. private void ultraGridRegion_AfterRowActivate(object sender, EventArgs e)
  826. {
  827. if (this.ultraGridRegion.ActiveRow != null)
  828. {
  829. //查询区域属性
  830. ComboEdiRegPro.Text = this.ultraGridRegion.DisplayLayout.ActiveRow.Cells["REGION_TYPE_NM"].Text.Trim();
  831. ComboEdiRegPro.Value = this.ultraGridRegion.DisplayLayout.ActiveRow.Cells["REGION_TYPE_NO"].Text.Trim();
  832. regIonID = this.ultraGridRegion.DisplayLayout.ActiveRow.Cells["REGION_NO"].Value.ToString(); //修改使用的id
  833. this.txtName.Text = this.ultraGridRegion.DisplayLayout.ActiveRow.Cells["REGION_NM"].Text.Trim();
  834. textBoxMemo.Text = this.ultraGridRegion.DisplayLayout.ActiveRow.Cells["MEMO"].Text.Trim();
  835. this.comboRegIon.Text = this.ultraGridRegion.DisplayLayout.ActiveRow.Cells["BIGAREA"].Value.ToString();
  836. //保存上一级区域属性信息
  837. if (!string.IsNullOrEmpty(this.ultraGridRegion.DisplayLayout.ActiveRow.Cells["P_REGION_NO"].Value.ToString()))
  838. {
  839. ComboEditorPro.Text = this.ultraGridRegion.DisplayLayout.ActiveRow.Cells["P_REGION_NM"].Value.ToString();
  840. ComboEditorPro.Value = this.ultraGridRegion.DisplayLayout.ActiveRow.Cells["P_REGION_NO"].Value.ToString();
  841. }
  842. }
  843. }
  844. }
  845. }