using System;
using System.Data;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using Core.Mes.Client.Common;
using CoreFS.CA06;
namespace Core.LgMes.Client.LgDeviceManager
{
public partial class frmpotrepaire : FrmLgDevFunctions
{
public string _strPotNo = "";
private bool _IsInsert = true;
private string _strWorkNo = "";
public frmpotrepaire(OpeBase oba)
{
InitializeComponent();
this.udteStart.DateTime = DateTime.Now;
this.udteEnd.DateTime = DateTime.Now;
this.btnWithTime.Click += new System.EventHandler(this.button3_Click);
this.chkStart.CheckedChanged += new System.EventHandler(this.checkBox1_CheckedChanged);
this.chkEnd.CheckedChanged += new System.EventHandler(this.checkBox2_CheckedChanged);
ob = oba;
}
private void frmpotrepaire_Load(object sender, EventArgs e)
{
InitComboBox();
GetData();
}
///
/// 加载维修信息
///
private void GetData()
{
try
{
string strErr = "";
ArrayList arry = new ArrayList();
arry.Add("frmpotrepaire_Query1");
CommonClientToServer ccs = new CommonClientToServer();
ccs.ob = this.ob;
arry.Add(_strPotNo);
DataSet ds = ccs.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery", "doSimpleQuery", arry, out strErr);
if (strErr == "" && ds.Tables[0].Rows.Count > 0)
{
DataRow dr = ds.Tables[0].Rows[0];
this.cmbLocation.Text = ds.Tables[0].Rows[0]["REPAIRPART"].ToString();// dr[0].ToString();位置
this.cmbReason.Text = ds.Tables[0].Rows[0]["REASON"].ToString();//dr[1].ToString();原因
this.cmbCategory.Text = ds.Tables[0].Rows[0]["REPAIRTYPE"].ToString();//dr[2].ToString();类别
this.udteStart.Text = ds.Tables[0].Rows[0]["REPAIRTIME"].ToString();//dr[3].ToString();开始时间
this.txtWithTime.Text = ds.Tables[0].Rows[0]["duration"].ToString();//dr[4].ToString();用时
this.cmbRefr.Text = ds.Tables[0].Rows[0]["MATERIALREPLACING"].ToString();//dr[5].ToString();耐材
this.chkStart.Checked = true;
this.chkStart.BackColor = Color.Pink;
_strWorkNo = dr[1].ToString();
_IsInsert = false;
}
}
catch { }
}
///
/// 加载耐材厂家
///
private void InitComboBox()
{
try
{
string strErr = "";
ArrayList ar = new ArrayList();
ar.Add(LadleCommonClass.strRefractoryMatterFactoryCode);
ar.Add("");
ar.Add("order by inputtime");
DataSet ds = QueryArray("Core.LgMes.Server.LgDeviceManager.LadleManager", "GetFactory", new object[] { ar });
if (strErr == "" && ds.Tables[0].Rows.Count > 0)
{
cmbRefr.Items.Clear();
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
cmbRefr.Items.Add(ds.Tables[0].Rows[i][1].ToString());
}
}
}
catch { }
}
///
/// 维修开始
///
///
///
private void checkBox1_CheckedChanged(object sender, System.EventArgs e)
{
if (this.chkStart.Checked)
{
this.chkStart.BackColor = Color.Pink;
}
else
{
this.chkStart.BackColor = Color.Transparent;
}
}
///
/// 维修结束
///
///
///
private void checkBox2_CheckedChanged(object sender, System.EventArgs e)
{
if (this.chkEnd.Checked)
{
this.chkEnd.BackColor = Color.Pink;
this.udteEnd.DateTime = System.DateTime.Now;
GetDuration();
}
else
{
this.chkEnd.BackColor = Color.Transparent;
}
}
private void button3_Click(object sender, System.EventArgs e)
{
GetDuration();
}
///
/// 用时
///
private void GetDuration()
{
try
{
string sqlstr = "select round((sysdate-to_date('" + udteStart.DateTime.ToString("yyyy-MM-dd HH:mm:ss") + "','yyyy-MM-dd hh24:mi:ss'))*24*60) from dual";
string strOut = "";
DataSet ds = QueryFixedFunions(sqlstr,ob);
if (strOut != "")
{
MessageBox.Show(strOut, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
this.txtWithTime.Text = ds.Tables[0].Rows[0][0].ToString();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
///
/// 维修
///
private void proc_OK()
{
if (this.cmbLocation.Text.Trim().Length == 0)
{
MessageBox.Show("请选择维修位置!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
try
{
ArrayList ar = new ArrayList();
string v10 = Convert.ToString(_IsInsert);
string v0 =_strPotNo;
string v1 =_strWorkNo;
string v2 =cmbLocation.Text.Trim();
string v3 =cmbReason.Text.Trim();
string v4 =cmbCategory.Text.Trim();
string v5 =cmbRefr.Text.Trim();
string v6 = Convert.ToString(chkStart.Checked);
string v7 =Convert.ToString(chkEnd.Checked);
string v8 =udteStart.DateTime.ToString("yyyy-MM-dd HH:mm:ss");
string v9 = udteEnd.DateTime.ToString("yyyy-MM-dd HH:mm:ss");
string[] strParams = new string[11] { v10,v0,v1,v2,v3,v4,v5,v6,v7,v8,v9};
string strErr = "";
string msg = "";
ProcedureZ("Core.LgMes.Server.DEV.Methods.DEVPublicMethods", "procedure", new object[] { "lgmes_dev_info.lg_gbinfo_edit", strParams }, ob, out strErr, out msg);
if (Convert.ToInt32(strErr) > 0)
{
MessageBox.Show(msg, "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
}
else
MessageBox.Show(msg, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
FrmPotMgt frm = new FrmPotMgt();
frm.Tag = this.Tag;
frm.Getpotbasedata();
this.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void toolStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
{
switch (e.ClickedItem.Name)
{
case "OK":
this.proc_OK();
break;
case "CANCEL":
this.Close();
break;
default:
break;
}
}
private void button2_Click(object sender, EventArgs e)
{
this.proc_OK();
}
private void button1_Click(object sender, EventArgs e)
{
this.Close();
}
}
}