?? 主要功能.cs
字號:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;
namespace ATM取款機(jī)
{
/// <summary>
/// Form2 的摘要說明。
/// </summary>
public class Form2 : System.Windows.Forms.Form
{
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button3;
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;
private System.Data.SqlClient.SqlConnection sqlConnection1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
/// <summary>
/// 必需的設(shè)計(jì)器變量。
/// </summary>
private System.ComponentModel.Container components = null;
public Form2()
{
//
// Windows 窗體設(shè)計(jì)器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 調(diào)用后添加任何構(gòu)造函數(shù)代碼
//
}
/// <summary>
/// 清理所有正在使用的資源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows 窗體設(shè)計(jì)器生成的代碼
/// <summary>
/// 設(shè)計(jì)器支持所需的方法 - 不要使用代碼編輯器修改
/// 此方法的內(nèi)容。
/// </summary>
private void InitializeComponent()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form2));
this.button2 = new System.Windows.Forms.Button();
this.button1 = new System.Windows.Forms.Button();
this.button3 = new System.Windows.Forms.Button();
this.sqlDataAdapter1 = new System.Data.SqlClient.SqlDataAdapter();
this.sqlSelectCommand1 = new System.Data.SqlClient.SqlCommand();
this.sqlInsertCommand1 = new System.Data.SqlClient.SqlCommand();
this.sqlUpdateCommand1 = new System.Data.SqlClient.SqlCommand();
this.sqlDeleteCommand1 = new System.Data.SqlClient.SqlCommand();
this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// button2
//
this.button2.BackColor = System.Drawing.SystemColors.HotTrack;
this.button2.Font = new System.Drawing.Font("Microsoft Sans Serif", 18F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.button2.ForeColor = System.Drawing.SystemColors.ControlLightLight;
this.button2.Location = new System.Drawing.Point(24, 344);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(104, 40);
this.button2.TabIndex = 7;
this.button2.Text = "取 款";
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// button1
//
this.button1.BackColor = System.Drawing.SystemColors.HotTrack;
this.button1.Font = new System.Drawing.Font("Microsoft Sans Serif", 18F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.button1.ForeColor = System.Drawing.SystemColors.ControlLightLight;
this.button1.Location = new System.Drawing.Point(24, 200);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(104, 40);
this.button1.TabIndex = 6;
this.button1.Text = "查 詢";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button3
//
this.button3.BackColor = System.Drawing.SystemColors.HotTrack;
this.button3.Font = new System.Drawing.Font("Microsoft Sans Serif", 18F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.button3.ForeColor = System.Drawing.SystemColors.ControlLightLight;
this.button3.Location = new System.Drawing.Point(24, 488);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(104, 40);
this.button3.TabIndex = 8;
this.button3.Text = "取 卡";
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// 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("金額", "金額"),
new System.Data.Common.DataColumnMapping("最大金額", "最大金額")})});
this.sqlDataAdapter1.UpdateCommand = this.sqlUpdateCommand1;
//
// sqlSelectCommand1
//
this.sqlSelectCommand1.CommandText = "SELECT 用戶帳號, 密碼, 金額, 最大金額 FROM 用戶表";
this.sqlSelectCommand1.Connection = this.sqlConnection1;
//
// 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, "金額"));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@最大金額", System.Data.SqlDbType.VarChar, 10, "最大金額"));
//
// 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) 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("@最大金額", 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));
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));
//
// 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) 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));
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取款機(jī)";
//
// label1
//
this.label1.Enabled = false;
this.label1.Location = new System.Drawing.Point(168, 24);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(88, 32);
this.label1.TabIndex = 9;
this.label1.Text = "label1";
this.label1.Visible = false;
//
// label2
//
this.label2.Enabled = false;
this.label2.Location = new System.Drawing.Point(272, 24);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(64, 32);
this.label2.TabIndex = 10;
this.label2.Text = "label2";
this.label2.Visible = false;
//
// Form2
//
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.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.button3);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "Form2";
this.Text = "主要功能";
this.ResumeLayout(false);
}
#endregion
private void button1_Click(object sender, System.EventArgs e)
{
Form4 frm =new Form4();
frm.ShowDialog();
this.Close ();
}
private void button2_Click(object sender, System.EventArgs e)
{
sqlConnection1.Open();
string strin2="select 金額,最大金額 from 用戶表 where 用戶帳號='" + ATM取款機(jī).Form1.kanum + "'";
SqlCommand cmd2=new SqlCommand(strin2,sqlConnection1);
SqlDataReader dr2=cmd2.ExecuteReader();
if(dr2.Read())
{
label1.Text=dr2.GetString(0).ToString();
label2.Text=dr2.GetString(1).ToString();
dr2.Close();
int c;
int d;
c=int.Parse(label1.Text);
d=int.Parse(label2.Text);
if(c>0 && d>0)
{
Form3 frm =new Form3();
frm.Show();
this.Close();
}
else
MessageBox.Show("余額不足,或你今天已經(jīng)取足了,不能再取!", "超支錯(cuò)誤", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
sqlConnection1.Close();
}
private void button3_Click(object sender, System.EventArgs e)
{
Application.Exit();
}
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -