📄 landframe.cs
字号:
this.textUserName.DropDownStyle = System.Windows.Forms.ComboBoxStyle.Simple;
this.textUserName.ForeColor = System.Drawing.Color.FromArgb(((System.Byte)(128)), ((System.Byte)(128)), ((System.Byte)(255)));
this.textUserName.Location = new System.Drawing.Point(256, 48);
this.textUserName.Name = "textUserName";
this.textUserName.Size = new System.Drawing.Size(128, 20);
this.textUserName.TabIndex = 14;
this.tool.SetToolTip(this.textUserName, "右键导入历史...");
this.textUserName.TextChanged += new System.EventHandler(this.textUserName_TextChanged);
this.textUserName.SelectedIndexChanged += new System.EventHandler(this.textUserName_SelectedIndexChanged);
this.textUserName.MouseEnter += new System.EventHandler(this.textUserName_MouseEnter_1);
this.textUserName.MouseLeave += new System.EventHandler(this.textUserName_MouseLeave_1);
//
// textUserDate
//
this.textUserDate.DropDownStyle = System.Windows.Forms.ComboBoxStyle.Simple;
this.textUserDate.Location = new System.Drawing.Point(256, 144);
this.textUserDate.Name = "textUserDate";
this.textUserDate.Size = new System.Drawing.Size(128, 20);
this.textUserDate.TabIndex = 15;
this.tool.SetToolTip(this.textUserDate, "右键导入历史...");
this.textUserDate.SelectedIndexChanged += new System.EventHandler(this.textUserDate_SelectedIndexChanged);
this.textUserDate.MouseEnter += new System.EventHandler(this.textUserDate_MouseEnter);
this.textUserDate.MouseLeave += new System.EventHandler(this.textUserDate_MouseLeave);
//
// currentTime
//
this.currentTime.Enabled = true;
this.currentTime.Interval = 1000;
this.currentTime.Tick += new System.EventHandler(this.currentTime_Tick);
//
// pictureBox1
//
this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
this.pictureBox1.Location = new System.Drawing.Point(0, 16);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(168, 160);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBox1.TabIndex = 16;
this.pictureBox1.TabStop = false;
this.tool.SetToolTip(this.pictureBox1, "右键导入历史...");
//
// groupBox1
//
this.groupBox1.Controls.Add(this.textBox1);
this.groupBox1.Location = new System.Drawing.Point(0, 176);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(144, 104);
this.groupBox1.TabIndex = 17;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "使用说明";
//
// textBox1
//
this.textBox1.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.textBox1.Cursor = System.Windows.Forms.Cursors.Hand;
this.textBox1.ForeColor = System.Drawing.Color.FromArgb(((System.Byte)(128)), ((System.Byte)(128)), ((System.Byte)(255)));
this.textBox1.Location = new System.Drawing.Point(8, 17);
this.textBox1.Multiline = true;
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(128, 79);
this.textBox1.TabIndex = 0;
this.textBox1.Text = "\r\n\r\n 初始用户为:user\r\n\r\n 密码:252127";
this.tool.SetToolTip(this.textBox1, "右键导入历史...");
//
// label4
//
this.label4.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.label4.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(128)), ((System.Byte)(128)), ((System.Byte)(255)));
this.label4.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.label4.Cursor = System.Windows.Forms.Cursors.SizeAll;
this.label4.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.label4.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label4.ForeColor = System.Drawing.SystemColors.ActiveCaptionText;
this.label4.Location = new System.Drawing.Point(0, 288);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(426, 32);
this.label4.TabIndex = 18;
this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// pictureBox2
//
this.pictureBox2.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(128)), ((System.Byte)(128)), ((System.Byte)(255)));
this.pictureBox2.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox2.Image")));
this.pictureBox2.Location = new System.Drawing.Point(8, 0);
this.pictureBox2.Name = "pictureBox2";
this.pictureBox2.Size = new System.Drawing.Size(24, 24);
this.pictureBox2.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBox2.TabIndex = 19;
this.pictureBox2.TabStop = false;
//
// userLabel
//
this.userLabel.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(128)), ((System.Byte)(128)), ((System.Byte)(255)));
this.userLabel.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.userLabel.Font = new System.Drawing.Font("宋体", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.userLabel.ForeColor = System.Drawing.Color.White;
this.userLabel.Location = new System.Drawing.Point(72, 296);
this.userLabel.Name = "userLabel";
this.userLabel.Size = new System.Drawing.Size(160, 16);
this.userLabel.TabIndex = 20;
this.userLabel.Text = "用户名:";
this.userLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// dateLabel
//
this.dateLabel.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(128)), ((System.Byte)(128)), ((System.Byte)(255)));
this.dateLabel.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.dateLabel.Font = new System.Drawing.Font("宋体", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.dateLabel.ForeColor = System.Drawing.Color.White;
this.dateLabel.Location = new System.Drawing.Point(256, 296);
this.dateLabel.Name = "dateLabel";
this.dateLabel.Size = new System.Drawing.Size(160, 16);
this.dateLabel.TabIndex = 21;
this.dateLabel.Text = "日期:";
this.dateLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// 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", "UserDengluHistory", 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 UserDengluHistory WHERE (编号 = @Original_编号) AND (日期 = @Original_日期 OR @Original_日期 IS NULL AND 日期 IS NULL) AND (时间 = @Original_时间 OR @Original_时间 IS NULL AND 时间 IS NULL) 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.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));
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 UserDengluHistory(日期, 时间, 用户名称, 状态) VALUES (@日期, @时间, @用户名称, @状态); SE" +
"LECT 编号, 日期, 时间, 用户名称, 状态 FROM UserDengluHistory WHERE (编号 = @@IDENTITY)";
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 UserDengluHistory";
this.sqlSelectCommand1.Connection = this.sqlConnection;
//
// sqlUpdateCommand1
//
this.sqlUpdateCommand1.CommandText = @"UPDATE UserDengluHistory SET 日期 = @日期, 时间 = @时间, 用户名称 = @用户名称, 状态 = @状态 WHERE (编号 = @Original_编号) AND (日期 = @Original_日期 OR @Original_日期 IS NULL AND 日期 IS NULL) AND (时间 = @Original_时间 OR @Original_时间 IS NULL AND 时间 IS NULL) AND (状态 = @Original_状态 OR @Original_状态 IS NULL AND 状态 IS NULL) AND (用户名称 = @Original_用户名称 OR @Original_用户名称 IS NULL AND 用户名称 IS NULL); SELECT 编号, 日期, 时间, 用户名称, 状态 FROM UserDengluHistory 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.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("@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, "编号"));
//
// userdengluSet
//
this.userdengluSet.DataSetName = "userdengluSet";
this.userdengluSet.Locale = new System.Globalization.CultureInfo("zh-CN");
//
// context
//
this.context.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuDengLuHistory});
//
// menuDengLuHistory
//
this.menuDengLuHistory.Index = 0;
this.menuDengLuHistory.Text = "导入历史(&V)";
this.menuDengLuHistory.Click += new System.EventHandler(this.menuDengLuHistory_Click);
//
// landFrame
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.BackColor = System.Drawing.Color.White;
this.ClientSize = new System.Drawing.Size(426, 320);
this.ContextMenu = this.context;
this.Controls.Add(this.dateLabel);
this.Controls.Add(this.userLabel);
this.Controls.Add(this.pictureBox2);
this.Controls.Add(this.label4);
this.Controls.Add(this.textUserDate);
this.Controls.Add(this.textUserName);
this.Controls.Add(this.textUserPassword);
this.Controls.Add(this.label1);
this.Controls.Add(this.btnZhuChe);
this.Controls.Add(this.btnCancel);
this.Controls.Add(this.btnLogin);
this.Controls.Add(this.radioAdmin);
this.Controls.Add(this.radioUser);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.TitleLabel);
this.Controls.Add(this.pictureBox1);
this.Controls.Add(this.groupBox1);
this.Cursor = System.Windows.Forms.Cursors.Hand;
this.ForeColor = System.Drawing.Color.FromArgb(((System.Byte)(128)), ((System.Byte)(128)), ((System.Byte)(255)));
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "landFrame";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "登陆窗体";
this.tool.SetToolTip(this, "右键导入历史...");
this.Closing += new System.ComponentModel.CancelEventHandler(this.landFrame_Closing);
this.Load += new System.EventHandler(this.landFrame_Load);
this.groupBox1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.userdengluSet)).EndInit();
this.ResumeLayout(false);
}
#endregion
#region 两个选框不能同时选中
// private bool f=false;
#endregion
#region 事件如下...
//界面初始化...事件...
private void landFrame_Load(object sender, System.EventArgs e)
{
#region 填充下拉表框...
try
{
string strUserSql="select distinct 用户名称 from System_UserTable";
string strUserTableName="System_UserTable";
System.Data.DataSet dsUser=new DataSet();
System.Data.DataTable dsUserTable=new DataTable();
ConnectionData data=new ConnectionData();
dsUser=data.ExcuteDataSetResult(strUserSql,strUserTableName);
dsUserTable=dsUser.Tables[0];
for(int i=0;i<dsUserTable.Rows.Count;i++)
{
this.textUserName.Items.Add(dsUserTable.Rows[i][0].ToString());
}
// this.textUserName.SelectedIndex=1;
}
catch(NullReferenceException ele)
{
MessageBox.Show(ele.ToString());
}
#endregion
this.btnLogin.Focus();
#region 运行login.txt
loginRead();
#endregion
#region 初始化CheckBox控件
this.radioAdmin.Checked=true;
#endregion
}
//文本改变时....
private void textUserName_SelectedIndexChanged(object sender, System.EventArgs e)
{
try
{
string sql="select 用户名称,密码 from System_UserTable where 用户类型='普通用户'";
DataSet dsSet=new DataSet();
DataTable dsTable=new DataTable();
ConnectionData conn=new ConnectionData();
dsSet=conn.ExcuteDataSetResult(sql,"System_UserTable");
dsTable=dsSet.Tables[0];
for(int i=0;i<dsTable.Rows.Count;i++)
{
if(dsTable.Rows[i][0].ToString().Equals(this.textUserName.Text))
{
this.textUserPassword.Text=MD4.DecryptString(dsTable.Rows[i][1].ToString());
strUserName=this.textUserName.Text;
this.textBox1.Text = "\r\n\r\n 初始用户为:user\r\n\r\n 密码:"+this.textUserPassword.Text.ToString().Trim();
}
}
}
catch(Exception exles)
{
MessageBox.Show(this,exles.ToString(),"提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
this.userLabel.Text="用户名:"+this.textUserName.Text;
this.dateLabel.Text="时间:"+System.DateTime.Now.ToLongTimeString().Trim();
}
private void textUserName_TextChanged(object sender, System.EventArgs e)
{
this.textUserName.SelectAll();
}
//登录
private void btnLogin_Click(object sender, System.EventArgs e)
{
try
{
if(this.CheckNull().Equals(false))
{
return;
}
ConnectionData dataConnection=new ConnectionData();
string strSql="select * from System_UserTable";
string strTableName="System_UserTable";
ds=dataConnection.ExcuteDataSetResult(strSql,strTableName);
System.Data.DataTable dsUsers=new DataTable();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -