frmSetHopper.cs 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Windows.Forms;
  8. using Core.Mes.Client.Comm;
  9. using Core.Mes.Client.Comm.Server;
  10. using Core.Mes.Client.Comm.Tool;
  11. using Core.StlMes.Client.LgClassModel;
  12. using CoreFS.CA06;
  13. using Infragistics.Win;
  14. namespace Core.StlMes.Client.LgCommon
  15. {
  16. public partial class frmSetHopper : frmStyleBase
  17. {
  18. private OpeBase ob = null;
  19. public frmSetHopper(string szDeviceName, OpeBase ob)
  20. {
  21. InitializeComponent();
  22. this.ob = ob;
  23. this.devicePos = szDeviceName;
  24. ClsControlPack.SetUltraGridAppearance(this);
  25. ulgridMtrInfo.DisplayLayout.Override.RowSelectors = DefaultableBoolean.False;
  26. }
  27. #region " Member Variable"
  28. private List<CostBaseMetalTypeEntity> CostBaseMetalTypeEntityList;
  29. private DataTable m_dtMain = null;
  30. //private DataTable m_dtStationconMaterial = null;
  31. private DataTable _dtHopper;
  32. private string devicePos = ""; //CVT01
  33. private string _curMaterType = ""; //FL
  34. private PictureBox _curPicBx = null;
  35. private Label _curLbl = null;
  36. #endregion
  37. //选择料斗
  38. private void PicClickHandler(object sender, System.EventArgs e)
  39. {
  40. SetPicNoSelectState();
  41. _curPicBx = (PictureBox) sender;
  42. _curPicBx.BorderStyle = BorderStyle.Fixed3D;
  43. SetLabelColor();
  44. }
  45. private void SetPicNoSelectState()
  46. {
  47. _curPicBx = null;
  48. _curLbl = null;
  49. foreach (Control ctl in panel2.Controls)
  50. {
  51. if (ctl is PictureBox)
  52. ((PictureBox) ctl).BorderStyle = BorderStyle.None;
  53. }
  54. foreach (Control ctl in panel2.Controls)
  55. {
  56. if (ctl is Label)
  57. ((Label) ctl).ForeColor = Color.Black;
  58. }
  59. foreach (Control ctl in panel3.Controls)
  60. {
  61. if (ctl is PictureBox)
  62. ((PictureBox) ctl).BorderStyle = BorderStyle.None;
  63. }
  64. foreach (Control ctl in panel3.Controls)
  65. {
  66. if (ctl is Label)
  67. ((Label) ctl).ForeColor = Color.Black;
  68. }
  69. }
  70. private void SetLabelColor()
  71. {
  72. try
  73. {
  74. if (_curPicBx == null)
  75. {
  76. return;
  77. }
  78. string lbName;
  79. if (Convert.ToInt32(_curPicBx.Name.Substring(10, _curPicBx.Name.Length - 10)) < 31)
  80. {
  81. lbName = "label" + _curPicBx.Tag.ToString();
  82. foreach (Control c in this.panel2.Controls)
  83. {
  84. if (c.Name == lbName)
  85. {
  86. ((Label) c).ForeColor = Color.Red;
  87. return;
  88. }
  89. }
  90. }
  91. else
  92. {
  93. lbName = "label" + _curPicBx.Tag.ToString();
  94. foreach (Control c in this.panel3.Controls)
  95. {
  96. if (c.Name == lbName)
  97. {
  98. ((Label) c).ForeColor = Color.Red;
  99. return;
  100. }
  101. }
  102. }
  103. }
  104. catch
  105. {
  106. }
  107. }
  108. private void frmSetHopper_Load(object sender, EventArgs e)
  109. {
  110. switch (this.devicePos.Substring(0, 3))
  111. {
  112. case "BOF": // 转炉
  113. this.ultraGroupBox2.Visible = false;
  114. this.rbWS.Visible = false;
  115. this.rbFZL.Text = "辅助料";
  116. this.rbHJ.Text = "合金";
  117. this.ultraGroupBox1.Dock = DockStyle.Fill;
  118. break;
  119. case "EAF": // 转炉
  120. this.ultraGroupBox2.Visible = false;
  121. this.rbWS.Visible = false;
  122. this.rbFZL.Text = "辅助料";
  123. this.rbHJ.Text = "合金";
  124. this.rbHJ.Visible = false;
  125. this.ultraGroupBox1.Dock = DockStyle.Fill;
  126. break;
  127. case "CAS": // 钢包站
  128. this.rbFZL.Visible = true;
  129. this.rbHJ.Text = "合金微调";
  130. break;
  131. case "LF0": // 精炼炉
  132. this.rbFZL.Visible = true;
  133. this.rbHJ.Text = "合金微调";
  134. break;
  135. case "RH0": // RH炉
  136. case "VD0": // RH炉
  137. this.rbFZL.Visible = true;
  138. this.rbHJ.Text = "合金微调";
  139. break;
  140. case "THJ": // 转炉合金
  141. this.ultraGroupBox2.Visible = false;
  142. this.rbWS.Visible = false; // 喂丝料按钮
  143. this.rbFZL.Enabled = false; // 辅助料
  144. this.ultraGroupBox1.Dock = DockStyle.Fill;
  145. break;
  146. default:
  147. break;
  148. }
  149. this.comboBox1.SelectedIndex = 6;
  150. this.ClearLableText();
  151. GetDataSource();
  152. //GetStationconMaterialData(this.devicePos.Substring(0, 3));
  153. // BindingGrid(m_dtMain);
  154. if (rbFZL.Visible)
  155. {
  156. rbFZL.Checked = true;
  157. radioButton_Click(rbFZL, null);
  158. }
  159. else if (rbHJ.Visible)
  160. {
  161. rbHJ.Checked = true;
  162. radioButton_Click(rbHJ, null);
  163. }
  164. else if (rbWS.Visible)
  165. {
  166. rbWS.Checked = true;
  167. radioButton_Click(rbWS, null);
  168. }
  169. //chkdevNo.Checked = true;
  170. }
  171. #region " InitDataSoutce"
  172. private void GetDataSource()
  173. {
  174. ClsControlPack.SetReadOnly(ulgridMtrInfo);
  175. EntityHelper.ShowGridCaption<CostBaseMetalTypeEntity>(ulgridMtrInfo.DisplayLayout.Bands[0]);
  176. string strMsg = "";
  177. bool bSuccess = false;
  178. CostBaseMetalTypeEntityList = EntityHelper.GetData<CostBaseMetalTypeEntity>(
  179. "Core.LgMes.Server.LgDeviceManager.StlAdditive.GetMaterialData", null, ob);
  180. costBaseMetalTypeEntityBindingSource.DataSource = CostBaseMetalTypeEntityList;
  181. ClsControlPack.RefreshAndAutoSize(ulgridMtrInfo);
  182. //DataSet ds = ClsDataAccessPack.GetMaterialData(out bSuccess, out strMsg, ob);
  183. //if (bSuccess && ds != null && ds.Tables.Count > 0)
  184. //{
  185. // this.m_dtMain = ds.Tables[0];
  186. //}
  187. }
  188. #endregion
  189. private void ClearLableText()
  190. {
  191. this.lblG1.Text = "";
  192. this.lblG2.Text = "";
  193. this.lblG3.Text = "";
  194. this.lblG4.Text = "";
  195. this.lblG5.Text = "";
  196. this.lblG6.Text = "";
  197. this.lblG7.Text = "";
  198. this.lblG8.Text = "";
  199. this.lblG9.Text = "";
  200. this.lblG10.Text = "";
  201. this.lblG11.Text = "";
  202. this.lblG12.Text = "";
  203. this.lblG13.Text = "";
  204. this.lblG14.Text = "";
  205. this.lblG15.Text = "";
  206. this.lblG16.Text = "";
  207. this.lblG17.Text = "";
  208. this.lblG18.Text = "";
  209. this.lblG19.Text = "";
  210. this.lblG20.Text = "";
  211. this.lblG21.Text = "";
  212. this.lblG22.Text = "";
  213. this.lblG23.Text = "";
  214. this.lblG24.Text = "";
  215. this.lblW1.Text = "";
  216. this.lblW2.Text = "";
  217. this.lblW3.Text = "";
  218. this.lblW4.Text = "";
  219. this.lblW5.Text = "";
  220. this.lblW6.Text = "";
  221. this.lblW7.Text = "";
  222. this.lblW8.Text = "";
  223. }
  224. private void GetCurrLabel()
  225. {
  226. try
  227. {
  228. if (_curPicBx == null)
  229. {
  230. this._curLbl = null;
  231. return;
  232. }
  233. string lbName;
  234. if (Convert.ToInt32(_curPicBx.Name.Substring(10, _curPicBx.Name.Length - 10)) < 31)
  235. {
  236. lbName = "lblG" + _curPicBx.Tag.ToString();
  237. foreach (Control c in this.panel2.Controls)
  238. {
  239. if (c.Name == lbName)
  240. {
  241. this._curLbl = (Label) c;
  242. return;
  243. }
  244. }
  245. }
  246. else
  247. {
  248. lbName = "lblW" + _curPicBx.Tag.ToString();
  249. foreach (Control c in this.panel3.Controls)
  250. {
  251. if (c.Name == lbName)
  252. {
  253. this._curLbl = (Label) c;
  254. return;
  255. }
  256. }
  257. }
  258. }
  259. catch
  260. {
  261. this._curLbl = null;
  262. }
  263. }
  264. private void btClose_Click(object sender, EventArgs e)
  265. {
  266. this.Close();
  267. }
  268. /// <summary>
  269. /// 添料
  270. /// </summary>
  271. /// <param name="sender"></param>
  272. /// <param name="e"></param>
  273. private void btAdd_Click(object sender, EventArgs e)
  274. {
  275. string szWLLX = "";
  276. Infragistics.Win.UltraWinGrid.UltraGridRow urg = this.ulgridMtrInfo.ActiveRow;
  277. if (urg == null)
  278. {
  279. MessageBox.Show("请选择物料!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  280. return;
  281. }
  282. if (_curPicBx == null)
  283. {
  284. MessageBox.Show("请选择料斗!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  285. return;
  286. }
  287. GetCurrLabel();
  288. if (_curLbl.Tag != null)
  289. szWLLX = _curLbl.Tag.ToString();
  290. var CostBaseMetalTypeEntity = urg.ListObject as CostBaseMetalTypeEntity;
  291. if (CostBaseMetalTypeEntity==null ) return;
  292. string MATERIELTYPE = "";
  293. //switch (CostBaseMetalTypeEntity.ArcCode)
  294. //{
  295. // case "HJ":
  296. // MATERIELTYPE = "HJ";
  297. // break;
  298. // case "FL":
  299. // MATERIELTYPE = "FL";
  300. // break;
  301. //}
  302. try
  303. {
  304. ServerHelper.SetData("Core.LgMes.Server.LgDeviceManager.StlAdditive.InsertStlMaterialConfig",
  305. new object[]
  306. {
  307. new object[]
  308. {
  309. _curPicBx.Tag.ToString(),
  310. this.devicePos,
  311. rbFZL.Checked?rbFZL.Tag.ToString():rbHJ.Checked?rbHJ.Tag.ToString():rbWS.Tag.ToString(),
  312. CostBaseMetalTypeEntity.ItemCode,
  313. comboBox1.SelectedItem.ToString(),
  314. "1"
  315. }
  316. }, ob);
  317. this._curLbl.Text = CostBaseMetalTypeEntity.ItemName;
  318. _curLbl.Tag = CostBaseMetalTypeEntity.ArcCode;
  319. }
  320. catch (Exception ex)
  321. {
  322. if (ex is MESException)
  323. {
  324. }
  325. else
  326. MessageBox.Show("添料失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  327. }
  328. }
  329. private void btReset_Click(object sender, EventArgs e)
  330. {
  331. if (this._curPicBx == null)
  332. {
  333. MessageBox.Show("请选择料斗!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  334. return;
  335. }
  336. GetCurrLabel();
  337. if (this._curLbl.Text.Equals(string.Empty))
  338. return;
  339. DialogResult dia = MessageBox.Show("是否确认重置当前选中的料斗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
  340. if (dia == DialogResult.No) return;
  341. try
  342. {
  343. ServerHelper.SetData("Core.LgMes.Server.LgDeviceManager.StlAdditive.DeleteStlMaterialConfig",
  344. new object[]
  345. {
  346. new object[]
  347. {
  348. _curPicBx.Tag.ToString(),
  349. this.devicePos,
  350. rbFZL.Checked?rbFZL.Tag.ToString():rbHJ.Checked?rbHJ.Tag.ToString():rbWS.Tag.ToString()
  351. }
  352. }, ob);
  353. this._curLbl.Text = "";
  354. _curLbl.Tag = "";
  355. }
  356. catch (Exception ex)
  357. {
  358. if (ex is MESException)
  359. {
  360. }
  361. else
  362. MessageBox.Show("重置失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  363. }
  364. this._curLbl.Text = "";
  365. }
  366. private void SetPicText(bool IsJS, string hopperNo, string str, string szWLLX)
  367. {
  368. if (!IsJS)
  369. {
  370. switch (hopperNo)
  371. {
  372. case "1":
  373. this.lblG1.Text = str;
  374. this.lblG1.Tag = szWLLX;
  375. break;
  376. case "2":
  377. this.lblG2.Text = str;
  378. this.lblG2.Tag = szWLLX;
  379. break;
  380. case "3":
  381. this.lblG3.Text = str;
  382. this.lblG3.Tag = szWLLX;
  383. break;
  384. case "4":
  385. this.lblG4.Text = str;
  386. this.lblG4.Tag = szWLLX;
  387. break;
  388. case "5":
  389. this.lblG5.Text = str;
  390. this.lblG5.Tag = szWLLX;
  391. break;
  392. case "6":
  393. this.lblG6.Text = str;
  394. this.lblG6.Tag = szWLLX;
  395. break;
  396. case "7":
  397. this.lblG7.Text = str;
  398. this.lblG7.Tag = szWLLX;
  399. break;
  400. case "8":
  401. this.lblG8.Text = str;
  402. this.lblG8.Tag = szWLLX;
  403. break;
  404. case "9":
  405. this.lblG9.Text = str;
  406. this.lblG9.Tag = szWLLX;
  407. break;
  408. case "10":
  409. this.lblG10.Text = str;
  410. this.lblG10.Tag = szWLLX;
  411. break;
  412. case "11":
  413. this.lblG11.Text = str;
  414. this.lblG11.Tag = szWLLX;
  415. break;
  416. case "12":
  417. this.lblG12.Text = str;
  418. this.lblG12.Tag = szWLLX;
  419. break;
  420. case "13":
  421. this.lblG13.Text = str;
  422. this.lblG13.Tag = szWLLX;
  423. break;
  424. case "14":
  425. this.lblG14.Text = str;
  426. this.lblG14.Tag = szWLLX;
  427. break;
  428. case "15":
  429. this.lblG15.Text = str;
  430. this.lblG15.Tag = szWLLX;
  431. break;
  432. case "16":
  433. this.lblG16.Text = str;
  434. this.lblG16.Tag = szWLLX;
  435. break;
  436. case "17":
  437. this.lblG17.Text = str;
  438. this.lblG17.Tag = szWLLX;
  439. break;
  440. case "18":
  441. this.lblG18.Text = str;
  442. this.lblG18.Tag = szWLLX;
  443. break;
  444. case "19":
  445. this.lblG19.Text = str;
  446. this.lblG19.Tag = szWLLX;
  447. break;
  448. case "20":
  449. this.lblG20.Text = str;
  450. this.lblG20.Tag = szWLLX;
  451. break;
  452. case "21":
  453. this.lblG21.Text = str;
  454. this.lblG21.Tag = szWLLX;
  455. break;
  456. case "22":
  457. this.lblG22.Text = str;
  458. this.lblG22.Tag = szWLLX;
  459. break;
  460. case "23":
  461. this.lblG23.Text = str;
  462. this.lblG23.Tag = szWLLX;
  463. break;
  464. case "24":
  465. this.lblG24.Text = str;
  466. this.lblG24.Tag = szWLLX;
  467. break;
  468. default:
  469. break;
  470. }
  471. }
  472. else
  473. {
  474. if (hopperNo == "1")
  475. {
  476. this.lblW1.Text = str;
  477. this.lblW1.Tag = szWLLX;
  478. }
  479. if (hopperNo == "2")
  480. {
  481. this.lblW2.Text = str;
  482. this.lblW2.Tag = szWLLX;
  483. }
  484. if (hopperNo == "3")
  485. {
  486. this.lblW3.Text = str;
  487. this.lblW3.Tag = szWLLX;
  488. }
  489. if (hopperNo == "4")
  490. {
  491. this.lblW4.Text = str;
  492. this.lblW4.Tag = szWLLX;
  493. }
  494. if (hopperNo == "5")
  495. {
  496. this.lblW5.Text = str;
  497. this.lblW5.Tag = szWLLX;
  498. }
  499. if (hopperNo == "6")
  500. {
  501. this.lblW6.Text = str;
  502. this.lblW6.Tag = szWLLX;
  503. }
  504. if (hopperNo == "7")
  505. {
  506. this.lblW7.Text = str;
  507. this.lblW7.Tag = szWLLX;
  508. }
  509. if (hopperNo == "8")
  510. {
  511. this.lblW8.Text = str;
  512. this.lblW8.Tag = szWLLX;
  513. }
  514. }
  515. }
  516. private void GetDataForHopper()
  517. {
  518. string SqlID = "";
  519. ArrayList Args = new ArrayList();
  520. SqlID = "StlMaterialConfig.Select";
  521. Args.Add(devicePos);
  522. Args.Add(_curMaterType);
  523. bool bSuccess = false;
  524. string strMsg = "";
  525. DataSet ds = ClsDataAccessPack.GetData(SqlID, Args, out bSuccess, out strMsg, ob);
  526. if (bSuccess && ds != null && ds.Tables.Count > 0)
  527. {
  528. _dtHopper = ds.Tables[0];
  529. DataRow[] drs = null;
  530. bool bFlag = false;
  531. for (int i = 0; i < _dtHopper.Rows.Count; i++)
  532. {
  533. try
  534. {
  535. DataRow dr = _dtHopper.Rows[i];
  536. string id = dr["MSNUMID"].ToString();
  537. drs = _dtHopper.Select(" MSNUMID = '" + id + "'"); //and MATERIELTYPE='" + _curMaterType + "'"
  538. if (drs.Length > 0)
  539. {
  540. for (int j = 0; j < drs.Length; j++)
  541. {
  542. if (drs[j]["MATERIELCODE"].ToString() != "")
  543. {
  544. SetPicText((_curMaterType == "WS"), drs[j]["MSNUMID"].ToString(), drs[j]["ITEM_NAME"].ToString(), drs[j]["MATERIELTYPE"].ToString());
  545. bFlag = true;
  546. break;
  547. }
  548. }
  549. }
  550. if (false == bFlag)
  551. SetPicText((_curMaterType == "WS"), dr["MSNUMID"].ToString(), dr["ITEM_NAME"].ToString(), dr["MATERIELTYPE"].ToString());
  552. if (bFlag)
  553. bFlag = false;
  554. }
  555. catch { }
  556. }
  557. }
  558. }
  559. //显示料斗配置信息
  560. private void radioButton_Click(object sender, System.EventArgs e)
  561. {
  562. try
  563. {
  564. this.btAdd.Enabled = true;
  565. if (_curMaterType != ((RadioButton)sender).Tag.ToString())
  566. _curMaterType = ((RadioButton)sender).Tag.ToString();
  567. else
  568. return;
  569. if (_curMaterType != "WS")
  570. {
  571. panel2.Enabled = true;
  572. panel3.Enabled = false;
  573. }
  574. else // 物料类型为喂丝
  575. {
  576. panel2.Enabled = false;
  577. panel3.Enabled = true;
  578. }
  579. ClearLableText();
  580. SetPicNoSelectState();
  581. GetDataForHopper();
  582. //costBaseMetalTypeEntityBindingSource.DataSource =
  583. // CostBaseMetalTypeEntityList.Where(p => p.ArcCode == _curMaterType).ToList();
  584. ulgridMtrInfo.DataBind();
  585. //if (chkdevNo.Checked)
  586. //{
  587. // this.m_dtStationconMaterial.DefaultView.RowFilter = "MATERIELTYPE='" + _curMaterType + "'";
  588. // ulgridMtrInfo.DataSource = this.m_dtStationconMaterial;
  589. //}
  590. //else
  591. //{
  592. // this.m_dtMain.DefaultView.RowFilter = "MATERIELTYPE='" + _curMaterType + "'";
  593. // ulgridMtrInfo.DataSource = this.m_dtMain;
  594. //}
  595. this.ulgridMtrInfo.UpdateData();
  596. }
  597. catch { }
  598. finally
  599. {
  600. ClsControlPack.RefreshAndAutoSize(ulgridMtrInfo);
  601. }
  602. }
  603. private void chkdevNo_CheckedChanged(object sender, EventArgs e)
  604. {
  605. try
  606. {
  607. //if (chkdevNo.Checked)
  608. //{
  609. // this.m_dtStationconMaterial.DefaultView.RowFilter = "MATERIELTYPE='" + _curMaterType + "'";
  610. // ulgridMtrInfo.DataSource = this.m_dtStationconMaterial;
  611. //}
  612. //else
  613. //{
  614. // this.m_dtMain.DefaultView.RowFilter = "MATERIELTYPE='" + _curMaterType + "'";
  615. // ulgridMtrInfo.DataSource = this.m_dtMain;
  616. //}
  617. //this.ulgridMtrInfo.UpdateData();
  618. }
  619. catch { }
  620. finally
  621. {
  622. ClsControlPack.RefreshAndAutoSize(ulgridMtrInfo);
  623. }
  624. }
  625. }
  626. }