📄 mainform.cs
字号:
this.textBox7.Name = "textBox7";
this.textBox7.PasswordChar = '*';
this.textBox7.Size = new System.Drawing.Size(144, 21);
this.textBox7.TabIndex = 3;
this.textBox7.Text = "";
//
// label7
//
this.label7.Location = new System.Drawing.Point(352, 24);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(56, 23);
this.label7.TabIndex = 2;
this.label7.Text = "口令:";
//
// textBox6
//
this.textBox6.Location = new System.Drawing.Point(88, 24);
this.textBox6.Name = "textBox6";
this.textBox6.Size = new System.Drawing.Size(256, 21);
this.textBox6.TabIndex = 1;
this.textBox6.Text = "";
//
// label6
//
this.label6.Location = new System.Drawing.Point(8, 24);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(72, 23);
this.label6.TabIndex = 0;
this.label6.Text = "帐号:";
//
// groupBox3
//
this.groupBox3.Controls.Add(this.button6);
this.groupBox3.Controls.Add(this.button5);
this.groupBox3.Controls.Add(this.comboBox2);
this.groupBox3.Controls.Add(this.label12);
this.groupBox3.Controls.Add(this.textBox10);
this.groupBox3.Controls.Add(this.label11);
this.groupBox3.Controls.Add(this.textBox9);
this.groupBox3.Controls.Add(this.label10);
this.groupBox3.Location = new System.Drawing.Point(32, 240);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(672, 96);
this.groupBox3.TabIndex = 2;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "卡号信息";
//
// button6
//
this.button6.Location = new System.Drawing.Point(576, 56);
this.button6.Name = "button6";
this.button6.TabIndex = 7;
this.button6.Text = "消卡";
this.button6.Click += new System.EventHandler(this.button6_Click);
//
// button5
//
this.button5.Location = new System.Drawing.Point(576, 24);
this.button5.Name = "button5";
this.button5.TabIndex = 6;
this.button5.Text = "办卡";
this.button5.Click += new System.EventHandler(this.button5_Click);
//
// comboBox2
//
this.comboBox2.Location = new System.Drawing.Point(88, 56);
this.comboBox2.Name = "comboBox2";
this.comboBox2.Size = new System.Drawing.Size(256, 20);
this.comboBox2.TabIndex = 5;
//
// label12
//
this.label12.Location = new System.Drawing.Point(8, 56);
this.label12.Name = "label12";
this.label12.Size = new System.Drawing.Size(72, 23);
this.label12.TabIndex = 4;
this.label12.Text = "帐号:";
//
// textBox10
//
this.textBox10.Location = new System.Drawing.Point(416, 24);
this.textBox10.Name = "textBox10";
this.textBox10.PasswordChar = '*';
this.textBox10.Size = new System.Drawing.Size(144, 21);
this.textBox10.TabIndex = 3;
this.textBox10.Text = "";
//
// label11
//
this.label11.Location = new System.Drawing.Point(352, 24);
this.label11.Name = "label11";
this.label11.Size = new System.Drawing.Size(48, 23);
this.label11.TabIndex = 2;
this.label11.Text = "口令:";
//
// textBox9
//
this.textBox9.Location = new System.Drawing.Point(88, 24);
this.textBox9.Name = "textBox9";
this.textBox9.Size = new System.Drawing.Size(256, 21);
this.textBox9.TabIndex = 1;
this.textBox9.Text = "";
//
// label10
//
this.label10.Location = new System.Drawing.Point(8, 24);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(72, 23);
this.label10.TabIndex = 0;
this.label10.Text = "卡号:";
//
// groupBox4
//
this.groupBox4.Controls.Add(this.listBox1);
this.groupBox4.Location = new System.Drawing.Point(32, 344);
this.groupBox4.Name = "groupBox4";
this.groupBox4.Size = new System.Drawing.Size(192, 176);
this.groupBox4.TabIndex = 3;
this.groupBox4.TabStop = false;
this.groupBox4.Text = "帐号显示信息";
//
// listBox1
//
this.listBox1.ItemHeight = 12;
this.listBox1.Location = new System.Drawing.Point(8, 16);
this.listBox1.Name = "listBox1";
this.listBox1.Size = new System.Drawing.Size(176, 148);
this.listBox1.TabIndex = 0;
this.listBox1.DoubleClick += new System.EventHandler(this.listBox1_DoubleClick);
this.listBox1.SelectedIndexChanged += new System.EventHandler(this.listBox1_SelectedIndexChanged);
//
// groupBox5
//
this.groupBox5.Controls.Add(this.richTextBox1);
this.groupBox5.Location = new System.Drawing.Point(424, 344);
this.groupBox5.Name = "groupBox5";
this.groupBox5.Size = new System.Drawing.Size(280, 176);
this.groupBox5.TabIndex = 4;
this.groupBox5.TabStop = false;
this.groupBox5.Text = "操作信息";
//
// richTextBox1
//
this.richTextBox1.Location = new System.Drawing.Point(8, 16);
this.richTextBox1.Name = "richTextBox1";
this.richTextBox1.Size = new System.Drawing.Size(408, 152);
this.richTextBox1.TabIndex = 0;
this.richTextBox1.Text = "";
//
// groupBox7
//
this.groupBox7.Controls.Add(this.listBox2);
this.groupBox7.Location = new System.Drawing.Point(224, 344);
this.groupBox7.Name = "groupBox7";
this.groupBox7.Size = new System.Drawing.Size(192, 176);
this.groupBox7.TabIndex = 5;
this.groupBox7.TabStop = false;
this.groupBox7.Text = "卡号信息";
//
// listBox2
//
this.listBox2.ItemHeight = 12;
this.listBox2.Location = new System.Drawing.Point(8, 16);
this.listBox2.Name = "listBox2";
this.listBox2.Size = new System.Drawing.Size(184, 148);
this.listBox2.TabIndex = 0;
//
// MainForm
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(744, 525);
this.Controls.Add(this.groupBox7);
this.Controls.Add(this.groupBox5);
this.Controls.Add(this.groupBox4);
this.Controls.Add(this.groupBox3);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.groupBox1);
this.Name = "MainForm";
this.Text = "操作主窗口";
this.groupBox1.ResumeLayout(false);
this.groupBox6.ResumeLayout(false);
this.groupBox2.ResumeLayout(false);
this.groupBox3.ResumeLayout(false);
this.groupBox4.ResumeLayout(false);
this.groupBox5.ResumeLayout(false);
this.groupBox7.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new MainForm());
}
//初始化
private void init()
{
bank=new Bank.Bank();
ArrayList list=bank.GetAllAccounts();
foreach(string item in list)
{
listBox1.Items.Add(item);
comboBox2.Items.Add(item);
}
list=bank.GetAllCustomers();
foreach(string item in list)
{
comboBox1.Items.Add(item);
}
listBox1.SelectedIndex=0;
comboBox1.SelectedIndex=0;
comboBox2.SelectedIndex=0;
}
//注册客户
private void button1_Click(object sender, System.EventArgs e)
{
string CustomerID=textBox1.Text;
string Name=textBox2.Text;
string Gender;
if(radioButton1.Checked)
Gender="男";
else
Gender="女";
DateTime Birthday=DateTime.Parse(textBox3.Text);
string Address=textBox5.Text;
string Phone=textBox4.Text;
if(bank.CreateCustomer(CustomerID,Name,Gender,Birthday,Address,Phone))
{
comboBox1.Items.Add(CustomerID);
richTextBox1.AppendText("注册客户成功!\r\n");
}
else
{
richTextBox1.AppendText("注册客户失败!\r\n");
}
}
//注销客户
private void button2_Click(object sender, System.EventArgs e)
{
string CustomerID=textBox1.Text;
ArrayList list=bank.GetAllCustomers();
if(list.Contains(CustomerID))
{
ArrayList accounts=bank.GetAllAccountsByCustomerID(CustomerID);
foreach(string account in accounts)
{
ArrayList cards=bank.GetAllCardsByAccountNo(account);
foreach(string card in cards)
{
bank.DeleteCard(card);
}
bank.DeleteAccount(account);
comboBox2.Items.Remove(account);
listBox1.Items.Remove(account);
}
bank.DeleteCustomer(CustomerID);
comboBox1.Items.Remove(CustomerID);
richTextBox1.AppendText("注销客户成功,所有与该客");
richTextBox1.AppendText("户有关的帐号和卡号都已经删除!\r\n");
}
else
{
richTextBox1.AppendText("要注销的客户不存在!\r\n");
}
}
//开户
private void button3_Click(object sender, System.EventArgs e)
{
string AccountNo=textBox6.Text;
string Password=textBox7.Text;
decimal Balance=decimal.Parse(textBox8.Text);
string CustomerID=comboBox1.SelectedItem.ToString();
if(bank.CreateAccount(AccountNo,CustomerID,Password,Balance))
{
comboBox2.Items.Add(AccountNo);
listBox1.Items.Add(AccountNo);
richTextBox1.AppendText("开户成功!\r\n");
}
else
{
richTextBox1.AppendText("开户失败!\r\n");
}
}
//消户
private void button4_Click(object sender, System.EventArgs e)
{
string AccountNo=textBox6.Text;
ArrayList list=bank.GetAllAccounts();
if(list.Contains(AccountNo))
{
ArrayList cards=bank.GetAllCardsByAccountNo(AccountNo);
foreach(string card in cards)
{
bank.DeleteCard(card);
}
bank.DeleteAccount(AccountNo);
listBox1.Items.Remove(AccountNo);
comboBox2.Items.Remove(AccountNo);
richTextBox1.AppendText("消户成功,与该帐号有关的卡号都已删除!\r\n");
}
else
{
richTextBox1.AppendText("你要消的帐号不存在!\r\n");
}
}
//办卡
private void button5_Click(object sender, System.EventArgs e)
{
string CardNo=textBox9.Text;
string Password=textBox10.Text;
string AccountNo=comboBox2.SelectedItem.ToString();
if(bank.CreateCard(CardNo,AccountNo,Password))
{
richTextBox1.AppendText("办卡 成功!\r\n");
}
else
{
richTextBox1.AppendText("办卡失败!\r\n");
}
}
//消卡
private void button6_Click(object sender, System.EventArgs e)
{
string CardNo=textBox9.Text;
ArrayList list=bank.GetAllCards();
if(list.Contains(CardNo))
{
bank.DeleteCard(CardNo);
richTextBox1.AppendText("消卡成功!\r\n");
}
else
{
richTextBox1.AppendText("要取消的卡号不存在!\r\n");
}
}
//处理单个帐号的业务
private void listBox1_DoubleClick(object sender, System.EventArgs e)
{
string AccountNo=listBox1.SelectedItem.ToString();
Form2 AccountForm=new Form2(AccountNo);
AccountForm.Show();
}
//显示所选帐号的所有卡号
private void listBox1_SelectedIndexChanged(object sender, System.EventArgs e)
{
listBox2.Items.Clear();
string AccountNo=listBox1.SelectedItem.ToString();
ArrayList list=bank.GetAllCardsByAccountNo(AccountNo);
foreach(string card in list)
{
listBox2.Items.Add(card);
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -