using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Collections;
using CoreFS.CA06;
using Core.Mes.Client.Common;
namespace Core.LgMes.Client.LgDeviceManager
{
public partial class FrmOxygenLanceManage : FrmLgDevFunctions
{
//定义一个时间变量,用于确定氧枪喷头累计消耗量的清空
public static string LastUpdateTime;
public static string NowUpdateTime;
public FrmOxygenLanceManage()
{
InitializeComponent();
}
public void FrmOxygenLanceManage_Load(object sender, EventArgs e)
{
LastUpdateTime = System.DateTime.Now.ToString("yyyy-MM-dd");
OLInfoToShow();
}
public override void ToolBar_Click(object sender, string ToolbarKey)
{
switch (ToolbarKey)
{
case "Basicinfo"://基本信息
FrmOLBaseInfo fb = new FrmOLBaseInfo(ob);
fb.Tag = this;
fb.ShowDialog();
break;
case "Recordinfo"://使用记录信息
FrmOLUseDetailOperation FrmOLUDO = new FrmOLUseDetailOperation(this.ob);
FrmOLUDO.Tag = this;
FrmOLUDO.Show();
break;
case "Query":
this.OLInfoToShow();
break;
case "exit":
this.Close();
break;
}
}
/// <氧枪查询信息>
/// 氧枪查询信息
///
public void OLInfoToShow()
{
try
{
string SqlCommand = "CALL UPDATE_YQ_BASE_CUT()";
string err1 = NoQueryExecutive(SqlCommand, ob);
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "Core.LgMes.Server.DEV.Methods.DEVPublicMethods";
ccp.MethodName = "QueryMethods";
string strsql = "select t1.OxygenLanceID,case t1.Status when '使用' then t2.NOWPOSITION end usetype,case t1.Status when '使用' then t2.OVENID end nowposition,t1.Status,t1.usemaxtime,"
+ "case t1.yqtype when '1' then '炼钢' when '2' then '提钒' end yqtype,"
+ "to_char(t1.BuyDate, 'yyyy-mm-dd') BuyDate,to_char(T3.BEGINTIME, 'yyyy-mm-dd HH:mm:ss') BEGINTIME,to_char(T3.ENDTIME, 'yyyy-mm-dd HH:mm:ss') ENDTIME,CUTSULFUR USETIMES,t1.Memo,t1.ParaID "
+ "from DEV_YQ_Base_Info t1,(select * from DEV_YQ_USE_DETAIL where RECRODID in (select max(to_number(RECRODID)) from DEV_YQ_USE_DETAIL group by OXYGENLANCEID)) t2,"
+ " (select OXYGENLANCEID,count(*) USETIMES,max(BEGINTIME)BEGINTIME,max(ENDTIME)ENDTIME from DEV_yq_use_detail group by OXYGENLANCEID )t3 "
+ "where t1.OXYGENLANCEID = t2.OXYGENLANCEID(+) and t1.oxygenlanceid = t3.oxygenlanceid(+) "
+ "order by t1.Status,"
+ "case t1.Status when '使用' then t2.OVENID else '' end,"
+ "case t1.Status when '使用' then t2.NOWPOSITION else '' end,"
+ "length(t1.OxygenLanceID),t1.OxygenLanceID";
ccp.ServerParams = new Object[] { strsql };//查询条件
DataTable dt = new DataTable();
ccp.SourceDataTable = dt;
this.ExecuteQueryToDataTable(ccp,CoreInvokeType.Internal);//
DataSet ds = new DataSet();
ds.Tables.Add(dt);
try
{
((DataTable)ulgridBaseInfo.DataSource).Rows.Clear();
((DataSet)ulgridUseInfo.DataSource).Tables[0].Rows.Clear();
}
catch (Exception)
{
}
if(ds.Tables[0].Rows.Count>0)
{
ulgridBaseInfo.DataSource = ds;
}
if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
{
Hashtable htOperate = new Hashtable();
htOperate.Add("使用", Color.LightGreen);
htOperate.Add("备用", Color.LightBlue);
htOperate.Add("下线", Color.LightYellow);
}
else
{
FrmOxygenLanceManage FrmOLM = (FrmOxygenLanceManage)this;
FrmOLM.Show();
MessageBox.Show("Warning:未查到任何记录!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
/// <返回氧枪总数量>
/// //返回氧枪总数量
///
///
public string YQAdd()
{
//取出不在库氧枪数量
string sql = "select count(*) from DEV_yq_base_info";
//string err = "";
string month = System.DateTime.Now.ToString("yyyy-MM-dd").Substring(5, 2);
int YQAdd1 = 0;
DataSet ds = QueryFixedFunions(sql,ob);
if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
{
YQAdd1 = Convert.ToInt32(ds.Tables[0].Rows[0][0].ToString());
}
else
{
YQAdd1 = 0;
}
//取出在库氧枪数量
string sql1 = "select StockNumber from DEV_bak_yq_inv where ToolName='氧枪' and UseType='备用' and month ='" + month + "'";
int YQAdd2 = 0;
DataSet ds1 = QueryFixedFunions(sql1, ob);
if (ds1 != null && ds1.Tables.Count > 0 && ds1.Tables[0].Rows.Count > 0)
{
YQAdd2 = Convert.ToInt32(ds1.Tables[0].Rows[0][0].ToString());
}
else
{
YQAdd2 = 0;
}
return Convert.ToString(YQAdd1 + YQAdd2);
}
/// <氧枪使用记录查询>
/// 氧枪使用记录查询
///
///
///
private void ulgridBaseInfo_AfterRowActivate(object sender, EventArgs e)
{
string strOxygenLanceID = ulgridBaseInfo.ActiveRow.Cells[0].Value.ToString();
string sql = "select RECRODID,OXYGENLANCEID,CLASS,NOWPOSITION,OVENID,NOWSTATUS,USETIMES,to_char(BEGINTIME, 'yyyy-mm-dd HH:mm:ss') BEGINTIME,"
+"to_char(ENDTIME, 'yyyy-mm-dd HH:mm:ss') ENDTIME,REASON,SPOUTFACTORY,FLUX,MEMO from DEV_yq_use_detail t where t.oxygenlanceid='" + strOxygenLanceID + "' and t.RECRODID=" +
"(select max(to_number(g.RECRODID)) from DEV_yq_use_detail g where g.oxygenlanceid='" + strOxygenLanceID + "')";
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "Core.LgMes.Server.DEV.Methods.DEVPublicMethods";
ccp.MethodName = "QueryMethods";
ccp.ServerParams = new Object[] { sql };//查询条件
DataTable dt = new DataTable();
ccp.SourceDataTable = dt;
ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal);
DataSet ds = new DataSet();
ds.Tables.Add(dt);
try
{
((DataSet)ulgridUseInfo.DataSource).Tables[0].Rows.Clear();
}
catch (Exception)
{
}
if (ds.Tables[0].Rows.Count > 0)
{
ulgridUseInfo.DataSource = ds;
}
}
private string ClassTransChar(string code)
{
string str = "";
switch (code)
{
case "1":
{
str = "甲";
break;
}
case "2":
{
str = "乙";
break;
}
case "3":
{
str = "丙";
break;
}
case "4":
{
str = "丁";
break;
}
}
return str;
}
private void timer1_Tick(object sender, EventArgs e)
{
OLInfoToShow();
}
}
}