?? formsystemevent.cs
字號(hào):
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>
/// 必需的設(shè)計(jì)器變量。
/// </summary>
private System.ComponentModel.Container components = null;
public FormSystemEvent()
{
//
// Windows 窗體設(shè)計(jì)器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 調(diào)用后添加任何構(gòu)造函數(shù)代碼
//
}
/// <summary>
/// 清理所有正在使用的資源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows 窗體設(shè)計(jì)器生成的代碼
/// <summary>
/// 設(shè)計(jì)器支持所需的方法 - 不要使用代碼編輯器修改
/// 此方法的內(nèi)容。
/// </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 = "系統(tǒng)事件";
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 ();
}
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -