?? 登錄.cs
字號:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;
namespace 機房計費系統
{
/// <summary>
/// 登錄 的摘要說明。
/// </summary>
public class frmLogin : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private System.Data.SqlClient.SqlConnection sqlConnection1;
private string sql;
private System.Windows.Forms.ComboBox comboBox1;
private System.Data.SqlClient.SqlDataAdapter sqlDataAdapter1;
private System.Data.SqlClient.SqlCommand sqlSelectCommand1;
private System.Data.SqlClient.SqlCommand sqlInsertCommand1;
private System.Data.SqlClient.SqlCommand sqlUpdateCommand1;
private System.Data.SqlClient.SqlCommand sqlDeleteCommand1;
/// <summary>
/// 必需的設計器變量。
/// </summary>
private System.ComponentModel.Container components = null;
public frmLogin()
{
//
// 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()
{
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.textBox2 = new System.Windows.Forms.TextBox();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();
this.comboBox1 = new System.Windows.Forms.ComboBox();
this.sqlDataAdapter1 = new System.Data.SqlClient.SqlDataAdapter();
this.sqlDeleteCommand1 = new System.Data.SqlClient.SqlCommand();
this.sqlInsertCommand1 = new System.Data.SqlClient.SqlCommand();
this.sqlSelectCommand1 = new System.Data.SqlClient.SqlCommand();
this.sqlUpdateCommand1 = new System.Data.SqlClient.SqlCommand();
this.SuspendLayout();
//
// label1
//
this.label1.Font = new System.Drawing.Font("宋體", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label1.Location = new System.Drawing.Point(8, 32);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(72, 23);
this.label1.TabIndex = 0;
this.label1.Text = "用戶名";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
this.label1.Click += new System.EventHandler(this.label1_Click);
//
// label2
//
this.label2.Font = new System.Drawing.Font("宋體", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label2.Location = new System.Drawing.Point(8, 72);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(72, 23);
this.label2.TabIndex = 1;
this.label2.Text = "密碼";
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
this.label2.Click += new System.EventHandler(this.label2_Click);
//
// textBox2
//
this.textBox2.Font = new System.Drawing.Font("宋體", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.textBox2.Location = new System.Drawing.Point(96, 64);
this.textBox2.MaxLength = 20;
this.textBox2.Name = "textBox2";
this.textBox2.PasswordChar = '*';
this.textBox2.Size = new System.Drawing.Size(184, 26);
this.textBox2.TabIndex = 1;
this.textBox2.Text = "";
this.textBox2.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.textBox2_KeyPress);
this.textBox2.TextChanged += new System.EventHandler(this.textBox2_TextChanged);
//
// button1
//
this.button1.Location = new System.Drawing.Point(88, 112);
this.button1.Name = "button1";
this.button1.TabIndex = 2;
this.button1.Text = "確定";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.Location = new System.Drawing.Point(192, 112);
this.button2.Name = "button2";
this.button2.TabIndex = 3;
this.button2.Text = "退出";
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// sqlConnection1
//
this.sqlConnection1.ConnectionString = "workstation id=XU;packet size=4096;integrated security=SSPI;data source=XU;persis" +
"t security info=False;initial catalog=jifei";
//
// comboBox1
//
this.comboBox1.Font = new System.Drawing.Font("宋體", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.comboBox1.Location = new System.Drawing.Point(96, 32);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(184, 24);
this.comboBox1.TabIndex = 4;
this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
//
// sqlDataAdapter1
//
this.sqlDataAdapter1.DeleteCommand = this.sqlDeleteCommand1;
this.sqlDataAdapter1.InsertCommand = this.sqlInsertCommand1;
this.sqlDataAdapter1.SelectCommand = this.sqlSelectCommand1;
this.sqlDataAdapter1.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
new System.Data.Common.DataTableMapping("Table", "操作員表", new System.Data.Common.DataColumnMapping[] {
new System.Data.Common.DataColumnMapping("ID", "ID"),
new System.Data.Common.DataColumnMapping("姓名", "姓名"),
new System.Data.Common.DataColumnMapping("密碼", "密碼"),
new System.Data.Common.DataColumnMapping("權限", "權限")})});
this.sqlDataAdapter1.UpdateCommand = this.sqlUpdateCommand1;
//
// sqlDeleteCommand1
//
this.sqlDeleteCommand1.CommandText = "DELETE FROM 操作員表 WHERE (ID = @Original_ID) AND (姓名 = @Original_姓名 OR @Original_姓名" +
" IS NULL AND 姓名 IS NULL) AND (密碼 = @Original_密碼 OR @Original_密碼 IS NULL AND 密碼 I" +
"S NULL) AND (權限 = @Original_權限 OR @Original_權限 IS NULL AND 權限 IS NULL)";
this.sqlDeleteCommand1.Connection = this.sqlConnection1;
this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_ID", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "ID", 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));
//
// sqlInsertCommand1
//
this.sqlInsertCommand1.CommandText = "INSERT INTO 操作員表(姓名, 密碼, 權限) VALUES (@姓名, @密碼, @權限); SELECT ID, 姓名, 密碼, 權限 FROM 操" +
"作員表 WHERE (ID = @@IDENTITY)";
this.sqlInsertCommand1.Connection = this.sqlConnection1;
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
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -