frmChargeConfig.cs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Text;
  7. using System.Windows.Forms;
  8. using System.Collections;
  9. using System.IO;
  10. using System.Diagnostics;
  11. using Infragistics.Win.UltraWinGrid;
  12. using CoreFS.CA06;
  13. using Core.StlMes.Client.LgCommon;
  14. namespace Core.StlMes.Client.LgResMgt
  15. {
  16. public partial class frmChargeConfig : frmStyleBase
  17. {
  18. private bool ok_flag = false;
  19. public string WorkShopNo = "";
  20. public frmChargeConfig(OpeBase ob_)
  21. {
  22. InitializeComponent();
  23. this.ob = ob_;
  24. }
  25. private void frmCutInfoAssit_Load(object sender, EventArgs e)
  26. {
  27. proc_Query();
  28. }
  29. // 查询全部料斗信息
  30. /// <summary>
  31. /// 查询全部料斗信息
  32. /// </summary>
  33. private void proc_Query()
  34. {
  35. try
  36. {
  37. string strErr = "";
  38. ArrayList arry = new ArrayList();
  39. arry.Add(WorkShopNo);
  40. CommonClientToServer ccTos = new CommonClientToServer();
  41. ccTos.ob = this.ob;
  42. DataSet ds = ccTos.ExecuteQueryFunctionsSqlID("Core.Mes.Server.Common.ComDataAccess",
  43. "QueryWithParameter", "STL_RESULT0001", 5, arry, out strErr);
  44. ultraDataSource1.Rows.Clear();
  45. if (strErr == "" && ds != null)
  46. {
  47. if (ds.Tables.Count > 0)
  48. {
  49. foreach (DataRow dr in ds.Tables[0].Rows)
  50. {
  51. ultraDataSource1.Rows.Add(new object[] {
  52. dr["ID"].ToString(),
  53. dr["CHARGENO"].ToString(),
  54. dr["STATUS"].ToString(),
  55. dr["TAREWEIGHT"].ToString(),
  56. dr["MEMO"].ToString()
  57. });
  58. }
  59. // PublicMethod.RefreshAndAutoSize(ultraGrid1);
  60. }
  61. }
  62. }
  63. catch { }
  64. }
  65. // 新增料斗信息
  66. /// <summary>
  67. /// 新增料斗信息
  68. /// </summary>
  69. private void proc_Add()
  70. {
  71. try
  72. {
  73. if (txtChargeNo.Text.Length == 0)
  74. {
  75. MessageBox.Show("料斗号不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  76. txtChargeNo.Focus();
  77. return;
  78. }
  79. //if (cboCutType.SelectedIndex < 0)
  80. //{
  81. // MessageBox.Show("切割类别不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  82. // cboCutType.Focus();
  83. // return;
  84. //}
  85. //if (ultraFlux.SelectedIndex < 0)
  86. //{
  87. // MessageBox.Show("流号不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  88. // ultraFlux.Focus();
  89. // return;
  90. //}
  91. //if (txtLength.Text.Length == 0)
  92. //{
  93. // MessageBox.Show("长度不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  94. // txtLength.Focus();
  95. // return;
  96. //}
  97. //if (txtWeight.Text.Length == 0)
  98. //{
  99. // MessageBox.Show("重量不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  100. // txtWeight.Focus();
  101. // return;
  102. //}
  103. //if (txtThickness.Text.Length == 0)
  104. //{
  105. // MessageBox.Show("厚度不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  106. // txtThickness.Focus();
  107. // return;
  108. //}
  109. //if (txtWidth.Text.Length == 0)
  110. //{
  111. // MessageBox.Show("宽度不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  112. // txtWidth.Focus();
  113. // return;
  114. //}
  115. string strErr = "";
  116. string strSqlID = "STL_RESULT0002"; //SQLID
  117. Hashtable ht = new Hashtable();
  118. ht.Add("I1", txtChargeNo.Text.Trim()); //料斗号
  119. ht.Add("I2", chkStatus.Checked ? "1" : "0"); //是否在用
  120. ht.Add("I3", txtWeight.Text.Trim()); //重量
  121. ht.Add("I4", WorkShopNo); //车间号
  122. ht.Add("I5", UserInfo.GetUserName()); //维护人
  123. ht.Add("I6", txtMemo.Text.Trim()); //备注
  124. ht.Add("O1", "");
  125. ht.Add("O2", "");
  126. CommonClientToServer ccTs = new CommonClientToServer();
  127. ccTs.ob = ob;
  128. CoreClientParam ccp = ccTs.ExecuteProcedureFunctionsSqlID("Core.Mes.Server.Common.ComDataAccess",
  129. "executeProcedure", strSqlID, 5, ht, out strErr);
  130. ArrayList alReturn = ccp.ReturnObject as ArrayList;
  131. if (alReturn[3].ToString() == "")
  132. {
  133. MessageBox.Show("料斗信息新增成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  134. }
  135. else
  136. {
  137. MessageBox.Show(alReturn[3].ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  138. }
  139. }
  140. catch { }
  141. }
  142. // 修改
  143. /// <summary>
  144. /// 修改
  145. /// </summary>
  146. private void proc_Edit()
  147. {
  148. try
  149. {
  150. //string heatno = txtChargeNo.Text.Trim();
  151. //string strErr = "";
  152. //ArrayList arry = new ArrayList();
  153. //arry.Add("IncisionAssistInfo.Query"); // 位于 QueryLgIntegration.xml 中
  154. //arry.Add(heatno);
  155. //if (WorkShopNo == "1")
  156. //{
  157. // arry.Add("0");
  158. // arry.Add("1");
  159. // arry.Add("2");
  160. //}
  161. //else
  162. //{
  163. // arry.Add("3");
  164. // arry.Add("4");
  165. // arry.Add("5");
  166. //}
  167. //CommonClientToServer ccs = new CommonClientToServer();
  168. //ccs.ob = this.ob;
  169. //DataSet ds = ccs.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery", "doSimpleQuery", arry, out strErr);
  170. //if (ds.Tables[0].Rows.Count == 0)
  171. //{
  172. // MessageBox.Show("炉号【" + heatno + "】不存在切割信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  173. // return;
  174. //}
  175. //if (txtChargeNo.Text.Length != 8)
  176. //{
  177. // MessageBox.Show("炉号不正确!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  178. // txtChargeNo.Focus();
  179. // return;
  180. //}
  181. //if (cboCutType.SelectedIndex < 0)
  182. //{
  183. // MessageBox.Show("切割类别不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  184. // cboCutType.Focus();
  185. // return;
  186. //}
  187. //if (ultraFlux.SelectedIndex < 0)
  188. //{
  189. // MessageBox.Show("流号不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  190. // ultraFlux.Focus();
  191. // return;
  192. //}
  193. //if (txtLength.Text.Length == 0)
  194. //{
  195. // MessageBox.Show("长度不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  196. // txtLength.Focus();
  197. // return;
  198. //}
  199. //if (txtWeight.Text.Length == 0)
  200. //{
  201. // MessageBox.Show("重量不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  202. // txtWeight.Focus();
  203. // return;
  204. //}
  205. //if (txtThickness.Text.Length == 0)
  206. //{
  207. // MessageBox.Show("厚度不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  208. // txtThickness.Focus();
  209. // return;
  210. //}
  211. //if (txtWidth.Text.Length == 0)
  212. //{
  213. // MessageBox.Show("宽度不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  214. // txtWidth.Focus();
  215. // return;
  216. //}
  217. string strErr = "";
  218. string strSqlID = "STL_RESULT0003"; //SQLID
  219. Hashtable ht = new Hashtable();
  220. ht.Add("I1", txtChargeNo.Text.Trim()); //料斗号
  221. ht.Add("I2", chkStatus.Checked ? "1" : "0"); //是否在用
  222. ht.Add("I3", txtWeight.Text.Trim()); //重量
  223. ht.Add("I4", WorkShopNo); //车间号
  224. ht.Add("I5", UserInfo.GetUserName()); //维护人
  225. ht.Add("I6", txtMemo.Text.Trim()); //备注
  226. ht.Add("I7", ultraGrid1.ActiveRow.Cells["ID"].Value.ToString()); //ID
  227. ht.Add("O1", "");
  228. ht.Add("O2", "");
  229. CommonClientToServer ccTs = new CommonClientToServer();
  230. ccTs.ob = ob;
  231. CoreClientParam ccp = ccTs.ExecuteProcedureFunctionsSqlID("Core.Mes.Server.Common.ComDataAccess",
  232. "executeProcedure", strSqlID, 5, ht, out strErr);
  233. ArrayList alReturn = ccp.ReturnObject as ArrayList;
  234. if (strErr == "")
  235. {
  236. MessageBox.Show("料斗信息修改成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  237. }
  238. else
  239. {
  240. MessageBox.Show("料斗信息修改失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  241. }
  242. }
  243. catch { }
  244. }
  245. // 删除
  246. /// <summary>
  247. /// 删除
  248. /// </summary>
  249. private void proc_Delete()
  250. {
  251. try
  252. {
  253. if (ultraGrid1.Rows.Count == 0)
  254. {
  255. MessageBox.Show("没有可删除的信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  256. return;
  257. }
  258. if (ultraGrid1.ActiveRow == null)
  259. {
  260. MessageBox.Show("请选择要删除的信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  261. return;
  262. }
  263. DialogResult dr = MessageBox.Show("是否确认删除信息?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
  264. if (dr == DialogResult.No) return;
  265. string ID = ultraGrid1.ActiveRow.Cells["ID"].Value.ToString().Trim();
  266. string strErr = "";
  267. Hashtable ht = new Hashtable();
  268. ht.Add("I1", ID); //料斗号
  269. ht.Add("O1", "");
  270. ht.Add("O2", "");
  271. CommonClientToServer ccTs = new CommonClientToServer();
  272. ccTs.ob = ob;
  273. CoreClientParam ccp = ccTs.ExecuteProcedureFunctionsSqlID("Core.Mes.Server.Common.ComDataAccess",
  274. "executeProcedure", "STL_RESULT0004", 5, ht, out strErr);
  275. ArrayList alReturn = ccp.ReturnObject as ArrayList;
  276. if (strErr == "")
  277. {
  278. MessageBox.Show("料斗信息删除成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  279. }
  280. else
  281. {
  282. MessageBox.Show("料斗信息删除失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  283. }
  284. }
  285. catch { }
  286. }
  287. // 设置编辑区域是否可编辑
  288. /// <summary>
  289. /// 设置编辑区域是否可编辑
  290. /// </summary>
  291. /// <param name="t_Enable"></param>
  292. private void setToolEnable(bool t_Enable)
  293. {
  294. try
  295. {
  296. txtChargeNo.ReadOnly = t_Enable;
  297. txtWeight.ReadOnly = t_Enable;
  298. chkStatus.Enabled = !t_Enable;
  299. txtMemo.ReadOnly = t_Enable;
  300. }
  301. catch { }
  302. }
  303. // 清空编辑区域
  304. /// <summary>
  305. /// 清空编辑区域
  306. /// </summary>
  307. private void clearWidget()
  308. {
  309. txtChargeNo.Text = "";
  310. txtWeight.Text = "0";
  311. chkStatus.Checked = false;
  312. txtMemo.Text = "";
  313. }
  314. public override void ToolBar_Click(object sender, string ToolbarKey)
  315. {
  316. base.ToolBar_Click(sender, ToolbarKey);
  317. switch (ToolbarKey)
  318. {
  319. case "Query":
  320. this.proc_Query();
  321. break;
  322. case "Add":
  323. this.proc_Add();
  324. break;
  325. case "Update":
  326. this.proc_Edit();
  327. break;
  328. case "Delete":
  329. this.proc_Delete();
  330. break;
  331. case "Export":
  332. try
  333. {
  334. Core.Mes.Client.Comm.Globals.ulGridToExcel(ultraGrid1, Text);
  335. }
  336. catch (Exception ex)
  337. {
  338. MessageBox.Show(ex.Message);
  339. }
  340. break;
  341. case "Upload":
  342. this.proc_Query();
  343. break;
  344. case "Exit":
  345. this.Close();
  346. break;
  347. default:
  348. break;
  349. }
  350. }
  351. private void txtWeight_KeyPress(object sender, KeyPressEventArgs e)
  352. {
  353. if (!(Char.IsNumber(e.KeyChar) || e.KeyChar == '\b' || e.KeyChar == '.'))
  354. {
  355. e.Handled = true;
  356. }
  357. char[] arrary = ((TextBox)sender).Text.ToCharArray();
  358. if (e.KeyChar == '.')
  359. {
  360. if (arrary.Length == 0)
  361. {
  362. ((TextBox)sender).Text = "0.";
  363. ((TextBox)sender).SelectionStart = ((TextBox)sender).Text.Trim().Length;
  364. e.Handled = true;
  365. }
  366. else
  367. {
  368. for (int i = 0; i < arrary.Length; i++)
  369. {
  370. if (arrary[i] == '.')
  371. e.Handled = true;
  372. }
  373. }
  374. }
  375. if (arrary.Length == 1)
  376. {
  377. if (e.KeyChar == '0')
  378. {
  379. if (arrary[0] == '0')
  380. e.Handled = true;
  381. }
  382. if (arrary[0] == '0' && e.KeyChar != '.' && e.KeyChar != '\b' && e.KeyChar != '0')
  383. {
  384. ((TextBox)sender).Text = "0." + e.KeyChar.ToString();
  385. ((TextBox)sender).SelectionStart = ((TextBox)sender).Text.Trim().Length;
  386. e.Handled = true;
  387. }
  388. }
  389. }
  390. private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
  391. {
  392. try
  393. {
  394. SetDetailToolBarEnable(false, "");
  395. setToolEnable(true);
  396. txtChargeNo.Text = ultraGrid1.ActiveRow.Cells["CHARGENO"].Value.ToString();
  397. txtWeight.Text = ultraGrid1.ActiveRow.Cells["TAREWEIGHT"].Value.ToString();
  398. chkStatus.Checked = ultraGrid1.ActiveRow.Cells["STATUS"].Value.ToString() == "是" ? true : false;
  399. txtMemo.Text = ultraGrid1.ActiveRow.Cells["MEMO"].Value.ToString();
  400. }
  401. catch { }
  402. }
  403. // 点击修改或删除时显示确认和取消按钮
  404. /// <summary>
  405. /// 点击修改或删除时显示确认和取消按钮
  406. /// </summary>
  407. /// <param name="bEnable"></param>
  408. private void SetDetailToolBarEnable(bool bEnable, string flag)
  409. {
  410. int count = this.uTbMTool.Tools.Count;
  411. for (int i = 0; i < count; i++)
  412. {
  413. this.uTbMTool.Tools[i].SharedProps.Enabled = !bEnable;
  414. }
  415. this.uTbMTool.Tools["ok"].SharedProps.Enabled = bEnable;
  416. this.uTbMTool.Tools["cancel"].SharedProps.Enabled = bEnable;
  417. this.uTbMTool.Tools["ok"].SharedProps.Visible = bEnable;
  418. this.uTbMTool.Tools["cancel"].SharedProps.Visible = bEnable;
  419. }
  420. private void ultraToolbarsManager_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
  421. {
  422. switch (e.Tool.Key)
  423. {
  424. case "add":
  425. SetDetailToolBarEnable(true, "add");
  426. setToolEnable(false);
  427. this.uTbMTool.Tools["ok"].Tag = "add";
  428. clearWidget();
  429. ok_flag = false;
  430. break;
  431. case "edit":
  432. if (ultraGrid1.Rows.Count == 0)
  433. {
  434. MessageBox.Show("没有可修改的信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  435. return;
  436. }
  437. if (ultraGrid1.ActiveRow == null)
  438. {
  439. MessageBox.Show("请选择要修改的信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  440. return;
  441. }
  442. SetDetailToolBarEnable(true, "edit");
  443. setToolEnable(false);
  444. this.uTbMTool.Tools["ok"].Tag = "edit";
  445. ok_flag = false;
  446. txtChargeNo.ReadOnly = true;
  447. break;
  448. case "del":
  449. proc_Delete();
  450. proc_Query();
  451. break;
  452. case "ok":
  453. string flag = this.uTbMTool.Tools["ok"].Tag.ToString();
  454. if (flag == "edit")
  455. {
  456. proc_Edit();
  457. }
  458. if (flag == "add")
  459. {
  460. proc_Add();
  461. }
  462. if (ok_flag)
  463. {
  464. SetDetailToolBarEnable(false, "");
  465. setToolEnable(true);
  466. }
  467. proc_Query();
  468. break;
  469. case "cancel":
  470. SetDetailToolBarEnable(false, "");
  471. setToolEnable(true);
  472. ultraGrid1_AfterRowActivate(null, null);
  473. break;
  474. case "left":
  475. if (ultraGrid1.Rows.Count == 0) return;
  476. //将位置移动到前一条记录
  477. try
  478. {
  479. if (ultraGrid1.ActiveRow == null)
  480. {
  481. ultraGrid1.Rows[0].Activate();
  482. }
  483. else
  484. {
  485. int nIndex = ultraGrid1.ActiveRow.Index;
  486. nIndex = nIndex - 1;
  487. if (nIndex < 0) nIndex = ultraGrid1.Rows.Count - 1;
  488. ultraGrid1.Rows[nIndex].Activate();
  489. }
  490. }
  491. catch { }
  492. break;
  493. case "right":
  494. if (ultraGrid1.Rows.Count == 0) return;
  495. //将位置移动到后一条记录
  496. try
  497. {
  498. if (ultraGrid1.ActiveRow == null)
  499. {
  500. ultraGrid1.Rows[0].Activate();
  501. }
  502. else
  503. {
  504. int nIndex = ultraGrid1.ActiveRow.Index;
  505. nIndex = nIndex + 1;
  506. if (nIndex >= ultraGrid1.Rows.Count) nIndex = 0;
  507. ultraGrid1.Rows[nIndex].Activate();
  508. }
  509. }
  510. catch { }
  511. break;
  512. }
  513. }
  514. }
  515. }