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 System.Collections;
namespace Core.LgMes.Client.LgJobMgt
{
public partial class frmSendSteelPot : Form
{
public DataSet dsGBInfo = new DataSet();
public int intAge = 0; //包龄
public frmSendSteelPot(string szLH1, string szLH2, string szLH3)
{
InitializeComponent();
this.m_szLH1 = szLH1;
this.m_szLH2 = szLH2;
this.m_szLH3 = szLH3;
}
#region " Variable"
private string _szDev = "BOF01"; // 转炉号
private string m_szLH1 = "", m_szLH2 = "", m_szLH3 = "";
#endregion
private void frmSendSteelPot_Load(object sender, EventArgs e)
{
GetGBBHXX(); //获取钢包信息
InitControlVisible();
JudgeSmeltInfo();
ZL1.CheckedChanged += new EventHandler(ZL_CheckedChanged);
ZL2.CheckedChanged += new EventHandler(ZL_CheckedChanged);
ZL3.CheckedChanged += new EventHandler(ZL_CheckedChanged);
}
private void InitControlVisible()
{
txtLH1.Text = this.m_szLH1;
txtLH2.Text = this.m_szLH2;
txtLH3.Text = this.m_szLH3;
if (m_szLH3 != "")
{
this.ZL1.Checked = false;
this.ZL2.Checked = false;
this.ZL3.Checked = true;
}
if (m_szLH2 != "")
{
this.ZL1.Checked = false;
this.ZL2.Checked = true;
this.ZL3.Checked = false;
}
if (m_szLH1 != "")
{
this.ZL1.Checked = true;
this.ZL2.Checked = false;
this.ZL3.Checked = false;
}
txtLH1.Enabled = ZL1.Checked;
txtLH2.Enabled = ZL2.Checked;
txtLH3.Enabled = ZL3.Checked;
}
private void JudgeSmeltInfo()
{
string szLH = "";
if (this.m_szLH1 != "")
{
szLH = this.m_szLH1;
}
else if (this.m_szLH2 != "")
{
szLH = this.m_szLH2;
}
else if (this.m_szLH3 != "")
{
szLH = this.m_szLH3;
}
if (szLH != "")
{
string strOut = "", strWhere = " where SendOvenID = '" + szLH + "'";
object obj = null;// RemotingHelp.ExecuteMethod("lgJobMgt", "Core.LgMes.Server.lgJobMgt.classCommonModule", "GetPotInfo", new object[] { strWhere }, out strOut);
if (strOut == "" && obj != null)
{
DataTable tb = ((DataSet)obj).Tables[0];
if (tb.Rows.Count > 0)
{
this.txtGH.Text = tb.Rows[0]["SENDTOOLID"].ToString();
this.cbGJ.Text = tb.Rows[0]["SENDGRADE"].ToString();
this.cbGY.Text = tb.Rows[0]["INSTANCE"].ToString();
}
else
{
this.txtGH.SelectedIndex = -1;
this.cbGJ.SelectedIndex = -1;
this.cbGY.SelectedIndex = -1;
}
}
}
}
///
/// 检测数据的有效性
///
///
private bool CheckIsValid()
{
if (ZL1.Checked == false && ZL2.Checked == false && ZL3.Checked == false)
{
MessageBox.Show("炉号未加载,钢包暂时不能确认!");
return false;
}
if ( (ZL1.Checked && txtLH1.Text.Trim() == "")
|| (ZL2.Checked && txtLH2.Text.Trim() == "")
|| (ZL3.Checked && txtLH3.Text.Trim() == "") )
{
MessageBox.Show("炉号未加载,钢包暂时不能确认!");
return false;
}
if (this.txtGH.Text.Trim() == "")
{
MessageBox.Show("请输入罐号!");
return false;
}
return true;
}
private void ZL_CheckedChanged(object sender, EventArgs e)
{
txtLH1.Enabled = ZL1.Checked;
txtLH2.Enabled = ZL2.Checked;
txtLH3.Enabled = ZL3.Checked;
if (this.ZL1.Checked)
this.SetPotInfo(this.txtLH1.Text);
else if (this.ZL2.Checked)
this.SetPotInfo(this.txtLH2.Text);
else if (this.ZL3.Checked)
this.SetPotInfo(this.txtLH3.Text);
}
private void SetPotInfo(string szLH)
{
if (szLH != "")
{
string strOut = "", strWhere = " where SENDOVENID = '" + szLH + "'";
//hengxing
//CallingMessage par = new CallingMessage();
//par.ServerName = "lgJobMgt";
//par.AssemblyName = "Core.LgMes.Server.lgJobMgt";
//par.ClassName = "Core.LgMes.Server.lgJobMgt.classCommonModule";
//par.MethodName = "GetPotInfo";
//par.args = new object[] { strWhere };
object obj = null;// RemotingHelp.ExecuteMethod(par, out strOut);
if (strOut == "" && obj != null)
{
DataTable tb = ((DataSet)obj).Tables[0];
if (tb.Rows.Count > 0)
{
this.txtGH.Text = tb.Rows[0]["SENDTOOLID"].ToString();
this.cbGJ.Text = tb.Rows[0]["SENDGRADE"].ToString();
this.cbGY.Text = tb.Rows[0]["INSTANCE"].ToString();
}
else
{
this.txtGH.SelectedIndex = -1;
this.cbGJ.SelectedIndex =-1;
this.cbGY.SelectedIndex = -1;
}
}
}
else if (szLH == "")
{
this.txtGH.Text = "";
this.cbGJ.SelectedIndex = 2;
this.cbGY.SelectedIndex = 2;
}
}
///
/// 获取转炉信息
///
private void GetCVTData()
{
if (this.ZL1.Checked)
{
this.m_szLH1 = this.txtLH1.Text.Trim();
_szDev = "BOF01";
}
else if (this.ZL2.Checked)
{
this.m_szLH2 = this.txtLH2.Text.Trim();
_szDev = "BOF02";
}
else if (this.ZL3.Checked)
{
this.m_szLH3 = this.txtLH3.Text.Trim();
_szDev = "BOF03";
}
}
private void btnOk_Click(object sender, EventArgs e)
{
GetCVTData();
if (!CheckIsValid())
return;
string strMsg = string.Format("是否确认将罐号{0}发送至{1}#转炉", this.txtGH.Text.Trim(), _szDev);
DialogResult Rel = MessageBox.Show(strMsg, "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
if (Rel == DialogResult.No) return;
ArrayList ar = new ArrayList();
string szLH = "";
ar.Add(this.txtGH.Text.Trim());
ar.Add(this.cbGJ.Text);
ar.Add(this.cbGY.Text);
if (ZL3.Checked)
szLH = this.m_szLH3;
if (ZL2.Checked)
szLH = this.m_szLH2;
if (ZL1.Checked)
szLH = this.m_szLH1;
ar.Add(szLH);
ar.Add(this._szDev);
ar.Add(Convert.ToString(intAge));
try
{
string strOut = "";
//hengxing
//CallingMessage par = new CallingMessage();
//par.ServerName = "lgJobMgt";
//par.AssemblyName = "Core.LgMes.Server.lgJobMgt";
//par.ClassName = "Core.LgMes.Server.lgJobMgt.classCommonModule";
//par.MethodName = "SendPotInfo";
//par.args = new object[] { ar };
//RemotingHelp.ExecuteMethod(par, out strOut);
if (strOut == "")
MessageBox.Show("钢包信息发送成功!");
}
catch (Exception ex)
{
string Msg = ex.Message;
}
this.Close();
}
private void btnNo_Click(object sender, EventArgs e)
{
this.Close();
}
///
/// 获取当前可以使用的钢包
///
private void GetGBBHXX()
{
try
{
string strError = "";
dsGBInfo = null;// (DataSet)RemotingHelp.ExecuteMethod("LgDeviceManager", "Core.LgMes.Server.LadleManager.LadleManager", "GetEnsureGBBH", new object[] { }, out strError);
if (strError == "")
{
this.txtGH.DataSource = dsGBInfo.Tables[0];
this.txtGH.DisplayMember = "LadleID";
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void txtGH_SelectedIndexChanged(object sender, EventArgs e)
{
if (dsGBInfo != null && dsGBInfo.Tables[0].Rows.Count > 0)
{
foreach (DataRow dr in dsGBInfo.Tables[0].Rows)
{
if (dr["ladleid"].ToString().Trim() == txtGH.Text.Trim().ToString())
{
if(!string.IsNullOrEmpty(dr["lvl"].ToString()))
cbGJ.SelectedIndex =Convert.ToInt32(dr["lvl"])-1;
cbGY.Text = dr["instance"].ToString();
if (!string.IsNullOrEmpty(dr["Age"].ToString()))
intAge = Convert.ToInt32(dr["Age"]);
}
}
}
}
}
}