using System; using System.Collections; using System.Collections.Generic; using System.Data; using System.Drawing; using System.Linq; using System.Windows.Forms; using Core.Mes.Client.Comm; using Core.Mes.Client.Comm.Server; using Core.Mes.Client.Comm.Tool; using Core.StlMes.Client.LgClassModel; using CoreFS.CA06; using Infragistics.Win; namespace Core.StlMes.Client.LgCommon { public partial class frmSetHopper : frmStyleBase { private OpeBase ob = null; public frmSetHopper(string szDeviceName, OpeBase ob) { InitializeComponent(); this.ob = ob; this.devicePos = szDeviceName; ClsControlPack.SetUltraGridAppearance(this); ulgridMtrInfo.DisplayLayout.Override.RowSelectors = DefaultableBoolean.False; } #region " Member Variable" private List CostBaseMetalTypeEntityList; private DataTable m_dtMain = null; //private DataTable m_dtStationconMaterial = null; private DataTable _dtHopper; 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)) < 31) { lbName = "label" + _curPicBx.Tag.ToString(); foreach (Control c in this.panel2.Controls) { if (c.Name == lbName) { ((Label) c).ForeColor = Color.Red; return; } } } else { lbName = "label" + _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.Visible = false; this.rbFZL.Text = "辅助料"; this.rbHJ.Text = "合金"; this.ultraGroupBox1.Dock = DockStyle.Fill; break; case "EAF": // 转炉 this.ultraGroupBox2.Visible = false; this.rbWS.Visible = false; this.rbFZL.Text = "辅助料"; this.rbHJ.Text = "合金"; this.rbHJ.Visible = false; this.ultraGroupBox1.Dock = DockStyle.Fill; break; case "CAS": // 钢包站 this.rbFZL.Visible = true; this.rbHJ.Text = "合金微调"; break; case "LF0": // 精炼炉 this.rbFZL.Visible = true; this.rbHJ.Text = "合金微调"; break; case "RH0": // RH炉 case "VD0": // RH炉 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; } this.comboBox1.SelectedIndex = 6; this.ClearLableText(); GetDataSource(); //GetStationconMaterialData(this.devicePos.Substring(0, 3)); // BindingGrid(m_dtMain); if (rbFZL.Visible) { rbFZL.Checked = true; radioButton_Click(rbFZL, null); } else if (rbHJ.Visible) { rbHJ.Checked = true; radioButton_Click(rbHJ, null); } else if (rbWS.Visible) { rbWS.Checked = true; radioButton_Click(rbWS, null); } //chkdevNo.Checked = true; } #region " InitDataSoutce" private void GetDataSource() { ClsControlPack.SetReadOnly(ulgridMtrInfo); EntityHelper.ShowGridCaption(ulgridMtrInfo.DisplayLayout.Bands[0]); string strMsg = ""; bool bSuccess = false; CostBaseMetalTypeEntityList = EntityHelper.GetData( "Core.LgMes.Server.LgDeviceManager.StlAdditive.GetMaterialData", null, ob); costBaseMetalTypeEntityBindingSource.DataSource = CostBaseMetalTypeEntityList; ClsControlPack.RefreshAndAutoSize(ulgridMtrInfo); //DataSet ds = ClsDataAccessPack.GetMaterialData(out bSuccess, out strMsg, ob); //if (bSuccess && ds != null && ds.Tables.Count > 0) //{ // this.m_dtMain = ds.Tables[0]; //} } #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.lblG23.Text = ""; this.lblG24.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)) < 31) { 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(); } /// /// 添料 /// /// /// private void btAdd_Click(object sender, EventArgs e) { 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(); var CostBaseMetalTypeEntity = urg.ListObject as CostBaseMetalTypeEntity; if (CostBaseMetalTypeEntity==null ) return; string MATERIELTYPE = ""; //switch (CostBaseMetalTypeEntity.ArcCode) //{ // case "HJ": // MATERIELTYPE = "HJ"; // break; // case "FL": // MATERIELTYPE = "FL"; // break; //} try { ServerHelper.SetData("Core.LgMes.Server.LgDeviceManager.StlAdditive.InsertStlMaterialConfig", new object[] { new object[] { _curPicBx.Tag.ToString(), this.devicePos, rbFZL.Checked?rbFZL.Tag.ToString():rbHJ.Checked?rbHJ.Tag.ToString():rbWS.Tag.ToString(), CostBaseMetalTypeEntity.ItemCode, comboBox1.SelectedItem.ToString(), "1" } }, ob); this._curLbl.Text = CostBaseMetalTypeEntity.ItemName; _curLbl.Tag = CostBaseMetalTypeEntity.ArcCode; } catch (Exception ex) { if (ex is MESException) { } else MessageBox.Show("添料失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } } private void btReset_Click(object sender, EventArgs e) { 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; try { ServerHelper.SetData("Core.LgMes.Server.LgDeviceManager.StlAdditive.DeleteStlMaterialConfig", new object[] { new object[] { _curPicBx.Tag.ToString(), this.devicePos, rbFZL.Checked?rbFZL.Tag.ToString():rbHJ.Checked?rbHJ.Tag.ToString():rbWS.Tag.ToString() } }, ob); this._curLbl.Text = ""; _curLbl.Tag = ""; } catch (Exception ex) { if (ex is MESException) { } else MessageBox.Show("重置失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } 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; case "23": this.lblG23.Text = str; this.lblG23.Tag = szWLLX; break; case "24": this.lblG24.Text = str; this.lblG24.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 SqlID = ""; ArrayList Args = new ArrayList(); SqlID = "StlMaterialConfig.Select"; Args.Add(devicePos); Args.Add(_curMaterType); bool bSuccess = false; string strMsg = ""; DataSet ds = ClsDataAccessPack.GetData(SqlID, Args, out bSuccess, out strMsg, ob); if (bSuccess && ds != null && ds.Tables.Count > 0) { _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]["ITEM_NAME"].ToString(), drs[j]["MATERIELTYPE"].ToString()); bFlag = true; break; } } } if (false == bFlag) SetPicText((_curMaterType == "WS"), dr["MSNUMID"].ToString(), dr["ITEM_NAME"].ToString(), dr["MATERIELTYPE"].ToString()); if (bFlag) bFlag = false; } catch { } } } } //显示料斗配置信息 private void radioButton_Click(object sender, System.EventArgs e) { try { this.btAdd.Enabled = true; if (_curMaterType != ((RadioButton)sender).Tag.ToString()) _curMaterType = ((RadioButton)sender).Tag.ToString(); else return; if (_curMaterType != "WS") { panel2.Enabled = true; panel3.Enabled = false; } else // 物料类型为喂丝 { panel2.Enabled = false; panel3.Enabled = true; } ClearLableText(); SetPicNoSelectState(); GetDataForHopper(); //costBaseMetalTypeEntityBindingSource.DataSource = // CostBaseMetalTypeEntityList.Where(p => p.ArcCode == _curMaterType).ToList(); ulgridMtrInfo.DataBind(); //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 { } finally { ClsControlPack.RefreshAndAutoSize(ulgridMtrInfo); } } 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 { } finally { ClsControlPack.RefreshAndAutoSize(ulgridMtrInfo); } } } }