| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Text;
- using System.Windows.Forms;
- using CoreFS.CA06;
- using Core.LgMes.Client.lgClassModel;
- using Core.Mes.Client.Common;
- using System.Collections;
- namespace Core.LgMes.Client.LgJobMgt
- {
- public partial class frmSetHopper : frmStyleBase
- {
- public OpeBase ob=null;
- public frmSetHopper(string szDeviceName)
- {
- InitializeComponent();
- this.devicePos = szDeviceName;
- }
- #region " Member Variable"
- // private string m_szDeviceName = "";
- private DataTable m_dtMain = null;
- private DataTable m_dtStationconMaterial = null;
- private DataTable _dtHopper;
- private string sCraftPos = ""; //LG02
- private string devicePos = ""; //CVT01
- private string _curMaterType = ""; //FL
- private PictureBox _curPicBx = null;
- private Label _curLbl = null;
- #endregion
- //选择料斗
- private void PicClickHandler(object sender, System.EventArgs e)
- {
- SetPicNoSelectState();
- _curPicBx = (PictureBox)sender;
- _curPicBx.BorderStyle = BorderStyle.Fixed3D;
- SetLabelColor();
- }
- private void SetPicNoSelectState()
- {
- _curPicBx = null;
- _curLbl = null;
- foreach (Control ctl in panel2.Controls)
- {
- if (ctl is PictureBox)
- ((PictureBox)ctl).BorderStyle = BorderStyle.None;
- }
- foreach (Control ctl in panel2.Controls)
- {
- if (ctl is Label)
- ((Label)ctl).ForeColor = Color.Black;
- }
- foreach (Control ctl in panel3.Controls)
- {
- if (ctl is PictureBox)
- ((PictureBox)ctl).BorderStyle = BorderStyle.None;
- }
- foreach (Control ctl in panel3.Controls)
- {
- if (ctl is Label)
- ((Label)ctl).ForeColor = Color.Black;
- }
- }
- private void SetLabelColor()
- {
- try
- {
- if (_curPicBx == null)
- {
- return;
- }
- string lbName;
- if (Convert.ToInt32(_curPicBx.Name.Substring(10, _curPicBx.Name.Length - 10)) < 23)
- {
- lbName = "label" + _curPicBx.Tag.ToString();
- foreach (Control c in this.panel2.Controls)
- {
- if (c.Name == lbName)
- {
- ((Label)c).ForeColor = Color.Red;
- return;
- }
- }
- }
- else
- {
- lbName = "label3" + _curPicBx.Tag.ToString();
- foreach (Control c in this.panel3.Controls)
- {
- if (c.Name == lbName)
- {
- ((Label)c).ForeColor = Color.Red;
- return;
- }
- }
- }
- }
- catch
- {
- }
- }
- private void frmSetHopper_Load(object sender, EventArgs e)
- {
- switch (this.devicePos.Substring(0, 3))
- {
- case "BOF": // 转炉
- this.ultraGroupBox2.Visible = false;
- //this.rbWS.Enabled = false; // 喂丝料按钮
- this.rbWS.Visible = false;
- this.rbFZL.Text = "辅助料";
- this.rbHJ.Text = "合金";
- this.ultraGroupBox1.Dock = DockStyle.Fill;
- break;
- case "CAS": // 钢包站
- // this.rbFZL.Enabled = false;
- this.rbFZL.Visible = true;
- this.rbHJ.Text = "合金微调";
- break;
- case "LFS": // 精炼炉
- // this.rbFZL.Enabled = false;
- this.rbFZL.Visible = true;
- this.rbHJ.Text = "合金微调";
- break;
- case "RHS": // RH炉
- // this.rbFZL.Enabled = false;
- this.rbFZL.Visible = true;
- this.rbHJ.Text = "合金微调";
- break;
- case "THJ": // 转炉合金
- this.ultraGroupBox2.Visible = false;
- this.rbWS.Visible = false; // 喂丝料按钮
- this.rbFZL.Enabled = false; // 辅助料
- this.ultraGroupBox1.Dock = DockStyle.Fill;
- break;
- default:
- break;
- }
- //btAdd.Enabled = false;
- this.comboBox1.SelectedIndex = 6;
- this.ClearLableText();
- GetDataSource();
- GetStationconMaterialData(this.devicePos.Substring(0, 3));
- BindingGrid(this.m_dtStationconMaterial);
- }
- #region " InitDataSoutce"
- private void GetDataSource()
- {
- string strErr = "";
- string strSqlID = "";
- try
- {
- strSqlID = "GetMaterialData.Select";//此ID为XML文件ID
-
- CommonClientToServer cctos=new CommonClientToServer();
- cctos.ob = ob;
- //查询物料配置信息
- DataSet ds = cctos.ExecuteQueryFunctions("Core.LgMes.Server.LgJobMgt.ClassCommonModule",
- "GetMaterialData", strSqlID, out strErr);
-
- if (strErr == "" && ds != null)
- {
- this.m_dtMain = ds.Tables[0];
- }
- }
- catch (Exception ex)
- {
- string Msg = ex.Message;
- }
- }
- /// <summary>
- /// 取岗位物料数据
- /// </summary>
- private void GetStationconMaterialData(string strStrcraftposId)
- {
- string strErr = "";
- string strSqlID = "";
- try
- {
- ArrayList arry = new ArrayList();
- arry.Add("GetStationconMaterialData.Select");//此ID为XML文件ID
- arry.Add(strStrcraftposId);
- CommonClientToServer cctos = new CommonClientToServer();
- cctos.ob = ob;
- //查询物料配置信息
- DataSet ds = cctos.ExecuteQueryFunctions("Core.LgMes.Server.LgJobMgt.ClassCommonModule",
- "GetStationconMaterialData", arry, out strErr);
-
- if (strErr == "" && ds != null)
- {
- this.m_dtStationconMaterial = ds.Tables[0];
- }
- }
- catch (Exception ex)
- {
- string Msg = ex.Message;
- }
- }
- private void BindingGrid(DataTable dt)
- {
-
- //this.ulgridMtrInfo.DataSource = dt;
- this.ulgridMtrInfo.DisplayLayout.Bands[0].Columns["MATERIELCODE"].Width = 60;
- this.ulgridMtrInfo.DisplayLayout.Bands[0].Columns["MATERIELCODE"].Header.Caption = "物料编码";
- this.ulgridMtrInfo.DisplayLayout.Bands[0].Columns["MATERIELCODE"].CellActivation = Infragistics.Win.UltraWinGrid.Activation.NoEdit;
- this.ulgridMtrInfo.DisplayLayout.Bands[0].Columns["MATERIELCODE"].SortIndicator = Infragistics.Win.UltraWinGrid.SortIndicator.Ascending;
- this.ulgridMtrInfo.DisplayLayout.Bands[0].Columns["MATERIELNAME"].Width = 140;
- this.ulgridMtrInfo.DisplayLayout.Bands[0].Columns["MATERIELNAME"].Header.Caption = "物料全称";
- this.ulgridMtrInfo.DisplayLayout.Bands[0].Columns["MATERIELNAME"].CellActivation = Infragistics.Win.UltraWinGrid.Activation.NoEdit;
- this.ulgridMtrInfo.DisplayLayout.Bands[0].Columns["MATERIELFORSHORT"].Width = 100;
- this.ulgridMtrInfo.DisplayLayout.Bands[0].Columns["MATERIELFORSHORT"].Header.Caption = "物料简称";
- this.ulgridMtrInfo.DisplayLayout.Bands[0].Columns["MATERIELFORSHORT"].CellActivation = Infragistics.Win.UltraWinGrid.Activation.NoEdit;
- this.ulgridMtrInfo.DisplayLayout.Bands[0].Columns["WLLXM"].Width = 65;
- this.ulgridMtrInfo.DisplayLayout.Bands[0].Columns["WLLXM"].Header.Caption = "物料类型";
- this.ulgridMtrInfo.DisplayLayout.Bands[0].Columns["WLLXM"].CellActivation = Infragistics.Win.UltraWinGrid.Activation.NoEdit;
- this.ulgridMtrInfo.DisplayLayout.Bands[0].Columns["MATERIELTYPE"].Width = 0;
- this.ulgridMtrInfo.DisplayLayout.Bands[0].Columns["MATERIELTYPE"].Header.Caption = "";
- this.ulgridMtrInfo.DisplayLayout.Bands[0].Columns["MATERIELTYPE"].CellActivation = Infragistics.Win.UltraWinGrid.Activation.NoEdit;
- this.ulgridMtrInfo.DisplayLayout.Bands[0].Columns["MATERIELTYPE"].Hidden = true;
-
- }
- #endregion
- private void ClearLableText()
- {
- this.lblG1.Text = "";
- this.lblG2.Text = "";
- this.lblG3.Text = "";
- this.lblG4.Text = "";
- this.lblG5.Text = "";
- this.lblG6.Text = "";
- this.lblG7.Text = "";
- this.lblG8.Text = "";
- this.lblG9.Text = "";
- this.lblG10.Text = "";
- this.lblG11.Text = "";
- this.lblG12.Text = "";
- this.lblG13.Text = "";
- this.lblG14.Text = "";
- this.lblG15.Text = "";
- this.lblG16.Text = "";
- this.lblG17.Text = "";
- this.lblG18.Text = "";
- this.lblG19.Text = "";
- this.lblG20.Text = "";
- this.lblG21.Text = "";
- this.lblG22.Text = "";
- this.lblW1.Text = "";
- this.lblW2.Text = "";
- this.lblW3.Text = "";
- this.lblW4.Text = "";
- this.lblW5.Text = "";
- this.lblW6.Text = "";
- this.lblW7.Text = "";
- this.lblW8.Text = "";
- }
- private void GetCurrLabel()
- {
- try
- {
- if (_curPicBx == null)
- {
- this._curLbl = null;
- return;
- }
- string lbName;
- if (Convert.ToInt32(_curPicBx.Name.Substring(10, _curPicBx.Name.Length - 10)) < 23)
- {
- lbName = "lblG" + _curPicBx.Tag.ToString();
- foreach (Control c in this.panel2.Controls)
- {
- if (c.Name == lbName)
- {
- this._curLbl = (Label)c;
- return;
- }
- }
- }
- else
- {
- lbName = "lblW" + _curPicBx.Tag.ToString();
- foreach (Control c in this.panel3.Controls)
- {
- if (c.Name == lbName)
- {
- this._curLbl = (Label)c;
- return;
- }
- }
- }
- }
- catch
- {
- this._curLbl = null;
- }
- }
- private void btClose_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- /// <summary>
- /// 添料
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btAdd_Click(object sender, EventArgs e)
- {
- string strErr = "";
- string szWLLX = "";
- Infragistics.Win.UltraWinGrid.UltraGridRow urg = this.ulgridMtrInfo.ActiveRow;
- if (urg == null)
- {
- MessageBox.Show("请选择物料!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- if (_curPicBx == null)
- {
- MessageBox.Show("请选择料斗!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- GetCurrLabel();
- if (_curLbl.Tag != null)
- szWLLX = _curLbl.Tag.ToString();
- string materialName = Convert.ToString(urg.Cells["MATERIELNAME"].Value);
- string strSqlID = "SwapHopper.Procedure";
- Hashtable hashtb = new Hashtable();
- hashtb.Add("I1", _curPicBx.Tag.ToString()); //料仓编号
- hashtb.Add("I2", this.devicePos); //料仓置位
- hashtb.Add("I3", urg.Cells["MATERIELTYPE"].Value.ToString()); //物料类型
- hashtb.Add("I4", Convert.ToString(urg.Cells["MATERIELCODE"].Value)); //物料编码
- hashtb.Add("I5", comboBox1.SelectedItem.ToString()); //物料单位
- hashtb.Add("I6", "1"); // 1 为料仓自动投料 2 为手投料
- hashtb.Add("I7", "0"); //清空标志 1 为清空 0 为添料
- hashtb.Add("I8", szWLLX); //物料类型
- CommonClientToServer cctos = new CommonClientToServer();
- cctos.ob = ob;
- string strCode= cctos.ExecuteProcedureFunctions("Core.LgMes.Server.LgJobMgt.ClassCommonModule",
- "SwapHopper", strSqlID, hashtb, out strErr);
- if (strErr.Trim().Length > 0)
- {
- MessageBox.Show("添料失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
- return;
- }
- else
- {
- this._curLbl.Text = materialName;
- _curLbl.Tag = urg.Cells["MATERIELTYPE"].Value.ToString();
- }
- }
- private void btReset_Click(object sender, EventArgs e)
- {
- string strErr = "";
- if (this._curPicBx == null)
- {
- MessageBox.Show("请选择料斗!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- GetCurrLabel();
- if (this._curLbl.Text.Equals(string.Empty))
- return;
- DialogResult dia = MessageBox.Show("是否确认重置当前选中的料斗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
- if (dia == DialogResult.No) return;
-
- string szWLLX = _curLbl.Tag.ToString();
- string strSqlID = "SwapHopper.Procedure";
- Hashtable hashtb = new Hashtable();
- hashtb.Add("I1", _curPicBx.Tag.ToString()); //料仓编号
- hashtb.Add("I2", this.devicePos); //料仓置位
- hashtb.Add("I3", _curLbl.Tag.ToString()); //物料类型
- hashtb.Add("I4", ""); //物料编码
- hashtb.Add("I5", ""); //物料单位
- hashtb.Add("I6", "1"); // 1 为料仓自动投料 2 为手投料
- hashtb.Add("I7", "1"); //清空标志 1 为清空 0 为添料
- hashtb.Add("I8", szWLLX); //物料类型
- CommonClientToServer cctos = new CommonClientToServer();
- cctos.ob = ob;
- string strCode = cctos.ExecuteProcedureFunctions("Core.LgMes.Server.LgJobMgt.ClassCommonModule",
- "SwapHopper", strSqlID, hashtb, out strErr);
-
- if (strErr.Trim().Length > 0)
- {
- MessageBox.Show("重置失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
- return;
- }
- this._curLbl.Text = "";
- }
- private void SetPicText(bool IsJS, string hopperNo, string str, string szWLLX)
- {
- if (!IsJS)
- {
- switch (hopperNo)
- {
- case "1":
- this.lblG1.Text = str;
- this.lblG1.Tag = szWLLX;
- break;
- case "2":
- this.lblG2.Text = str;
- this.lblG2.Tag = szWLLX;
- break;
- case "3":
- this.lblG3.Text = str;
- this.lblG3.Tag = szWLLX;
- break;
- case "4":
- this.lblG4.Text = str;
- this.lblG4.Tag = szWLLX;
- break;
- case "5":
- this.lblG5.Text = str;
- this.lblG5.Tag = szWLLX;
- break;
- case "6":
- this.lblG6.Text = str;
- this.lblG6.Tag = szWLLX;
- break;
- case "7":
- this.lblG7.Text = str;
- this.lblG7.Tag = szWLLX;
- break;
- case "8":
- this.lblG8.Text = str;
- this.lblG8.Tag = szWLLX;
- break;
- case "9":
- this.lblG9.Text = str;
- this.lblG9.Tag = szWLLX;
- break;
- case "10":
- this.lblG10.Text = str;
- this.lblG10.Tag = szWLLX;
- break;
- case "11":
- this.lblG11.Text = str;
- this.lblG11.Tag = szWLLX;
- break;
- case "12":
- this.lblG12.Text = str;
- this.lblG12.Tag = szWLLX;
- break;
- case "13":
- this.lblG13.Text = str;
- this.lblG13.Tag = szWLLX;
- break;
- case "14":
- this.lblG14.Text = str;
- this.lblG14.Tag = szWLLX;
- break;
- case "15":
- this.lblG15.Text = str;
- this.lblG15.Tag = szWLLX;
- break;
- case "16":
- this.lblG16.Text = str;
- this.lblG16.Tag = szWLLX;
- break;
- case "17":
- this.lblG17.Text = str;
- this.lblG17.Tag = szWLLX;
- break;
- case "18":
- this.lblG18.Text = str;
- this.lblG18.Tag = szWLLX;
- break;
- case "19":
- this.lblG19.Text = str;
- this.lblG19.Tag = szWLLX;
- break;
- case "20":
- this.lblG20.Text = str;
- this.lblG20.Tag = szWLLX;
- break;
- case "21":
- this.lblG21.Text = str;
- this.lblG21.Tag = szWLLX;
- break;
- case "22":
- this.lblG22.Text = str;
- this.lblG22.Tag = szWLLX;
- break;
- default:
- break;
- }
- }
- else
- {
- if (hopperNo == "1")
- {
- this.lblW1.Text = str;
- this.lblW1.Tag = szWLLX;
- }
- if (hopperNo == "2")
- {
- this.lblW2.Text = str;
- this.lblW2.Tag = szWLLX;
- }
- if (hopperNo == "3")
- {
- this.lblW3.Text = str;
- this.lblW3.Tag = szWLLX;
- }
- if (hopperNo == "4")
- {
- this.lblW4.Text = str;
- this.lblW4.Tag = szWLLX;
- }
- if (hopperNo == "5")
- {
- this.lblW5.Text = str;
- this.lblW5.Tag = szWLLX;
- }
- if (hopperNo == "6")
- {
- this.lblW6.Text = str;
- this.lblW6.Tag = szWLLX;
- }
- if (hopperNo == "7")
- {
- this.lblW7.Text = str;
- this.lblW7.Tag = szWLLX;
- }
- if (hopperNo == "8")
- {
- this.lblW8.Text = str;
- this.lblW8.Tag = szWLLX;
- }
- }
- }
- private void GetDataForHopper()
- {
- string strErr = "";
- string strSqlId = "";
- ArrayList arry = new ArrayList();
- //处理转炉与WS数据
- if ((devicePos.Substring(0, 3) != "CAS" && devicePos.Substring(0, 3) != "LFS" && devicePos.Substring(0, 3) != "RHS"
- && devicePos.Substring(0, 3) != "VDS") || _curMaterType == "WS")
- {
- strSqlId = "GetHopperNameBof.Select";
- arry.Add(strSqlId);//此ID为XML文件ID
- arry.Add(devicePos);
- arry.Add(_curMaterType);
- }
- else
- {
- strSqlId = "GetHopperNameSet.Select";
- arry.Add(strSqlId);//此ID为XML文件ID
- arry.Add(devicePos);
- }
-
- CommonClientToServer cctos = new CommonClientToServer();
- cctos.ob = ob;
- //查询料斗物料配置信息
- DataSet ds = cctos.ExecuteQueryFunctions("Core.LgMes.Server.LgJobMgt.ClassCommonModule",
- "GetHopperName", arry, out strErr);
- if (strErr=="" && ds != null )
- {
- _dtHopper = ds.Tables[0];
- DataRow[] drs = null;
- bool bFlag = false;
- for (int i = 0; i < _dtHopper.Rows.Count; i++)
- {
- try
- {
- DataRow dr = _dtHopper.Rows[i];
- string id = dr["MSNUMID"].ToString();
- drs = _dtHopper.Select(" MSNUMID = '" + id + "'"); //and MATERIELTYPE='" + _curMaterType + "'"
- if (drs.Length > 0)
- {
- for (int j = 0; j < drs.Length; j++)
- {
- if (drs[j]["MATERIELCODE"].ToString() != "")
- {
- SetPicText((_curMaterType == "WS"), drs[j]["MSNUMID"].ToString(), drs[j]["MATERIELFORSHORT"].ToString(), drs[j]["MATERIELTYPE"].ToString());
- bFlag = true;
- break;
- }
- }
- }
- if (false == bFlag)
- SetPicText((_curMaterType == "WS"), dr["MSNUMID"].ToString(), dr["MATERIELFORSHORT"].ToString(), dr["MATERIELTYPE"].ToString());
- if (bFlag)
- bFlag = false;
- }
- catch { }
- }
- }
- }
- //显示料斗配置信息
- private void radioButton_Click(object sender, System.EventArgs e)
- {
- this.btAdd.Enabled = true;
- if (_curMaterType != ((RadioButton)sender).Tag.ToString())
- _curMaterType = ((RadioButton)sender).Tag.ToString();
- else
- return;
- if (_curMaterType != "WS")
- {
- // this.ultraGroupBox4.Visible = false;
- // this.rbWS.Enabled=false; // 喂丝料按钮
- // this.ultraGroupBox3.Dock = DockStyle.Fill;
- panel2.Enabled = true;
- panel3.Enabled = false;
- }
- else // 物料类型为喂丝
- {
- // this.ultraGroupBox3.Visible = false;
- // this.rbWS.Enabled = true; // 喂丝料按钮
- // this.rbFZL.Enabled = false;
- // this.rbHJ.Enabled = false;
- // this.ultraGroupBox4.Dock = DockStyle.Fill;
- panel2.Enabled = false;
- panel3.Enabled = true;
- }
- ClearLableText();
- SetPicNoSelectState();
- GetDataForHopper();
- if (chkdevNo.Checked)
- {
- if (this.m_dtStationconMaterial.Rows.Count > 0)
- {
- this.m_dtStationconMaterial.DefaultView.RowFilter = "MATERIELTYPE='" + _curMaterType + "'";
- ulgridMtrInfo.DataSource = this.m_dtStationconMaterial;
- }
-
- }
- else
- {
- this.m_dtMain.DefaultView.RowFilter = "MATERIELTYPE='" + _curMaterType + "'";
- ulgridMtrInfo.DataSource = this.m_dtMain;
- }
-
- this.ulgridMtrInfo.UpdateData();
- }
- private void chkdevNo_CheckedChanged(object sender, EventArgs e)
- {
- try
- {
- if (chkdevNo.Checked)
- {
- this.m_dtStationconMaterial.DefaultView.RowFilter = "MATERIELTYPE='" + _curMaterType + "'";
- ulgridMtrInfo.DataSource = this.m_dtStationconMaterial;
- }
- else
- {
- this.m_dtMain.DefaultView.RowFilter = "MATERIELTYPE='" + _curMaterType + "'";
- ulgridMtrInfo.DataSource = this.m_dtMain;
- }
- this.ulgridMtrInfo.UpdateData();
- }
- catch
- {
- }
- }
- }
- }
|