frmScrapSteel2.cs 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using System.Collections;
  10. using CoreFS.CA06;
  11. using Infragistics.Win.UltraWinGrid;
  12. using System.Threading;
  13. using System.Diagnostics;
  14. using System.IO;
  15. using Core.StlMes.Client.LgCommon;
  16. using Infragistics.Win.UltraWinEditors;
  17. using Infragistics.Win.Misc;
  18. namespace Core.StlMes.Client.LgResMgt
  19. {
  20. public partial class frmScrapSteel2 : frmStyleBase
  21. {
  22. private System.Threading.Thread myThread_FG;
  23. private Hashtable hashLD = new Hashtable();
  24. private string _strSendSucceededForBof1 = "";
  25. private string _strSendSucceededForBof2 = "";
  26. private string _strSendSucceededForBof3 = "";
  27. private string _strSendSucceededForBof4 = "";
  28. private string _strSendSucceededForBof5 = "";
  29. public string workshopNo = "";
  30. public frmScrapSteel2()
  31. {
  32. InitializeComponent();
  33. CheckForIllegalCrossThreadCalls = false;
  34. }
  35. private void frmScrapSteel_Load(object sender, EventArgs e)
  36. {
  37. workshopNo = this.CustomInfo;
  38. intForm();
  39. checkJZ.Checked = true;
  40. ultraSBZ.SelectedIndex = 0;
  41. this.udte_StartTime.Text = System.DateTime.Now.ToString("yyyy-MM-dd") + " 00:00:00";
  42. this.udte_EndTime.Text = System.DateTime.Now.ToString("yyyy-MM-dd") + " 23:59:59";
  43. ute_RLSJ.Text = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  44. GetZL_Thread();
  45. pro_QueryLD();
  46. ultraSBZ.SelectedIndex = 0;
  47. if (ultraSLD.Items.Count > 0)
  48. {
  49. ultraLD.SelectedIndex = 0;
  50. }
  51. GetRLMX_Data();
  52. pro_QueryNullWgt();
  53. }
  54. private void intForm()
  55. {
  56. try
  57. {
  58. if (workshopNo == "1")
  59. {
  60. label15.Text = "1#转炉";
  61. label16.Text = "2#转炉";
  62. label17.Visible = false;
  63. ute_ZL3.Visible = false;
  64. button3.Visible = false;
  65. }
  66. }
  67. catch (Exception ex)
  68. {
  69. MessageBox.Show(ex.Message + "错误行数59");
  70. }
  71. }
  72. // 获取料斗信息
  73. /// <summary>
  74. /// 获取料斗信息
  75. /// </summary>
  76. private void pro_QueryLD()
  77. {
  78. try
  79. {
  80. string strErr = "";
  81. ArrayList arry = new ArrayList();
  82. arry.Add(workshopNo);
  83. CommonClientToServer ccTos = new CommonClientToServer();
  84. ccTos.ob = this.ob;
  85. DataSet ds = ccTos.ExecuteQueryFunctionsSqlID("Core.Mes.Server.Common.ComDataAccess",
  86. "QueryWithParameter", "STL_RESULT0001", 5, arry, out strErr);
  87. if (strErr == "" && ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
  88. {
  89. hashLD.Clear();
  90. for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
  91. {
  92. if (!hashLD.Contains(ds.Tables[0].Rows[i]["CHARGENO"].ToString()))
  93. {
  94. hashLD.Add(ds.Tables[0].Rows[i]["CHARGENO"].ToString(), ds.Tables[0].Rows[i]["TAREWEIGHT"].ToString());
  95. }
  96. ultraLD.Items.Add(ds.Tables[0].Rows[i]["CHARGENO"].ToString());
  97. ultraSLD.Items.Add(ds.Tables[0].Rows[i]["CHARGENO"].ToString());
  98. }
  99. }
  100. }
  101. catch (Exception ex)
  102. {
  103. MessageBox.Show(ex.Message + "错误行数82");
  104. }
  105. }
  106. // 取入炉明细数据主表
  107. /// <summary>
  108. /// 取入炉明细数据主表
  109. /// </summary>
  110. private void GetRLMX_Data()
  111. {
  112. try
  113. {
  114. try
  115. {
  116. string bz = "";
  117. string heatno = "";
  118. string ld = "";
  119. string strStartTime = this.udte_StartTime.DateTime.ToString("yyyy-MM-dd HH:mm:ss");
  120. string strEndTime = this.udte_EndTime.DateTime.ToString("yyyy-MM-dd HH:mm:ss");
  121. if(chkBZ.Checked)
  122. {
  123. bz = ultraSBZ.Value.ToString();
  124. }
  125. if (chkHeatno.Checked)
  126. {
  127. heatno = textHeatno.Text.Trim();
  128. }
  129. if (chkLD.Checked)
  130. {
  131. ld = ultraSLD.Text.Trim();
  132. }
  133. string strErr = "";
  134. ArrayList arry = new ArrayList();
  135. arry.Add(strStartTime);
  136. arry.Add(strEndTime);
  137. arry.Add(bz);
  138. arry.Add(bz);
  139. arry.Add(ld);
  140. arry.Add(ld);
  141. arry.Add(heatno);
  142. arry.Add(heatno);
  143. arry.Add(workshopNo);
  144. CommonClientToServer ccTos = new CommonClientToServer();
  145. ccTos.ob = this.ob;
  146. DataSet ds = ccTos.ExecuteQueryFunctionsSqlID("Core.Mes.Server.Common.ComDataAccess",
  147. "QueryWithParameter", "STL_RESULT0005", 5, arry, out strErr);
  148. ultraDataSource1.Rows.Clear();
  149. if (strErr == "" && ds != null)
  150. {
  151. if (ds.Tables.Count > 0)
  152. {
  153. foreach (DataRow dr in ds.Tables[0].Rows)
  154. {
  155. ultraDataSource1.Rows.Add(new object[] {
  156. dr["JOBID"].ToString(),
  157. dr["HEATNO"].ToString(),
  158. dr["BLOCKFUR"].ToString(),
  159. dr["STATIONCODE"].ToString(),
  160. dr["SHIFTCODE"].ToString(),
  161. dr["CHARGENO"].ToString(),
  162. dr["TOTALWGT"].ToString(),
  163. dr["CHUTEWGT"].ToString(),
  164. dr["JOINSTOVEWGT"].ToString(),
  165. dr["JOBDATE"].ToString(),
  166. dr["MEMO"].ToString(),
  167. dr["OPTPERSONNEL"].ToString()
  168. });
  169. }
  170. }
  171. }
  172. }
  173. catch (Exception ex)
  174. {
  175. MessageBox.Show(ex.Message + "错误行数122");
  176. }
  177. SetSteelSum();
  178. PublicMethod.RefreshAndAutoSize(ultraGrid1);
  179. }
  180. catch (Exception ex)
  181. {
  182. MessageBox.Show(ex.Message + "错误行数120");
  183. }
  184. }
  185. // 获取未发送废钢的炉号信息
  186. /// <summary>
  187. /// 获取未发送废钢的炉号信息
  188. /// </summary>
  189. private void pro_QueryNullWgt()
  190. {
  191. try
  192. {
  193. string beginNum = "";
  194. string endNum = "";
  195. string strNum = "";
  196. if (radioButton1.Checked)
  197. {
  198. strNum = "0";
  199. }
  200. else
  201. {
  202. strNum = "1";
  203. }
  204. if (workshopNo == "1")
  205. {
  206. beginNum = "1";
  207. endNum = "2";
  208. }
  209. else
  210. {
  211. beginNum = "3";
  212. endNum = "5";
  213. }
  214. string strErr = "";
  215. string strStartTime = this.udte_StartTime.DateTime.ToString("yyyy-MM-dd HH:mm:ss");
  216. string strEndTime = this.udte_EndTime.DateTime.ToString("yyyy-MM-dd HH:mm:ss");
  217. ArrayList arry = new ArrayList();
  218. arry.Add(strStartTime);
  219. arry.Add(strEndTime);
  220. arry.Add(strNum);
  221. arry.Add(beginNum);
  222. arry.Add(endNum);
  223. arry.Add(strStartTime);
  224. arry.Add(strEndTime);
  225. arry.Add(strNum);
  226. arry.Add(beginNum);
  227. arry.Add(endNum);
  228. CommonClientToServer ccTos = new CommonClientToServer();
  229. ccTos.ob = this.ob;
  230. DataSet ds = ccTos.ExecuteQueryFunctionsSqlID("Core.Mes.Server.Common.ComDataAccess",
  231. "QueryWithParameter", "STL_RESULT0006", 5, arry, out strErr);
  232. ultraDataSource2.Rows.Clear();
  233. if (strErr == "" && ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
  234. {
  235. foreach (DataRow dr in ds.Tables[0].Rows)
  236. {
  237. ultraDataSource2.Rows.Add(new object[] {
  238. dr["HEATNO"].ToString(),
  239. dr["STATIONCODE"].ToString(),
  240. dr["IRONPOTWGT"].ToString(),
  241. dr["WSTEELWGT"].ToString(),
  242. dr["OPTDATE"].ToString(),
  243. dr["FLAG"].ToString()
  244. });
  245. }
  246. }
  247. PublicMethod.RefreshAndAutoSize(ultraGrid5);
  248. }
  249. catch (Exception ex)
  250. {
  251. MessageBox.Show(ex.Message + "错误行数201");
  252. }
  253. }
  254. // 统计废钢重量
  255. /// <summary>
  256. /// 统计废钢重量
  257. /// </summary>
  258. private void SetSteelSum()
  259. {
  260. UltraGridBand band = this.ultraGrid1.DisplayLayout.Bands[0];
  261. band.Summaries.Clear();
  262. SummarySettings summary = band.Summaries.Add(SummaryType.Count, band.Columns[5]);
  263. summary.SummaryPosition = SummaryPosition.UseSummaryPositionColumn;
  264. summary.DisplayFormat = "合计:";
  265. for (int i = 6; i < 10; i++)
  266. {
  267. summary = band.Summaries.Add(SummaryType.Sum, band.Columns[i]);
  268. summary.SummaryPosition = SummaryPosition.UseSummaryPositionColumn;
  269. summary.DisplayFormat = " {0:#####.00}";
  270. summary.Appearance.TextHAlign = Infragistics.Win.HAlign.Center;
  271. summary.Appearance.ForeColor = Color.DarkBlue;
  272. summary.Appearance.BackColor = Color.White;
  273. }
  274. band.Override.SummaryFooterCaptionVisible = Infragistics.Win.DefaultableBoolean.False;
  275. }
  276. // 取消发送
  277. /// <summary>
  278. /// 取消发送
  279. /// </summary>
  280. private void CancelSend()
  281. {
  282. try
  283. {
  284. ultraGrid1.UpdateData();
  285. string strXH = ultraGrid1.ActiveRow.Cells["JOBID"].Value.ToString();
  286. string strLH = ultraGrid1.ActiveRow.Cells["HEATNO"].Value.ToString();
  287. if (strXH.Length == 0)
  288. {
  289. MessageBox.Show("无效的炉号!\n无法取消发送!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  290. return;
  291. }
  292. if (strLH.Length == 0)
  293. {
  294. MessageBox.Show("无效的序号!\n无法取消发送!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  295. return;
  296. }
  297. DialogResult dr = MessageBox.Show("确定取消已经发送的废钢信息?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
  298. if (dr == DialogResult.No) return;
  299. String strErr = "";
  300. string strSqlID = "frmScrapMater.Cancelsendtwo";
  301. object[] sArgs = new object[2];
  302. sArgs[0] = strLH; //炉号
  303. sArgs[1] = strXH; //序号
  304. CommonClientToServer ccTs = new CommonClientToServer();
  305. ccTs.ob = ob;
  306. string strRCode = ccTs.ExecuteProcedureFunctions("Core.LgMes.Server.Common.ComDBProcedure",
  307. "ExecProcWithCollParam", strSqlID, sArgs, out strErr);
  308. if (strErr != "")
  309. {
  310. // MessageBox.Show("废钢信息取消发送失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  311. }
  312. else
  313. {
  314. MessageBox.Show("废钢信息取消发送成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  315. GetRLMX_Data();
  316. pro_QueryNullWgt();
  317. }
  318. }
  319. catch (Exception ex)
  320. {
  321. MessageBox.Show(ex.Message + "错误行数298");
  322. }
  323. }
  324. //实时刷新当前转炉正在冶炼的熔炼号
  325. ///<summary>
  326. ///实时刷新当前转炉正在冶炼的熔炼号
  327. ///</summary>
  328. private void GetZL_Thread()
  329. {
  330. try
  331. {
  332. myThread_FG = new Thread(new ThreadStart(getZLCurrentLH));
  333. myThread_FG.Priority = ThreadPriority.Normal;
  334. myThread_FG.Start();
  335. }
  336. catch (Exception ex)
  337. {
  338. MessageBox.Show(ex.Message + "错误行数348");
  339. }
  340. }
  341. // 取当前转炉正在冶炼熔炼号 C##01_DEVICE
  342. /// <summary>
  343. /// 取当前转炉正在冶炼熔炼号 CVT01_DEVICE
  344. /// </summary>
  345. private void getZLCurrentLH()
  346. {
  347. try
  348. {
  349. System.Windows.Forms.Control.CheckForIllegalCrossThreadCalls = false;
  350. while (true)
  351. {
  352. if (!this.On_Off_Thread)
  353. {
  354. System.Threading.Thread.Sleep(500);
  355. continue;
  356. }
  357. this.ute_ZL1.Text = "";
  358. this.ute_ZL2.Text = "";
  359. this.ute_ZL3.Text = "";
  360. //初始化颜色
  361. ute_ZL1.Appearance.BackColor = Color.White;//.Gainsboro;
  362. ute_ZL2.Appearance.BackColor = Color.White;
  363. ute_ZL3.Appearance.BackColor = Color.White;
  364. ute_RLSJ.Text = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  365. string strError = "";
  366. ArrayList arry = new ArrayList();
  367. arry.Clear();
  368. arry.Add("getZLCurrentLH.query");
  369. CommonClientToServer ccs = new CommonClientToServer();
  370. ccs.ob = this.ob;
  371. DataSet ds = ccs.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery", "doSimpleQuery", arry, out strError);
  372. if (strError == "")
  373. {
  374. if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
  375. {
  376. //初始化颜色
  377. ute_ZL1.Appearance.BackColor = Color.White;
  378. ute_ZL2.Appearance.BackColor = Color.White;
  379. ute_ZL3.Appearance.BackColor = Color.White;
  380. for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
  381. {
  382. string v_ZLH = ds.Tables[0].Rows[i]["objectpos"].ToString().Substring(3, 2);
  383. string v_LH = (ds.Tables[0].Rows[i]["objectid"].ToString().Substring(5, ds.Tables[0].Rows[i]["objectid"].ToString().Length - 5));
  384. // if (ds.Tables[0].Rows[i]["objectid"].ToString().Substring(0, 1) == "V") v_LH = "V" + v_LH;
  385. if (workshopNo == "1")
  386. {
  387. if (v_ZLH == "01")
  388. {
  389. this.ute_ZL1.Text = v_LH;
  390. HeatNo_HudwId_Exist(v_LH, "01");
  391. }
  392. if (v_ZLH == "02")
  393. {
  394. this.ute_ZL2.Text = v_LH;
  395. HeatNo_HudwId_Exist(v_LH, "02");
  396. }
  397. }
  398. else
  399. {
  400. if (v_ZLH == "03")
  401. {
  402. this.ute_ZL1.Text = v_LH;
  403. HeatNo_HudwId_Exist(v_LH, "03");
  404. }
  405. if (v_ZLH == "04")
  406. {
  407. this.ute_ZL2.Text = v_LH;
  408. HeatNo_HudwId_Exist(v_LH, "04");
  409. }
  410. if (v_ZLH == "05")
  411. {
  412. this.ute_ZL3.Text = v_LH;
  413. HeatNo_HudwId_Exist(v_LH, "05");
  414. }
  415. }
  416. }
  417. }
  418. }
  419. Thread.Sleep(10000);
  420. }
  421. }
  422. catch (Exception ex)
  423. {
  424. MessageBox.Show(ex.Message + "错误行数367");
  425. }
  426. }
  427. // 判断是否已经发送废钢
  428. /// <summary>
  429. /// 判断是否已经发送废钢
  430. /// </summary>
  431. /// <熔炼号="strID"></param>
  432. /// <炉座号="strGw"></param>
  433. private void HeatNo_HudwId_Exist(string strID, string strGw)
  434. {
  435. string strErr = "";
  436. try
  437. {
  438. ArrayList arry = new ArrayList();
  439. arry.Add("HeatNo_HudwId_Exist.query");
  440. CommonClientToServer ccs = new CommonClientToServer();
  441. ccs.ob = this.ob;
  442. arry.Add(strID);
  443. arry.Add(strID);
  444. DataSet ds = ccs.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery", "doSimpleQuery", arry, out strErr);
  445. if (strErr == "")
  446. {
  447. switch (strGw)
  448. {
  449. case "01":
  450. _strSendSucceededForBof1 = ds.Tables[0].Rows[0]["intCount"].ToString()=="0"?"N":"Y";
  451. if (_strSendSucceededForBof1 == "N") ute_ZL1.Appearance.BackColor = Color.White;
  452. if (_strSendSucceededForBof1 == "Y") ute_ZL1.Appearance.BackColor = Color.LightBlue;
  453. break;
  454. case "02":
  455. _strSendSucceededForBof2 = ds.Tables[0].Rows[0]["intCount"].ToString() == "0" ? "N" : "Y";
  456. if (_strSendSucceededForBof2 == "N") ute_ZL2.Appearance.BackColor = Color.White;
  457. if (_strSendSucceededForBof2 == "Y") ute_ZL2.Appearance.BackColor = Color.LightBlue;
  458. break;
  459. case "03":
  460. _strSendSucceededForBof3 = ds.Tables[0].Rows[0]["intCount"].ToString() == "0" ? "N" : "Y";
  461. if (_strSendSucceededForBof3 == "N") ute_ZL1.Appearance.BackColor = Color.White;
  462. if (_strSendSucceededForBof3 == "Y") ute_ZL1.Appearance.BackColor = Color.LightBlue;
  463. break;
  464. case "04":
  465. _strSendSucceededForBof4 = ds.Tables[0].Rows[0]["intCount"].ToString() == "0" ? "N" : "Y";
  466. if (_strSendSucceededForBof4 == "N") ute_ZL2.Appearance.BackColor = Color.White;
  467. if (_strSendSucceededForBof4 == "Y") ute_ZL2.Appearance.BackColor = Color.LightBlue;
  468. break;
  469. case "05":
  470. _strSendSucceededForBof5 = ds.Tables[0].Rows[0]["intCount"].ToString() == "0" ? "N" : "Y";
  471. if (_strSendSucceededForBof5 == "N") ute_ZL3.Appearance.BackColor = Color.White;
  472. if (_strSendSucceededForBof5 == "Y") ute_ZL3.Appearance.BackColor = Color.LightBlue;
  473. break;
  474. default:
  475. break;
  476. }
  477. }
  478. }
  479. catch (Exception ex)
  480. {
  481. MessageBox.Show(ex.Message + "错误行数459");
  482. }
  483. }
  484. // 系统菜单栏
  485. /// <summary>
  486. /// 系统菜单栏
  487. /// </summary>
  488. /// <param name="sender"></param>
  489. /// <param name="ToolbarKey"></param>
  490. public override void ToolBar_Click(object sender, string ToolbarKey)
  491. {
  492. base.ToolBar_Click(sender, ToolbarKey);
  493. switch (ToolbarKey)
  494. {
  495. case "Add"://新增
  496. try
  497. {
  498. ute_RLSJ.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  499. }
  500. catch
  501. {
  502. return;
  503. }
  504. GetRLMX_Data();
  505. break;
  506. case "Update"://修改
  507. //if (!string.IsNullOrEmpty(ute_DH2.Text.Trim()) && !string.IsNullOrEmpty(ultNo.Text.Trim()))
  508. //{
  509. DialogResult result;
  510. string mk = "确实要修改吗?";
  511. result = MessageBox.Show(this, mk, "提示", MessageBoxButtons.YesNo,
  512. MessageBoxIcon.Question);
  513. if (result == DialogResult.Yes)
  514. {
  515. if (ultraGrid1.ActiveRow != null)
  516. {
  517. try
  518. {
  519. DateTime aa = Convert.ToDateTime(ute_RLSJ.Text.ToString());
  520. string strXH = this.ultraGrid1.ActiveRow.Cells["ZYXH"].Value.ToString().Trim();
  521. // UpdateDataRow(strXH);
  522. GetRLMX_Data();
  523. }
  524. catch
  525. {
  526. MessageBox.Show("入炉时间 不是合法的日期时间!\n\n请重新选择入炉时间!", "提示");
  527. }
  528. }
  529. else
  530. {
  531. MessageBox.Show("请选择需要修改的记录!", "提示");
  532. }
  533. }
  534. // }
  535. else
  536. MessageBox.Show("请选择需要修改的记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  537. break;
  538. case "Query":// 查询
  539. GetRLMX_Data();
  540. pro_QueryNullWgt();
  541. break;
  542. case "Config":
  543. frmChargeConfig config = new frmChargeConfig(ob);
  544. config.Tag = this;
  545. config.WorkShopNo = workshopNo;
  546. config.ShowDialog();
  547. break;
  548. case "Export"://导出Excel
  549. Core.Mes.Client.Comm.Globals.ulGridToExcel(ultraGrid1, Text);
  550. break;
  551. case "Cancel"://取消发送
  552. CancelSend();
  553. break;
  554. case "Exit":
  555. this.Close();
  556. break;
  557. default:
  558. break;
  559. }
  560. }
  561. private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
  562. {
  563. try
  564. {
  565. if (this.ultraGrid1.Rows.Count == 0 || this.ultraGrid1.ActiveRow == null)
  566. {
  567. return;
  568. }
  569. UltraGridRow row = null;
  570. if (ultraGrid1.ActiveRow.HasParent())
  571. {
  572. row = ultraGrid1.ActiveRow.ParentRow;
  573. }
  574. else
  575. {
  576. row = ultraGrid1.ActiveRow;
  577. }
  578. ultNo.Text = row.Cells["JOBID"].Value.ToString();
  579. ute_LH.Text = row.Cells["HEATNO"].Value.ToString();
  580. utlcbdevNo.Text = row.Cells["STATIONCODE"].Value.ToString();
  581. //ute_DH2.Text = row.Cells["CHARGENO"].Value.ToString();
  582. ute_RLSJ.Text = row.Cells["JOBDATE"].Value.ToString();
  583. ute_RLZL.Text = row.Cells["JOINSTOVEWGT"].Value.ToString();
  584. ute_DZ.Text = row.Cells["CHUTEWGT"].Value.ToString();
  585. ute_ZZ.Text = row.Cells["TOTALWGT"].Value.ToString();
  586. ute_BZ.Text = row.Cells["MEMO"].Value.ToString();
  587. //cbb_BC.Text = row.Cells["SHIFTCODE"].Value.ToString();
  588. }
  589. catch (Exception ex)
  590. {
  591. MessageBox.Show(ex.Message + "错误行数590");
  592. }
  593. }
  594. private void ute_RLSJ_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
  595. {
  596. try
  597. {
  598. frmSetTime frm = new frmSetTime(e.Context);
  599. //frm.Location = ClsControlPack.GetChildWindowLocation(frm.Size);
  600. frm.Location = new Point(556,376);//ClsControlPack.GetChildWindowLocation(frm.Size);
  601. frm.AutoSize = true;
  602. if (frm.ShowDialog() == DialogResult.OK)
  603. {
  604. ute_RLSJ.Text = (Convert.ToDateTime(frm.SelectDate.ToString())).ToString("yyyy-MM-dd HH:mm:ss");
  605. ute_RLSJ.Update();
  606. }
  607. }
  608. catch (Exception ex)
  609. {
  610. MessageBox.Show(ex.Message + "错误行数625");
  611. }
  612. }
  613. // 发送废钢到转炉
  614. /// <summary>
  615. /// 发送废钢到转炉
  616. /// </summary>
  617. /// <param name="sender"></param>
  618. /// <param name="e"></param>
  619. private void button_Click(object sender, EventArgs e)
  620. {
  621. try
  622. {
  623. Button button = (Button)sender;
  624. string stationcode = button.Tag == null ? "" : button.Tag.ToString();
  625. if (stationcode == "") return;
  626. string heatno="";
  627. if (stationcode == "03")
  628. {
  629. heatno = this.ute_ZL1.Text.Trim().ToString();
  630. }
  631. else if (stationcode == "04")
  632. {
  633. heatno = this.ute_ZL2.Text.Trim().ToString();
  634. }
  635. else if (stationcode == "05")
  636. {
  637. heatno = this.ute_ZL3.Text.Trim().ToString();
  638. }
  639. else if (stationcode == "all")
  640. {
  641. heatno = this.ute_ZLInput.Text.Trim().ToString();
  642. }
  643. if (heatno.Length == 0)
  644. {
  645. MessageBox.Show("无效的炉号!\n无法发送废钢!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  646. return;
  647. }
  648. //if (ultraGrid1.ActiveRow.Appearance.BackColor == Color.LightGreen)
  649. //{
  650. // MessageBox.Show("选取的废钢信息已发送,不能重复发送\n如需重新发送,请先取消发送!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  651. // return;
  652. //}
  653. //if (ute_ZL1.Appearance.BackColor == Color.LightBlue)
  654. //{
  655. // DialogResult dr = MessageBox.Show("当前炉号已发送过废钢信息,是否替换原来已经发送的废钢信息?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
  656. // if (dr == DialogResult.No) return;
  657. //}
  658. this.ultraGrid1.DisplayLayout.Bands[0].Override.WrapHeaderText = Infragistics.Win.DefaultableBoolean.True;
  659. string v_DATE = (ute_RLSJ.Text.ToString() == "" ? DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") :
  660. (Convert.ToDateTime(ute_RLSJ.Text.Trim())).ToString("yyyy-MM-dd HH:mm:ss")); //入炉时间
  661. string v_RLZL = ute_RLZL.Text.Trim() == "" ? "0" : ute_RLZL.Text.Trim(); //入炉重量
  662. string v_LDZL = ute_DZ.Text.Trim() == "" ? "0" : ute_DZ.Text.Trim(); // 料斗重
  663. string v_ZZL = ute_ZZ.Text.Trim() == "" ? "0" : ute_ZZ.Text.Trim(); //总重
  664. try
  665. {
  666. Convert.ToDouble(v_RLZL);
  667. Convert.ToDouble(v_ZZL);
  668. }
  669. catch
  670. {
  671. MessageBox.Show("重量不是有效数字!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  672. return;
  673. }
  674. if (v_RLZL == "0" || v_RLZL == "")
  675. {
  676. MessageBox.Show("废钢总重为零,发送无意义!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  677. return;
  678. }
  679. string strErr = "";
  680. string strSqlID = "frmScrapMater.sendtwo";
  681. object[] sArgs = new object[10];
  682. sArgs[0] = heatno; //炉号
  683. sArgs[1] = stationcode; //岗位
  684. sArgs[2] = ultraLD.Text.Trim(); //料斗号
  685. sArgs[3] = v_DATE; //入炉时间
  686. sArgs[4] = v_RLZL; //入炉重量
  687. sArgs[5] = v_LDZL; // 料斗重
  688. sArgs[6] = v_ZZL; //总重
  689. sArgs[7] = this.UserInfo.GetUserName(); //操作人
  690. sArgs[8] = ute_BZ.Text.Trim(); //备注
  691. sArgs[9] = workshopNo;
  692. try
  693. {
  694. CommonClientToServer ccTs = new CommonClientToServer();
  695. ccTs.ob = ob;
  696. string strRCode = ccTs.ExecuteProcedureFunctions("Core.LgMes.Server.Common.ComDBProcedure",
  697. "ExecProcWithCollParam", strSqlID, sArgs, out strErr);
  698. if (strErr != "")
  699. {
  700. // MessageBox.Show("发送失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  701. return;
  702. }
  703. else
  704. {
  705. GetRLMX_Data();
  706. pro_QueryNullWgt();
  707. if (stationcode == "03")
  708. {
  709. _strSendSucceededForBof3 = "Y";
  710. }
  711. else if (stationcode == "04")
  712. {
  713. _strSendSucceededForBof4 = "Y";
  714. }
  715. else if (stationcode == "05")
  716. {
  717. _strSendSucceededForBof5 = "Y";
  718. }
  719. HeatNo_HudwId_Exist(heatno, stationcode);
  720. if (stationcode == "all")
  721. {
  722. if (chkHeatnoAdd.Checked)
  723. {
  724. try
  725. {
  726. ute_ZLInput.Text = (Convert.ToInt32(heatno) + 1).ToString();
  727. }
  728. catch { }
  729. }
  730. }
  731. MessageBox.Show("发送成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  732. }
  733. }
  734. catch (Exception ex)
  735. {
  736. MessageBox.Show(ex.Message + "错误行数651");
  737. }
  738. }
  739. catch (Exception ex)
  740. {
  741. MessageBox.Show(ex.Message + "错误行数651");
  742. }
  743. }
  744. private void ute_ZZ_ValueChanged(object sender, EventArgs e)
  745. {
  746. Double dZz = 0, dDz = 0, dRlzl = 0; //入炉重量,斗重
  747. try
  748. {
  749. //废钢重量
  750. if (!string.IsNullOrEmpty(ute_DZ.Text.Trim()))
  751. {
  752. dDz = Convert.ToDouble(ute_DZ.Text.Trim());
  753. }
  754. if (!string.IsNullOrEmpty(ute_ZZ.Text.Trim()))
  755. {
  756. dZz = Convert.ToDouble(ute_ZZ.Text.Trim());
  757. }
  758. if (dZz - dDz > 0)
  759. {
  760. dRlzl = dZz - dDz;
  761. }
  762. ute_RLZL.Text = Convert.ToString(dRlzl); //入炉重量
  763. }
  764. catch (Exception ex)
  765. {
  766. MessageBox.Show(ex.Message + "错误行数779");
  767. }
  768. }
  769. private void ute_RLZL_ValueChanged(object sender, EventArgs e)
  770. {
  771. Double dRlzl = 0, dDz = 0; //入炉重量,斗重
  772. try
  773. {
  774. //废钢重量
  775. if (!string.IsNullOrEmpty(ute_DZ.Text.Trim()))
  776. {
  777. dDz = Convert.ToDouble(ute_DZ.Text.Trim());
  778. }
  779. if (!string.IsNullOrEmpty(ute_RLZL.Text.Trim()))
  780. {
  781. dRlzl = Convert.ToDouble(ute_RLZL.Text.Trim());
  782. }
  783. ute_ZZ.Text = Convert.ToString(dRlzl + dDz);//总重量
  784. }
  785. catch (Exception ex)
  786. {
  787. MessageBox.Show(ex.Message + "错误行数807");
  788. }
  789. }
  790. //private void NumberInput_KeyPress(object sender, KeyPressEventArgs e)
  791. //{
  792. // if (!(Char.IsNumber(e.KeyChar) || e.KeyChar == '\b' || e.KeyChar == '.'))
  793. // {
  794. // e.Handled = true;
  795. // }
  796. // char[] arrary = ((UltraTextEditor)sender).Text.ToCharArray();
  797. // if (e.KeyChar == '.')
  798. // {
  799. // if (arrary.Length == 0)
  800. // {
  801. // ((UltraTextEditor)sender).Text = "0.";
  802. // ((UltraTextEditor)sender).SelectionStart = ((UltraTextEditor)sender).Text.Trim().Length;
  803. // e.Handled = true;
  804. // }
  805. // else
  806. // {
  807. // for (int i = 0; i < arrary.Length; i++)
  808. // {
  809. // if (arrary[i] == '.')
  810. // e.Handled = true;
  811. // }
  812. // }
  813. // }
  814. // if (arrary.Length == 1)
  815. // {
  816. // if (e.KeyChar == '0')
  817. // {
  818. // if (arrary[0] == '0')
  819. // e.Handled = true;
  820. // }
  821. // if (arrary[0] == '0' && e.KeyChar != '.' && e.KeyChar != '\b' && e.KeyChar != '0'&&!(Char.IsNumber(e.KeyChar)))
  822. // {
  823. // ((UltraTextEditor)sender).Text = e.KeyChar.ToString();
  824. // ((UltraTextEditor)sender).SelectionStart = ((UltraTextEditor)sender).Text.Trim().Length;
  825. // e.Handled = true;
  826. // }
  827. // }
  828. //}
  829. private void HeatNoInput_KeyPress(object sender, KeyPressEventArgs e)
  830. {
  831. if (!(Char.IsNumber(e.KeyChar) || e.KeyChar == '\b'))
  832. {
  833. e.Handled = true;
  834. }
  835. }
  836. private void chkSend_CheckedChanged(object sender, EventArgs e)
  837. {
  838. GetRLMX_Data();
  839. }
  840. private void ultraLD_ValueChanged(object sender, EventArgs e)
  841. {
  842. try
  843. {
  844. ute_DZ.Text = hashLD[ultraLD.Text.Trim()].ToString();
  845. }
  846. catch { }
  847. }
  848. private void checkJZ_CheckedChanged(object sender, EventArgs e)
  849. {
  850. try
  851. {
  852. if (checkJZ.Checked)
  853. {
  854. ute_RLZL.ReadOnly = false;
  855. ute_ZZ.ReadOnly = true;
  856. }
  857. else
  858. {
  859. ute_RLZL.ReadOnly = true;
  860. ute_ZZ.ReadOnly = false;
  861. }
  862. }
  863. catch { }
  864. }
  865. private void chkLD_CheckedChanged(object sender, EventArgs e)
  866. {
  867. ultraSLD.Enabled = chkLD.Checked;
  868. }
  869. private void chkBZ_CheckedChanged(object sender, EventArgs e)
  870. {
  871. ultraSBZ.Enabled = chkBZ.Checked;
  872. }
  873. private void chkHeatno_CheckedChanged(object sender, EventArgs e)
  874. {
  875. textHeatno.Enabled = chkHeatno.Checked;
  876. }
  877. private void radioButton1_CheckedChanged(object sender, EventArgs e)
  878. {
  879. pro_QueryNullWgt();
  880. }
  881. private void ultraGrid5_DoubleClickRow(object sender, DoubleClickRowEventArgs e)
  882. {
  883. try
  884. {
  885. if (ultraGrid5.ActiveRow.Cells["HEATNO"].Value.ToString() != "")
  886. {
  887. ute_ZLInput.Text = ultraGrid5.ActiveRow.Cells["HEATNO"].Value.ToString().Trim();
  888. }
  889. }
  890. catch { }
  891. }
  892. private void ultraGrid5_InitializeRow(object sender, InitializeRowEventArgs e)
  893. {
  894. try
  895. {
  896. if (e.Row.Cells["FLAG"].Value.ToString() == "未发送")
  897. {
  898. e.Row.Cells["FLAG"].Appearance.BackColor = Color.Salmon;
  899. }
  900. if (e.Row.Cells["FLAG"].Value.ToString() == "已发送")
  901. {
  902. e.Row.Cells["FLAG"].Appearance.BackColor = Color.PaleGreen;
  903. }
  904. }
  905. catch (Exception ex)
  906. {
  907. MessageBox.Show(ex.Message + "错误行数946");
  908. }
  909. }
  910. }
  911. }