📄 useroperatorframehistory.cs
字号:
#region 命名空间...using System;using System.Collections;using System.ComponentModel;using System.Drawing;using System.Windows.Forms;using System.Data;using System.Data.SqlClient;#endregionnamespace WindowsApplication.History{ public class UserOperatorFrameHistory : WindowsApplication.ParentMDiFrame.ParentFrame { #region Control... private System.ComponentModel.IContainer components = null;
private System.Data.SqlClient.SqlCommand sqlSelectCommand1;
private System.Data.SqlClient.SqlCommand sqlInsertCommand1;
private System.Data.SqlClient.SqlCommand sqlUpdateCommand1;
private System.Data.SqlClient.SqlCommand sqlDeleteCommand1;
private System.Data.SqlClient.SqlConnection sqlConnection;
private WindowsApplication.History.userOperatorTableSet userOperatorTableSet;
private System.Data.SqlClient.SqlDataAdapter sqlDataAdapter;
// private WindowsApplication.History.UserOperatorHistorySet userOperatorHistorySet; #endregion #region Function... public UserOperatorFrameHistory() { // 该调用是 Windows 窗体设计器所必需的。 InitializeComponent(); // TODO: 在 InitializeComponent 调用后添加任何初始化 } /// <summary> /// 清理所有正在使用的资源。 /// </summary> protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); } #endregion #region 设计器生成的代码 /// <summary> /// 设计器支持所需的方法 - 不要使用代码编辑器修改 /// 此方法的内容。 /// </summary> private void InitializeComponent() { System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(UserOperatorFrameHistory));
this.sqlDataAdapter = new System.Data.SqlClient.SqlDataAdapter();
this.sqlDeleteCommand1 = new System.Data.SqlClient.SqlCommand();
this.sqlConnection = new System.Data.SqlClient.SqlConnection();
this.sqlInsertCommand1 = new System.Data.SqlClient.SqlCommand();
this.sqlSelectCommand1 = new System.Data.SqlClient.SqlCommand();
this.sqlUpdateCommand1 = new System.Data.SqlClient.SqlCommand();
this.userOperatorTableSet = new WindowsApplication.History.userOperatorTableSet();
((System.ComponentModel.ISupportInitialize)(this.ds)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.stStauts)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.stUserOperator)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.stDateText)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.stTimeText)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.stState)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.dataGridSource)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.userOperatorTableSet)).BeginInit();
//
// tool
//
this.tool.Name = "tool";
this.tool.Size = new System.Drawing.Size(862, 40);
//
// image
//
this.image.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("image.ImageStream")));
//
// TitleLabel
//
this.TitleLabel.Name = "TitleLabel";
this.TitleLabel.Text = "用户操作历史";
//
// status
//
this.status.Name = "status";
//
// stDateText
//
this.stDateText.Text = "当前日期:2006年11月10日";
//
// stTimeText
//
this.stTimeText.Text = "当前时间:05:15:56PM";
//
// stState
//
this.stState.Text = "状态:无";
//
// dataGridSource
//
this.dataGridSource.Name = "dataGridSource";
this.dataGridSource.Size = new System.Drawing.Size(864, 344);
//
// sqlDataAdapter
//
this.sqlDataAdapter.DeleteCommand = this.sqlDeleteCommand1;
this.sqlDataAdapter.InsertCommand = this.sqlInsertCommand1;
this.sqlDataAdapter.SelectCommand = this.sqlSelectCommand1;
this.sqlDataAdapter.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
new System.Data.Common.DataTableMapping("Table", "UserOperatorTable_History", new System.Data.Common.DataColumnMapping[] {
new System.Data.Common.DataColumnMapping("编号", "编号"),
new System.Data.Common.DataColumnMapping("日期", "日期"),
new System.Data.Common.DataColumnMapping("时间", "时间"),
new System.Data.Common.DataColumnMapping("操作员", "操作员"),
new System.Data.Common.DataColumnMapping("状态", "状态")})});
this.sqlDataAdapter.UpdateCommand = this.sqlUpdateCommand1;
//
// sqlDeleteCommand1
//
this.sqlDeleteCommand1.CommandText = @"DELETE FROM UserOperatorTable_History WHERE (编号 = @Original_编号) AND (操作员 = @Original_操作员 OR @Original_操作员 IS NULL AND 操作员 IS NULL) AND (日期 = @Original_日期) AND (时间 = @Original_时间 OR @Original_时间 IS NULL AND 时间 IS NULL) AND (状态 = @Original_状态 OR @Original_状态 IS NULL AND 状态 IS NULL)";
this.sqlDeleteCommand1.Connection = this.sqlConnection;
this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_编号", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "编号", System.Data.DataRowVersion.Original, null));
this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_操作员", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "操作员", System.Data.DataRowVersion.Original, null));
this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_日期", System.Data.SqlDbType.DateTime, 8, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "日期", System.Data.DataRowVersion.Original, null));
this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_时间", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "时间", System.Data.DataRowVersion.Original, null));
this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_状态", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "状态", System.Data.DataRowVersion.Original, null));
//
// sqlConnection
//
this.sqlConnection.ConnectionString = "workstation id=localhost;integrated security=SSPI;database=SystemODBC";
//
// sqlInsertCommand1
//
this.sqlInsertCommand1.CommandText = "INSERT INTO UserOperatorTable_History(日期, 时间, 操作员, 状态) VALUES (@日期, @时间, @操作员, @状" +
"态); SELECT 编号, 日期, 时间, 操作员, 状态 FROM UserOperatorTable_History WHERE (编号 = @@IDEN" +
"TITY)";
this.sqlInsertCommand1.Connection = this.sqlConnection;
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@日期", System.Data.SqlDbType.DateTime, 8, "日期"));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@时间", System.Data.SqlDbType.VarChar, 50, "时间"));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@操作员", System.Data.SqlDbType.VarChar, 50, "操作员"));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@状态", System.Data.SqlDbType.VarChar, 50, "状态"));
//
// sqlSelectCommand1
//
this.sqlSelectCommand1.CommandText = "SELECT 编号, 日期, 时间, 操作员, 状态 FROM UserOperatorTable_History";
this.sqlSelectCommand1.Connection = this.sqlConnection;
//
// sqlUpdateCommand1
//
this.sqlUpdateCommand1.CommandText = @"UPDATE UserOperatorTable_History SET 日期 = @日期, 时间 = @时间, 操作员 = @操作员, 状态 = @状态 WHERE (编号 = @Original_编号) AND (操作员 = @Original_操作员 OR @Original_操作员 IS NULL AND 操作员 IS NULL) AND (日期 = @Original_日期) AND (时间 = @Original_时间 OR @Original_时间 IS NULL AND 时间 IS NULL) AND (状态 = @Original_状态 OR @Original_状态 IS NULL AND 状态 IS NULL); SELECT 编号, 日期, 时间, 操作员, 状态 FROM UserOperatorTable_History WHERE (编号 = @编号)";
this.sqlUpdateCommand1.Connection = this.sqlConnection;
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@日期", System.Data.SqlDbType.DateTime, 8, "日期"));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@时间", System.Data.SqlDbType.VarChar, 50, "时间"));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@操作员", System.Data.SqlDbType.VarChar, 50, "操作员"));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@状态", System.Data.SqlDbType.VarChar, 50, "状态"));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_编号", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "编号", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_操作员", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "操作员", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_日期", System.Data.SqlDbType.DateTime, 8, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "日期", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_时间", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "时间", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_状态", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "状态", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@编号", System.Data.SqlDbType.Int, 4, "编号"));
//
// userOperatorTableSet
//
this.userOperatorTableSet.DataSetName = "userOperatorTableSet";
this.userOperatorTableSet.Locale = new System.Globalization.CultureInfo("zh-CN");
//
// UserOperatorFrameHistory
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(862, 459);
this.Name = "UserOperatorFrameHistory";
this.Text = "userOperatorFrameHistory";
this.Load += new System.EventHandler(this.UserOperatorFrameHistory_Load);
((System.ComponentModel.ISupportInitialize)(this.ds)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.stStauts)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.stUserOperator)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.stDateText)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.stTimeText)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.stState)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.dataGridSource)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.userOperatorTableSet)).EndInit();
} #endregion
#region 初始化事件 ...
private void UserOperatorFrameHistory_Load(object sender, System.EventArgs e)
{
try
{
#region Init DataGrid...
DataTable tempUserOperator=new DataTable();
this.sqlDataAdapter.Fill(userOperatorTableSet);
tempUserOperator=userOperatorTableSet.Tables[0];
base.dataGridSource.DataSource=tempUserOperator;
base.stStauts.Text="所有记录:"+selectCount();
base.dataAdapter=sqlDataAdapter;
base.ds=userOperatorTableSet;
base.cmOrders=(System.Windows.Forms.CurrencyManager) BindingContext[tempUserOperator];
#endregion
}
catch(Exception ele)
{
MessageBox.Show(this,ele.ToString(),"提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
} #endregion #region selectCount() private String selectCount() { string temp=""; try { DataTable tempTable=new DataTable(); tempTable=DataConnection.DataConnection.ExcuteSql("select count(*) from UserOperatorTable_History","UserOperatorTable_History"); for(int j=0;j<tempTable.Rows.Count;j++) { temp=tempTable.Rows[j][0].ToString(); } } catch(Exception ele) { MessageBox.Show(this,ele.ToString()," 提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information); } return temp; } #endregion }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -