FrmPop_upDeliveryLocation.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459
  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;using Pur.Entity;
  10. using Pur.Entity.configureEntity;
  11. using Core.Mes.Client.Comm.Control;
  12. using Infragistics.Win.UltraWinGrid;
  13. using com.hnshituo.pur.vo;
  14. using Core.Mes.Client.Comm.Tool;
  15. using Pur.require_plan;
  16. using Infragistics.Win;
  17. namespace Pur.Pop_upWindow
  18. {
  19. public partial class FrmPop_upDeliveryLocation : FrmPmsBase
  20. {
  21. public String tips = "0";
  22. public String isNotAll = "1";//0全部
  23. public String isCK = "1";//不可以修改
  24. public String isJIT = "";
  25. public FrmPop_upDeliveryLocation()
  26. {
  27. isCK = "0";//非弹出对话框不需要控制权限
  28. isNotAll = "0";
  29. InitializeComponent();
  30. }
  31. public FrmPop_upDeliveryLocation(OpeBase ob)
  32. {
  33. this.ob = ob;
  34. InitializeComponent();
  35. }
  36. public FrmPop_upDeliveryLocation(OpeBase opeBase, string strd,String strisJIT)
  37. {
  38. // TODO: Complete member initialization
  39. this.ob = opeBase;
  40. this.isNotAll = strd;
  41. this.isJIT = strisJIT;
  42. InitializeComponent();
  43. }
  44. /** 交付地点编码 */
  45. private string deliveryLocationCode;
  46. public string DeliveryLocationCode
  47. {
  48. get { return deliveryLocationCode; }
  49. set { deliveryLocationCode = value; }
  50. }
  51. /** 交付地点 */
  52. private string deliveryLocation;
  53. public string DeliveryLocation
  54. {
  55. get { return deliveryLocation; }
  56. set { deliveryLocation = value; }
  57. }
  58. private void FrmPop_upDeliveryLocation_Load(object sender, EventArgs e)//load
  59. {
  60. ultraExpandableGroupBox1.Expanded = false;
  61. txt_isDefault.SelectedIndex = 0;
  62. Cop_isDefault.SelectedIndex = 0;
  63. txt_isJit.SelectedIndex = 0;
  64. QueryDz();
  65. ultraGrid1.DisplayLayout.Bands[0].Override.AllowUpdate = DefaultableBoolean.False;
  66. }
  67. /// <summary>
  68. /// toolbar菜单
  69. /// </summary>
  70. /// <param name="sender"></param>
  71. /// <param name="ToolbarKey"></param>
  72. public override void ToolBar_Click(object sender, string ToolbarKey)// toolbar菜单
  73. {
  74. switch (ToolbarKey)
  75. {
  76. case "Query":
  77. {
  78. QueryDz();
  79. }
  80. break;
  81. case "Add"://新增
  82. {
  83. AddDz();
  84. }
  85. break;
  86. case "update":
  87. {
  88. updateDz();
  89. }
  90. break;
  91. case "delete"://删除
  92. {
  93. deleteDz();
  94. }
  95. break;
  96. case "ESC":
  97. {
  98. EscDz();
  99. }
  100. break;
  101. }
  102. }
  103. private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
  104. {
  105. switch (e.Tool.Key.ToString())
  106. {
  107. case "Query":
  108. {
  109. QueryDz();
  110. }
  111. break;
  112. case "Add":
  113. {
  114. AddDz();
  115. }
  116. break;
  117. case "update":
  118. {
  119. updateDz();
  120. }
  121. break;
  122. case "delete":
  123. {
  124. deleteDz();
  125. }
  126. break;
  127. case "conFirmation":
  128. {
  129. conFirmationDz();
  130. }
  131. break;
  132. case "doClear":
  133. {
  134. clearDz();
  135. }
  136. break;
  137. case "ESC":
  138. {
  139. EscDz();
  140. }
  141. break;
  142. }
  143. }
  144. /// <summary>
  145. ///
  146. /// </summary>
  147. private void EscDz()
  148. {
  149. this.Close();
  150. }
  151. /// <summary>
  152. /// 确认
  153. /// </summary>
  154. private void conFirmationDz()
  155. {
  156. UltraGridRow uge = ultraGrid1.ActiveRow;
  157. this.DeliveryLocationCode = uge.Cells["DeliveryLocationCode"].Value.ToString();
  158. this.DeliveryLocation = uge.Cells["DeliveryLocation"].Value.ToString();
  159. tips = "1";
  160. this.Close();
  161. }
  162. private void clearDz()
  163. {
  164. UltraGridRow uge = ultraGrid1.ActiveRow;
  165. this.DeliveryLocationCode = "";
  166. this.DeliveryLocation = "";
  167. tips = "1";
  168. this.Close();
  169. }
  170. /// <summary>
  171. /// 删除
  172. /// </summary>
  173. private void deleteDz()// 删除
  174. {
  175. try
  176. {
  177. this.Cursor = Cursors.WaitCursor;
  178. UltraGridRow uge = ultraGrid1.ActiveRow;
  179. DeliveryLocationDz Dz = new DeliveryLocationDz();
  180. Dz.Validflag = "0";
  181. Dz.DeliveryLocationCode = uge.Cells["DeliveryLocationCode"].Value.ToString();
  182. Dz.DeleteName = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName();
  183. Dz.DeleteTime = DateTime.Now;
  184. Dz.DeleteUserid = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserID();
  185. if (testDZ(Dz.DeliveryLocationCode) == false)
  186. {
  187. return;
  188. }
  189. if (MessageUtil.ShowYesNoAndQuestion("确定删除该地址?") == DialogResult.No)
  190. {
  191. return;
  192. }
  193. CoreResult cRt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.DeliveryLocationService", "doUpdate", new object[] { Dz });
  194. if (cRt.Resultcode != 0)
  195. {
  196. MessageUtil.ShowTips("删除失败" + cRt.Resultmsg);
  197. return;
  198. }
  199. MessageUtil.ShowTips("删除成功!");
  200. QueryDz();
  201. }
  202. catch (Exception ex)
  203. {
  204. MessageUtil.ShowTips("操作失败:" + ex);
  205. }
  206. finally
  207. {
  208. this.Cursor = Cursors.Default;
  209. }
  210. }
  211. private bool testDZ(String dz)
  212. {
  213. DeliveryLocationDz cRt = this.execute<DeliveryLocationDz>("com.hnshituo.pur.configure.service.DeliveryLocationService", "findById", new object[] { dz });
  214. if (cRt == null)
  215. {
  216. MessageUtil.ShowTips("地址不存在,可能已被废除");
  217. return false;
  218. }
  219. if (cRt.Validflag == "0")
  220. {
  221. MessageUtil.ShowTips("地址信息已作废");
  222. return false;
  223. }
  224. if (isCK == "1")
  225. {
  226. if (cRt.OrgId != UserInfo.GetDeptid())
  227. {
  228. MessageUtil.ShowTips("非地址所属科室/单位,无权限删改");
  229. return false;
  230. }
  231. }
  232. return true;
  233. }
  234. /// <summary>
  235. /// 修改
  236. /// </summary>
  237. private void updateDz()// 修改
  238. {
  239. try
  240. {
  241. this.Cursor = Cursors.WaitCursor;
  242. UltraGridRow uge = ultraGrid1.ActiveRow;
  243. DeliveryLocationDz Dz = new DeliveryLocationDz();
  244. if (testInput() == false)
  245. {
  246. return;
  247. }
  248. Dz.InvPhysic = txtPhysicCode.Text.Trim();
  249. Dz.InvPhysicName = txtPhysic.Text.Trim();
  250. Dz.UpdateName = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName();
  251. Dz.UpdateTime = DateTime.Now;
  252. Dz.UpdateUserid = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserID();
  253. Dz.IsJit = txt_isJit.Value.ToString().Trim();
  254. Dz.DeliveryLocationCode = uge.Cells["DeliveryLocationCode"].Value.ToString();
  255. Dz.DeliveryLocation = Cop_deliveryLocation.Text.ToString().Trim();
  256. Dz.IsDefault = Cop_isDefault.Value.ToString();
  257. if (testDZ(Dz.DeliveryLocationCode) == false)
  258. {
  259. return;
  260. }
  261. if (MessageUtil.ShowYesNoAndQuestion("确定修改该地址?") == DialogResult.No)
  262. {
  263. return;
  264. }
  265. CoreResult cRt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.DeliveryLocationService", "doUpdate_D", new object[] { Dz });
  266. if (cRt.Resultcode != 0)
  267. {
  268. MessageUtil.ShowTips("修改失败:" + cRt.Resultmsg);
  269. return;
  270. }
  271. MessageUtil.ShowTips("修改成功!");
  272. QueryDz();
  273. comm.doActiveSelRow(ultraGrid1, "DeliveryLocationCode", Dz.DeliveryLocationCode);
  274. }
  275. catch (Exception ex)
  276. {
  277. MessageUtil.ShowTips("操作失败;" + ex);
  278. }
  279. finally
  280. {
  281. this.Cursor = Cursors.Default;
  282. }
  283. }
  284. /// <summary>
  285. /// 新增
  286. /// </summary>
  287. private void AddDz()// 新增
  288. {
  289. ////
  290. //if (Cop_isDefault.Text.Equals("否"))
  291. //{
  292. // DeliveryLocationDz Dz1 = new DeliveryLocationDz();
  293. // Dz1.Validflag = "1";
  294. // Dz1.IsDefault = "1";
  295. // DataTable dt = this.execute<DataTable>("com.hnshituo.pur.configure.service.DeliveryLocationService", "find", new object[] { Dz1,0,0});
  296. // if (dt.Rows.Count != 0)
  297. // {
  298. // CoreResult cRt1 = this.execute<CoreResult>("com.hnshituo.pur.configure.service.DeliveryLocationService", "update_is", new object[] { });
  299. // }
  300. //}
  301. try
  302. {
  303. this.Cursor = Cursors.WaitCursor;
  304. DeliveryLocationDz Dz = new DeliveryLocationDz();
  305. if (testInput() == false)
  306. {
  307. return;
  308. }
  309. Dz.CreateName = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName();
  310. Dz.CreateTime = DateTime.Now;
  311. Dz.CreateUserid = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserID();
  312. Dz.OrgId = CoreFS.SA06.CoreUserInfo.UserInfo.GetDeptid();
  313. Dz.OrgName = CoreFS.SA06.CoreUserInfo.UserInfo.GetDepartment();
  314. Dz.OwnerName = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName();
  315. Dz.OwnerUserid = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserID();
  316. Dz.DeliveryLocationCode = getDELIVERY_LOCATION_CODE();//后台复写
  317. Dz.InvPhysic = txtPhysicCode.Text.Trim();
  318. Dz.IsJit = txt_isJit.Value.ToString().Trim();
  319. Dz.InvPhysicName = txtPhysic.Text.Trim();
  320. Dz.DeliveryLocation = Cop_deliveryLocation.Text.ToString().Trim();
  321. Dz.IsDefault = Cop_isDefault.Value.ToString();
  322. Dz.Validflag = "1";
  323. CoreResult cRt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.DeliveryLocationService", "doInsert_D", new object[] { Dz });
  324. if (cRt.Resultcode != 0)
  325. {
  326. MessageUtil.ShowTips("添加失败:" + cRt.Resultmsg);
  327. return;
  328. }
  329. MessageUtil.ShowTips("添加成功!");
  330. QueryDz();
  331. comm.doActiveSelRow(ultraGrid1, "DeliveryLocationCode", cRt.Resultmsg);
  332. }
  333. catch (Exception ex)
  334. {
  335. MessageUtil.ShowTips("操作失败:" + ex);
  336. }
  337. finally
  338. {
  339. this.Cursor = Cursors.Default;
  340. }
  341. }
  342. private bool testInput()
  343. {
  344. if (Cop_deliveryLocation.Text.ToString().Trim() == "")
  345. {
  346. MessageUtil.ShowTips("请输入有效地址");
  347. Cop_deliveryLocation.Focus();
  348. return false;
  349. }
  350. if (Cop_isDefault.SelectedIndex == -1)
  351. {
  352. MessageUtil.ShowTips("请指定是否为默认值!");
  353. Cop_isDefault.Focus();
  354. return false;
  355. }
  356. if (String.IsNullOrEmpty(txtPhysic.Text.Trim()))
  357. {
  358. MessageUtil.ShowTips("请指定默认入库库区!");
  359. txtPhysic.Focus();
  360. return false;
  361. }
  362. if (String.IsNullOrEmpty(txtPhysicCode.Text.Trim()))
  363. {
  364. MessageUtil.ShowTips("请指定默认入库库区,库区编码不能为空!");
  365. txtPhysic.Focus();
  366. return false;
  367. }
  368. if (txt_isJit.SelectedIndex==-1)
  369. {
  370. MessageUtil.ShowTips("请指定是否为JIT交付地址!");
  371. txt_isJit.Focus();
  372. return false;
  373. }
  374. return true;
  375. }
  376. /// <summary>
  377. /// 查询
  378. /// </summary>
  379. private void QueryDz()// 查询
  380. {
  381. try
  382. {
  383. this.Cursor = Cursors.WaitCursor;
  384. DeliveryLocationDz Dz = new DeliveryLocationDz();
  385. Dz.DeliveryLocationCode = txt_deliveryLocationCode.Text.ToString().Trim();
  386. Dz.DeliveryLocation = txt_deliveryLocation.Text.ToString().Trim();
  387. Dz.IsDefault = txt_isDefault.Value == null ? "" : txt_isDefault.Value.ToString().Trim();
  388. Dz.Validflag = "1";
  389. if (isNotAll == "1")
  390. {
  391. Dz.OrgId = UserInfo.GetDeptid();
  392. }
  393. Dz.IsJit = isJIT;
  394. DataTable dt = this.execute<DataTable>("com.hnshituo.pur.configure.service.DeliveryLocationService", "doQuery_D", new object[] { Dz });
  395. GridHelper.CopyDataToDatatable(dt, dataTable1, true);
  396. GridHelper.RefreshAndAutoSize(ultraGrid1);
  397. }
  398. catch (Exception ex)
  399. {
  400. MessageUtil.ShowTips("查询数据失败:"+ex);
  401. }
  402. finally
  403. {
  404. this.Cursor = Cursors.Default;
  405. }
  406. }
  407. private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)//激活行
  408. {
  409. String code=ultraGrid1.ActiveRow.Cells["deliveryLocationCode"].Value.ToString().Trim();
  410. if (String.IsNullOrEmpty(code))
  411. {
  412. return;
  413. }
  414. DeliveryLocationDz cRt = this.execute<DeliveryLocationDz>("com.hnshituo.pur.configure.service.DeliveryLocationService", "findById", new object[] { code });
  415. Cop_deliveryLocationCode.Text = cRt.DeliveryLocationCode;
  416. Cop_deliveryLocation.Text = cRt.DeliveryLocation;
  417. Cop_isDefault.Value = cRt.IsDefault;
  418. txtPhysic.Text = cRt.InvPhysicName;
  419. txtPhysicCode.Text = cRt.InvPhysic;
  420. txt_isJit.Value = cRt.IsJit;
  421. }
  422. /// <summary>
  423. /// 获取交付地点编码
  424. /// </summary>
  425. /// <returns></returns>
  426. public String getDELIVERY_LOCATION_CODE()// 获取交付地点编码
  427. {
  428. DataTable dt = this.execute<DataTable>("com.hnshituo.pur.configure.service.DeliveryLocationService", "findAll", new object[] { });
  429. string code = "0";
  430. code = (dt.Rows.Count+1).ToString();
  431. while (code.Length < 5)
  432. {
  433. code = "0" + code;
  434. }
  435. return code;
  436. }
  437. private void txtPhysic_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
  438. {
  439. frmPopActualSeat popAs = new frmPopActualSeat(this.ob, "0");
  440. popAs.ShowDialog();
  441. if (popAs.Tips=="1")
  442. {
  443. txtPhysic.Text = popAs.DeliveryLocation;
  444. txtPhysicCode.Text = popAs.DeliveryLocationCode;
  445. }
  446. }
  447. }
  448. }