frmLocationDefine.cs 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972
  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.Control;
  11. using System.Text.RegularExpressions;
  12. using Core.Mes.Client.Comm.Server;
  13. using Infragistics.Win.UltraWinGrid;
  14. using Core.Mes.Client.Comm.Tool;
  15. using System.Collections;
  16. using Infragistics.Win;
  17. namespace Core.StlMes.Client.YdmBase
  18. {
  19. public partial class frmLocationDefine : FrmBase
  20. {
  21. public frmLocationDefine()
  22. {
  23. InitializeComponent();
  24. this.IsLoadUserView = true;
  25. }
  26. bool isvalid = false; //包含无效
  27. string isdummy = "0"; //是否虚拟 默认不虚拟
  28. string islock = "1"; //是否封锁 默认释放
  29. ArrayList parms = new ArrayList();
  30. private ArrayList listLoca = new ArrayList(); //勾选的奇数位的料位编码
  31. private ArrayList listRack = new ArrayList(); //供选择的料架
  32. private ArrayList listSelected = new ArrayList(); //已经选择的料架
  33. private ArrayList returnlist; //传回来的料位码-料架码
  34. public ArrayList Returnlist
  35. {
  36. get { return returnlist; }
  37. set { returnlist = value; }
  38. }
  39. /// <summary>
  40. /// 重写基类方法
  41. /// </summary>
  42. /// <param name="sender"></param>
  43. /// <param name="ToolbarKey"></param>
  44. public override void ToolBar_Click(object sender, string ToolbarKey)
  45. {
  46. switch (ToolbarKey)
  47. {
  48. case "Query":
  49. DoQuery();
  50. break;
  51. case "Add":
  52. DoAdd();
  53. break;
  54. case "Update":
  55. DoUpdate();
  56. break;
  57. case "Delete":
  58. DoDeleteOrResume(true);
  59. break;
  60. case "Resume":
  61. DoDeleteOrResume(false);
  62. break;
  63. case "Refresh":
  64. DoRefresh();
  65. break;
  66. case "Export":
  67. ExportGridData();
  68. break;
  69. case "Rack":
  70. DoRack();
  71. break;
  72. case "Close":
  73. this.Close();
  74. break;
  75. }
  76. }
  77. /// <summary>
  78. /// 初始化
  79. /// </summary>
  80. /// <param name="sender"></param>
  81. /// <param name="e"></param>
  82. private void frmLocationDefine_Load(object sender, EventArgs e)
  83. {
  84. InitComBo();
  85. //InitGrid2();
  86. //QueryTree();
  87. //getDepartMent();
  88. cbm_Dw.Enabled = false;
  89. YdmBaseClass.InitSection(cbm_Dw, this.ValidDataPurviewIds, this.ob);
  90. }
  91. //加载作业单位
  92. private void getDepartMent()
  93. {
  94. //DataTable dt = new DataTable();
  95. //string flag = "0";
  96. //string userName = this.UserInfo.GetUserName();
  97. //string departMent = ClsBaseInfo.GetDepartBySectionId(UserInfo.GetDeptid(), this.ob);
  98. //if (userName.Equals("admin"))
  99. //{
  100. // dt = ServerHelper.GetData("com.steering.pss.ydm.base.YdmBaseQuery.departQuery", new object[] { departMent, flag }, this.ob);
  101. // if (dt.Rows.Count > 0)
  102. // {
  103. // cbm_Dw.DataSource = dt;
  104. // cbm_Dw.DisplayMember = "DEPARTNAME";
  105. // cbm_Dw.ValueMember = "DEPARTID";
  106. // this.cbm_Dw.SelectedIndex = -1;
  107. // }
  108. //}
  109. //else
  110. //{
  111. // flag = "1";
  112. // dt = ServerHelper.GetData("com.steering.pss.ydm.base.YdmBaseQuery.departQuery", new object[] { departMent, flag }, this.ob);
  113. // if (dt.Rows.Count > 0)
  114. // {
  115. // cbm_Dw.DataSource = dt;
  116. // cbm_Dw.DisplayMember = "DEPARTNAME";
  117. // cbm_Dw.ValueMember = "DEPARTID";
  118. // this.cbm_Dw.SelectedIndex = 0;
  119. // }
  120. //}
  121. }
  122. //刷新Tree
  123. public void QueryTree()
  124. {
  125. //this.cmbManage.Nodes.Clear();
  126. DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.base.YdmBaseQuery.departQuery", null, this.ob);
  127. //树控件递归绑定方法。
  128. //YdmBaseClass.MakeTree(dt, "PID", null, "DEPARTID", "DEPARTNAME", cmbManage.Nodes, -1);
  129. }
  130. /// <summary>
  131. /// 初始化下拉框
  132. /// </summary>
  133. private void InitComBo()
  134. {
  135. YdmBaseClass.InitComboEditor(cmbLocationType, "com.steering.pss.ydm.base.YdmBaseQuery.getLocationType", "BASECODE", this.ob,false);
  136. YdmBaseClass.InitComboEditor(cmbLocationAttr, "com.steering.pss.ydm.base.YdmBaseQuery.getLocationAttribute", "BASECODE", this.ob, false);
  137. }
  138. /// <summary>
  139. /// 初始化左边GRID的仓库数据
  140. /// </summary>
  141. private void InitGrid2()
  142. {
  143. DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.base.CoreLocationDefine.getStorage", null, this.ob);
  144. GridHelper.CopyDataToDatatable(ref dt, ref dataTable1, true);
  145. YdmBaseClass.SetGridActivateOnly(ultraGrid2);
  146. }
  147. /// <summary>
  148. /// 刷新
  149. /// </summary>
  150. private void DoRefresh()
  151. {
  152. // InitGrid2();
  153. InitComBo();
  154. //QueryTree();
  155. }
  156. /// <summary>
  157. /// 导出
  158. /// </summary>
  159. private void ExportGridData()
  160. {
  161. GridHelper.ulGridToExcel(ultraGrid1, this.Text);
  162. }
  163. /// <summary>
  164. /// 获取编辑区的数据
  165. /// </summary>
  166. private void GetEditData()
  167. {
  168. ultraGrid2.UpdateData();
  169. UltraGridRow ugr = ultraGrid2.ActiveRow;
  170. if (ugr == null)
  171. {
  172. MessageBox.Show("请选择对应的库号行!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  173. return;
  174. }
  175. parms = new ArrayList();
  176. if (cmbLocationType.SelectedItem == null)
  177. {
  178. MessageBox.Show("请选择料位类型", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  179. return;
  180. }
  181. string locatype="";
  182. switch (cmbLocationType.Text.Trim())
  183. {
  184. case "垛位":
  185. locatype = "D";
  186. break;
  187. case "料架":
  188. locatype = "J";
  189. break;
  190. }
  191. if (cmbLocationAttr.SelectedItem == null)
  192. {
  193. MessageBox.Show("请选择料位属性", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  194. return;
  195. }
  196. if (txtArea.Text.Trim() == "")
  197. {
  198. MessageBox.Show("请输入区号", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  199. return;
  200. }
  201. if (txtRow.Text.Trim() == "")
  202. {
  203. MessageBox.Show("请输入行号", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  204. return;
  205. }
  206. if (txtColStart.Text.Trim() == "")
  207. {
  208. MessageBox.Show("请输入列号", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  209. return;
  210. }
  211. if (txtColEnd.Text.Trim() != "")
  212. {
  213. if (Convert.ToInt16(txtColEnd.Value.ToString()) < Convert.ToInt16(txtColStart.Value.ToString()))
  214. {
  215. MessageBox.Show("列号结束位置不能小于起始位置", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  216. return;
  217. }
  218. }
  219. if (txtXCoordinates.Text.Trim() == "")
  220. {
  221. MessageBox.Show("请输入X坐标", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  222. return;
  223. }
  224. if (!StringUtil.Is_Below_zero(txtXCoordinates.Value.ToString()))
  225. {
  226. MessageBox.Show("X坐标,请输入数字", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  227. return;
  228. }
  229. if (txtYCoordinates.Text.Trim() == "")
  230. {
  231. MessageBox.Show("请输入Y坐标", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  232. return;
  233. }
  234. if (!StringUtil.Is_Below_zero(txtYCoordinates.Value.ToString()))
  235. {
  236. MessageBox.Show("Y坐标,请输入数字", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  237. return;
  238. }
  239. if (locatype == "D")
  240. {
  241. if (txtLocationWidth.Text.Trim() == "")
  242. {
  243. MessageBox.Show("请输入料位宽度", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  244. return;
  245. }
  246. if (!StringUtil.Is_Below_zero(txtLocationWidth.Value.ToString()))
  247. {
  248. MessageBox.Show("料位宽度,请输入数字", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  249. return;
  250. }
  251. if (txtLocationHeght.Text.Trim() == "")
  252. {
  253. MessageBox.Show("请输入料位高度", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  254. return;
  255. }
  256. if (!StringUtil.Is_Below_zero(txtLocationHeght.Value.ToString()))
  257. {
  258. MessageBox.Show("料位高度,请输入数字", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  259. return;
  260. }
  261. if (txtLocationLen.Text.Trim() == "")
  262. {
  263. MessageBox.Show("请输入料位长度", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  264. return;
  265. }
  266. if (!StringUtil.Is_Below_zero(txtLocationLen.Value.ToString()))
  267. {
  268. MessageBox.Show("料位长度,请输入数字", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  269. return;
  270. }
  271. }
  272. parms.Add(txtStorNo.Text.Trim());
  273. parms.Add(locatype);
  274. parms.Add(txtArea.Text.Trim());
  275. parms.Add(txtRow.Text.Trim());
  276. parms.Add(txtColStart.Text.Trim()); //初始列号
  277. parms.Add(txtColEnd.Text.Trim()); //结束列号
  278. parms.Add(txtLocationLen.Text.Trim()); //长
  279. parms.Add(txtLocationWidth.Text.Trim()); //宽
  280. parms.Add(txtLocationHeght.Text.Trim()); //高
  281. parms.Add(txtXCoordinates.Text.Trim());
  282. parms.Add(txtYCoordinates.Text.Trim());
  283. parms.Add(islock);
  284. parms.Add(cmbLocationAttr.Value.ToString());
  285. parms.Add(cmbLocationAttr.Text.Trim());
  286. parms.Add(isdummy);
  287. parms.Add(ugr.Cells["MANAGEMENT_NO"].Value.ToString());
  288. parms.Add(ugr.Cells["MANAGEMENT_NAME"].Value.ToString());
  289. parms.Add(ugr.Cells["DEPARTMENT_CODE"].Value.ToString());
  290. parms.Add(ugr.Cells["DEPARTMENT_DESC"].Value.ToString());
  291. parms.Add(this.UserInfo.GetUserName());
  292. parms.Add(txtMemo.Text.Trim()); //备注
  293. parms.Add(txtLocationName.Text.Trim());//料位名称
  294. parms.Add(txtRackType.Value.ToString3());
  295. parms.Add(txtRackQuality.Value.ToString3());
  296. }
  297. /// <summary>
  298. /// 查询
  299. /// </summary>
  300. private void DoQuery()
  301. {
  302. if (!CheckQuery()) return;
  303. string LocationNo = "";//库位编码
  304. string RackNo = "";//料位号
  305. string storageno = "";
  306. //if (chkStorageNo.Checked)
  307. //{
  308. // storageno = txtStorageNo.Text.Trim();
  309. //}
  310. //else
  311. //{
  312. // storageno = ugr.Cells["STORAGE_NO"].Value.ToString();
  313. //}
  314. //if (chkLocationNo.Checked)
  315. // LocationNo = txtLocationNo.Text.Trim();
  316. //if (chkRackNo.Checked)
  317. // RackNo = txtRackNo.Text.Trim();
  318. string management="";
  319. string departMent = "";
  320. //if (ultraCheckEditor2.Checked)
  321. //{
  322. // management = cbm_Dw.SelectedValue.ToString();
  323. //}
  324. if (this.ultrlSection.Checked)
  325. {
  326. if (cbm_Dw.Text.ToString() == "")
  327. {
  328. MessageBox.Show("请选择作业科室!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  329. return;
  330. }
  331. else
  332. {
  333. departMent = cbm_Dw.Value.ToString();
  334. }
  335. }
  336. string[] arr = YdmBaseClass.BaseSection(this.ValidDataPurviewIds, this.ob);
  337. DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.base.CoreLocationDefine.getStorage", new object[] { departMent, arr }, this.ob);
  338. GridHelper.CopyDataToDatatable(ref dt, ref dataTable1, true);
  339. YdmBaseClass.SetGridActivateOnly(ultraGrid2);
  340. }
  341. /// <summary>
  342. /// 查询时验证
  343. /// </summary>
  344. /// <returns></returns>
  345. private bool CheckQuery()
  346. {
  347. if (chkStorageNo.Checked && string.IsNullOrEmpty(txtStorageNo.Text.Trim()))
  348. {
  349. MessageBox.Show("请输入库号编码!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  350. return false;
  351. }
  352. if (chkLocationNo.Checked && string.IsNullOrEmpty(txtLocationNo.Text.Trim()))
  353. {
  354. MessageBox.Show("请输入库位编码!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  355. return false;
  356. }
  357. if (chkRackNo.Checked && string.IsNullOrEmpty(txtRackNo.Text.Trim()))
  358. {
  359. MessageBox.Show("请输入料架号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  360. return false;
  361. }
  362. //if (ultraCheckEditor2.Checked && string.IsNullOrEmpty(cmbManage.Text.Trim()))
  363. //{
  364. // MessageBox.Show("请选择作业单位!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  365. // return false;
  366. //}
  367. return true;
  368. }
  369. /// <summary>
  370. /// 增加、修改时数据验证
  371. /// </summary>
  372. /// <returns></returns>
  373. private bool updateAddCheck()
  374. {
  375. if(txtArea.Text.Trim() == "")
  376. {
  377. MessageBox.Show("区号不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  378. return false;
  379. }
  380. if (txtRow.Text.Trim() == "")
  381. {
  382. MessageBox.Show("行号不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  383. return false;
  384. }
  385. if (!StringUtil.IsInt32(txtColStart.Text.Trim()))
  386. {
  387. MessageBox.Show("开始列号不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  388. return false;
  389. }
  390. if (!StringUtil.IsInt32(txtColEnd.Text.Trim()))
  391. {
  392. MessageBox.Show("结束列号不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  393. return false;
  394. }
  395. if (!StringUtil.IsInt32(txtXCoordinates.Text.Trim()))
  396. {
  397. MessageBox.Show("X坐标不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  398. return false;
  399. }
  400. if (!StringUtil.IsInt32(txtYCoordinates.Text.Trim()))
  401. {
  402. MessageBox.Show("Y坐标不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  403. return false;
  404. }
  405. if (!StringUtil.IsInt32(txtLocationWidth.Text.Trim()))
  406. {
  407. MessageBox.Show("料位宽度不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  408. return false;
  409. }
  410. if (!StringUtil.IsInt32(txtLocationHeght.Text.Trim()))
  411. {
  412. MessageBox.Show("料位高度不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  413. return false;
  414. }
  415. if (!StringUtil.IsInt32(txtLocationLen.Text.Trim()))
  416. {
  417. MessageBox.Show("料位长度不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  418. return false;
  419. }
  420. return true;
  421. }
  422. /// <summary>
  423. /// 新增
  424. /// </summary>
  425. private void DoAdd()
  426. {
  427. string type = "";
  428. if (!updateAddCheck()) return;
  429. if(this.cmbLocationType.Text.ToString() == "垛位")
  430. {
  431. type = "D";
  432. }
  433. else if(this.cmbLocationType.Text.ToString() == "料架")
  434. {
  435. type = "J";
  436. }
  437. string row = this.txtRow.Text.Trim();//行号
  438. string storeNo = this.txtStorNo.Text.Trim();//库号
  439. string areNo = this.txtArea.Text.Trim();//区号
  440. DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.base.CoreLocationDefine.getDorJ", new object[] { row, storeNo,areNo }, this.ob);
  441. if (dt.Rows.Count > 0)
  442. {
  443. if (!dt.Rows[0]["LOCATION_TYPE"].ToString().Equals(type))
  444. {
  445. MessageBox.Show("一排中不允许既维护垛位又维护料架!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  446. return;
  447. }
  448. }
  449. GetEditData();
  450. if (parms.Count <=0)
  451. {
  452. return;
  453. }
  454. int count = 0;
  455. try
  456. {
  457. count = ServerHelper.SetData("com.steering.pss.ydm.base.CoreLocationDefine.doAdd", new Object[] { parms }, this.ob);
  458. }catch(Exception )
  459. {
  460. return;
  461. }
  462. if (count > 0)
  463. {
  464. MessageBox.Show("数据新增成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  465. //DoQuery();
  466. queryUltraGrid1();
  467. }
  468. }
  469. /// <summary>
  470. /// 更新数据
  471. /// </summary>
  472. private void DoUpdate()
  473. {
  474. string locano = "";
  475. string type = "";
  476. if (!updateAddCheck()) return;
  477. UltraGridRow ugr = ultraGrid1.ActiveRow;
  478. if (ugr == null)
  479. {
  480. MessageBox.Show("请选择需要修改的记录", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  481. return;
  482. }
  483. if (ugr.Cells["VALIDFLAG"].Value.ToString() == "无效")
  484. {
  485. MessageBox.Show("无效数据,无法修改!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  486. return;
  487. }
  488. if (this.cmbLocationType.Text.ToString() == "垛位")
  489. {
  490. type = "D";
  491. }
  492. else if (this.cmbLocationType.Text.ToString() == "料架")
  493. {
  494. type = "J";
  495. }
  496. string row = this.txtRow.Text.Trim();
  497. string storeNo = this.txtStorNo.Text.Trim();//库号
  498. string areNo = this.txtArea.Text.Trim();//区号
  499. DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.base.CoreLocationDefine.getDorJ", new object[] { row, storeNo, areNo }, this.ob);
  500. if (dt.Rows.Count > 0)
  501. {
  502. if (!dt.Rows[0]["LOCATION_TYPE"].ToString().Equals(type))
  503. {
  504. MessageBox.Show("一排中不允许既维护垛位又维护料架!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  505. return;
  506. }
  507. }
  508. GetEditData();
  509. if (parms.Count > 0)
  510. {
  511. locano = ugr.Cells["LOCATION_NO"].Value.ToString();
  512. parms.Add(locano);
  513. }
  514. //if (txtArea.Text.Trim() != this.ultraGrid1.ActiveRow.Cells["AREA_NO"].Text.Trim())
  515. //{
  516. // MessageBox.Show("区号不允许修改!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  517. // return;
  518. //}
  519. //if (txtRow.Text.Trim() != this.ultraGrid1.ActiveRow.Cells["ROW_NO"].Text.Trim())
  520. //{
  521. // MessageBox.Show("行号不允许修改!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  522. // return;
  523. //}
  524. //if (txtColStart.Text.Trim() != this.ultraGrid1.ActiveRow.Cells["COL_NO"].Text.Trim())
  525. //{
  526. // MessageBox.Show("列号不允许修改!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  527. // return;
  528. //}
  529. int count = 0;
  530. if (MessageBox.Show("是否确认修改该行数据?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
  531. {
  532. return;
  533. }
  534. try
  535. {
  536. count = ServerHelper.SetData("com.steering.pss.ydm.base.CoreLocationDefine.doUpdate", new Object[] { parms }, this.ob);
  537. }catch(Exception)
  538. {
  539. return;
  540. }
  541. if (count > 0)
  542. {
  543. MessageBox.Show("数据修改成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  544. queryUltraGrid1();
  545. foreach(UltraGridRow ulgr in ultraGrid1.Rows){
  546. if (ulgr.Cells["LOCATION_NO"].Value.ToString().Equals(locano))
  547. {
  548. ulgr.Activate();
  549. }
  550. }
  551. }
  552. }
  553. /// <summary>
  554. /// UltraGrid激活某行
  555. /// </summary>
  556. /// <param name="ug">UltraGrid</param>
  557. /// <param name="keys">列名</param>
  558. /// <param name="values">对应的值</param>
  559. public static void UltraGridLocation(UltraGrid ug, String[] keys, String[] values)
  560. {
  561. if (ug.Rows.Count == 0)
  562. {
  563. return;
  564. }
  565. if (keys.Length == 0 || values.Length == 0 || values.Length != keys.Length)
  566. {
  567. return;
  568. }
  569. foreach (UltraGridRow ugr in ug.Rows)
  570. {
  571. Boolean flag = true;
  572. for (int i = 0; i < keys.Length; i++)
  573. {
  574. if (!ugr.Cells[keys[i]].ToString().Equals(values[i]))
  575. {
  576. flag = false;
  577. }
  578. }
  579. if (flag == true)
  580. {
  581. ugr.Activate();
  582. return;
  583. }
  584. }
  585. }
  586. /// <summary>
  587. /// 作废或恢复
  588. /// </summary>
  589. /// <param name="flag">true 作废 false 恢复</param>
  590. private void DoDeleteOrResume(bool flag)
  591. {
  592. UltraGridRow ugr = ultraGrid1.ActiveRow;
  593. if (ugr == null)
  594. {
  595. MessageBox.Show("请选择你要操作的记录", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  596. return;
  597. }
  598. if (flag == false && ugr.Cells["VALIDFLAG"].Value.ToString().ToUpper() == "有效")
  599. {
  600. MessageBox.Show("有效数据,无法恢复!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  601. return;
  602. }
  603. if (flag == true && ugr.Cells["VALIDFLAG"].Value.ToString().ToUpper() != "有效")
  604. {
  605. MessageBox.Show("无效数据,无法删除!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  606. return;
  607. }
  608. if (flag == true && ugr.Cells["RACK_NO"].Text.ToString() != "")
  609. {
  610. MessageBox.Show("此料位维护了料架信息,无法删除!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  611. return;
  612. }
  613. else
  614. {
  615. DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.base.CoreLocationDefine.getButessCount", new object[] { ugr.Cells["LOCATION_NO"].Text.ToString().Trim() }, this.ob);
  616. if (int.Parse(dt.Rows[0][0].ToString()) > 0)
  617. {
  618. MessageBox.Show("此料位已存放实物,无法删除!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  619. return;
  620. }
  621. }
  622. if (MessageBox.Show("是否确认" + (flag ? "删除" : "恢复") + "该行数据?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
  623. {
  624. return;
  625. }
  626. string rackno = ugr.Cells["LOCATION_NO"].Value.ToString();
  627. string name = this.UserInfo.GetUserName();
  628. int count = ServerHelper.SetData("com.steering.pss.ydm.base.CoreLocationDefine.doDelete", new Object[] { rackno, name, flag }, this.ob);
  629. if (count > 0)
  630. {
  631. MessageBox.Show("数据" + (flag ? "删除" : "恢复") + "成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  632. //DoQuery();
  633. queryUltraGrid1();
  634. }
  635. }
  636. /// <summary>
  637. /// 料架维护
  638. /// </summary>
  639. private void DoRack()
  640. {
  641. listLoca = new ArrayList();
  642. listRack= new ArrayList();
  643. listSelected= new ArrayList();
  644. returnlist = new ArrayList();
  645. ArrayList locarack = new ArrayList(); //料位-料架
  646. ArrayList rackupdate = new ArrayList(); //需要更新的料架
  647. ArrayList newrackno = new ArrayList(); //更新后的料架编号
  648. foreach (UltraGridRow row in ultraGrid1.Rows)
  649. {
  650. if (row.Selected || row.Activated)
  651. {
  652. string locationno = row.Cells["LOCATION_NO"].Value.ToString();
  653. int _locationNo = int.Parse(locationno.Substring(locationno.Length -1,1));
  654. if (_locationNo % 2 != 0)
  655. {
  656. //int col = Convert.ToInt16(locationno.Substring(locationno.Length - 2, 2));
  657. //col % 2 == 1&&
  658. if (row.Cells["LOCATION_TYPE"].Value.ToString() == "J" && row.Cells["VALIDFLAG"].Value.ToString() == "有效") // 垛位不能维护料架
  659. {
  660. listLoca.Add(locationno);
  661. listSelected.Add(row.Cells["RACK_NO"].Value.ToString());
  662. }
  663. }
  664. }
  665. }
  666. if (listLoca.Count > 0)
  667. {
  668. DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.base.CoreLocationDefine.getRack", null, this.ob);
  669. if (dt != null && dt.Rows.Count > 0)
  670. {
  671. for (int i = 0; i < dt.Rows.Count; i++)
  672. {
  673. listRack.Add(dt.Rows[i][0]);
  674. }
  675. }
  676. else
  677. {
  678. MessageBox.Show("没有可供选择的料架", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  679. return;
  680. }
  681. FrmRackSelect frs = new FrmRackSelect();
  682. frs.Localist = listLoca;
  683. frs.Racklist = listRack;
  684. frs.Selectlist = listSelected;
  685. frs.ShowDialog();
  686. if (frs.flag == false)
  687. return; //窗口的关闭不是确定引起的 不进行信息更新。
  688. this.Returnlist = frs.ReturnData;
  689. if (returnlist.Count > 0)
  690. {
  691. for (int i = 0; i < returnlist.Count; i++)
  692. {
  693. ArrayList list = new ArrayList();
  694. string msg = returnlist[i].ToString();
  695. char[] ch = { ',' };
  696. string[] str = msg.Split(ch, StringSplitOptions.RemoveEmptyEntries);
  697. if (str.Length >0)
  698. {
  699. string locationno = str[0];
  700. string rackno="";
  701. if(str.Length==2)
  702. rackno = str[1];
  703. DataRow[] dr = dt.Select("RACK_NO='"+rackno+"'", "");
  704. if (dr.Length > 0)
  705. {
  706. string basewidth = dr[0]["BASE_WIDTH"].ToString();
  707. string baseheight = dr[0]["BASE_HEIGHT"].ToString();
  708. string racklen = dr[0]["RACK_LEN"].ToString();
  709. list.Add(rackno);
  710. list.Add(Convert.ToDouble(racklen) / 1000);
  711. list.Add(Convert.ToDouble(basewidth) / 1000);
  712. list.Add(Convert.ToDouble(baseheight) / 1000);
  713. list.Add(locationno);
  714. newrackno.Add(rackno);
  715. locarack.Add(list);
  716. }
  717. else
  718. {
  719. list.Add(rackno);
  720. list.Add("");
  721. list.Add("");
  722. list.Add("");
  723. list.Add(locationno);
  724. newrackno.Add(rackno);
  725. locarack.Add(list);
  726. }
  727. }
  728. }
  729. }
  730. //以前的料架编码和选择以后的料架编码作比较,被取消了的就该把其状态更新为未使用。
  731. for (int i = 0; i < listSelected.Count; i++)
  732. {
  733. if (!newrackno.Contains(listSelected[i].ToString()))
  734. rackupdate.Add(listSelected[i].ToString());
  735. }
  736. int count = ServerHelper.SetData("com.steering.pss.ydm.base.CoreLocationDefine.setRack", new Object[] { locarack,rackupdate }, this.ob);
  737. if (count > 0)
  738. {
  739. MessageBox.Show("料架维护成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  740. queryUltraGrid1();
  741. }
  742. }
  743. else
  744. {
  745. MessageBox.Show("垛位与料位偶数位不能维护料架!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  746. return;
  747. }
  748. }
  749. private void ultraCheckEditor1_CheckedChanged(object sender, EventArgs e)
  750. {
  751. if (chkLocationNo.Checked)
  752. {
  753. txtLocationNo.ReadOnly = false;
  754. }
  755. else
  756. {
  757. txtLocationNo.ReadOnly = true;
  758. }
  759. }
  760. private void ultraCheckEditor3_CheckedChanged(object sender, EventArgs e)
  761. {
  762. if (chkRackNo.Checked)
  763. {
  764. txtRackNo.ReadOnly = false;
  765. }
  766. else
  767. {
  768. txtRackNo.ReadOnly = true;
  769. }
  770. }
  771. private void ultraCheckEditor6_CheckedChanged(object sender, EventArgs e)
  772. {
  773. if (chkStorageNo.Checked)
  774. {
  775. txtStorageNo.ReadOnly = false;
  776. }
  777. else
  778. {
  779. txtStorageNo.ReadOnly = true;
  780. }
  781. }
  782. private void ultraCheckEditor7_CheckedChanged(object sender, EventArgs e)
  783. {
  784. if (chkValid.Checked)
  785. {
  786. isvalid = true;
  787. }
  788. else
  789. {
  790. isvalid = false;
  791. }
  792. }
  793. /// <summary>
  794. /// 文本框输入事件
  795. /// </summary>
  796. /// <param name="sender"></param>
  797. /// <param name="e"></param>
  798. private void ultraTextEditor5_KeyPress(object sender, KeyPressEventArgs e)
  799. {
  800. string reg = "^[1-9A-Z]$"; //只能输入1-9 A-Z和退格键
  801. string word = e.KeyChar.ToString();
  802. if (Regex.IsMatch(word, reg)||e.KeyChar=='\b')
  803. e.Handled = false;
  804. else
  805. e.Handled = true;
  806. }
  807. /// <summary>
  808. /// 查询ultraGrid1
  809. /// </summary>
  810. private void queryUltraGrid1()
  811. {
  812. UltraGridRow ugr = ultraGrid2.ActiveRow;
  813. if (ugr == null)
  814. return;
  815. txtStorNo.Value = ugr.Cells["STORAGE_NO"].Value.ToString();
  816. string dummy = ugr.Cells["DUMMY_FLAG"].Value.ToString();
  817. if (dummy == "1") //库是虚拟的 料位也必须是虚拟的
  818. {
  819. chkVitual.Checked = true;
  820. chkVitual.Enabled = false;
  821. }
  822. else //库不是虚拟的 料位可以虚拟 也可不虚拟
  823. {
  824. chkVitual.Checked = false;
  825. chkVitual.Enabled = true;
  826. }
  827. string storageno = ugr.Cells["STORAGE_NO"].Value.ToString(); ;//库号编码
  828. DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.base.CoreLocationDefine.doQuery", new Object[] { isvalid, storageno }, this.ob);
  829. GridHelper.CopyDataToDatatable(ref dt, ref dataTable2, true);
  830. YdmBaseClass.SetGridActivateOnly(ultraGrid1);
  831. YdmBaseClass.SetGridRowColor(ultraGrid1);
  832. YdmBaseClass.SetColAutoSizeExceptMemo(ultraGrid1);
  833. }
  834. /// <summary>
  835. /// 行激活事件
  836. /// </summary>
  837. /// <param name="sender"></param>
  838. /// <param name="e"></param>
  839. private void ultraGrid2_AfterRowActivate(object sender, EventArgs e)
  840. {
  841. queryUltraGrid1();
  842. }
  843. //private void ultraTextEditor6_KeyPress(object sender, KeyPressEventArgs e)
  844. //{
  845. // if (!(Char.IsNumber(e.KeyChar)) && e.KeyChar != (char)13 && e.KeyChar != (char)8)
  846. // {
  847. // e.Handled = true;
  848. // }
  849. //}
  850. private void ultraTextEditor9_KeyPress(object sender, KeyPressEventArgs e)
  851. {
  852. if (!(Char.IsNumber(e.KeyChar)) && e.KeyChar != (char)13 && e.KeyChar != (char)8)
  853. {
  854. e.Handled = true;
  855. }
  856. }
  857. private void ultraTextEditor8_KeyPress(object sender, KeyPressEventArgs e)
  858. {
  859. if (!(Char.IsNumber(e.KeyChar)) && e.KeyChar != (char)13 && e.KeyChar != (char)8)
  860. {
  861. e.Handled = true;
  862. }
  863. }
  864. private void ultraCheckEditor5_CheckedChanged(object sender, EventArgs e)
  865. {
  866. if (chkVitual.Checked)
  867. isdummy = "1";
  868. else
  869. isdummy = "0";
  870. }
  871. private void ultraCheckEditor4_CheckedChanged(object sender, EventArgs e)
  872. {
  873. if (chkLock.Checked)
  874. islock = "0";
  875. else
  876. islock = "1";
  877. }
  878. private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
  879. {
  880. ultraGrid1.UpdateData();
  881. UltraGridRow ugr = ultraGrid1.ActiveRow;
  882. if (ugr == null)
  883. return;
  884. switch (ugr.Cells["LOCATION_TYPE"].Value.ToString())
  885. {
  886. case "D":
  887. cmbLocationType.Text = "垛位";
  888. break;
  889. case "J":
  890. cmbLocationType.Text = "料架";
  891. break;
  892. }
  893. txtLocaNo.Text = ugr.Cells["LOCATION_NO"].Value.ToString();
  894. cmbLocationAttr.Text = ugr.Cells["LOCATION_ATTR_NAME"].Value.ToString();
  895. txtArea.Value = ugr.Cells["AREA_NO"].Value.ToString();
  896. txtRow.Value = ugr.Cells["ROW_NO"].Value.ToString();
  897. txtColStart.Value = ugr.Cells["COL_NO"].Value.ToString();
  898. txtColEnd.Value = ugr.Cells["COL_NO"].Value.ToString();
  899. txtMemo.Value = ugr.Cells["MEMO"].Value.ToString();
  900. txtXCoordinates.Value = ugr.Cells["X_COORDINATE"].Value.ToString();
  901. txtYCoordinates.Value = ugr.Cells["Y_COORDINATE"].Value.ToString();
  902. txtLocationWidth.Value = ugr.Cells["LOCATION_WIDTH"].Value.ToString();
  903. txtLocationHeght.Value = ugr.Cells["LOCATION_HEIGHT"].Value.ToString();
  904. txtLocationLen.Value = ugr.Cells["LOCATION_LEN"].Value.ToString();
  905. chkLock.Checked = Convert.ToBoolean(ugr.Cells["LOCATION_STATE"].Value);
  906. chkVitual.Checked = Convert.ToBoolean(ugr.Cells["DUMMY_FLAG"].Value);
  907. txtLocationName.Text = ugr.Cells["LOCATION_NAME"].Text.ToString();
  908. txtRackType.Value = ugr.Cells["RACK_TYPE"].Value.ToString();
  909. txtRackQuality.Value = ugr.Cells["RACK_QUALITY"].Value.ToString();
  910. }
  911. private void frmLocationDefine_Shown(object sender, EventArgs e)
  912. {
  913. //toolMenu.Toolbars[0].Tools["Resume"].InstanceProps.Visible = DefaultableBoolean.False;
  914. }
  915. private void ultrlSection_CheckedChanged(object sender, EventArgs e)
  916. {
  917. cbm_Dw.Enabled = this.ultrlSection.Checked;
  918. }
  919. }
  920. }