FrmProductionLineInfo.cs 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903
  1. using Core.Mes.Client.Comm.Control;
  2. using Core.Mes.Client.Comm.Server;
  3. using Core.Mes.Client.Comm.Tool;
  4. using Core.StlMes.Client.Qcm.model;
  5. using CoreFS.CA06;
  6. using Infragistics.Win.Misc;
  7. using Infragistics.Win.UltraWinEditors;
  8. using Infragistics.Win.UltraWinGrid;
  9. using System;
  10. using System.Collections;
  11. using System.Collections.Generic;
  12. using System.Data;
  13. using System.Drawing;
  14. using System.Text.RegularExpressions;
  15. using System.Windows.Forms;
  16. namespace Core.StlMes.Client.Qcm
  17. {
  18. public partial class FrmProductionLineInfo : FrmBase
  19. {
  20. private UltraPopupControlContainer popup = new UltraPopupControlContainer();
  21. private List<TreeViewEntity> listTreeView;
  22. private CtrlTreeView ctrlTreeView;
  23. public FrmProductionLineInfo()
  24. {
  25. InitializeComponent();
  26. IsLoadUserView = true;
  27. }
  28. public void PopupLoad(OpeBase ob)
  29. {
  30. this.ob = ob;
  31. this.OnLoad(EventArgs.Empty);
  32. }
  33. /// <summary>
  34. /// 重写基类方法
  35. /// </summary>
  36. /// <param name="sender"></param>
  37. /// <param name="ToolbarKey"></param>
  38. public override void ToolBar_Click(object sender, string ToolbarKey)
  39. {
  40. switch (ToolbarKey)
  41. {
  42. case "doQuery":
  43. doQuery();
  44. break;
  45. case "doAdd":
  46. doAdd();
  47. break;
  48. case "doModify":
  49. doModify();
  50. break;
  51. case "doDelete":
  52. this.doDeleteOrResume(true);
  53. break;
  54. case "doResume":
  55. this.doDeleteOrResume(false);
  56. break;
  57. case "Refresh":
  58. LoadBaseInfo();
  59. break;
  60. case "Export":
  61. Export();
  62. break;
  63. case "Close":
  64. ((Form)ultraGrid1.TopLevelControl).Close();
  65. break;
  66. }
  67. }
  68. private void Export()
  69. {
  70. GridHelper.ulGridToExcel(ultraGrid1, "生产产线");
  71. }
  72. /// <summary>
  73. /// load事件
  74. /// </summary>
  75. /// <param name="sender"></param>
  76. /// <param name="e"></param>
  77. private void FrmProductionLineInfo_Load(object sender, EventArgs e)
  78. {
  79. LoadBaseInfo();
  80. }
  81. /// <summary>
  82. /// 界面数据初始化
  83. /// </summary>
  84. private void LoadBaseInfo()
  85. {
  86. BindCmbDepart();
  87. cmbDepart.SelectedIndex = 0;
  88. //绑定工序描述数据源
  89. BindCmbProcess();
  90. cmbProcess.SelectedIndex = 0;
  91. //listTreeView = EntityHelper.GetData<TreeViewEntity>(
  92. // "com.steering.pss.qcm.ProductionLineInfo.queryDepartment", new object[]{}, ob);
  93. //ctrlTreeView = new CtrlTreeView(listTreeView);
  94. //ctrlTreeView.CtrlTreeViewDoubleClick += CtrlTreeView_CtrlTreeViewDoubleClick;
  95. //ctrlTreeView.Width = 350;
  96. //popup.PopupControl = ctrlTreeView;
  97. ClsBaseInfo.FillDepartment(cmbDepart, ob, false);
  98. ClsBaseInfo.FillSection(cmbUnit, ob, false);
  99. DataTable dtGroupPay = ClsBaseInfo.GetComBaseInfo("408002", ob);
  100. ultraComboEditor1.DataSource = dtGroupPay;
  101. ultraComboEditor1.DisplayMember = "BASENAME";
  102. ultraComboEditor1.ValueMember = "BASECODE";
  103. ClsBaseInfo.FillComBaseInfo(ultraComboEditor3, "4105", ob, true);
  104. ClsBaseInfo.FillComBaseInfo(ultraComboEditor4, "4106", ob, true);
  105. ((DataTable)ultraComboEditor4.DataSource).DefaultView.Sort = "BASECODE";
  106. //ultraComboEditor5
  107. DataTable dtStorage = ServerHelper.GetData("com.steering.pss.qcm.ProductionLineInfo.getStorageInfo",
  108. null, ob );
  109. ultraComboEditor5.DisplayMember = "STORAGE_NAME";
  110. ultraComboEditor5.ValueMember = "STORAGE_NO";
  111. ultraComboEditor5.DataSource = dtStorage;
  112. ClsBaseInfo.SetComboItemHeight(ultraComboEditor5);
  113. ultraComboEditor6.DisplayMember = "STORAGE_NAME";
  114. ultraComboEditor6.ValueMember = "STORAGE_NO";
  115. ultraComboEditor6.DataSource = dtStorage;
  116. ClsBaseInfo.SetComboItemHeight(ultraComboEditor6);
  117. //加载所属制造商
  118. string basecode = "1205";
  119. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreBaseInfoNew.doQuery", new Object[] { basecode }, this.ob);
  120. manufacturers.DataSource = dt;
  121. manufacturers.DisplayMember = "BASENAME";
  122. manufacturers.ValueMember = "BASECODE";
  123. //加载核算中心
  124. DataTable dtAccounting = ServerHelper.GetData("com.steering.pss.qcm.ProductionLineInfo.getAccountingBaseInfo", new object[] { }, ob);
  125. accounting_center_txt.DataSource = dtAccounting;
  126. accounting_center_txt.DisplayMember = "BASENAME";
  127. accounting_center_txt.ValueMember = "BASECODE";
  128. }
  129. /// <summary>
  130. /// 绑定工序描述数据源
  131. /// </summary>
  132. private void BindCmbProcess()
  133. {
  134. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.ProductionLineInfo.GetProcess", null, this.ob);
  135. cmbProcess.DataSource = dt;
  136. cmbProcess.DisplayMember = "PROCESS_DESC";
  137. cmbProcess.ValueMember = "PROCESS_CODE";
  138. }
  139. /// <summary>
  140. /// 绑定管理部门描述数据源
  141. /// </summary>
  142. private void BindCmbDepart()
  143. {
  144. //DEPARTID, T.DEPARTNAME
  145. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.ProductionLineInfo.queryDepartment", null, this.ob);
  146. cmbDepart.DataSource = dt;
  147. cmbDepart.DisplayMember = "NAME";
  148. cmbDepart.ValueMember = "CODE";
  149. }
  150. /// <summary>
  151. /// 查询
  152. /// </summary>
  153. private void doQuery()
  154. {
  155. bool validFlag = chkValid.Checked;
  156. string plineName = txtPLineName.Text.Trim();
  157. //string departmentDesc = cmbDepartment.Text.Trim();
  158. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.ProductionLineInfo.getLineList", new Object[] { validFlag, plineName }, this.ob);
  159. GridHelper.CopyDataToDatatable(ref dt, ref this.dataTable1, true);
  160. //不同颜色区分是否有效数据
  161. Infragistics.Win.UltraWinGrid.UltraGridRow row = null;
  162. for (int i = 0; i < ultraGrid1.Rows.Count; i++)
  163. {
  164. row = ultraGrid1.Rows[i];
  165. if (!row.Cells["VALIDFLAG"].Value.ToString().Equals("1"))
  166. {
  167. row.Appearance.ForeColor = Color.Red;
  168. }
  169. else
  170. {
  171. row.Appearance.ForeColor = Color.Black;
  172. }
  173. }
  174. //列自适应
  175. GridHelper.RefreshAndAutoSizeExceptRows(ultraGrid1, new UltraGridColumn[] {
  176. ultraGrid1.DisplayLayout.Bands[0].Columns["MEMO"]
  177. });
  178. }
  179. /// <summary>
  180. /// 获取Table中最大编号,自增1返回。
  181. /// </summary>
  182. /// <param name="code"></param>
  183. /// <returns></returns>
  184. private string AutoCode(DataTable dt)
  185. {
  186. int maxCode = 0;
  187. //substring去除S001中的S,得到001。
  188. string maxCodeString = dt.Rows[0][0].ToString().Substring(1);
  189. //是否为数字
  190. if (StringUtil.IsNumber(maxCodeString))
  191. {
  192. maxCode = Convert.ToInt32(maxCodeString);
  193. }
  194. else
  195. {
  196. MessageBox.Show("传入编号格式有误,请查看代码!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  197. }
  198. //比较得出最大id。
  199. for (int i = 1; i < dt.Rows.Count; i++)
  200. {
  201. string maxCodeString_Two = dt.Rows[i][0].ToString().Substring(1);
  202. int maxCode_Two = 0;
  203. if (StringUtil.IsNumber(maxCodeString_Two))
  204. {
  205. maxCode_Two = Convert.ToInt32(maxCodeString_Two);
  206. if (maxCode_Two > maxCode)
  207. {
  208. maxCode = maxCode_Two;
  209. }
  210. }
  211. }
  212. //新增行
  213. maxCode += 1;
  214. string codeTop = "";
  215. if (maxCode < 10)
  216. {
  217. codeTop = "00";
  218. }
  219. else if (maxCode < 100)
  220. {
  221. codeTop = "0";
  222. }
  223. //获取头文字D。
  224. string d = dt.Rows[0][0].ToString().Substring(0, 1);
  225. //头文字+0+最大数字
  226. string newCode = d + codeTop + maxCode;
  227. return newCode;
  228. }
  229. /// <summary>
  230. /// 获取生产产线代码最大值
  231. /// </summary>
  232. /// <returns></returns>
  233. private string GetMaxCode()
  234. {
  235. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.ProductionLineInfo.GetMaxCode", null, this.ob);
  236. string maxCode = "";
  237. if (dt.Rows.Count > 0)
  238. {
  239. if (!"".Equals(dt.Rows[0][0].ToString()))
  240. {
  241. maxCode = dt.Rows[0][0].ToString();
  242. }
  243. else
  244. {
  245. maxCode = "C000";
  246. }
  247. }
  248. return maxCode;
  249. }
  250. /// <summary>
  251. /// 验证描述是否重复。
  252. /// </summary>
  253. /// <param name="name"></param>
  254. /// <returns></returns>
  255. private bool isRepeatName(string name)
  256. {
  257. DataTable dt = new DataTable();
  258. dt = ServerHelper.GetData("com.steering.pss.qcm.ProductionLineInfo.GetName", new Object[] { name }, this.ob);
  259. if (dt.Rows.Count > 0)
  260. {
  261. return true;
  262. }
  263. else
  264. {
  265. return false;
  266. }
  267. }
  268. /// <summary>
  269. /// 新增
  270. /// </summary>
  271. private void doAdd()
  272. {
  273. if (ValidInput())
  274. {
  275. try
  276. {
  277. string plineName = txtName.Text.Trim();
  278. //验证描述不允许重复。
  279. if (isRepeatName(plineName))
  280. {
  281. MessageBox.Show("产线描述\"" + plineName + "\"已存在,请重新输入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  282. return;
  283. }
  284. //自动生成编号
  285. //string plineCode = AutoCode(this.dataTable1);
  286. ArrayList parm = new ArrayList();
  287. //自动生成编号
  288. string plineCode = StringUtil.SequenceIncrease(GetMaxCode());
  289. string departCode = cmbDepart.Value.ToString2();
  290. string departDesc = cmbDepart.Text;
  291. string unitCode = cmbUnit.Value.ToString2();
  292. string unitDesc = cmbUnit.Text;
  293. string processCode = cmbProcess.Value.ToString();
  294. string processDesc = cmbProcess.Text;
  295. string memo = txtMemo.Text.Trim();
  296. parm.Add(plineCode);
  297. parm.Add(plineName);
  298. parm.Add(departCode);
  299. parm.Add(departDesc);
  300. parm.Add(unitCode);
  301. parm.Add(unitDesc);
  302. parm.Add(processCode);
  303. parm.Add(processDesc);
  304. parm.Add(memo);
  305. parm.Add(UserInfo.GetUserName());
  306. parm.Add(ultraTextEditor2.Text.Trim());
  307. parm.Add(ultraTextEditor1.Text.Trim());
  308. parm.Add(ultraTextEditor4.Text.Trim());
  309. parm.Add(ultraTextEditor3.Text.Trim());
  310. parm.Add(ultraTextEditor6.Text.Trim());
  311. parm.Add(ultraTextEditor5.Text.Trim());
  312. parm.Add(ultraTextEditor7.Text.Trim());
  313. parm.Add(ultraComboEditor2.Value.ToString2());
  314. parm.Add(ultraComboEditor1.Value.ToString2());
  315. string toleranceZone = "";
  316. if (ultraNumericEditor1.Value != null)
  317. {
  318. toleranceZone = ultraNumericEditor1.Value.ToString();
  319. }
  320. parm.Add(toleranceZone);
  321. parm.Add(ultraNumericEditor2.Value.ToString2());
  322. parm.Add(ultraNumericEditor3.Value.ToString2());
  323. parm.Add(ultraNumericEditor4.Value.ToString2());
  324. parm.Add(ultraTextEditor8.Text.Trim());
  325. parm.Add(ultraTextEditor9.Text.Trim().ToUpper());
  326. parm.Add(ultraComboEditor3.Value.ToString2());
  327. parm.Add(ultraComboEditor4.Value.ToString2());
  328. parm.Add(ultraComboEditor5.Value.ToString2());
  329. parm.Add(ultraComboEditor6.Value.ToString2());
  330. parm.Add(ultraTextEditor10.Text.Trim());
  331. parm.Add(manufacturers.Value.ToString2());
  332. parm.Add(manufacturers.Text.Trim());
  333. parm.Add(accounting_center_txt.Value.ToString2());
  334. int count = ServerHelper.SetData("com.steering.pss.qcm.ProductionLineInfo.addLineInfo",
  335. new Object[] { parm }, this.ob);
  336. if (count > 0)
  337. {
  338. MessageUtil.ShowTips("新增成功!");
  339. doQuery();
  340. //高亮显示新增的数据
  341. Infragistics.Win.UltraWinGrid.UltraGridRow row = null;
  342. for (int i = 0; i < ultraGrid1.Rows.Count; i++)
  343. {
  344. row = ultraGrid1.Rows[i];
  345. if (row.Cells["PLINE_CODE"].Value.ToString().Equals(plineCode))
  346. {
  347. row.Activate();
  348. break;
  349. }
  350. }
  351. }
  352. }
  353. catch (Exception ex)
  354. {
  355. MessageBox.Show(ex.Message);
  356. }
  357. }
  358. }
  359. /// <summary>
  360. /// 用于验证修改时,描述是否已存在
  361. /// </summary>
  362. private static string VName = "";
  363. /// <summary>
  364. /// 修改
  365. /// </summary>
  366. private void doModify()
  367. {
  368. if (ultraGrid1.ActiveRow == null)
  369. {
  370. MessageBox.Show("请选择需要修改的数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  371. return;
  372. }
  373. string validflagStr = ultraGrid1.ActiveRow.Cells["VALIDFLAG"].Value.ToString();
  374. //无效数据不允许修改
  375. if ("0".Equals(validflagStr))
  376. {
  377. MessageBox.Show("无效数据不支持修改操作。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  378. return;
  379. }
  380. if (ValidInput())
  381. {
  382. try
  383. {
  384. //验证描述不允许重复。
  385. string name = txtName.Text.Trim();
  386. if (!VName.Equals(name))
  387. {
  388. if (isRepeatName(name))
  389. {
  390. MessageBox.Show("产线描述\"" + name + "\"已存在,请重新输入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  391. return;
  392. }
  393. }
  394. //确认修改吗?
  395. if (MessageBox.Show("是否确认修改选中的数据!", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
  396. {
  397. return;
  398. }
  399. ArrayList parm = new ArrayList();
  400. string PlineCode = ultraGrid1.ActiveRow.Cells["PLINE_CODE"].Value.ToString(); ;
  401. parm.Add(name);
  402. parm.Add(cmbDepart.Value.ToString2());
  403. parm.Add(cmbDepart.Text);
  404. parm.Add(cmbUnit.Value.ToString2());
  405. parm.Add(cmbUnit.Text);
  406. parm.Add(cmbProcess.Value.ToString());
  407. parm.Add(cmbProcess.Text);
  408. parm.Add(txtMemo.Text.Trim());
  409. parm.Add(this.UserInfo.GetUserName());
  410. parm.Add(ultraTextEditor2.Text.Trim());
  411. parm.Add(ultraTextEditor1.Text.Trim());
  412. parm.Add(ultraTextEditor4.Text.Trim());
  413. parm.Add(ultraTextEditor3.Text.Trim());
  414. parm.Add(ultraTextEditor6.Text.Trim());
  415. parm.Add(ultraTextEditor5.Text.Trim());
  416. parm.Add(ultraTextEditor7.Text.Trim());
  417. parm.Add(ultraComboEditor2.Value.ToString2());
  418. parm.Add(ultraComboEditor1.Value.ToString2());
  419. string toleranceZone = "";
  420. if (ultraNumericEditor1.Value != null)
  421. {
  422. toleranceZone = ultraNumericEditor1.Value.ToString();
  423. }
  424. parm.Add(toleranceZone);
  425. parm.Add(ultraNumericEditor2.Value.ToString2());
  426. parm.Add(ultraNumericEditor3.Value.ToString2());
  427. parm.Add(ultraNumericEditor4.Value.ToString2());
  428. parm.Add(ultraTextEditor8.Text.Trim());
  429. parm.Add(ultraTextEditor9.Text.Trim().ToUpper());
  430. parm.Add(ultraComboEditor3.Value.ToString2());
  431. parm.Add(ultraComboEditor4.Value.ToString2());
  432. parm.Add(ultraComboEditor5.Value.ToString2());
  433. parm.Add(ultraComboEditor6.Value.ToString2());
  434. parm.Add(ultraTextEditor10.Text.Trim());
  435. parm.Add(manufacturers.Value.ToString2());
  436. parm.Add(manufacturers.Text.Trim());
  437. parm.Add(accounting_center_txt.Value.ToString2());
  438. parm.Add(PlineCode);
  439. //利用JSONFormat.Format(plObj)方法,把自己定义的类,转换成Object[]传送到服务端。用ArrayList是一样的。
  440. int count = ServerHelper.SetData("com.steering.pss.qcm.ProductionLineInfo.updateLineInfo", new Object[] { parm }, this.ob);
  441. if (count > 0)
  442. {
  443. MessageUtil.ShowTips("修改成功!");
  444. doQuery();
  445. //高亮显示修改的数据
  446. Infragistics.Win.UltraWinGrid.UltraGridRow row = null;
  447. for (int i = 0; i < ultraGrid1.Rows.Count; i++)
  448. {
  449. row = ultraGrid1.Rows[i];
  450. if (row.Cells["PLINE_CODE"].Value.ToString().Equals(PlineCode))
  451. {
  452. row.Activate();
  453. break;
  454. }
  455. }
  456. }
  457. }
  458. catch (Exception ex)
  459. {
  460. MessageBox.Show(ex.Message);
  461. }
  462. }
  463. }
  464. /// <summary>
  465. /// 作废或恢复
  466. /// </summary>
  467. /// <param name="isDelete">true作废 false恢复</param>
  468. private void doDeleteOrResume(bool isDelete)
  469. {
  470. if (ultraGrid1.ActiveRow == null)
  471. {
  472. MessageBox.Show("请选择需要" + (isDelete ? "作废" : "恢复") + "的数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  473. return;
  474. }
  475. string validflagStr = ultraGrid1.ActiveRow.Cells["VALIDFLAG"].Value.ToString();
  476. //无效数据不允许作废
  477. if ("0".Equals(validflagStr))
  478. {
  479. if (isDelete)
  480. {
  481. MessageBox.Show("无效数据不支持作废操作。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  482. return;
  483. }
  484. }
  485. else
  486. {
  487. //有效数据不允许恢复
  488. if (!isDelete)
  489. {
  490. MessageBox.Show("有效数据不支持恢复操作。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  491. return;
  492. }
  493. }
  494. UltraGridRow row = ultraGrid1.ActiveRow;
  495. ArrayList param = new ArrayList();
  496. string pline_code = row.Cells["PLINE_CODE"].Value.ToString();
  497. param.Add(pline_code);
  498. if (param.Count > 0 && MessageBox.Show("是否确认" + (isDelete ? "作废" : "恢复") + "选中的数据!", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
  499. {
  500. try
  501. {
  502. int count = ServerHelper.SetData("com.steering.pss.qcm.ProductionLineInfo.deleteLineInfo", new Object[] { param, UserInfo.GetUserName(), isDelete }, this.ob);
  503. if (count > 0)
  504. {
  505. doQuery();
  506. Infragistics.Win.UltraWinGrid.UltraGridRow rowD = null;
  507. for (int i = 0; i < ultraGrid1.Rows.Count; i++)
  508. {
  509. rowD = ultraGrid1.Rows[i];
  510. if (rowD.Cells["PLINE_CODE"].Value.ToString().Equals(pline_code))
  511. {
  512. rowD.Activate();
  513. break;
  514. }
  515. }
  516. }
  517. }
  518. catch (Exception ex)
  519. {
  520. MessageBox.Show(ex.Message);
  521. }
  522. }
  523. }
  524. /// <summary>
  525. /// 验证非空字段
  526. /// </summary>
  527. /// <returns></returns>
  528. private bool ValidInput()
  529. {
  530. if (string.IsNullOrEmpty(txtName.Text.Trim()))
  531. {
  532. MessageBox.Show("请输入产线描述!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  533. return false;
  534. }
  535. //if (cmbDepart.SelectedRow == null)
  536. //{
  537. // MessageBox.Show("请选择管理部门!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  538. // return false;
  539. //}
  540. string lengthmax = ultraTextEditor1.Text.Trim(); //上限
  541. string lengthmin = ultraTextEditor2.Text.Trim(); //下限
  542. if (lengthmin == "")
  543. {
  544. MessageBox.Show("请输入成品长度下限值!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  545. return false;
  546. }
  547. else
  548. {
  549. if (!StringUtil.IsNumber(lengthmin))
  550. {
  551. MessageBox.Show("成品长度下限值:请输入数值!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  552. return false;
  553. }
  554. }
  555. if (lengthmax == "")
  556. {
  557. MessageBox.Show("请输入成品长度上限值!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  558. return false;
  559. }
  560. else
  561. {
  562. if (!StringUtil.IsNumber(lengthmax))
  563. {
  564. MessageBox.Show("成品长度上限值:请输入数值!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  565. return false;
  566. }
  567. }
  568. if (Convert.ToDouble(lengthmax) < Convert.ToDouble(lengthmin))
  569. {
  570. MessageBox.Show("成品长度上限不能小于成品长度下限", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  571. return false;
  572. }
  573. if (cmbProcess.Text.Equals("轧管"))
  574. {
  575. string ringlengthmin = ultraTextEditor4.Text.Trim(); //环型下限
  576. string ringlengthmax = ultraTextEditor3.Text.Trim(); //环形上限
  577. string cubelengthmin = ultraTextEditor6.Text.Trim(); //脱机下限
  578. string cubelengthmax = ultraTextEditor5.Text.Trim(); //脱机上限
  579. if (ringlengthmin == "")
  580. {
  581. MessageBox.Show("请输入环形炉长度下限值!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  582. ultraTextEditor4.Focus();
  583. return false;
  584. }
  585. else
  586. {
  587. if (!StringUtil.IsNumber(ringlengthmin))
  588. {
  589. MessageBox.Show("环形炉长度下限值:请输入数字!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  590. ultraTextEditor4.Focus();
  591. return false;
  592. }
  593. }
  594. if (ringlengthmax == "")
  595. {
  596. MessageBox.Show("请输入环形炉长度上限值!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  597. ultraTextEditor3.Focus();
  598. return false;
  599. }
  600. else
  601. {
  602. if (!StringUtil.IsNumber(ringlengthmax))
  603. {
  604. MessageBox.Show("环形炉长度上限值:请输入数字!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  605. ultraTextEditor3.Focus();
  606. return false;
  607. }
  608. }
  609. if (Convert.ToDouble(ringlengthmax) < Convert.ToDouble(ringlengthmin))
  610. {
  611. MessageBox.Show("环形炉长度上限不能小于环形炉长度下限", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  612. return false;
  613. }
  614. if (cubelengthmin == "")
  615. {
  616. MessageBox.Show("请输入脱机管长度下限值!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  617. ultraTextEditor6.Focus();
  618. return false;
  619. }
  620. else
  621. {
  622. if (!StringUtil.IsNumber(cubelengthmin))
  623. {
  624. MessageBox.Show("脱机管长度下限值:请输入数字!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  625. ultraTextEditor6.Focus();
  626. return false;
  627. }
  628. }
  629. if (cubelengthmax == "")
  630. {
  631. MessageBox.Show("请输入脱机管长度上限值!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  632. ultraTextEditor5.Focus();
  633. return false;
  634. }
  635. else
  636. {
  637. if (!StringUtil.IsNumber(cubelengthmax))
  638. {
  639. MessageBox.Show("脱机管长度上限值:请输入数字!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  640. ultraTextEditor5.Focus();
  641. return false;
  642. }
  643. }
  644. if (Convert.ToDouble(cubelengthmax) < Convert.ToDouble(cubelengthmin))
  645. {
  646. MessageBox.Show("脱机管长度上限不能小于脱机管长度下限", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  647. return false;
  648. }
  649. if (ultraTextEditor7.Text.Trim() == "")
  650. {
  651. MessageBox.Show("请输入冷床长度!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  652. return false;
  653. }
  654. else
  655. {
  656. if (!StringUtil.IsNumber(ultraTextEditor7.Text.Trim()))
  657. {
  658. MessageBox.Show("冷床长度:请输入数字!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  659. return false;
  660. }
  661. }
  662. }
  663. if (ultraTextEditor8.Text.Trim() != "" && ultraTextEditor8.Text.Length != 2)
  664. {
  665. MessageBox.Show("检验委托号缩写必须为两个字符!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  666. return false;
  667. }
  668. //if (ultraTextEditor9.Text.Trim() == "")
  669. //{
  670. // MessageBox.Show("请输入产线标识符!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  671. // return false;
  672. //}
  673. if (ultraTextEditor9.Text.Trim() != "" && !Regex.IsMatch(ultraTextEditor9.Text.Trim(), @"^[a-zA-Z]*$"))
  674. {
  675. MessageBox.Show("产线标识符只能输入字母!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  676. return false;
  677. }
  678. return true;
  679. }
  680. /// <summary>
  681. /// GRID ROW激活时信息带至编辑区
  682. /// </summary>
  683. /// <param name="sender"></param>
  684. /// <param name="e"></param>
  685. private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
  686. {
  687. Infragistics.Win.UltraWinGrid.UltraGridRow row = ultraGrid1.ActiveRow;
  688. if (row != null)
  689. {
  690. txtName.Text = row.Cells["PLINE_NAME"].Value.ToString();
  691. VName = txtName.Text.Trim();
  692. cmbDepart.Value = row.Cells["DEPARTMENT_CODE_P"].Value.ToString();
  693. cmbUnit.Value = row.Cells["DEPARTMENT_CODE"].Value.ToString();
  694. cmbProcess.Value = row.Cells["PROCESS_CODE"].Value.ToString();
  695. accounting_center_txt.Value = row.Cells["ACCOUNTING_CENTER"].Value.ToString();
  696. txtMemo.Text = row.Cells["MEMO"].Value.ToString();
  697. ultraTextEditor2.Text = row.Cells["LENGTH_MIN"].Value.ToString();
  698. ultraTextEditor1.Text = row.Cells["LENGTH_MAX"].Value.ToString();
  699. ultraTextEditor4.Text = row.Cells["LENGTH_MIN_RING"].Value.ToString();
  700. ultraTextEditor3.Text = row.Cells["LENGTH_MAX_RING"].Value.ToString();
  701. ultraTextEditor6.Text = row.Cells["LENGTH_MIN_TUBE"].Value.ToString();
  702. ultraTextEditor5.Text = row.Cells["LENGTH_MAX_TUBE"].Value.ToString();
  703. ultraTextEditor7.Text = row.Cells["LENGTH_COLDBED"].Value.ToString();
  704. ultraComboEditor2.Text = row.Cells["GROUP_PLAN"].Value.ToString();
  705. ultraComboEditor1.Text = row.Cells["GROUP_PAY"].Value.ToString();
  706. ultraNumericEditor2.Value = row.GetValue("BURNOUT_RATE");
  707. ultraNumericEditor3.Value = row.GetValue("IN_MATERIAL_LEN_MIN");
  708. ultraNumericEditor4.Value = row.GetValue("IN_MATERIAL_LEN_MAX");
  709. ultraTextEditor8.Text = row.GetValue("CHECK_NO_SHORT");
  710. ultraTextEditor9.Text = row.GetValue("SPLINE_DESC");
  711. ultraComboEditor3.Value = row.GetValue("FACTORY_CODE");
  712. ultraComboEditor4.Value = row.GetValue("CHECK_STATION");
  713. ultraComboEditor5.Value = row.GetValue("IN_REPOSITORY");
  714. ultraComboEditor6.Value = row.GetValue("OUT_REPOSITORY");
  715. ultraTextEditor10.Text = row.GetValue("VELOCITY_FLOW");
  716. double toleanceZone = 0;
  717. if (row.Cells["TOLERANCE_ZONE"].Value != null && !row.Cells["TOLERANCE_ZONE"].Value.ToString().Equals(""))
  718. {
  719. toleanceZone = double.Parse(row.Cells["TOLERANCE_ZONE"].Value.ToString());
  720. }
  721. ultraNumericEditor1.Value = toleanceZone;
  722. manufacturers.Value = row.GetValue("SUPPLY_UNIT_CODE");
  723. }
  724. }
  725. private void SetDControl(bool enable)
  726. {
  727. foreach (System.Windows.Forms.Control control in ultraGroupBox1.Controls)
  728. {
  729. if (control is UltraTextEditor || control is UltraNumericEditor)
  730. {
  731. control.Enabled = enable;
  732. }
  733. }
  734. }
  735. private void cmbProcess_ValueChanged(object sender, EventArgs e)
  736. {
  737. if (cmbProcess.Value.ToString() == "D")
  738. {
  739. SetDControl(true);
  740. }
  741. else if (cmbProcess.Value.ToString() == "E" || cmbProcess.Value.ToString() == "F")
  742. {
  743. SetDControl(false);
  744. ultraNumericEditor2.Enabled = true;
  745. }
  746. else
  747. {
  748. SetDControl(false);
  749. }
  750. if (cmbProcess.Value.ToString() == "F")
  751. {
  752. DataTable dtGroupPlan = ClsBaseInfo.GetComBaseInfo("2005", ob);
  753. ultraComboEditor2.DataSource = dtGroupPlan;
  754. ultraComboEditor2.DisplayMember = "BASENAME";
  755. ultraComboEditor2.ValueMember = "BASECODE";
  756. ultraComboEditor2.Enabled = true;
  757. }
  758. else if (cmbProcess.Value.ToString() == "G")
  759. {
  760. DataTable dtGroupPlan = ClsBaseInfo.GetComBaseInfo("2004", ob);
  761. ultraComboEditor2.DataSource = dtGroupPlan;
  762. ultraComboEditor2.DisplayMember = "BASENAME";
  763. ultraComboEditor2.ValueMember = "BASECODE";
  764. ultraComboEditor2.Enabled = true;
  765. }
  766. else
  767. {
  768. ultraComboEditor2.DataSource = null;
  769. ultraComboEditor2.Enabled = false;
  770. }
  771. }
  772. private void cmbDepart_AfterDropDown(object sender, EventArgs e)
  773. {
  774. //int x = ultraExpandableGroupBox1.PointToScreen(cmbDepart.Location).X + 2;
  775. //int y = ultraExpandableGroupBox1.PointToScreen(cmbDepart.Location).Y - popup.PopupControl.Height + 20;
  776. //string code = cmbDepart.Value.ToString2();
  777. //popup.Show(new Point(x, y));
  778. //ctrlTreeView.Focus();
  779. //ctrlTreeView.SetTreeViewNodeSelected(code);
  780. }
  781. private void CtrlTreeView_CtrlTreeViewDoubleClick(object sender, EventArgs e)
  782. {
  783. cmbDepart.Value = ctrlTreeView.NodeCode;
  784. popup.Close();
  785. }
  786. private void cmbDepart_ValueChanged(object sender, EventArgs e)
  787. {
  788. cmbUnit.Value = null;
  789. DataTable dt = (DataTable)cmbUnit.DataSource;
  790. if (dt != null) dt.DefaultView.RowFilter = "PID = '" + cmbDepart.Value.ToString2() + "'";
  791. }
  792. }
  793. }