You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
175 lines
6.1 KiB
175 lines
6.1 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
|
|
using DBFactory;
|
|
namespace wcfControlMonitorClient
|
|
{
|
|
/// <summary>
|
|
/// Creator:Richard.liu
|
|
/// 设备故障查询
|
|
/// </summary>
|
|
public partial class FrmDeviceErrorLog : Form
|
|
{
|
|
private static FrmDeviceErrorLog _formInstance;
|
|
|
|
public static FrmDeviceErrorLog FormInstance
|
|
{
|
|
get
|
|
|
|
{
|
|
if (_formInstance == null)
|
|
{
|
|
_formInstance = new FrmDeviceErrorLog();
|
|
}
|
|
return _formInstance;
|
|
}
|
|
set { _formInstance = value; }
|
|
}
|
|
DBOperator dbo =CStaticClass.dbo;
|
|
public FrmDeviceErrorLog()
|
|
{
|
|
InitializeComponent();
|
|
_formInstance = this;//20101028
|
|
}
|
|
|
|
private void btQuery_Click(object sender, EventArgs e)
|
|
{
|
|
string dfield,sql;
|
|
switch (this.cbField.Text )
|
|
{
|
|
case "设备索引":
|
|
dfield = "设备索引";
|
|
break;
|
|
case "设备名称":
|
|
dfield = "设备名称";
|
|
break;
|
|
case "设备故障编号":
|
|
dfield = "设备故障编号";
|
|
break;
|
|
case "设备种类索引":
|
|
dfield = "设备种类索引";
|
|
break;
|
|
case "发生时间":
|
|
dfield = "发生时间";
|
|
break;
|
|
default:
|
|
dfield = "设备索引";
|
|
break;
|
|
}
|
|
if (this.cbField.Text == "发生时间")
|
|
{
|
|
sql = "select * from V_Device_Error_log where 是否为报警='1' and " + dfield + " >= '" + this.dateTimePicker1.Text + "' and " + dfield + " <= '" + this.dateTimePicker2.Text + "' order by 7 desc";
|
|
}
|
|
else
|
|
{
|
|
sql = "select * from V_Device_Error_log where 是否为报警='1' and " + dfield + " like '%" + this.tbContent.Text + "%' order by 7 desc";
|
|
}
|
|
DataSet ds = dbo.ExceSQL(sql);
|
|
this.dataGridView1.DataSource = ds.Tables[0].DefaultView;
|
|
}
|
|
|
|
private void btNullQuery_Click(object sender, EventArgs e)
|
|
{
|
|
if (MessageBox.Show("您确认要清空数据库内记录的所有历史报警吗?", "操作提示:", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK)
|
|
{
|
|
return;
|
|
}
|
|
dbo.ExceSQL("delete from T_Base_Device_Error_Log");
|
|
}
|
|
|
|
private void cbField_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
string dfield, sql;
|
|
switch (this.cbField.Text)
|
|
{
|
|
case "设备索引":
|
|
dfield = "设备索引";
|
|
break;
|
|
case "设备名称":
|
|
dfield = "设备名称";
|
|
break;
|
|
case "设备故障编号":
|
|
dfield = "设备故障编号";
|
|
break;
|
|
case "设备种类索引":
|
|
dfield = "设备种类索引";
|
|
break;
|
|
case "发生时间":
|
|
dfield = "发生时间";
|
|
break;
|
|
default:
|
|
dfield = "设备索引";
|
|
break;
|
|
}
|
|
if (this.cbField.Text == "发生时间")
|
|
{
|
|
this.dateTimePicker1.Visible = true;
|
|
this.dateTimePicker2.Visible = true;
|
|
this.label1.Visible = true;
|
|
this.tbContent.Visible = false;
|
|
this.dateTimePicker1.Value = DateTime.Today;
|
|
this.dateTimePicker2.Value = DateTime.Today;
|
|
}
|
|
else
|
|
{
|
|
this.dateTimePicker1.Visible = false;
|
|
this.dateTimePicker2.Visible = false;
|
|
this.label1.Visible = false;
|
|
this.tbContent.Visible = true;
|
|
|
|
sql = "select distinct " + dfield + " from V_Device_Error_log";
|
|
DataView dv = dbo.ExceSQL(sql).Tables[0].DefaultView;
|
|
this.tbContent.DisplayMember = dfield;
|
|
|
|
this.tbContent.DataSource = dv;
|
|
this.tbContent.ValueMember = dfield;
|
|
}
|
|
}
|
|
|
|
private void FrmDeviceErrorLog_FormClosing(object sender, FormClosingEventArgs e)
|
|
{
|
|
_formInstance = null;
|
|
}
|
|
|
|
private void button1_Click(object sender, EventArgs e)
|
|
{
|
|
string dfield, sql;
|
|
switch (this.cbField.Text)
|
|
{
|
|
case "设备索引":
|
|
dfield = "设备索引";
|
|
break;
|
|
case "设备名称":
|
|
dfield = "设备名称";
|
|
break;
|
|
case "设备故障编号":
|
|
dfield = "设备故障编号";
|
|
break;
|
|
case "设备种类索引":
|
|
dfield = "设备种类索引";
|
|
break;
|
|
case "发生时间":
|
|
dfield = "发生时间";
|
|
break;
|
|
default:
|
|
dfield = "设备索引";
|
|
break;
|
|
}
|
|
if (this.cbField.Text == "发生时间")
|
|
{
|
|
sql = "select * from V_Device_Error_log where 是否为报警='0' and " + dfield + " >= '" + this.dateTimePicker1.Text + "' and " + dfield + " <= '" + this.dateTimePicker2.Text + "' order by 7 desc";
|
|
}
|
|
else
|
|
{
|
|
sql = "select * from V_Device_Error_log where 是否为报警='0' and " + dfield + " like '%" + this.tbContent.Text + "%' order by 7 desc";
|
|
}
|
|
DataSet ds = dbo.ExceSQL(sql);
|
|
this.dataGridView1.DataSource = ds.Tables[0].DefaultView;
|
|
}
|
|
}
|
|
}
|