frmCutInfoAssit.cs 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739
  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.Mes.Client.Common;
  14. using Core.LgMes.Client.Comm;
  15. namespace Core.LgMes.Client.LgResMgt
  16. {
  17. public partial class frmCutInfoAssit : frmStyleBase
  18. {
  19. private bool bAddNow, bEditNow, bDelNow; //是否在进行新增、修改或者删除操作
  20. private UltraGridRow currRow = null;
  21. private CoreClientParam par;
  22. private string strReturn = "ExecuteCommand_Return";
  23. public frmCutInfoAssit()
  24. {
  25. InitializeComponent();
  26. }
  27. private void frmCutInfoAssit_Load(object sender, EventArgs e)
  28. {
  29. proc_Init();
  30. proc_Query("", -1);
  31. proc_SetToolbarButtons();
  32. }
  33. private void proc_Init()
  34. {
  35. try
  36. {
  37. ultraDateTimeEditor1.DateTime = DateTime.Today;
  38. ultraDateTimeEditor2.DateTime = DateTime.Today;
  39. par = new CoreClientParam();
  40. par.ServerName = "lgResMgt.Core.LgMes.Server.LgResMgt";
  41. par.MethodName = "classResCommonModule";
  42. //par.ClassName = "Core.LgMes.Server.LgResMgt.classResCommonModule";
  43. }
  44. catch (Exception ex)
  45. {
  46. MessageBox.Show("初始化失败!\r\n" + ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
  47. if (MessageBox.Show("点击[是]将重新初始化,强烈建议执行此操作!", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
  48. {
  49. proc_Init();
  50. }
  51. }
  52. }
  53. private void proc_SetToolbarButtons()
  54. {
  55. try
  56. {
  57. ultraToolbarsManager1.Toolbars[0].Tools["QUERY"].SharedProps.Enabled = !(bAddNow || bEditNow || bDelNow);
  58. ultraToolbarsManager1.Toolbars[0].Tools["NEW"].SharedProps.Enabled = !(bAddNow || bEditNow || bDelNow);
  59. ultraToolbarsManager1.Toolbars[0].Tools["MODIFY"].SharedProps.Enabled = (!(bAddNow || bEditNow || bDelNow) && (ultraGrid1.ActiveRow != null));
  60. ultraToolbarsManager1.Toolbars[0].Tools["DEL"].SharedProps.Enabled = (!(bAddNow || bEditNow || bDelNow) && (ultraGrid1.ActiveRow != null));
  61. ultraToolbarsManager1.Toolbars[0].Tools["EXPORT"].SharedProps.Enabled = (!(bAddNow || bEditNow || bDelNow) && ultraGrid1.Rows.Count > 0);
  62. ultraToolbarsManager1.Toolbars[0].Tools["SAVE"].SharedProps.Enabled = (bAddNow || bEditNow);
  63. ultraToolbarsManager1.Toolbars[0].Tools["CANCEL"].SharedProps.Enabled = (bAddNow || bEditNow);
  64. ultraToolbarsManager1.Toolbars[0].Tools["SAVE"].SharedProps.Visible = (bAddNow || bEditNow);
  65. ultraToolbarsManager1.Toolbars[0].Tools["CANCEL"].SharedProps.Visible = (bAddNow || bEditNow);
  66. }
  67. catch { }
  68. }
  69. private void proc_SetUltraGridReadOnly(Infragistics.Win.UltraWinGrid.UltraGridBase ultGrid)
  70. {
  71. foreach (UltraGridRow row in ultGrid.Rows)
  72. {
  73. row.Activation = Activation.ActivateOnly;
  74. }
  75. }
  76. private void proc_setCellReadOnly(UltraGridRow row, bool bReadOnly)
  77. {
  78. try
  79. {
  80. if (row == null)
  81. return;
  82. if (bReadOnly)
  83. {
  84. row.Activation = Activation.ActivateOnly;
  85. row.CellAppearance.BackColor = Color.White;
  86. foreach (Infragistics.Win.UltraWinGrid.UltraGridCell cell in row.Cells)
  87. {
  88. cell.CancelUpdate();
  89. }
  90. }
  91. else
  92. {
  93. row.Activation = Activation.AllowEdit;
  94. row.CellAppearance.BackColor = Color.Khaki;
  95. row.Cells["CATEGORY"].Activation = Activation.AllowEdit;
  96. row.Cells["LENGTH"].Activation = Activation.AllowEdit;
  97. row.Cells["THICKNESS"].Activation = Activation.AllowEdit;
  98. row.Cells["WIDTH"].Activation = Activation.AllowEdit;
  99. row.Cells["WEIGHT"].Activation = Activation.AllowEdit;
  100. row.Cells["CUTTIME"].Activation = Activation.AllowEdit;
  101. row.Cells["BILLETNO"].Activation = Activation.ActivateOnly;
  102. row.Cells["SERIALNUM"].Activation = Activation.ActivateOnly;
  103. row.Cells["HEATNO"].Activation = Activation.ActivateOnly;
  104. row.Cells["BOOKER"].Activation = Activation.ActivateOnly;
  105. row.Cells["OPTDATE"].Activation = Activation.ActivateOnly;
  106. }
  107. }
  108. catch (Exception ex)
  109. {
  110. MessageBox.Show(ex.Message);
  111. }
  112. }
  113. private void proc_Query(string strBilletNo, int iSerialNum)
  114. {
  115. Cursor oldCursor = this.Cursor;
  116. this.Cursor = Cursors.WaitCursor;
  117. try
  118. {
  119. string strFrom = ultraDateTimeEditor1.DateTime.ToString("yyyy-MM-dd");
  120. string strTo = ultraDateTimeEditor2.DateTime.ToString("yyyy-MM-dd");
  121. string strWhere = "where to_char(CUTTIME, 'yyyy-MM-dd') between '" + strFrom + "' and '" + strTo + "'";
  122. string str = "";
  123. str = ultraTextEditor1.Text.Trim();
  124. if (str.Length > 0)
  125. strWhere += " and BILLETNO = '" + str + "'";
  126. str = ultraTextEditor2.Text.Trim();
  127. if (str.Length > 0)
  128. strWhere += " and HEATNO = '" + str + "'";
  129. string strErr = "";
  130. string strSql = "select BILLETNO, HEATNO, CATEGORY, "
  131. + "LENGTH, THICKNESS, WIDTH, WEIGHT, CUTTIME, BOOKER, OPTDATE, SERIALNUM "
  132. + "from JOB_INCISION_ASSIST " + strWhere + " order by CUTTIME desc, BILLETNO, SERIALNUM desc";
  133. par.MethodName = strReturn;
  134. par.ServerParams = new object[] { strSql };
  135. DataSet ds = null;//hengxing ClientCommon._RemotingHelp.ExecuteMethod(par, out strErr) as DataSet;
  136. if (strErr != "" || !(ds != null && ds.Tables.Count > 0))
  137. {
  138. MessageBox.Show("数据加载失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  139. if (MessageBox.Show("是否重新加载数据?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
  140. proc_Query(strBilletNo, iSerialNum);
  141. return;
  142. }
  143. if (ds != null && ds.Tables.Count > 0)
  144. {
  145. this.dataTable1.Rows.Clear();
  146. DataRow dr;
  147. for (int iRow = 0; iRow < ds.Tables[0].Rows.Count; iRow++)
  148. {
  149. dr = this.dataTable1.NewRow();
  150. for (int jCol = 0; jCol < ds.Tables[0].Columns.Count; jCol++)
  151. {
  152. dr[ds.Tables[0].Columns[jCol].ColumnName] = Convert.ToString(ds.Tables[0].Rows[iRow][jCol]);
  153. }
  154. this.dataTable1.Rows.Add(dr);
  155. }
  156. ultraGrid1.UpdateData();
  157. }
  158. this.proc_SetUltraGridReadOnly(ultraGrid1);
  159. if (ultraGrid1.Rows.Count > 0)
  160. {
  161. ultraGrid1.ActiveCell = ultraGrid1.Rows[0].Cells["HEATNO"];
  162. ultraGrid1.Rows[0].Cells["HEATNO"].Selected = false;
  163. }
  164. if (strBilletNo.Trim().Length == 0) return;
  165. int iNum = 0;
  166. for (int i = 0; i < ultraGrid1.Rows.Count; i++)
  167. {
  168. str = Convert.ToString(ultraGrid1.Rows[i].Cells["BILLETNO"].Value);
  169. iNum = Convert.ToInt32(ultraGrid1.Rows[i].Cells["SERIALNUM"].Value);
  170. if (str == strBilletNo && iNum == iSerialNum)
  171. {
  172. ultraGrid1.ActiveCell = ultraGrid1.Rows[i].Cells["BILLETNO"];
  173. ultraGrid1.Rows[i].Cells["BILLETNO"].Selected = false;
  174. return;
  175. }
  176. }
  177. }
  178. catch (Exception ex)
  179. {
  180. MessageBox.Show(ex.Message);
  181. }
  182. finally
  183. {
  184. this.Cursor = oldCursor;
  185. }
  186. }
  187. private bool proc_CheckData(ref UltraGridRow row, out string strErr, out ArrayList alist)
  188. {
  189. strErr = "";
  190. alist = new ArrayList();
  191. try
  192. {
  193. if (row == null)
  194. {
  195. strErr = "未明确定义数据!";
  196. return false;
  197. }
  198. string str = "";
  199. decimal dValue = 0.0M;
  200. str = Convert.ToString(row.Cells["BILLETNO"].Value).Trim();
  201. if (str.Length == 0)
  202. {
  203. strErr = "请选择坯料号!";
  204. ultraGrid1.ActiveCell = row.Cells["BILLETNO"];
  205. return false;
  206. }
  207. alist.Add(str);
  208. str = Convert.ToString(row.Cells["SERIALNUM"].Value).Trim();
  209. alist.Add(str);
  210. str = Convert.ToString(row.Cells["HEATNO"].Value).Trim();
  211. alist.Add(str);
  212. str = Convert.ToString(row.Cells["CATEGORY"].Value).Trim();
  213. if (str.Length == 0)
  214. {
  215. strErr = "请选择类别!";
  216. ultraGrid1.ActiveCell = row.Cells["CATEGORY"];
  217. return false;
  218. }
  219. alist.Add(str);
  220. str = Convert.ToString(row.Cells["LENGTH"].Value).Trim();
  221. if (str.Length > 0 && !decimal.TryParse(str, out dValue))
  222. {
  223. strErr = "长度不正确!";
  224. ultraGrid1.ActiveCell = row.Cells["LENGTH"];
  225. return false;
  226. }
  227. alist.Add(str);
  228. str = Convert.ToString(row.Cells["THICKNESS"].Value).Trim();
  229. if (str.Length > 0 && !decimal.TryParse(str, out dValue))
  230. {
  231. strErr = "厚度不正确!";
  232. ultraGrid1.ActiveCell = row.Cells["THICKNESS"];
  233. return false;
  234. }
  235. alist.Add(str);
  236. str = Convert.ToString(row.Cells["WIDTH"].Value).Trim();
  237. if (str.Length > 0 && !decimal.TryParse(str, out dValue))
  238. {
  239. strErr = "宽度不正确!";
  240. ultraGrid1.ActiveCell = row.Cells["WIDTH"];
  241. return false;
  242. }
  243. alist.Add(str);
  244. str = Convert.ToString(row.Cells["WEIGHT"].Value).Trim();
  245. if (str.Length > 0 && !decimal.TryParse(str, out dValue))
  246. {
  247. strErr = "重量不正确!";
  248. ultraGrid1.ActiveCell = row.Cells["WEIGHT"];
  249. return false;
  250. }
  251. alist.Add(str);
  252. str = Convert.ToString(row.Cells["CUTTIME"].Value).Trim();
  253. if (str.Length == 0)
  254. {
  255. strErr = "请录入切割时间!";
  256. ultraGrid1.ActiveCell = row.Cells["CUTTIME"];
  257. return false;
  258. }
  259. alist.Add(str);
  260. alist.Add(this.UserInfo.GetUserName());
  261. }
  262. catch (Exception ex)
  263. {
  264. strErr = ex.Message.ToString();
  265. return false;
  266. }
  267. return true;
  268. }
  269. private void proc_Add()
  270. {
  271. try
  272. {
  273. if (currRow == null) return;
  274. ultraGrid1.UpdateData();
  275. string strMsg = "";
  276. ArrayList alist;
  277. if (!this.proc_CheckData(ref currRow, out strMsg, out alist))
  278. {
  279. MessageBox.Show(strMsg, "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  280. this.ultraGrid1.Focus();
  281. this.ultraGrid1.PerformAction(UltraGridAction.EnterEditMode, false, false);
  282. return;
  283. }
  284. par.MethodName = "CutInfoAssit_Add";
  285. par.ServerParams = new object[] { alist };
  286. int iNum = 0;//hengxing (int)ClientCommon._RemotingHelp.ExecuteMethod(par, out strMsg);
  287. if (iNum < 0)
  288. {
  289. MessageBox.Show("实绩信息保存失败!\r\n" + strMsg, "出错", MessageBoxButtons.OK, MessageBoxIcon.Error);
  290. return;
  291. }
  292. this.proc_setCellReadOnly(currRow, true);
  293. this.proc_Query(alist[0].ToString(), iNum);
  294. currRow = null;
  295. bAddNow = false;
  296. this.proc_SetToolbarButtons();
  297. }
  298. catch (Exception ex)
  299. {
  300. MessageBox.Show(ex.Message);
  301. }
  302. }
  303. private void proc_Edit()
  304. {
  305. try
  306. {
  307. if (currRow == null) return;
  308. ultraGrid1.UpdateData();
  309. string strMsg = "";
  310. ArrayList alist;
  311. if (!this.proc_CheckData(ref currRow, out strMsg, out alist))
  312. {
  313. MessageBox.Show(strMsg, "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  314. this.ultraGrid1.Focus();
  315. this.ultraGrid1.PerformAction(UltraGridAction.EnterEditMode, false, false);
  316. return;
  317. }
  318. par.MethodName = "CutInfoAssit_Edit";
  319. par.ServerParams = new object[] { alist };
  320. int iFlag = 0;//hengxing (int)ClientCommon._RemotingHelp.ExecuteMethod(par, out strMsg);
  321. if (iFlag < 0)
  322. {
  323. MessageBox.Show("实绩信息保存失败!\r\n" + strMsg, "出错", MessageBoxButtons.OK, MessageBoxIcon.Error);
  324. return;
  325. }
  326. this.proc_setCellReadOnly(currRow, true);
  327. this.proc_Query(alist[0].ToString(), Convert.ToInt32(alist[1].ToString()));
  328. currRow = null;
  329. bEditNow = false;
  330. this.proc_SetToolbarButtons();
  331. }
  332. catch (Exception ex)
  333. {
  334. MessageBox.Show(ex.Message);
  335. }
  336. }
  337. private void proc_Delete()
  338. {
  339. try
  340. {
  341. if (this.ultraGrid1.Rows.Count == 0) return;
  342. if (this.ultraGrid1.ActiveRow == null)
  343. {
  344. MessageBox.Show("请选择要删除的实绩信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  345. return;
  346. }
  347. if (MessageBox.Show("确定要删除所选实绩信息吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
  348. return;
  349. UltraGridRow row = ultraGrid1.ActiveRow;
  350. ArrayList alist = new ArrayList();
  351. alist.Add(Convert.ToString(row.Cells["BILLETNO"].Value));
  352. alist.Add(Convert.ToString(row.Cells["SERIALNUM"].Value));
  353. par.MethodName = "CutInfoAssit_Del";
  354. par.ServerParams = new object[] { alist };
  355. string strMsg = "";
  356. int iFlag = 0;//hengxing (int)ClientCommon._RemotingHelp.ExecuteMethod(par, out strMsg);
  357. if (iFlag < 0)
  358. {
  359. MessageBox.Show("实绩信息删除失败!\r\n" + strMsg, "出错", MessageBoxButtons.OK, MessageBoxIcon.Error);
  360. return;
  361. }
  362. this.proc_Query("", -1);
  363. }
  364. catch (Exception ex)
  365. {
  366. MessageBox.Show(ex.Message);
  367. }
  368. }
  369. public override void ToolBar_Click(object sender, string ToolbarKey)
  370. {
  371. base.ToolBar_Click(sender, ToolbarKey);
  372. switch (ToolbarKey)
  373. {
  374. case "Exit":
  375. this.Close();
  376. break;
  377. default:
  378. break;
  379. }
  380. }
  381. private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
  382. {
  383. switch (e.Tool.Key)
  384. {
  385. case "QUERY":
  386. {
  387. if (bAddNow || bEditNow || bDelNow)
  388. return;
  389. proc_Query("", -1);
  390. proc_SetToolbarButtons();
  391. break;
  392. }
  393. case "NEW":
  394. {
  395. if (bAddNow || bEditNow || bDelNow)
  396. return;
  397. currRow = this.ultraGrid1.DisplayLayout.Bands[0].AddNew();
  398. this.proc_setCellReadOnly(currRow, false);
  399. currRow.Cells["CUTTIME"].Value = DateTime.Now;
  400. bAddNow = true;
  401. ultraGrid1.ActiveCell = currRow.Cells["BILLETNO"];
  402. currRow.Cells["BILLETNO"].Selected = false;
  403. this.proc_SetToolbarButtons();
  404. break;
  405. }
  406. case "MODIFY":
  407. {
  408. if (ultraGrid1.ActiveRow == null || (bAddNow || bEditNow || bDelNow))
  409. return;
  410. currRow = ultraGrid1.ActiveRow;
  411. this.proc_setCellReadOnly(currRow, false);
  412. bEditNow = true;
  413. ultraGrid1.ActiveCell = currRow.Cells["BILLETNO"];
  414. currRow.Cells["BILLETNO"].Selected = false;
  415. currRow.Cells["BILLETNO"].Tag = currRow.Cells["BILLETNO"].Value;
  416. currRow.Cells["HEATNO"].Tag = currRow.Cells["HEATNO"].Value;
  417. currRow.Cells["CATEGORY"].Tag = currRow.Cells["CATEGORY"].Value;
  418. currRow.Cells["LENGTH"].Tag = currRow.Cells["LENGTH"].Value;
  419. currRow.Cells["THICKNESS"].Tag = currRow.Cells["THICKNESS"].Value;
  420. currRow.Cells["WIDTH"].Tag = currRow.Cells["WIDTH"].Value;
  421. currRow.Cells["WEIGHT"].Tag = currRow.Cells["WEIGHT"].Value;
  422. currRow.Cells["CUTTIME"].Tag = currRow.Cells["CUTTIME"].Value;
  423. this.proc_SetToolbarButtons();
  424. break;
  425. }
  426. case "DEL":
  427. {
  428. if (ultraGrid1.ActiveRow == null || (bAddNow || bEditNow || bDelNow))
  429. return;
  430. bDelNow = true;
  431. this.proc_SetToolbarButtons();
  432. proc_Delete();
  433. bDelNow = false;
  434. this.proc_SetToolbarButtons();
  435. break;
  436. }
  437. case "SAVE":
  438. {
  439. if (bAddNow)
  440. {
  441. proc_Add();
  442. }
  443. else if (bEditNow)
  444. {
  445. proc_Edit();
  446. }
  447. break;
  448. }
  449. case "CANCEL":
  450. {
  451. if (!(bAddNow || bEditNow)) return;
  452. string strOpt = " [" + (bAddNow ? "新增" : (bEditNow ? "修改" : "")) + "]";
  453. if (MessageBox.Show("确定要取消" + strOpt + "操作吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
  454. return;
  455. if (bAddNow)
  456. {
  457. currRow.Delete(false);
  458. currRow = null;
  459. if (ultraGrid1.Rows.Count > 0)
  460. {
  461. ultraGrid1.ActiveCell = ultraGrid1.Rows[ultraGrid1.Rows.Count - 1].Cells["BILLETNO"];
  462. ultraGrid1.Rows[ultraGrid1.Rows.Count - 1].Cells["BILLETNO"].Selected = false;
  463. }
  464. bAddNow = false;
  465. }
  466. else if (bEditNow)
  467. {
  468. this.proc_setCellReadOnly(currRow, true);
  469. currRow.Cells["BILLETNO"].Value = currRow.Cells["BILLETNO"].Tag;
  470. currRow.Cells["HEATNO"].Value = currRow.Cells["HEATNO"].Tag;
  471. currRow.Cells["CATEGORY"].Value = currRow.Cells["CATEGORY"].Tag;
  472. currRow.Cells["LENGTH"].Value = currRow.Cells["LENGTH"].Tag;
  473. currRow.Cells["THICKNESS"].Value = currRow.Cells["THICKNESS"].Tag;
  474. currRow.Cells["WIDTH"].Value = currRow.Cells["WIDTH"].Tag;
  475. currRow.Cells["WEIGHT"].Value = currRow.Cells["WEIGHT"].Tag;
  476. currRow.Cells["CUTTIME"].Value = currRow.Cells["CUTTIME"].Tag;
  477. ultraGrid1.ActiveCell = currRow.Cells["BILLETNO"];
  478. currRow.Cells["BILLETNO"].Selected = false;
  479. currRow = null;
  480. bEditNow = false;
  481. }
  482. this.proc_SetToolbarButtons();
  483. break;
  484. }
  485. case "EXPORT":
  486. {
  487. if ((bAddNow || bEditNow || bDelNow) || ultraGrid1.Rows.Count <= 0)
  488. return;
  489. bool bInstalled = (Type.GetTypeFromProgID("Excel.Application") != null);
  490. if (!bInstalled)
  491. {
  492. MessageBox.Show("系统没有安装EXCEL组件,无法导出数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  493. return;
  494. }
  495. string strFileName = Application.StartupPath + "\\Report\\切头、切尾、边角料实绩表.xls";
  496. ultraGridExcelExporter1.Export(ultraGrid1, strFileName);
  497. ProcessStartInfo p = new ProcessStartInfo(strFileName);
  498. p.WorkingDirectory = Path.GetDirectoryName(strFileName);
  499. Process.Start(p);
  500. break;
  501. }
  502. case "CLOSE":
  503. {
  504. this.Close();
  505. break;
  506. }
  507. }
  508. }
  509. private void frmCutInfoAssit_FormClosing(object sender, FormClosingEventArgs e)
  510. {
  511. try
  512. {
  513. if (bAddNow)
  514. {
  515. if (MessageBox.Show("[新增]操作尚未完成,确定要关闭吗?", "提示", MessageBoxButtons.OKCancel,
  516. MessageBoxIcon.Question) == DialogResult.Cancel)
  517. e.Cancel = true;
  518. else
  519. bAddNow = false;
  520. }
  521. else if (bEditNow)
  522. {
  523. if (MessageBox.Show("[修改]操作尚未完成,确定要关闭吗?", "提示", MessageBoxButtons.OKCancel,
  524. MessageBoxIcon.Question) == DialogResult.Cancel)
  525. e.Cancel = true;
  526. else
  527. bEditNow = false;
  528. }
  529. }
  530. catch (Exception ex)
  531. {
  532. MessageBox.Show(ex.Message);
  533. }
  534. }
  535. private void ultraTextEditor_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
  536. {
  537. try
  538. {
  539. Infragistics.Win.UltraWinEditors.UltraTextEditor ultraTextEditor = (Infragistics.Win.UltraWinEditors.UltraTextEditor)sender;
  540. if (ultraTextEditor == null) return;
  541. if (ultraTextEditor.Text.Trim().Length > 0)
  542. {
  543. ultraTextEditor.Tag = ultraTextEditor.Text.Trim();
  544. ultraTextEditor.Text = "";
  545. }
  546. else
  547. {
  548. if (ultraTextEditor.Tag != null)
  549. {
  550. ultraTextEditor.Text = Convert.ToString(ultraTextEditor.Tag);
  551. }
  552. }
  553. }
  554. catch { }
  555. }
  556. private void ultraGrid1_ClickCellButton(object sender, CellEventArgs e)
  557. {
  558. try
  559. {
  560. if (!(bAddNow || bEditNow)) return;
  561. if (e.Cell == null) return;
  562. if (e.Cell != currRow.Cells[e.Cell.Column.Key]) return;
  563. if (e.Cell.Row.Index < 0) return;
  564. switch (e.Cell.Column.Key)
  565. {
  566. case "BILLETNO":
  567. {
  568. if (bAddNow) //修改记录时不能修改坯料号
  569. {
  570. frmSelBillet frm = new frmSelBillet();
  571. frm.ShowDialog();
  572. if (frm.DialogResult == DialogResult.OK &&
  573. frm.alstReturn != null)
  574. {
  575. this.currRow.Cells["BILLETNO"].Value = frm.alstReturn[0];
  576. this.currRow.Cells["HEATNO"].Value = frm.alstReturn[1];
  577. if (Convert.ToString(this.currRow.Cells["CATEGORY"].Value) == "01" ||
  578. Convert.ToString(this.currRow.Cells["CATEGORY"].Value) == "02")
  579. {
  580. this.currRow.Cells["THICKNESS"].Value = frm.alstReturn[2];
  581. this.currRow.Cells["WIDTH"].Value = frm.alstReturn[3];
  582. }
  583. this.currRow.Cells["THICKNESS"].Tag = frm.alstReturn[2];
  584. this.currRow.Cells["WIDTH"].Tag = frm.alstReturn[3];
  585. }
  586. }
  587. break;
  588. }
  589. case "CUTTIME":
  590. {
  591. frmSetTime frm = new frmSetTime(e.Cell.Value);
  592. frm.Location = CStaticMethod.GetChildWindowLocation(frm.Size);
  593. frm.ShowDialog();
  594. if (frm._returnTime > new DateTime(2000, 1, 1, 0, 0, 0))
  595. e.Cell.Value = frm._returnTime;
  596. break;
  597. }
  598. }
  599. }
  600. catch { }
  601. }
  602. private void ultraGrid_CellListSelect(object sender, CellEventArgs e)
  603. {
  604. try
  605. {
  606. if (!bAddNow) return;
  607. if (e.Cell == null) return;
  608. if (e.Cell.Row.Index < 0) return;
  609. if (e.Cell.Column.Key != "CATEGORY") return;
  610. ultraGrid1.UpdateData();
  611. if (Convert.ToString(e.Cell.Value) == "01" ||
  612. Convert.ToString(e.Cell.Value) == "02")
  613. {
  614. if (this.currRow.Cells["THICKNESS"].Tag != null)
  615. this.currRow.Cells["THICKNESS"].Value = Convert.ToString(this.currRow.Cells["THICKNESS"].Tag);
  616. if (this.currRow.Cells["WIDTH"].Tag != null)
  617. this.currRow.Cells["WIDTH"].Value = Convert.ToString(this.currRow.Cells["WIDTH"].Tag);
  618. }
  619. }
  620. catch { }
  621. }
  622. private void ultraGrid_CellChange(object sender, CellEventArgs e)
  623. {
  624. try
  625. {
  626. if (!bAddNow && !bEditNow) return;
  627. if (e.Cell == null) return;
  628. if (e.Cell.Row.Index < 0) return;
  629. if (e.Cell.Column.Key != "LENGTH" &&
  630. e.Cell.Column.Key != "THICKNESS" &&
  631. e.Cell.Column.Key != "WIDTH" &&
  632. e.Cell.Column.Key != "WEIGHT")
  633. return;
  634. string strText = Convert.ToString(e.Cell.Text.Trim());
  635. if (strText.Length > 0)
  636. {
  637. decimal dValue = 0.0M;
  638. if (!decimal.TryParse(strText, out dValue))
  639. {
  640. MessageBox.Show("无效数字!", e.Cell.Column.Header.Caption, MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  641. e.Cell.CancelUpdate();
  642. }
  643. }
  644. }
  645. catch { }
  646. }
  647. private void ultraGrid_AfterCellActivate(object sender, EventArgs e)
  648. {
  649. try
  650. {
  651. if (!bAddNow && !bEditNow) return;
  652. this.ultraGrid1.PerformAction(UltraGridAction.EnterEditMode, false, false);
  653. }
  654. catch { }
  655. }
  656. }
  657. }