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)) < 21)
{
lbName = "label" + _curPicBx.Tag.ToString();
foreach (Control c in this.panel2.Controls)
{
if (c.Name == lbName)
{
((Label)c).ForeColor = Color.Red;
return;
}
}
}
else
{
lbName = "label2" + _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;
}
}
///
/// 取岗位物料数据
///
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.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)) < 21)
{
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 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.lblG20.Text = str;
this.lblG20.Tag = szWLLX;
break;
case "22":
this.lblG20.Text = str;
this.lblG20.Tag = szWLLX;
break;
case "23":
this.lblG20.Text = str;
this.lblG20.Tag = szWLLX;
break;
case "24":
this.lblG20.Text = str;
this.lblG20.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
{
}
}
}
}