?? 進入系統.cs
字號:
// 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("用戶帳號", "用戶帳號"),
new System.Data.Common.DataColumnMapping("密碼", "密碼"),
new System.Data.Common.DataColumnMapping("金額", "金額")})});
this.sqlDataAdapter1.UpdateCommand = this.sqlUpdateCommand1;
//
// sqlDeleteCommand1
//
this.sqlDeleteCommand1.CommandText = "DELETE FROM 用戶表 WHERE (用戶帳號 = @Original_用戶帳號) AND (密碼 = @Original_密碼 OR @Original" +
"_密碼 IS NULL AND 密碼 IS 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_用戶帳號", System.Data.SqlDbType.VarChar, 10, 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, 6, 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, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "金額", System.Data.DataRowVersion.Original, null));
//
// sqlConnection1
//
this.sqlConnection1.ConnectionString = "workstation id=\"MICROSOF-AC4FA8\";packet size=4096;integrated security=SSPI;data s" +
"ource=\".\";persist security info=False;initial catalog=ATM取款機";
//
// sqlInsertCommand1
//
this.sqlInsertCommand1.CommandText = "INSERT INTO 用戶表(用戶帳號, 密碼, 金額) VALUES (@用戶帳號, @密碼, @金額); SELECT 用戶帳號, 密碼, 金額 FROM " +
"用戶表 WHERE (用戶帳號 = @用戶帳號)";
this.sqlInsertCommand1.Connection = this.sqlConnection1;
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@用戶帳號", System.Data.SqlDbType.VarChar, 10, "用戶帳號"));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@密碼", System.Data.SqlDbType.VarChar, 6, "密碼"));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@金額", System.Data.SqlDbType.VarChar, 10, "金額"));
//
// sqlSelectCommand1
//
this.sqlSelectCommand1.CommandText = "SELECT 用戶帳號, 密碼, 金額 FROM 用戶表";
this.sqlSelectCommand1.Connection = this.sqlConnection1;
//
// sqlUpdateCommand1
//
this.sqlUpdateCommand1.CommandText = "UPDATE 用戶表 SET 用戶帳號 = @用戶帳號, 密碼 = @密碼, 金額 = @金額 WHERE (用戶帳號 = @Original_用戶帳號) AND" +
" (密碼 = @Original_密碼 OR @Original_密碼 IS NULL AND 密碼 IS NULL) AND (金額 = @Original_" +
"金額 OR @Original_金額 IS NULL AND 金額 IS NULL); SELECT 用戶帳號, 密碼, 金額 FROM 用戶表 WHERE (" +
"用戶帳號 = @用戶帳號)";
this.sqlUpdateCommand1.Connection = this.sqlConnection1;
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@用戶帳號", System.Data.SqlDbType.VarChar, 10, "用戶帳號"));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@密碼", System.Data.SqlDbType.VarChar, 6, "密碼"));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@金額", System.Data.SqlDbType.VarChar, 10, "金額"));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_用戶帳號", System.Data.SqlDbType.VarChar, 10, 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, 6, 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, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "金額", System.Data.DataRowVersion.Original, null));
//
// dataSet11
//
this.dataSet11.DataSetName = "DataSet1";
this.dataSet11.Locale = new System.Globalization.CultureInfo("zh-CN");
//
// label4
//
this.label4.Enabled = false;
this.label4.Location = new System.Drawing.Point(24, 16);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(56, 40);
this.label4.TabIndex = 11;
this.label4.Text = "label4";
this.label4.Visible = false;
//
// label5
//
this.label5.Enabled = false;
this.label5.Location = new System.Drawing.Point(96, 24);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(64, 32);
this.label5.TabIndex = 12;
this.label5.Text = "label5";
this.label5.Visible = false;
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
this.ClientSize = new System.Drawing.Size(1016, 734);
this.Controls.Add(this.label5);
this.Controls.Add(this.label4);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.label3);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "Form1";
this.Text = "進入系統";
((System.ComponentModel.ISupportInitialize)(this.dataSet11)).EndInit();
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// 應用程序的主入口點。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void button1_Click_1(object sender, System.EventArgs e)
{
if (textBox1.Text == "" || textBox2.Text == "")
{
MessageBox.Show("用戶名或者密碼不能為空!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
textBox1.Focus();
}
else
{
sqlConnection1.Open();
string strin = "select * from 用戶表 where 用戶帳號='" + textBox1.Text.Trim() + "'and 密碼='" + textBox2.Text.Trim() + "'";
SqlCommand cmd=new SqlCommand(strin,sqlConnection1);
SqlDataReader dr = cmd.ExecuteReader();
if(dr.Read())
{
dr.Close();
string strin2="select 金額,最大金額 from 用戶表 where 用戶帳號='" + textBox1.Text.Trim() + "'and 密碼='" + textBox2.Text.Trim() + "'";
SqlCommand cmd2=new SqlCommand(strin2,sqlConnection1);
SqlDataReader dr2=cmd2.ExecuteReader();
if(dr2.Read())
{
label4.Text=dr2.GetString(0).ToString();
label5.Text=dr2.GetString(1).ToString();
dr2.Close();
int c;
int d;
c=int.Parse(label4.Text);
d=int.Parse(label5.Text);
if(c>0 && d>0)
{
kanum=textBox1.Text;
Form2 frm =new Form2();
frm.Show();
this.Hide();
}
else
MessageBox.Show("余額不足,或你今天已經取足了,不能再取!", "超支錯誤", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
else
MessageBox.Show("用戶名或密碼錯誤,請重新輸入!!!");
textBox1.Clear();
textBox2.Clear();
textBox1.Focus();
sqlConnection1.Close();
}
}
private void button2_Click_1(object sender, System.EventArgs e)
{
this.Close();
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -