c#ATM之功能篇(存钱,取钱,转账,交易明细)完结篇带详细注释。一共七个功能,不难,代码还有优化空间,之后再发一篇ATM之优化篇。
首先先添加一条命名空间
1 | using System.Data.SqlClient; |
1 | public Form3() |
1, button1查询余额的功能
1 | private void button1_Click(object sender, EventArgs e) |
2, button2取钱功能
1 | //取钱的功能:→要判断自己有多少钱,能取的钱不能大于自己的本金,钱不能取负数 |
3, textBox2_KeyPress屏蔽要字母,有这段代码就是文本框里面不能输入字母和符号
1 |
|
4, textBox3_KeyPress屏蔽要字母,有这段代码就是文本框里面不能输入字母和符号
1 | private void textBox3_KeyPress(object sender, KeyPressEventArgs e) |
5, textBox4_KeyPress屏蔽要字母,有这段代码就是文本框里面不能输入字母和符号
1 | private void textBox4_KeyPress(object sender, KeyPressEventArgs e) |
6, button3存钱功能
1 | private void button3_Click(object sender, EventArgs e) |
7.,button4转账功能
1 | private void button4_Click(object sender, EventArgs e) |
8, button5交易明细
1 | private void button5_Click(object sender, EventArgs e) |
9, button6返回登录界面
1 | private void button6_Click(object sender, EventArgs e) |