海门当升调度软件
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.

119 lines
3.9 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();
this.dateTimePicker1.Value = DateTime.Today;
this.dateTimePicker2.Value = DateTime.Today.AddMinutes(1439);
_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;
}
sql = "select * from V_Device_Error_log where " + dfield + " like '%" + this.tbContent.Text + "%' and 发生时间 >= '" + dateTimePicker1.Text + "' AND 发生时间 <= '" + dateTimePicker2.Text + "'";
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;
}
sql = "select distinct " + dfield + " from V_Device_Error_log ";
DataView dv = dbo.ExceSQL(sql).Tables[0].DefaultView;
this.tbContent.DataSource = null;
this.tbContent.DisplayMember = dfield;
this.tbContent.ValueMember = dfield;
this.tbContent.DataSource = dv;
}
private void FrmDeviceErrorLog_FormClosing(object sender, FormClosingEventArgs e)
{
_formInstance = null;
}
}
}