📄 提取金额.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 + -