📄 formsystemevent.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data.SqlClient ;
using System.Data ;
using System.Text ;
namespace Security
{
/// <summary>
/// FormSystemEvent 的摘要说明。
/// </summary>
public class FormSystemEvent : System.Windows.Forms.Form
{
private System.Windows.Forms.DataGrid gridEvent;
private System.Windows.Forms.Button btnQueryEvent;
private System.Windows.Forms.Button btnOk;
private System.Windows.Forms.PictureBox pictureBox1;
private SqlConnection cn2;
private SqlCommand cmd2;
private SqlDataAdapter adp;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public FormSystemEvent()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(FormSystemEvent));
this.gridEvent = new System.Windows.Forms.DataGrid();
this.btnQueryEvent = new System.Windows.Forms.Button();
this.btnOk = new System.Windows.Forms.Button();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
((System.ComponentModel.ISupportInitialize)(this.gridEvent)).BeginInit();
this.SuspendLayout();
//
// gridEvent
//
this.gridEvent.DataMember = "";
this.gridEvent.HeaderForeColor = System.Drawing.SystemColors.ControlText;
this.gridEvent.Location = new System.Drawing.Point(8, 8);
this.gridEvent.Name = "gridEvent";
this.gridEvent.Size = new System.Drawing.Size(320, 360);
this.gridEvent.TabIndex = 0;
this.gridEvent.Navigate += new System.Windows.Forms.NavigateEventHandler(this.gridEvent_Navigate);
//
// btnQueryEvent
//
this.btnQueryEvent.Location = new System.Drawing.Point(344, 288);
this.btnQueryEvent.Name = "btnQueryEvent";
this.btnQueryEvent.TabIndex = 1;
this.btnQueryEvent.Text = "查询";
this.btnQueryEvent.Click += new System.EventHandler(this.btnQueryEvent_Click);
//
// btnOk
//
this.btnOk.Location = new System.Drawing.Point(344, 328);
this.btnOk.Name = "btnOk";
this.btnOk.TabIndex = 2;
this.btnOk.Text = "确定";
this.btnOk.Click += new System.EventHandler(this.btnOk_Click);
//
// pictureBox1
//
this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
this.pictureBox1.Location = new System.Drawing.Point(336, 248);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(32, 32);
this.pictureBox1.TabIndex = 3;
this.pictureBox1.TabStop = false;
//
// FormSystemEvent
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(432, 377);
this.Controls.Add(this.pictureBox1);
this.Controls.Add(this.btnOk);
this.Controls.Add(this.gridEvent);
this.Controls.Add(this.btnQueryEvent);
this.Name = "FormSystemEvent";
this.Text = "系统事件";
this.Load += new System.EventHandler(this.FormSystemEvent_Load);
((System.ComponentModel.ISupportInitialize)(this.gridEvent)).EndInit();
this.ResumeLayout(false);
}
#endregion
private void FormSystemEvent_Load(object sender, System.EventArgs e)
{
cn2=new SqlConnection("integrated security=SSPI;data source=(local);Initial Catalog=BlueHill");
adp=new SqlDataAdapter("select EventID,EventMessage,EventTime from tblSystemEvent",cn2);
DataSet ds=new DataSet();
adp.Fill(ds);
this.gridEvent.DataSource=ds.Tables[0];
}
private void gridEvent_Navigate(object sender, System.Windows.Forms.NavigateEventArgs ne)
{
cmd2=new SqlCommand("select EventID,EventMessage,EventTime from tblSystemEvent");
}
private void btnQueryEvent_Click(object sender, System.EventArgs e)
{
FormQueryEvent frm=new FormQueryEvent();
frm.ShowDialog();
cn2 = new SqlConnection("integrated security=SSPI;data source=(local);Initial Catalog=BlueHill");
try
{
string select="select EventID,EventMessage,EventTime from tblSystemEvent where EventTime between '"+frm.d1+"' and '"+frm.d2 +"'";
adp=new SqlDataAdapter(select,cn2);
DataSet ds=new DataSet();
adp.Fill(ds,"tblSystemEvent");
this.gridEvent.DataSource=ds.Tables[0];
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void btnOk_Click(object sender, System.EventArgs e)
{
this.Close ();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -