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.Mes.Client.Common;
using System.Collections;
namespace Core.LgMes.Client.LgDeviceManager
{
public partial class FrmILRepair : Core.Mes.Client.Common.frmStyleBase//frmModelFormStyle
{
private bool bOK = false;
#region "================================Add on 2009-07-28=============================="
#endregion
private string strInitID = "";
public FrmILRepair(string strInitID, OpeBase oba)
{
InitializeComponent();
ob = oba;
this.strInitID = strInitID;
}
private void FrmILRepair_Load(object sender, EventArgs e)
{
GetPosition();
proc_GetID(strInitID);
bOK = true;
cbbID_SelectedIndexChanged(null, null);
}
private void cbbID_SelectedIndexChanged(object sender, EventArgs e)
{
if (!bOK)
return;
if (cbbID.Items.Count == 0 || cbbID.SelectedIndex < 0)
{
ResetControlsBase(true);
ResetControlsRepair();
btnStart.Enabled = btnEnd.Enabled = false;
return;
}
string strID = cbbID.Text.Trim();
ResetControlsBase(false);
ResetControlsRepair();
proc_GetBaseInfo(strID);
proc_GetRepairInfo(strID);
}
///
/// 加载基础信息
///
///
private void proc_GetBaseInfo(string strID)
{
try
{
string strErr = "";
ArrayList arry = new ArrayList();
arry.Add("FrmILRepair_Query2");
arry.Add(cbbID.Text.Trim());
CommonClientToServer ccs = new CommonClientToServer();
ccs.ob = this.ob;
DataSet ds = ccs.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery", "doSimpleQuery", arry, out strErr);
if (strErr == "" && ds != null && ds.Tables.Count > 0)
{
if (ds.Tables[0].Rows.Count > 0)
{
tbCurrStatus.Text = ds.Tables[0].Rows[0]["当前状态"].ToString(); //当前状态
tbAgeTS.Text = ds.Tables[0].Rows[0]["铁水包龄"].ToString(); //铁水包龄
tbAgeBG.Text = ds.Tables[0].Rows[0]["半钢包龄"].ToString(); //半钢包龄
}
else
{
btnStart.Enabled = btnEnd.Enabled = false;
}
}
else
{
MessageBox.Show("铁包状态信息查询出错!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
catch (Exception ex)
{
MessageBox.Show("铁包状态信息查询出错!\r\n" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
///
/// 加载维修信息
///
///
private void proc_GetRepairInfo(string strID)
{
try
{
string strErr = "";
ArrayList arry = new ArrayList();
arry.Add("FrmILRepair_Query3");
arry.Add(cbbID.Text.Trim());
CommonClientToServer ccs = new CommonClientToServer();
ccs.ob = this.ob;
DataSet ds = ccs.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery", "doSimpleQuery", arry, out strErr);
if (strErr == "" && ds != null && ds.Tables.Count > 0)
{
if (ds.Tables[0].Rows.Count > 0)
{
cbbLB.Text = Convert.ToString(ds.Tables[0].Rows[0]["维修类别"]);
cbbWZ.Text = Convert.ToString(ds.Tables[0].Rows[0]["维修位置"]);
dateTimePicker1.Value = Convert.ToDateTime(Convert.ToString(ds.Tables[0].Rows[0]["送修时间"]));
dateTimePicker2.Value=DateTime.Now;
tbReason.Text = Convert.ToString(ds.Tables[0].Rows[0]["维修原因"]);
tbMemo.Text = Convert.ToString(ds.Tables[0].Rows[0]["备注"]);
btnStart.Enabled = false;
btnEnd.Enabled = true;
}
else
{
dateTimePicker1.Value = DateTime.Now;
btnStart.Enabled = true;
btnEnd.Enabled = false;
}
}
else
{
MessageBox.Show("铁包维修信息查询出错!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
catch (Exception ex)
{
MessageBox.Show("铁包维修信息查询出错!\r\n" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
///
/// 加载铁包编号
///
///
private void proc_GetID(string strID)
{
try
{
string strErr = "";
ArrayList arry = new ArrayList();
arry.Add("FrmILRepair_Query4");
CommonClientToServer ccs = new CommonClientToServer();
ccs.ob = this.ob;
DataSet ds = ccs.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery", "doSimpleQuery", arry, out strErr);
if (strErr == "" && ds != null && ds.Tables.Count > 0)
{
Core.Mes.Client.Common.Globals.FillUlcmeItems(cbbID, ds.Tables[0]);
this.cbbID.DataSource = ds.Tables[0];
this.cbbID.DisplayMember = "铁包编号";
//for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
//{
// cbbID.Items.Add(ds.Tables[0].Rows[i]["铁包编号"]);
//}
if (ds.Tables[0].Rows.Count == 0)
{
ResetControlsBase(true);
ResetControlsRepair();
btnStart.Enabled = btnEnd.Enabled = false;
return;
}
if (strID.Length > 0)
cbbID.Text = strID;
cbbID_SelectedIndexChanged(null, null);
}
else
{
MessageBox.Show("铁包包号信息查询出错!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
catch (Exception ex)
{
MessageBox.Show("铁包包号信息查询出错!\r\n" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
///
/// 维修开始
///
private void IB_RepairStart()
{
if (cbbID.Items.Count == 0 ||
cbbID.SelectedIndex < 0)
{
proc_GetID("");
MessageBox.Show("请选择需要维修的铁包!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
cbbID.Focus();
return;
}
string strErr = "";
ArrayList arry = new ArrayList();
arry.Add("FrmILRepair_Query5");
arry.Add(cbbID.Text.Trim());
CommonClientToServer ccs = new CommonClientToServer();
ccs.ob = this.ob;
DataSet ds = ccs.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery", "doSimpleQuery", arry, out strErr);
if (!(strErr == "" && ds != null && ds.Tables.Count > 0))
{
MessageBox.Show("铁包[" + cbbID.Text.Trim() + "]维修操作失败,请重试!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (ds.Tables[0].Rows.Count == 0)
{
MessageBox.Show("铁包编号[" + cbbID.Text.Trim() + "]不存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
cbbID.Focus();
return;
}
string strCurrStatus = Convert.ToString(ds.Tables[0].Rows[0]["当前状态"]);
if (strCurrStatus != "备用")
{
MessageBox.Show("铁包[" + cbbID.Text.Trim() + "]当前状态为[" + strCurrStatus + "],不能维修!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
cbbID.Focus();
return;
}
if (cbbLB.SelectedIndex < 0)
{
MessageBox.Show("请选择维修类别!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
cbbLB.Focus();
return;
}
if (cbbWZ.SelectedIndex < 0)
{
MessageBox.Show("请选择维修位置!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
cbbWZ.Focus();
return;
}
if (cbxClrTS.Checked || cbxClrBG.Checked)
{
MessageBox.Show("您选择了铁包包龄清零!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
}
if (MessageBox.Show("确认开始维修铁包[" + cbbID.Text.Trim() + "]吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
return;
}
try
{
string strReturn = "";
strErr = "";
arry.Clear();
arry.Add("FrmILRepair_Add");
arry.Add(cbbID.Text.Trim());
arry.Add(cbbWZ.Text.Trim());
arry.Add(cbbLB.Text.Trim());
arry.Add(CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName());
arry.Add(tbReason.Text.Trim());
arry.Add(cbbID.Text.Trim());
arry.Add(tbMemo.Text.Trim());
arry.Add(dateTimePicker1.Text.Length > 0 ? Convert.ToDateTime(dateTimePicker1.Value).ToString("yyyy-MM-dd HH:mm:ss") : DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
ccs.ob = this.ob;
strReturn = ccs.NoQueryFunctions("Core.LgMes.Server.Common.ComDBSave", "doSimpleSave", arry, out strErr);
if (strErr != "")
{
MessageBox.Show("铁包[" + cbbID.Text.Trim() + "]维修操作失败!\n" + strErr, "错误!", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
string str = "";
if (cbxClrTS.Checked)
str = " , AGE = '0' ";
if (cbxClrBG.Checked)
{
if (str.Length > 0)
str += ", LVL = '0' ";
else
str = " , LVL = '0' ";
}
strErr = "";
string strSql = "update dev_ib_base_info set "
+ "STATUS = '维修' " + str + " "
+ "where LADLEID = '" + cbbID.Text.Trim() + "'";
CoreClientParam ccp_K = new CoreClientParam();
ccp_K.ServerName = "Core.LgMes.Server.DEV.Methods.DEVPublicMethods";
ccp_K.MethodName = "UpdateMethods";
ccp_K.ServerParams = new object[]{strSql};
ob.ExecuteNonQuery(ccp_K, CoreInvokeType.Internal);
strErr = ccp_K.ReturnInfo.ToString();
if (strErr != "")
{
MessageBox.Show("铁包[" + cbbID.Text.Trim() + "]维修操作失败!\n" + strErr, "错误!", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
proc_GetID(cbbID.Text.Trim());
FrmIronLadleManage frm = (FrmIronLadleManage)this.Tag;
if (!frm._bAutoRefresh)
{
frm.GetID();
frm.GetAndSetData();
}
frm.GetAndSetData();
MessageBox.Show("铁包[" + cbbID.Text.Trim() + "]维修开始!", "提示");
}
catch (Exception ex)
{
MessageBox.Show("铁包维修操作失败!\r\n" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
return;
}
}
///
/// 维修结束
///
private void IB_RepairEnd()
{
if (cbbID.Items.Count == 0 ||
cbbID.SelectedIndex < 0)
{
proc_GetID("");
MessageBox.Show("请选择需要结束维修的铁包!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
cbbID.Focus();
return;
}
string strErr = "";
ArrayList arry = new ArrayList();
arry.Add("FrmILRepair_Query6");
arry.Add(cbbID.Text.Trim());
CommonClientToServer ccs = new CommonClientToServer();
ccs.ob = this.ob;
DataSet ds = ccs.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery", "doSimpleQuery", arry, out strErr);
if (!(strErr == "" && ds != null && ds.Tables.Count > 0))
{
MessageBox.Show("铁包[" + cbbID.Text.Trim() + "]结束维修操作失败,请重试!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (ds.Tables[0].Rows.Count == 0)
{
MessageBox.Show("铁包编号[" + cbbID.Text.Trim() + "]不存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
cbbID.Focus();
return;
}
string strCurrStatus = Convert.ToString(ds.Tables[0].Rows[0]["当前状态"]);
if (strCurrStatus != "维修")
{
MessageBox.Show("铁包[" + cbbID.Text.Trim() + "]当前状态为[" + strCurrStatus + "],还未开始维修!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
cbbID.Focus();
return;
}
if (cbbLB.SelectedIndex < 0)
{
MessageBox.Show("请选择维修类别!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
cbbLB.Focus();
return;
}
if (cbbWZ.SelectedIndex < 0)
{
MessageBox.Show("请选择维修位置!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
cbbWZ.Focus();
return;
}
if (cbxClrTS.Checked || cbxClrBG.Checked)
{
MessageBox.Show("您选择了铁包包龄清零!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
}
if (MessageBox.Show("确认铁包[" + cbbID.Text.Trim() + "]维修结束吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
return;
}
try
{
string strReturn = "";
strErr = "";
arry.Clear();
arry.Add("FrmILRepair_Update");
arry.Add(cbbWZ.Text.Trim());
arry.Add(cbbLB.Text.Trim());
arry.Add(CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName());
arry.Add(tbReason.Text.Trim());
arry.Add(tbMemo.Text.Trim());
arry.Add(Convert.ToDateTime(dateTimePicker1.Value).ToString("yyyy-MM-dd HH:mm:ss"));
arry.Add(dateTimePicker2.Text.Length > 0 ? Convert.ToDateTime(dateTimePicker2.Value).ToString("yyyy-MM-dd HH:mm:ss") : DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
arry.Add(cbbID.Text.Trim());
ccs.ob = this.ob;
strReturn = ccs.NoQueryFunctions("Core.LgMes.Server.Common.ComDBSave", "doSimpleSave", arry, out strErr);
if (strErr != "")
{
MessageBox.Show("铁包[" + cbbID.Text.Trim() + "]维修操作失败!\n" + strErr, "错误!", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
string str = "";
if (cbxClrTS.Checked)
str = " , AGE = '0' ";
if (cbxClrBG.Checked)
{
if (str.Length > 0)
str += ", LVL = '0' ";
else
str = " , LVL = '0' ";
}
strErr = "";
string strSql = "update dev_ib_base_info set "
+ "STATUS = '备用' " + str + " "
+ "where LADLEID = '" + cbbID.Text.Trim() + "'";
CoreClientParam ccp_K = new CoreClientParam();
ccp_K.ServerName = "Core.LgMes.Server.DEV.Methods.DEVPublicMethods";
ccp_K.MethodName = "UpdateMethods";
ccp_K.ServerParams = new object[] { strSql };
ob.ExecuteNonQuery(ccp_K, CoreInvokeType.Internal);
strErr = ccp_K.ReturnInfo.ToString();
if (strErr != "")
{
MessageBox.Show("铁包[" + cbbID.Text.Trim() + "]结束维修操作失败!\n" + strErr, "错误!", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
proc_GetID(cbbID.Text.Trim());
FrmIronLadleManage frm = (FrmIronLadleManage)this.Tag;
if (!frm._bAutoRefresh)
{
frm.GetID();
frm.GetAndSetData();
}
frm.GetAndSetData();
MessageBox.Show("铁包[" + cbbID.Text.Trim() + "]维修结束!", "提示");
}
catch (Exception ex)
{
MessageBox.Show("铁包结束维修操作失败!\r\n" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
return;
}
}
private void ResetControlsBase(bool bFlag)
{
try
{
if (bFlag)
cbbID.SelectedIndex = -1;
tbCurrStatus.Clear();
tbAgeTS.Clear();
tbAgeBG.Clear();
cbxClrTS.Checked = false;
cbxClrBG.Checked = false;
}
catch { }
}
private void ResetControlsRepair()
{
try
{
cbbLB.SelectedIndex = -1;
cbbWZ.SelectedIndex = -1;
//dateTimePicker1.CustomFormat = dateTimePicker2.CustomFormat = " ";
dateTimePicker1.Value = dateTimePicker2.Value = null;
tbReason.Clear();
tbMemo.Clear();
}
catch { }
}
///
/// 维修位置加载
///
private void GetPosition()
{
string strErr = "";
ArrayList arry = new ArrayList();
arry.Add("FrmILRepair_Query1");
arry.Add("铁包");
CommonClientToServer ccs = new CommonClientToServer();
ccs.ob = this.ob;
DataSet ds = ccs.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery", "doSimpleQuery", arry, out strErr);
if (strErr == "" && ds != null && ds.Tables.Count > 0)
{
cbbWZ.Items.Clear();
for (int i = 0; i