?? 提取金額.cs
字號:
this.button6.Click += new System.EventHandler(this.button6_Click);
//
// label8
//
this.label8.Enabled = false;
this.label8.Location = new System.Drawing.Point(16, 8);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(136, 40);
this.label8.TabIndex = 13;
this.label8.Text = "label8";
this.label8.Visible = false;
//
// 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");
//
// label9
//
this.label9.Enabled = false;
this.label9.Location = new System.Drawing.Point(192, 16);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(96, 32);
this.label9.TabIndex = 14;
this.label9.Text = "label9";
this.label9.Visible = false;
//
// label10
//
this.label10.Enabled = false;
this.label10.Location = new System.Drawing.Point(456, 616);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(48, 24);
this.label10.TabIndex = 15;
this.label10.Text = "label10";
this.label10.Visible = false;
//
// label11
//
this.label11.Enabled = false;
this.label11.Location = new System.Drawing.Point(536, 616);
this.label11.Name = "label11";
this.label11.Size = new System.Drawing.Size(80, 24);
this.label11.TabIndex = 16;
this.label11.Text = "label11";
this.label11.Visible = false;
//
// button7
//
this.button7.BackColor = System.Drawing.SystemColors.ActiveCaption;
this.button7.Font = new System.Drawing.Font("宋體", 21.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.button7.ForeColor = System.Drawing.Color.Yellow;
this.button7.Location = new System.Drawing.Point(808, 624);
this.button7.Name = "button7";
this.button7.Size = new System.Drawing.Size(136, 48);
this.button7.TabIndex = 17;
this.button7.Text = "返回";
this.button7.Click += new System.EventHandler(this.button7_Click);
//
// Form3
//
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.button7);
this.Controls.Add(this.label11);
this.Controls.Add(this.label10);
this.Controls.Add(this.label9);
this.Controls.Add(this.label8);
this.Controls.Add(this.button6);
this.Controls.Add(this.button5);
this.Controls.Add(this.button4);
this.Controls.Add(this.button3);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.label7);
this.Controls.Add(this.label6);
this.Controls.Add(this.label5);
this.Controls.Add(this.label4);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "Form3";
this.Text = "提取金額";
((System.ComponentModel.ISupportInitialize)(this.dataSet11)).EndInit();
this.ResumeLayout(false);
}
#endregion
private void button1_Click(object sender, System.EventArgs e)
{
sqlConnection1.Open();
string strin1="select 金額,最大金額 from 用戶表 where 用戶帳號='" + ATM取款機.Form1.kanum + "'";
SqlCommand cmd2=new SqlCommand(strin1,sqlConnection1);
SqlDataReader dr2=cmd2.ExecuteReader();
if(dr2.Read())
{
label10.Text=dr2.GetString(0).ToString();
label11.Text=dr2.GetString(1).ToString();
dr2.Close();
int c;
int d;
c=int.Parse(label10.Text);
d=int.Parse(label11.Text);
if(c>0 && d>=50)
{
string strin2 = "select 金額,最大金額 from 用戶表 where 用戶帳號='" + ATM取款機.Form1.kanum + "'";
SqlCommand cmd=new SqlCommand(strin2,sqlConnection1);
cmd.CommandText=strin2;
cmd.ExecuteNonQuery();
SqlDataReader dr=cmd.ExecuteReader();
if(dr.Read())
{
this.label8.Text=dr.GetString(0).ToString();
this.label9.Text=dr.GetString(1).ToString();
}
dr.Close();
int a =int.Parse(label8.Text);
int b=int.Parse(label9.Text);
a=a-50;
b=b-50;
label8.Text=a.ToString();
label9.Text=b.ToString();
// MessageBox.Show("看看對吧!");
string strin3="Update 用戶表 set 金額 = '" + label8.Text + "',最大金額='"+label9.Text+"' where 用戶帳號='" +ATM取款機.Form1.kanum + "'";
SqlCommand cmd1=new SqlCommand(strin3,sqlConnection1);
cmd1.ExecuteNonQuery();
Form5 frm =new Form5();
frm.Show();
this.Close();
}
else
MessageBox.Show("余額不足,或你今天已經取足了,不能再取!", "超支錯誤", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
sqlConnection1.Close();
}
private void button2_Click(object sender, System.EventArgs e)
{
sqlConnection1.Open();
string strin1="select 金額,最大金額 from 用戶表 where 用戶帳號='" + ATM取款機.Form1.kanum + "'";
SqlCommand cmd2=new SqlCommand(strin1,sqlConnection1);
SqlDataReader dr2=cmd2.ExecuteReader();
if(dr2.Read())
{
label10.Text=dr2.GetString(0).ToString();
label11.Text=dr2.GetString(1).ToString();
dr2.Close();
int c;
int d;
c=int.Parse(label10.Text);
d=int.Parse(label11.Text);
if(c>0 && d>=100)
{
string strin2 = "select 金額,最大金額 from 用戶表 where 用戶帳號='" + ATM取款機.Form1.kanum + "'";
SqlCommand cmd=new SqlCommand(strin2,sqlConnection1);
cmd.CommandText=strin2;
cmd.ExecuteNonQuery();
SqlDataReader dr=cmd.ExecuteReader();
if(dr.Read())
{
this.label8.Text=dr.GetString(0).ToString();
this.label9.Text=dr.GetString(1).ToString();
}
dr.Close();
int a =int.Parse(label8.Text);
int b=int.Parse(label9.Text);
a=a-100;
b=b-100;
label8.Text=a.ToString();
label9.Text=b.ToString();
// MessageBox.Show("看看對吧!");
string strin3="Update 用戶表 set 金額 = '" + label8.Text + "',最大金額='"+label9.Text+"' where 用戶帳號='" +ATM取款機.Form1.kanum + "'";
SqlCommand cmd1=new SqlCommand(strin3,sqlConnection1);
cmd1.ExecuteNonQuery();
Form5 frm =new Form5();
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -