FrmILFire.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
  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 CoreFS.CA06;
  12. using Core.Mes.Client.Common;
  13. using Infragistics.Win.UltraWinGrid;
  14. namespace Core.LgMes.Client.LgDeviceManager
  15. {
  16. public partial class FrmILFire : frmStyleBase
  17. {
  18. private bool bOK = false;
  19. private string strInitID = "";
  20. private OpeBase ob = null;
  21. #region "================================Add on 2009-07-28=============================="
  22. #endregion
  23. public FrmILFire(string strInitID, OpeBase oba)
  24. {
  25. InitializeComponent();
  26. ob = oba;
  27. this.strInitID = strInitID;
  28. }
  29. private void FrmILFire_Load(object sender, EventArgs e)
  30. {
  31. proc_GetID(strInitID);
  32. bOK = true;
  33. cbbID_SelectedIndexChanged(null, null);
  34. }
  35. private void cbbID_SelectedIndexChanged(object sender, EventArgs e)
  36. {
  37. if (!bOK)
  38. return;
  39. if (cbbID.Items.Count == 0 || cbbID.SelectedIndex < 0)
  40. {
  41. ResetControlsBase(true);
  42. ResetControlsRepair();
  43. btnStart.Enabled = btnEnd.Enabled = false;
  44. return;
  45. }
  46. string strID = cbbID.Text.Trim();
  47. ResetControlsBase(false);
  48. ResetControlsRepair();
  49. proc_GetBaseInfo(strID);
  50. proc_GetFireInfo(strID);
  51. }
  52. private void proc_GetBaseInfo(string strID)
  53. {
  54. try
  55. {
  56. string strErr = "";
  57. ArrayList arry = new ArrayList();
  58. arry.Add("FrmILBaseInfo_Query3");
  59. arry.Add(cbbID.Text.Trim());
  60. CommonClientToServer ccs = new CommonClientToServer();
  61. ccs.ob = this.ob;
  62. DataSet ds = ccs.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery", "doSimpleQuery", arry, out strErr);
  63. if (strErr == "" && ds != null && ds.Tables.Count > 0)
  64. {
  65. if (ds.Tables[0].Rows.Count > 0)
  66. {
  67. tbCurrStatus.Text = ds.Tables[0].Rows[0]["当前状态"].ToString(); //当前状态
  68. tbAgeTS.Text = ds.Tables[0].Rows[0]["铁水包龄"].ToString(); //铁水包龄
  69. tbAgeBG.Text = ds.Tables[0].Rows[0]["半钢包龄"].ToString(); //半钢包龄
  70. }
  71. else
  72. {
  73. btnStart.Enabled = btnEnd.Enabled = false;
  74. }
  75. }
  76. else
  77. {
  78. MessageBox.Show("铁包状态信息查询出错!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  79. }
  80. }
  81. catch (Exception ex)
  82. {
  83. MessageBox.Show("铁包状态信息查询出错!\r\n" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  84. }
  85. }
  86. private void proc_GetFireInfo(string strID)
  87. {
  88. try
  89. {
  90. string strErr = "";
  91. string strWhere = " and TOOLTYPE = '铁包' and FIRINGTOOLID = '" + this.cbbID.Text.Trim() + "' "
  92. + "and BEGINTIME is not null and ENDTIME is null";
  93. ArrayList arry = new ArrayList();
  94. ArrayList sqlList = new ArrayList();
  95. arry.Add("FrmILHistory_Query4");
  96. sqlList.Add(strWhere);
  97. CoreClientParam CCP_LgEts = new CoreClientParam();
  98. DataTable dt = new DataTable();
  99. CCP_LgEts.ServerName = "Core.LgMes.Server.Common.ComDBQuery";
  100. CCP_LgEts.MethodName = "doQuery";
  101. CCP_LgEts.ServerParams = new object[] { arry, sqlList };
  102. CCP_LgEts.SourceDataTable = dt;
  103. //this.ExecuteQueryToDataTable(CCP_LgEts, CoreInvokeType.Internal);
  104. DataSet ds = new DataSet();
  105. ds.Tables.Add(dt);
  106. if (strErr == "" && ds != null && ds.Tables.Count > 0)
  107. {
  108. if (ds.Tables[0].Rows.Count > 0)
  109. {
  110. tbWDKQ.Text = Convert.ToString(ds.Tables[0].Rows[0]["烤前温度"]);
  111. tbWDKH.Text = Convert.ToString(ds.Tables[0].Rows[0]["烤后温度"]);
  112. cbbWZ.Text = Convert.ToString(ds.Tables[0].Rows[0]["烘烤站号"]);
  113. // dateTimePicker1.CustomFormat = "yyyy-MM-dd HH:mm:ss";
  114. dateTimePicker1.Value = Convert.ToDateTime(Convert.ToString(ds.Tables[0].Rows[0]["开始时间"]));
  115. //dateTimePicker2.CustomFormat = "yyyy-MM-dd HH:mm:ss";
  116. dateTimePicker2.Value = DateTime.Now;
  117. tbMemo.Text = Convert.ToString(ds.Tables[0].Rows[0]["备注"]);
  118. btnStart.Enabled = false;
  119. btnEnd.Enabled = true;
  120. }
  121. else
  122. {
  123. // dateTimePicker1.CustomFormat = "yyyy-MM-dd HH:mm:ss";
  124. dateTimePicker1.Value = DateTime.Now;
  125. btnStart.Enabled = true;
  126. btnEnd.Enabled = false;
  127. }
  128. }
  129. else
  130. {
  131. MessageBox.Show("铁包烘烤信息查询出错!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  132. }
  133. }
  134. catch (Exception ex)
  135. {
  136. MessageBox.Show("铁包烘烤信息查询出错!\r\n" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  137. }
  138. }
  139. private void proc_GetID(string strID)
  140. {
  141. try
  142. {
  143. string strErr = "";
  144. ArrayList arry = new ArrayList();
  145. arry.Add("FrmILBaseInfo_Query3");
  146. arry.Add(strID);
  147. CommonClientToServer ccs = new CommonClientToServer();
  148. ccs.ob = this.ob;
  149. DataSet ds = ccs.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery", "doSimpleQuery", arry, out strErr);
  150. if (strErr == "" && ds != null && ds.Tables.Count > 0)
  151. {
  152. Core.Mes.Client.Common.Globals.FillUlcmeItems(cbbID, ds.Tables[0]);
  153. this.cbbID.DataSource = ds.Tables[0];
  154. this.cbbID.DisplayMember = "铁包编号";
  155. if (ds.Tables[0].Rows.Count == 0)
  156. {
  157. ResetControlsBase(true);
  158. ResetControlsRepair();
  159. btnStart.Enabled = btnEnd.Enabled = false;
  160. return;
  161. }
  162. if (strID.Length > 0)
  163. cbbID.Text = strID;
  164. cbbID_SelectedIndexChanged(null, null);
  165. }
  166. else
  167. {
  168. MessageBox.Show("铁包包号信息查询出错!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  169. }
  170. }
  171. catch (Exception ex)
  172. {
  173. MessageBox.Show("铁包包号信息查询出错!\r\n" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  174. }
  175. }
  176. /// <summary>
  177. /// 烘烤开始
  178. /// </summary>
  179. private void IB_FireStart()
  180. {
  181. if (cbbID.Items.Count == 0 ||
  182. cbbID.SelectedIndex < 0)
  183. {
  184. proc_GetID("");
  185. MessageBox.Show("请选择需要烘烤的铁包!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  186. cbbID.Focus();
  187. return;
  188. }
  189. string strErr = "";
  190. ArrayList arry = new ArrayList();
  191. arry.Add("FrmILBaseInfo_Query3");
  192. arry.Add(cbbID.Text.Trim());
  193. CommonClientToServer ccs = new CommonClientToServer();
  194. ccs.ob = this.ob;
  195. DataSet ds = ccs.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery", "doSimpleQuery", arry, out strErr);
  196. if (!(strErr == "" && ds != null && ds.Tables.Count > 0))
  197. {
  198. MessageBox.Show("铁包[" + cbbID.Text.Trim() + "]烘烤操作失败,请重试!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  199. return;
  200. }
  201. if (ds.Tables[0].Rows.Count == 0)
  202. {
  203. MessageBox.Show("铁包编号[" + cbbID.Text.Trim() + "]不存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  204. cbbID.Focus();
  205. return;
  206. }
  207. string strCurrStatus = Convert.ToString(ds.Tables[0].Rows[0]["当前状态"]);
  208. if (strCurrStatus != "备用")
  209. {
  210. MessageBox.Show("铁包[" + cbbID.Text.Trim() + "]当前状态为[" + strCurrStatus + "],不能开始烘烤!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  211. cbbID.Focus();
  212. return;
  213. }
  214. if (cbbWZ.SelectedIndex < 0)
  215. {
  216. MessageBox.Show("请选择烘烤站号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  217. cbbWZ.Focus();
  218. return;
  219. }
  220. if (MessageBox.Show("确认开始烘烤铁包[" + cbbID.Text.Trim() + "]吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
  221. {
  222. return;
  223. }
  224. try
  225. {
  226. strErr = "";
  227. string strSql = "insert into DEV_TOOLFIRINGDETAIL "
  228. + "(FIRINGID, TOOLTYPE, FIRINGTOOLID, CYCID, OVENID, BEGINTIME, ENDTIME, TEMPERATUREBEFOREFIRING, TEMPERATUREBEHINDFIRING, MEMO) "
  229. + "values "
  230. + "("
  231. + "(select nvl(max(to_number(FIRINGID)), 0) + 1 from DEV_TOOLFIRINGDETAIL), "
  232. + "'铁包', "
  233. + "'" + cbbID.Text.Trim() + "', "
  234. + "(select nvl(max(CYCID), 0) + 1 from DEV_TOOLFIRINGDETAIL where TOOLTYPE = '铁包' and FIRINGTOOLID = '" + cbbID.Text.Trim() + "'), "
  235. + "'" + cbbWZ.Text.Trim() + "', "
  236. + "to_date('" + (dateTimePicker1.Text.Length > 0 ? Convert.ToDateTime(dateTimePicker1.Value).ToString("yyyy-MM-dd HH:mm:ss") : DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")) + "', 'yyyy-MM-dd HH24:mi:ss'), "
  237. + "null, "
  238. + "'" + tbWDKQ.Text.Trim() + "', "
  239. + "'" + tbWDKH.Text.Trim() + "', "
  240. + "'" + tbMemo.Text.Trim() + "' "
  241. + ")";
  242. //ClientCommon._RemotingHelp.ExecuteMethod("LgDeviceManager", "Core.LgMes.Server.LgDeviceManager.LadleManager", "SetData", new object[] { strSql }, out strErr);
  243. if (strErr != "")
  244. {
  245. MessageBox.Show("铁包[" + cbbID.Text.Trim() + "]烘烤操作失败!\n" + strErr, "错误!", MessageBoxButtons.OK, MessageBoxIcon.Error);
  246. return;
  247. }
  248. strErr = "";
  249. strSql = "update dev_ib_base_info set "
  250. + "STATUS = '烘烤' "
  251. + "where LADLEID = '" + cbbID.Text.Trim() + "'";
  252. //ClientCommon._RemotingHelp.ExecuteMethod("LgDeviceManager", "Core.LgMes.Server.LgDeviceManager.LadleManager", "SetData", new object[] { strSql }, out strErr);
  253. if (strErr != "")
  254. {
  255. MessageBox.Show("铁包[" + cbbID.Text.Trim() + "]烘烤操作失败!\n" + strErr, "错误!", MessageBoxButtons.OK, MessageBoxIcon.Error);
  256. return;
  257. }
  258. proc_GetID(cbbID.Text.Trim());
  259. FrmIronLadleManage frm = (FrmIronLadleManage)this.Tag;
  260. if (!frm._bAutoRefresh)
  261. {
  262. frm.GetID();
  263. frm.GetAndSetData();
  264. }
  265. MessageBox.Show("铁包[" + cbbID.Text.Trim() + "]烘烤开始!", "提示");
  266. }
  267. catch (Exception ex)
  268. {
  269. MessageBox.Show("铁包烘烤操作失败!\r\n" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  270. return;
  271. }
  272. }
  273. /// <summary>
  274. /// 烘烤结束
  275. /// </summary>
  276. private void IB_FireEnd()
  277. {
  278. if (cbbID.Items.Count == 0 ||
  279. cbbID.SelectedIndex < 0)
  280. {
  281. proc_GetID("");
  282. MessageBox.Show("请选择需要结束烘烤的铁包!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  283. cbbID.Focus();
  284. return;
  285. }
  286. string strErr = "";
  287. ArrayList arry = new ArrayList();
  288. arry.Add("FrmILBaseInfo_Query3");
  289. arry.Add(cbbID.Text.Trim());
  290. CommonClientToServer ccs = new CommonClientToServer();
  291. ccs.ob = this.ob;
  292. DataSet ds = ccs.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery", "doSimpleQuery", arry, out strErr);
  293. if (!(strErr == "" && ds != null && ds.Tables.Count > 0))
  294. {
  295. MessageBox.Show("铁包[" + cbbID.Text.Trim() + "]结束烘烤操作失败,请重试!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  296. return;
  297. }
  298. if (ds.Tables[0].Rows.Count == 0)
  299. {
  300. MessageBox.Show("铁包编号[" + cbbID.Text.Trim() + "]不存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  301. cbbID.Focus();
  302. return;
  303. }
  304. string strCurrStatus = Convert.ToString(ds.Tables[0].Rows[0]["当前状态"]);
  305. if (strCurrStatus != "烘烤")
  306. {
  307. MessageBox.Show("铁包[" + cbbID.Text.Trim() + "]当前状态为[" + strCurrStatus + "],还未开始烘烤!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  308. cbbID.Focus();
  309. return;
  310. }
  311. if (cbbWZ.SelectedIndex < 0)
  312. {
  313. MessageBox.Show("请选择烘烤站号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  314. cbbWZ.Focus();
  315. return;
  316. }
  317. if (MessageBox.Show("确认铁包[" + cbbID.Text.Trim() + "]烘烤结束吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
  318. {
  319. return;
  320. }
  321. try
  322. {
  323. strErr = "";
  324. string strSql = "update DEV_TOOLFIRINGDETAIL set "
  325. + "OVENID = '" + cbbWZ.Text.Trim() + "', "
  326. + "TEMPERATUREBEFOREFIRING = '" + tbWDKQ.Text.Trim() + "', "
  327. + "TEMPERATUREBEHINDFIRING = '" + tbWDKH.Text.Trim() + "', "
  328. + "MEMO = '" + tbMemo.Text.Trim() + "', "
  329. + "BEGINTIME = to_date('" + Convert.ToDateTime(dateTimePicker1.Value).ToString("yyyy-MM-dd HH:mm:ss") + "', 'yyyy-MM-dd HH24:mi:ss'), "
  330. + "ENDTIME = to_date('" + (dateTimePicker2.Text.Length > 0 ? Convert.ToDateTime(dateTimePicker2.Value).ToString("yyyy-MM-dd HH:mm:ss") : DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")) + "', 'yyyy-MM-dd HH24:mi:ss') "
  331. + "where TOOLTYPE = '铁包' and FIRINGTOOLID = '" + cbbID.Text.Trim() + "' "
  332. + "and BEGINTIME is not null and ENDTIME is null";
  333. //ClientCommon._RemotingHelp.ExecuteMethod("LgDeviceManager", "Core.LgMes.Server.LgDeviceManager.LadleManager", "SetData", new object[] { strSql }, out strErr);
  334. if (strErr != "")
  335. {
  336. MessageBox.Show("铁包[" + cbbID.Text.Trim() + "]烘烤操作失败!\n" + strErr, "错误!", MessageBoxButtons.OK, MessageBoxIcon.Error);
  337. return;
  338. }
  339. strErr = "";
  340. strSql = "update dev_ib_base_info set "
  341. + "STATUS = '备用' "
  342. + "where LADLEID = '" + cbbID.Text.Trim() + "'";
  343. //ClientCommon._RemotingHelp.ExecuteMethod("LgDeviceManager", "Core.LgMes.Server.LgDeviceManager.LadleManager", "SetData", new object[] { strSql }, out strErr);
  344. if (strErr != "")
  345. {
  346. MessageBox.Show("铁包[" + cbbID.Text.Trim() + "]结束烘烤操作失败!\n" + strErr, "错误!", MessageBoxButtons.OK, MessageBoxIcon.Error);
  347. return;
  348. }
  349. proc_GetID(cbbID.Text.Trim());
  350. FrmIronLadleManage frm = (FrmIronLadleManage)this.Tag;
  351. if (!frm._bAutoRefresh)
  352. {
  353. frm.GetID();
  354. frm.GetAndSetData();
  355. }
  356. MessageBox.Show("铁包[" + cbbID.Text.Trim() + "]烘烤结束!", "提示");
  357. }
  358. catch (Exception ex)
  359. {
  360. MessageBox.Show("铁包结束烘烤操作失败!\r\n" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  361. return;
  362. }
  363. }
  364. private void ResetControlsBase(bool bFlag)
  365. {
  366. try
  367. {
  368. if (bFlag)
  369. cbbID.SelectedIndex = -1;
  370. tbCurrStatus.Clear();
  371. tbAgeTS.Clear();
  372. tbAgeBG.Clear();
  373. }
  374. catch { }
  375. }
  376. private void ResetControlsRepair()
  377. {
  378. try
  379. {
  380. tbWDKQ.Clear();
  381. tbWDKH.Clear();
  382. cbbWZ.SelectedIndex = -1;
  383. dateTimePicker1.Value = dateTimePicker2.Value = null;
  384. tbMemo.Clear();
  385. }
  386. catch { }
  387. }
  388. private void textBoxNumber_KeyPress(object sender, KeyPressEventArgs e)
  389. {
  390. try
  391. {
  392. if (!(Char.IsNumber(e.KeyChar) || e.KeyChar == '\b'))
  393. e.Handled = true;
  394. }
  395. catch { }
  396. }
  397. private void toolStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
  398. {
  399. switch (e.ClickedItem.Name)
  400. {
  401. case "FireStart":
  402. {
  403. IB_FireStart();
  404. break;
  405. }
  406. case "FireEnd":
  407. {
  408. IB_FireEnd();
  409. break;
  410. }
  411. case "CLOSE":
  412. {
  413. this.Close();
  414. break;
  415. }
  416. default:
  417. break;
  418. }
  419. }
  420. }
  421. }