FrmIronLadleManage.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517
  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.Threading;
  10. using Infragistics.Win;
  11. using Infragistics.Win.UltraWinGrid;
  12. using CoreFS.CA06;
  13. using Core.Mes.Client.Common;
  14. namespace Core.LgMes.Client.LgDeviceManager
  15. {
  16. public partial class FrmIronLadleManage : frmStyleBase
  17. {
  18. public FrmIronLadleManage()
  19. {
  20. InitializeComponent();
  21. CheckForIllegalCrossThreadCalls = false;
  22. }
  23. private string strCurrID = "";
  24. private bool bSelected = false;
  25. private bool bRefreshNow = false;
  26. private Thread _refreshThread;
  27. private bool _bStop = false;
  28. public bool _bAutoRefresh = false;
  29. private delegate void RefreshDataHandler();
  30. private RefreshDataHandler refreshDataHandler;
  31. private void FrmIronLadleManage_Load(object sender, EventArgs e)
  32. {
  33. GetID();
  34. chkAutoRefresh.Checked = true;
  35. refreshDataHandler = new RefreshDataHandler(GetAndSetData);
  36. StartupThread();
  37. GetAndSetData();
  38. }
  39. private void StartupThread()
  40. {
  41. try
  42. {
  43. _refreshThread = new Thread(new ThreadStart(refreshData));
  44. _refreshThread.IsBackground = true;
  45. _refreshThread.Start();
  46. }
  47. catch { }
  48. }
  49. private void refreshData()
  50. {
  51. There:
  52. while (!_bStop)
  53. {
  54. if (!this.On_Off_Thread || !_bAutoRefresh)
  55. {
  56. Thread.Sleep(500);
  57. continue;
  58. }
  59. try
  60. {
  61. if (refreshDataHandler != null)
  62. {
  63. this.Invoke(refreshDataHandler);
  64. }
  65. Thread.Sleep(1000 * 5);
  66. }
  67. catch { }
  68. }
  69. goto There;
  70. }
  71. /// <summary>
  72. /// 铁包信息查询
  73. /// </summary>
  74. public void GetAndSetData()
  75. {
  76. bRefreshNow = true;
  77. try
  78. {
  79. string strErr = "", strWhere = "";
  80. if (!chkShowBF.Checked)
  81. {
  82. strWhere = " and t.STATUS <> '报废'";
  83. }
  84. if (chkID.Checked && ucmeID.SelectedIndex > -1)
  85. {
  86. strWhere += " and t.LADLEID = '" + ucmeID.Text.Trim() + "'";
  87. }
  88. if (chkStatus.Checked && cmbStatus.SelectedIndex > -1)
  89. {
  90. strWhere += " and t.STATUS = '" + cmbStatus.Text.Trim() + "'";
  91. }
  92. ArrayList arry = new ArrayList();
  93. ArrayList sqlList = new ArrayList();
  94. arry.Add("FrmIronLadleManage_Query1");
  95. sqlList.Add(strWhere);
  96. CoreClientParam CCP_LgEts = new CoreClientParam();
  97. DataTable dt = new DataTable();
  98. CCP_LgEts.ServerName = "Core.LgMes.Server.Common.ComDBQuery";
  99. CCP_LgEts.MethodName = "doQuery";
  100. CCP_LgEts.ServerParams = new object[] { arry, sqlList };
  101. CCP_LgEts.SourceDataTable = dt;
  102. this.ExecuteQueryToDataTable(CCP_LgEts, CoreInvokeType.Internal);
  103. DataSet ds = new DataSet();
  104. ds.Tables.Add(dt);
  105. strErr = CCP_LgEts.ReturnInfo;
  106. if (strErr == "" && ds != null && ds.Tables.Count > 0)
  107. {
  108. ugrdTBinfo.BeginUpdate();
  109. dataTable1.Rows.Clear();
  110. DataRow row;
  111. for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
  112. {
  113. row = dataTable1.NewRow();
  114. for (int j = 0; j < ds.Tables[0].Columns.Count; j++)
  115. {
  116. if (dataTable1.Columns.Contains(ds.Tables[0].Columns[j].ColumnName))
  117. row[ds.Tables[0].Columns[j].ColumnName] = ds.Tables[0].Rows[i][j];
  118. }
  119. dataTable1.Rows.Add(row);
  120. }
  121. ugrdTBinfo.EndUpdate();
  122. }
  123. if (ugrdTBinfo.Rows.Count > 0)
  124. {
  125. SetGridBackColor();
  126. if (strCurrID.Length > 0)
  127. LocateRecord(strCurrID, bSelected);
  128. }
  129. else
  130. strCurrID = "";
  131. }
  132. catch
  133. { }
  134. finally
  135. {
  136. bRefreshNow = false;
  137. }
  138. }
  139. /// <summary>
  140. /// 颜色显示
  141. /// </summary>
  142. private void SetGridBackColor()
  143. {
  144. try
  145. {
  146. Hashtable htOperate = new Hashtable();
  147. htOperate.Add("备用", Color.GhostWhite);
  148. htOperate.Add("使用", Color.LightGreen);
  149. htOperate.Add("维修", Color.LightBlue);
  150. htOperate.Add("烘烤", Color.Yellow);
  151. htOperate.Add("报废", Color.Red);
  152. LadleCommonClass.SetGridBackColor(ugrdTBinfo, htOperate, "当前状态", true);
  153. }
  154. catch { }
  155. }
  156. private void LocateRecord(string strID, bool bSelect)
  157. {
  158. try
  159. {
  160. for (int i = 0; i < ugrdTBinfo.Rows.Count; i++)
  161. {
  162. if (Convert.ToString(ugrdTBinfo.Rows[i].Cells["铁包编号"].Value) == strID)
  163. {
  164. ugrdTBinfo.ActiveRow = ugrdTBinfo.Rows[i];
  165. ugrdTBinfo.Rows[i].Selected = bSelect;
  166. return;
  167. }
  168. }
  169. }
  170. catch { }
  171. }
  172. /// <summary>
  173. /// 加载铁包号
  174. /// </summary>
  175. public void GetID()
  176. {
  177. try
  178. {
  179. string strID = "";
  180. if (ucmeID.SelectedIndex >= 0)
  181. strID = ucmeID.Text;
  182. string strErr = "";
  183. ArrayList arry = new ArrayList();
  184. arry.Add("FrmIronLadleManage_Query2");
  185. CommonClientToServer ccs = new CommonClientToServer();
  186. ccs.ob = this.ob;
  187. DataSet ds = ccs.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery", "doSimpleQuery", arry, out strErr);
  188. if (strErr == "" && ds != null && ds.Tables.Count > 0)
  189. {
  190. this.ucmeID.Items.Clear();
  191. for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
  192. {
  193. ucmeID.Items.Add(ds.Tables[0].Rows[i]["铁包编号"]);
  194. }
  195. }
  196. if (ucmeID.Items.Count > 0 )
  197. {
  198. if (strID.Length > 0)
  199. ucmeID.Text = strID;
  200. else
  201. ucmeID.SelectedIndex = -1;
  202. }
  203. }
  204. catch { }
  205. }
  206. private void cbxID_CheckedChanged(object sender, EventArgs e)
  207. {
  208. ucmeID.Enabled = chkID.Checked;
  209. }
  210. private void cbxStatus_CheckedChanged(object sender, EventArgs e)
  211. {
  212. cmbStatus.Enabled = chkStatus.Checked;
  213. }
  214. private void ulgrid_AfterRowActivate(object sender, EventArgs e)
  215. {
  216. try
  217. {
  218. if (bRefreshNow) return;
  219. UltraGridRow row = ugrdTBinfo.ActiveRow;
  220. if (row != null)
  221. {
  222. strCurrID = Convert.ToString(row.Cells["铁包编号"].Value);
  223. bSelected = ugrdTBinfo.ActiveRow.Selected;
  224. }
  225. }
  226. catch
  227. {
  228. strCurrID = "";
  229. }
  230. }
  231. private void cbxAutoRefresh_CheckedChanged(object sender, EventArgs e)
  232. {
  233. _bAutoRefresh = chkAutoRefresh.Checked;
  234. }
  235. /// <summary>
  236. /// 铁包报废
  237. /// </summary>
  238. /// <param name="strID"></param>
  239. private void proc_RejectTB(string strID)
  240. {
  241. try
  242. {
  243. string strErr = "";
  244. ArrayList arry = new ArrayList();
  245. arry.Add("FrmIronLadleManage_Query3");
  246. arry.Add(strID);
  247. CommonClientToServer ccs = new CommonClientToServer();
  248. ccs.ob = this.ob;
  249. DataSet ds = ccs.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery", "doSimpleQuery", arry, out strErr);
  250. if (!(strErr == "" && ds != null && ds.Tables.Count > 0))
  251. {
  252. MessageBox.Show("铁包[" + strID + "]报废操作失败,请重试!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  253. return;
  254. }
  255. if (ds.Tables[0].Rows.Count == 0)
  256. {
  257. MessageBox.Show("铁包编号[" + strID + "]不存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  258. return;
  259. }
  260. string strCurrStatus = Convert.ToString(ds.Tables[0].Rows[0]["当前状态"]);
  261. if (strCurrStatus == "报废")
  262. {
  263. MessageBox.Show("铁包[" + strID + "]已经报废!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  264. return;
  265. }
  266. if (strCurrStatus != "备用")
  267. {
  268. MessageBox.Show("铁包[" + strID + "]当前状态为[" + strCurrStatus + "],不能执行报废操作!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  269. return;
  270. }
  271. for (int i = 0; i < 3; i++)
  272. {
  273. string strTimes = (i == 0 ? "一" : (i == 1 ? "二" : (i == 2 ? "三" : "")));
  274. if (MessageBox.Show("第[" + strTimes + "]次确认\r\n\r\n"
  275. + "铁包号:[" + strID + "]\r\n"
  276. + "报废操作不能撤销\r\n"
  277. + "确认要报废吗?",
  278. "报废",
  279. MessageBoxButtons.YesNo,
  280. MessageBoxIcon.Question,
  281. MessageBoxDefaultButton.Button2) == DialogResult.No)
  282. return;
  283. }
  284. string strReturn = "";
  285. strErr = "";
  286. arry.Clear();
  287. arry.Add("FrmIronLadleManage_Edit");
  288. arry.Add(strID);
  289. strReturn = ccs.NoQueryFunctions("Core.LgMes.Server.Common.ComDBSave", "doSimpleSave", arry, out strErr);
  290. if (strErr != "")
  291. {
  292. MessageBox.Show("铁包[" + strID + "]报废操作失败!\n" + strErr, "错误!", MessageBoxButtons.OK, MessageBoxIcon.Error);
  293. return;
  294. }
  295. if (!chkAutoRefresh.Checked)
  296. {
  297. GetID();
  298. GetAndSetData();
  299. }
  300. GetAndSetData();
  301. MessageBox.Show("铁包[" + strID + "]报废操作成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  302. }
  303. catch (Exception ex)
  304. {
  305. MessageBox.Show("铁包报废操作失败!\r\n" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  306. return;
  307. }
  308. }
  309. public override void ToolBar_Click(object sender, string ToolbarKey)
  310. {
  311. switch (ToolbarKey)
  312. {
  313. case "Query":
  314. {
  315. GetAndSetData();
  316. break;
  317. }
  318. case "BaseInfo": //基础信息
  319. {
  320. string strInitID = "";
  321. UltraGridRow row = ugrdTBinfo.ActiveRow;
  322. if (row != null)
  323. strInitID = Convert.ToString(row.Cells["铁包编号"].Value);
  324. FrmILBaseInfo frm = new FrmILBaseInfo(ob);
  325. frm.Tag = this;
  326. frm.strInitiD = strInitID;
  327. frm.ShowDialog();
  328. break;
  329. }
  330. case "Repair": //维修
  331. {
  332. string strInitID = "";
  333. UltraGridRow row = ugrdTBinfo.ActiveRow;
  334. if (row != null)
  335. strInitID = Convert.ToString(row.Cells["铁包编号"].Value);
  336. FrmILRepair frm = new FrmILRepair(strInitID,ob);
  337. frm.Tag = this;
  338. //frm.strInitiD = strInitID;
  339. frm.ShowDialog();
  340. break;
  341. }
  342. case "TBBake"://铁包烘烤
  343. {
  344. string strInitID = "";
  345. UltraGridRow row = ugrdTBinfo.ActiveRow;
  346. if (row != null)
  347. strInitID = Convert.ToString(row.Cells["铁包编号"].Value);
  348. FrmILFire frm = new FrmILFire(strInitID,ob);
  349. frm.Tag = this;
  350. frm.ShowDialog();
  351. break;
  352. }
  353. case "Reject": //报废
  354. {
  355. UltraGridRow row = ugrdTBinfo.ActiveRow;
  356. if (row != null)
  357. {
  358. proc_RejectTB(Convert.ToString(row.Cells["铁包编号"].Value));
  359. }
  360. break;
  361. }
  362. case "UseDetail": //使用信息
  363. {
  364. string strInitID = "";
  365. UltraGridRow row = ugrdTBinfo.ActiveRow;
  366. if (row != null)
  367. strInitID = Convert.ToString(row.Cells["铁包编号"].Value);
  368. FrmILHistory frm = new FrmILHistory(ToolsName.铁包, strInitID, RecordsName.使用记录,ob);
  369. frm.Tag = this;
  370. frm.ShowDialog();
  371. break;
  372. }
  373. case "RepairDetail": //维修记录
  374. {
  375. string strInitID = "";
  376. UltraGridRow row = ugrdTBinfo.ActiveRow;
  377. if (row != null)
  378. strInitID = Convert.ToString(row.Cells["铁包编号"].Value);
  379. FrmILHistory frm = new FrmILHistory(ToolsName.铁包, strInitID, RecordsName.维修记录,ob);
  380. frm.Tag = this;
  381. frm.ShowDialog();
  382. break;
  383. }
  384. case "烘烤记录":
  385. {
  386. string strInitID = "";
  387. UltraGridRow row = ugrdTBinfo.ActiveRow;
  388. if (row != null)
  389. strInitID = Convert.ToString(row.Cells["铁包编号"].Value);
  390. FrmILHistory frm = new FrmILHistory(ToolsName.铁包, strInitID, RecordsName.烘烤记录, ob);
  391. frm.Tag = this;
  392. frm.ShowDialog();
  393. break;
  394. }
  395. case "ILSend":
  396. frmILSend frmIL = new frmILSend(ob);
  397. frmIL._ds = dStTBinfo.Copy();
  398. frmIL.ShowDialog();
  399. break;
  400. case "Cance":
  401. CancelIronUserInfo();
  402. break;
  403. case "Exit":
  404. {
  405. this.Close();
  406. break;
  407. }
  408. }
  409. }
  410. /// <summary>
  411. /// 是否显示废钢信息
  412. /// </summary>
  413. /// <param name="sender"></param>
  414. /// <param name="e"></param>
  415. private void cbxShowBF_CheckedChanged(object sender, EventArgs e)
  416. {
  417. //GetAndSetData();
  418. }
  419. /// <summary>
  420. /// 取消铁水使用信息
  421. /// </summary>
  422. private void CancelIronUserInfo()
  423. {
  424. string strSqlID = ""; //sqlId
  425. string strErr = ""; //错误信息
  426. if (ugrdTBinfo.ActiveRow == null)
  427. {
  428. MessageBox.Show("没有选择要取消使用信息的铁包,请选择!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  429. return;
  430. }
  431. if (MessageBox.Show("是否确认取消【铁包号:" + ugrdTBinfo.ActiveRow.Cells["铁包编号"].Value.ToString() +
  432. "】铁水使用信息!", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk) == DialogResult.Yes)
  433. {
  434. strSqlID = "CancelIronUserInfo.Cancel"; //SQLID
  435. Hashtable ht = new Hashtable();
  436. ht.Add("I1", ugrdTBinfo.ActiveRow.Cells["铁包编号"].Value.ToString()); //铁水罐号
  437. ht.Add("O1", "");
  438. ht.Add("O2", "");
  439. CommonClientToServer ccTs = new CommonClientToServer();
  440. ccTs.ob = ob;
  441. string strRCode = ccTs.ExecuteProcedureFunctions("Core.LgMes.Server.LgDeviceManager.LadleManager",
  442. "CancelIronUserInfo", strSqlID, ht, out strErr);
  443. if (strErr == "")
  444. {
  445. MessageBox.Show("铁水使用信息取消成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  446. GetAndSetData();
  447. }
  448. else
  449. MessageBox.Show("铁水使用信息取消失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  450. }
  451. }
  452. }
  453. /// <summary>
  454. /// 工器具名称
  455. /// </summary>
  456. public enum ToolsName
  457. {
  458. 钢包, 铁包, 中包, 氧枪, 结晶器, 出钢口
  459. }
  460. /// <summary>
  461. /// 工器具记录类别
  462. /// </summary>
  463. public enum RecordsName
  464. {
  465. 使用记录, 维修记录, 烘烤记录
  466. }
  467. }