FrmILRepair.cs 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543
  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 CoreFS.CA06;
  9. using Core.Mes.Client.Common;
  10. using System.Collections;
  11. namespace Core.LgMes.Client.LgDeviceManager
  12. {
  13. public partial class FrmILRepair : Core.Mes.Client.Common.frmStyleBase//frmModelFormStyle
  14. {
  15. private bool bOK = false;
  16. #region "================================Add on 2009-07-28=============================="
  17. #endregion
  18. private string strInitID = "";
  19. public FrmILRepair(string strInitID, OpeBase oba)
  20. {
  21. InitializeComponent();
  22. ob = oba;
  23. this.strInitID = strInitID;
  24. }
  25. private void FrmILRepair_Load(object sender, EventArgs e)
  26. {
  27. GetPosition();
  28. proc_GetID(strInitID);
  29. bOK = true;
  30. cbbID_SelectedIndexChanged(null, null);
  31. }
  32. private void cbbID_SelectedIndexChanged(object sender, EventArgs e)
  33. {
  34. if (!bOK)
  35. return;
  36. if (cbbID.Items.Count == 0 || cbbID.SelectedIndex < 0)
  37. {
  38. ResetControlsBase(true);
  39. ResetControlsRepair();
  40. btnStart.Enabled = btnEnd.Enabled = false;
  41. return;
  42. }
  43. string strID = cbbID.Text.Trim();
  44. ResetControlsBase(false);
  45. ResetControlsRepair();
  46. proc_GetBaseInfo(strID);
  47. proc_GetRepairInfo(strID);
  48. }
  49. /// <summary>
  50. /// 加载基础信息
  51. /// </summary>
  52. /// <param name="strID"></param>
  53. private void proc_GetBaseInfo(string strID)
  54. {
  55. try
  56. {
  57. string strErr = "";
  58. ArrayList arry = new ArrayList();
  59. arry.Add("FrmILRepair_Query2");
  60. arry.Add(cbbID.Text.Trim());
  61. CommonClientToServer ccs = new CommonClientToServer();
  62. ccs.ob = this.ob;
  63. DataSet ds = ccs.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery", "doSimpleQuery", arry, out strErr);
  64. if (strErr == "" && ds != null && ds.Tables.Count > 0)
  65. {
  66. if (ds.Tables[0].Rows.Count > 0)
  67. {
  68. tbCurrStatus.Text = ds.Tables[0].Rows[0]["当前状态"].ToString(); //当前状态
  69. tbAgeTS.Text = ds.Tables[0].Rows[0]["铁水包龄"].ToString(); //铁水包龄
  70. tbAgeBG.Text = ds.Tables[0].Rows[0]["半钢包龄"].ToString(); //半钢包龄
  71. }
  72. else
  73. {
  74. btnStart.Enabled = btnEnd.Enabled = false;
  75. }
  76. }
  77. else
  78. {
  79. MessageBox.Show("铁包状态信息查询出错!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  80. }
  81. }
  82. catch (Exception ex)
  83. {
  84. MessageBox.Show("铁包状态信息查询出错!\r\n" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  85. }
  86. }
  87. /// <summary>
  88. /// 加载维修信息
  89. /// </summary>
  90. /// <param name="strID"></param>
  91. private void proc_GetRepairInfo(string strID)
  92. {
  93. try
  94. {
  95. string strErr = "";
  96. ArrayList arry = new ArrayList();
  97. arry.Add("FrmILRepair_Query3");
  98. arry.Add(cbbID.Text.Trim());
  99. CommonClientToServer ccs = new CommonClientToServer();
  100. ccs.ob = this.ob;
  101. DataSet ds = ccs.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery", "doSimpleQuery", arry, out strErr);
  102. if (strErr == "" && ds != null && ds.Tables.Count > 0)
  103. {
  104. if (ds.Tables[0].Rows.Count > 0)
  105. {
  106. cbbLB.Text = Convert.ToString(ds.Tables[0].Rows[0]["维修类别"]);
  107. cbbWZ.Text = Convert.ToString(ds.Tables[0].Rows[0]["维修位置"]);
  108. dateTimePicker1.Value = Convert.ToDateTime(Convert.ToString(ds.Tables[0].Rows[0]["送修时间"]));
  109. dateTimePicker2.Value=DateTime.Now;
  110. tbReason.Text = Convert.ToString(ds.Tables[0].Rows[0]["维修原因"]);
  111. tbMemo.Text = Convert.ToString(ds.Tables[0].Rows[0]["备注"]);
  112. btnStart.Enabled = false;
  113. btnEnd.Enabled = true;
  114. }
  115. else
  116. {
  117. dateTimePicker1.Value = DateTime.Now;
  118. btnStart.Enabled = true;
  119. btnEnd.Enabled = false;
  120. }
  121. }
  122. else
  123. {
  124. MessageBox.Show("铁包维修信息查询出错!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  125. }
  126. }
  127. catch (Exception ex)
  128. {
  129. MessageBox.Show("铁包维修信息查询出错!\r\n" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  130. }
  131. }
  132. /// <summary>
  133. /// 加载铁包编号
  134. /// </summary>
  135. /// <param name="strID"></param>
  136. private void proc_GetID(string strID)
  137. {
  138. try
  139. {
  140. string strErr = "";
  141. ArrayList arry = new ArrayList();
  142. arry.Add("FrmILRepair_Query4");
  143. CommonClientToServer ccs = new CommonClientToServer();
  144. ccs.ob = this.ob;
  145. DataSet ds = ccs.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery", "doSimpleQuery", arry, out strErr);
  146. if (strErr == "" && ds != null && ds.Tables.Count > 0)
  147. {
  148. Core.Mes.Client.Common.Globals.FillUlcmeItems(cbbID, ds.Tables[0]);
  149. this.cbbID.DataSource = ds.Tables[0];
  150. this.cbbID.DisplayMember = "铁包编号";
  151. //for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
  152. //{
  153. // cbbID.Items.Add(ds.Tables[0].Rows[i]["铁包编号"]);
  154. //}
  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_RepairStart()
  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("FrmILRepair_Query5");
  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 (cbbLB.SelectedIndex < 0)
  215. {
  216. MessageBox.Show("请选择维修类别!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  217. cbbLB.Focus();
  218. return;
  219. }
  220. if (cbbWZ.SelectedIndex < 0)
  221. {
  222. MessageBox.Show("请选择维修位置!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  223. cbbWZ.Focus();
  224. return;
  225. }
  226. if (cbxClrTS.Checked || cbxClrBG.Checked)
  227. {
  228. MessageBox.Show("您选择了铁包包龄清零!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  229. }
  230. if (MessageBox.Show("确认开始维修铁包[" + cbbID.Text.Trim() + "]吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
  231. {
  232. return;
  233. }
  234. try
  235. {
  236. string strReturn = "";
  237. strErr = "";
  238. arry.Clear();
  239. arry.Add("FrmILRepair_Add");
  240. arry.Add(cbbID.Text.Trim());
  241. arry.Add(cbbWZ.Text.Trim());
  242. arry.Add(cbbLB.Text.Trim());
  243. arry.Add(CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName());
  244. arry.Add(tbReason.Text.Trim());
  245. arry.Add(cbbID.Text.Trim());
  246. arry.Add(tbMemo.Text.Trim());
  247. arry.Add(dateTimePicker1.Text.Length > 0 ? Convert.ToDateTime(dateTimePicker1.Value).ToString("yyyy-MM-dd HH:mm:ss") : DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
  248. ccs.ob = this.ob;
  249. strReturn = ccs.NoQueryFunctions("Core.LgMes.Server.Common.ComDBSave", "doSimpleSave", arry, out strErr);
  250. if (strErr != "")
  251. {
  252. MessageBox.Show("铁包[" + cbbID.Text.Trim() + "]维修操作失败!\n" + strErr, "错误!", MessageBoxButtons.OK, MessageBoxIcon.Error);
  253. return;
  254. }
  255. string str = "";
  256. if (cbxClrTS.Checked)
  257. str = " , AGE = '0' ";
  258. if (cbxClrBG.Checked)
  259. {
  260. if (str.Length > 0)
  261. str += ", LVL = '0' ";
  262. else
  263. str = " , LVL = '0' ";
  264. }
  265. strErr = "";
  266. string strSql = "update dev_ib_base_info set "
  267. + "STATUS = '维修' " + str + " "
  268. + "where LADLEID = '" + cbbID.Text.Trim() + "'";
  269. CoreClientParam ccp_K = new CoreClientParam();
  270. ccp_K.ServerName = "Core.LgMes.Server.DEV.Methods.DEVPublicMethods";
  271. ccp_K.MethodName = "UpdateMethods";
  272. ccp_K.ServerParams = new object[]{strSql};
  273. ob.ExecuteNonQuery(ccp_K, CoreInvokeType.Internal);
  274. strErr = ccp_K.ReturnInfo.ToString();
  275. if (strErr != "")
  276. {
  277. MessageBox.Show("铁包[" + cbbID.Text.Trim() + "]维修操作失败!\n" + strErr, "错误!", MessageBoxButtons.OK, MessageBoxIcon.Error);
  278. return;
  279. }
  280. proc_GetID(cbbID.Text.Trim());
  281. FrmIronLadleManage frm = (FrmIronLadleManage)this.Tag;
  282. if (!frm._bAutoRefresh)
  283. {
  284. frm.GetID();
  285. frm.GetAndSetData();
  286. }
  287. frm.GetAndSetData();
  288. MessageBox.Show("铁包[" + cbbID.Text.Trim() + "]维修开始!", "提示");
  289. }
  290. catch (Exception ex)
  291. {
  292. MessageBox.Show("铁包维修操作失败!\r\n" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  293. return;
  294. }
  295. }
  296. /// <summary>
  297. /// 维修结束
  298. /// </summary>
  299. private void IB_RepairEnd()
  300. {
  301. if (cbbID.Items.Count == 0 ||
  302. cbbID.SelectedIndex < 0)
  303. {
  304. proc_GetID("");
  305. MessageBox.Show("请选择需要结束维修的铁包!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  306. cbbID.Focus();
  307. return;
  308. }
  309. string strErr = "";
  310. ArrayList arry = new ArrayList();
  311. arry.Add("FrmILRepair_Query6");
  312. arry.Add(cbbID.Text.Trim());
  313. CommonClientToServer ccs = new CommonClientToServer();
  314. ccs.ob = this.ob;
  315. DataSet ds = ccs.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery", "doSimpleQuery", arry, out strErr);
  316. if (!(strErr == "" && ds != null && ds.Tables.Count > 0))
  317. {
  318. MessageBox.Show("铁包[" + cbbID.Text.Trim() + "]结束维修操作失败,请重试!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  319. return;
  320. }
  321. if (ds.Tables[0].Rows.Count == 0)
  322. {
  323. MessageBox.Show("铁包编号[" + cbbID.Text.Trim() + "]不存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  324. cbbID.Focus();
  325. return;
  326. }
  327. string strCurrStatus = Convert.ToString(ds.Tables[0].Rows[0]["当前状态"]);
  328. if (strCurrStatus != "维修")
  329. {
  330. MessageBox.Show("铁包[" + cbbID.Text.Trim() + "]当前状态为[" + strCurrStatus + "],还未开始维修!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  331. cbbID.Focus();
  332. return;
  333. }
  334. if (cbbLB.SelectedIndex < 0)
  335. {
  336. MessageBox.Show("请选择维修类别!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  337. cbbLB.Focus();
  338. return;
  339. }
  340. if (cbbWZ.SelectedIndex < 0)
  341. {
  342. MessageBox.Show("请选择维修位置!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  343. cbbWZ.Focus();
  344. return;
  345. }
  346. if (cbxClrTS.Checked || cbxClrBG.Checked)
  347. {
  348. MessageBox.Show("您选择了铁包包龄清零!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  349. }
  350. if (MessageBox.Show("确认铁包[" + cbbID.Text.Trim() + "]维修结束吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
  351. {
  352. return;
  353. }
  354. try
  355. {
  356. string strReturn = "";
  357. strErr = "";
  358. arry.Clear();
  359. arry.Add("FrmILRepair_Update");
  360. arry.Add(cbbWZ.Text.Trim());
  361. arry.Add(cbbLB.Text.Trim());
  362. arry.Add(CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName());
  363. arry.Add(tbReason.Text.Trim());
  364. arry.Add(tbMemo.Text.Trim());
  365. arry.Add(Convert.ToDateTime(dateTimePicker1.Value).ToString("yyyy-MM-dd HH:mm:ss"));
  366. arry.Add(dateTimePicker2.Text.Length > 0 ? Convert.ToDateTime(dateTimePicker2.Value).ToString("yyyy-MM-dd HH:mm:ss") : DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
  367. arry.Add(cbbID.Text.Trim());
  368. ccs.ob = this.ob;
  369. strReturn = ccs.NoQueryFunctions("Core.LgMes.Server.Common.ComDBSave", "doSimpleSave", arry, out strErr);
  370. if (strErr != "")
  371. {
  372. MessageBox.Show("铁包[" + cbbID.Text.Trim() + "]维修操作失败!\n" + strErr, "错误!", MessageBoxButtons.OK, MessageBoxIcon.Error);
  373. return;
  374. }
  375. string str = "";
  376. if (cbxClrTS.Checked)
  377. str = " , AGE = '0' ";
  378. if (cbxClrBG.Checked)
  379. {
  380. if (str.Length > 0)
  381. str += ", LVL = '0' ";
  382. else
  383. str = " , LVL = '0' ";
  384. }
  385. strErr = "";
  386. string strSql = "update dev_ib_base_info set "
  387. + "STATUS = '备用' " + str + " "
  388. + "where LADLEID = '" + cbbID.Text.Trim() + "'";
  389. CoreClientParam ccp_K = new CoreClientParam();
  390. ccp_K.ServerName = "Core.LgMes.Server.DEV.Methods.DEVPublicMethods";
  391. ccp_K.MethodName = "UpdateMethods";
  392. ccp_K.ServerParams = new object[] { strSql };
  393. ob.ExecuteNonQuery(ccp_K, CoreInvokeType.Internal);
  394. strErr = ccp_K.ReturnInfo.ToString();
  395. if (strErr != "")
  396. {
  397. MessageBox.Show("铁包[" + cbbID.Text.Trim() + "]结束维修操作失败!\n" + strErr, "错误!", MessageBoxButtons.OK, MessageBoxIcon.Error);
  398. return;
  399. }
  400. proc_GetID(cbbID.Text.Trim());
  401. FrmIronLadleManage frm = (FrmIronLadleManage)this.Tag;
  402. if (!frm._bAutoRefresh)
  403. {
  404. frm.GetID();
  405. frm.GetAndSetData();
  406. }
  407. frm.GetAndSetData();
  408. MessageBox.Show("铁包[" + cbbID.Text.Trim() + "]维修结束!", "提示");
  409. }
  410. catch (Exception ex)
  411. {
  412. MessageBox.Show("铁包结束维修操作失败!\r\n" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  413. return;
  414. }
  415. }
  416. private void ResetControlsBase(bool bFlag)
  417. {
  418. try
  419. {
  420. if (bFlag)
  421. cbbID.SelectedIndex = -1;
  422. tbCurrStatus.Clear();
  423. tbAgeTS.Clear();
  424. tbAgeBG.Clear();
  425. cbxClrTS.Checked = false;
  426. cbxClrBG.Checked = false;
  427. }
  428. catch { }
  429. }
  430. private void ResetControlsRepair()
  431. {
  432. try
  433. {
  434. cbbLB.SelectedIndex = -1;
  435. cbbWZ.SelectedIndex = -1;
  436. //dateTimePicker1.CustomFormat = dateTimePicker2.CustomFormat = " ";
  437. dateTimePicker1.Value = dateTimePicker2.Value = null;
  438. tbReason.Clear();
  439. tbMemo.Clear();
  440. }
  441. catch { }
  442. }
  443. /// <summary>
  444. /// 维修位置加载
  445. /// </summary>
  446. private void GetPosition()
  447. {
  448. string strErr = "";
  449. ArrayList arry = new ArrayList();
  450. arry.Add("FrmILRepair_Query1");
  451. arry.Add("铁包");
  452. CommonClientToServer ccs = new CommonClientToServer();
  453. ccs.ob = this.ob;
  454. DataSet ds = ccs.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery", "doSimpleQuery", arry, out strErr);
  455. if (strErr == "" && ds != null && ds.Tables.Count > 0)
  456. {
  457. cbbWZ.Items.Clear();
  458. for (int i = 0; i <ds.Tables[0].Rows.Count; i++)
  459. {
  460. cbbWZ.Items.Add(ds.Tables[0].Rows[i]["维修位置"]);
  461. }
  462. cbbWZ.SelectedIndex = -1;
  463. }
  464. else
  465. cbbWZ.Items.Clear();
  466. }
  467. private void toolStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
  468. {
  469. switch (e.ClickedItem.Name)
  470. {
  471. case "RepairStar":
  472. {
  473. IB_RepairStart();
  474. break;
  475. }
  476. case "RepairEnd":
  477. {
  478. IB_RepairEnd();
  479. break;
  480. }
  481. case "CLOSE":
  482. {
  483. this.Close();
  484. break;
  485. }
  486. default:
  487. break;
  488. }
  489. }
  490. }
  491. }