您的位置:首页 > 数据库

银行存取款业务实现(C#非数据库)

2015-11-30 00:00 253 查看
摘要: 简单的c#程序

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace BankSystem
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void label1_Click(object sender, EventArgs e)
{

}

private void timer1_Tick(object sender, EventArgs e)
{
label1.Left = label1.Left - 3;
if (label1.Right < 0)
{

label1.Left = this.Width;

}

}

private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text == "20131214094" && textBox2.Text == "123456" || textBox1.Text == "20131214148" && textBox2.Text == "123456" || textBox1.Text == "20131214187" && textBox2.Text == "123456")
{
MessageBox.Show("欢迎进入个人银行!", "银行系统", MessageBoxButtons.OK,MessageBoxIcon.Warning);

}
else {
MessageBox.Show("您输入的不正确,请重新输入!","数据错误!",MessageBoxButtons.OK,MessageBoxIcon.Warning);
Application.Restart();

}
Form2 frm = new Form2();
frm.Show();
//Form3 frm1 = new Form3();
//frm1.Show();

this.Hide();
// frm.textBox1.Hide();
//  frm.t2.Hide();

}

private void button2_Click(object sender, EventArgs e)
{
Close();
}

private void Form1_Load(object sender, EventArgs e)
{

}
}
}

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace BankSystem
{
public partial class Form2 : Form
{
int m;

Card card = new Card();
public Form2()
{
InitializeComponent();
}

private void button4_Click(object sender, EventArgs e)
{
Close();
Form1 f1 = new Form1();
f1.Show();
}

private void timer1_Tick(object sender, EventArgs e)
{

label1.Left = label1.Left - 3;
if (label1.Right < 0)
{

label1.Left = this.Width;

}
}

private void Form2_Load(object sender, EventArgs e)
{

}

private void label2_Click(object sender, EventArgs e)
{

}

private void textBox1_TextChanged(object sender, EventArgs e)
{

}

private void button1_Click(object sender, EventArgs e)
{
//textBox1.Show();
//textBox1.Text = Convert.ToString("您的余额为"+ Card.smoney+"元人民币!");
MessageBox.Show("您的余额为"+ Card.smoney+"元", "银行系统", MessageBoxButtons.OK, MessageBoxIcon.Warning);

}

private void button3_Click(object sender, EventArgs e)
{
//button2.Hide();
//button3.Hide();
//button4.Hide();
//button5.Hide();

if (Card.number > 0)
{

m = Convert.ToInt32(int.Parse(t2.Text));

if (m > 5000)
{
MessageBox.Show("已达到最大金额上限", "银行系统", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
else if (m % 100 != 0 || m < 100)
{

MessageBox.Show("请输入100的整数倍", "银行系统", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
else {

card.store(m);
card.currentMoney += m;
card.ti++;
Card.number--;

MessageBox.Show("存款成功", "银行系统", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}

t2.Text = " ";
if (Card.smoney > 5000)
{
MessageBox.Show("已达到金额上限", "银行系统", MessageBoxButtons.OK, MessageBoxIcon.Warning);

}

}
else { MessageBox.Show("已达到操作上限", "银行系统", MessageBoxButtons.OK, MessageBoxIcon.Warning); }

}

private void button2_Click(object sender, EventArgs e)
{
int n;
n = Convert.ToInt32(int.Parse(t2.Text));
if (n% 100 != 0 || n < 100)
{

MessageBox.Show("请输入100的整数倍", "银行系统", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
else
{

card.quqian(n);
card.ti2++;
card.currentMoney2 -= n;

MessageBox.Show("取款成功", "银行系统", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}

t2.Text = " ";
if (Card.smoney < 0) {

MessageBox.Show("余额不足", "银行系统", MessageBoxButtons.OK, MessageBoxIcon.Warning);

}
else if (Card.smoney > 5000) {
MessageBox.Show("已达到金额上限", "银行系统", MessageBoxButtons.OK, MessageBoxIcon.Warning);

}

}

private void button5_Click(object sender, EventArgs e)
{
// textBox1.Show();
// textBox1.Text = Convert.ToString("您的总存款次数为" + card.ti + "次!" + "您的总存款金额为" + System.Math.Abs(card.currentMoney) + "元" + "\r\n" + "您的总取款次数为" + card.ti2 + "次!" + "您的总取款金额为" + System.Math.Abs(card.currentMoney2) + "元");
MessageBox.Show("您的总存款次数为" + card.ti + "次!" + "您的总存款金额为" + System.Math.Abs(card.currentMoney) + "元" + "\r\n" + "您的总取款次数为" + card.ti2 + "次!" + "您的总取款金额为" + System.Math.Abs(card.currentMoney2) + "元", "银行系统", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
}

using System;
using System.Collections;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BankSystem
{
class Card
{

public static decimal smoney = 0;

public decimal balance;

public  static int number=5;

public int c;

public int currentMoney = 0;

public int  currentMoney2 = 0;

public int ti;

public int ti2;

public void store(decimal Money)
{

if (smoney < 5000)
{

smoney += Money;

}

}

public void quqian(decimal M)
{

{
if (smoney < 5000)
{

smoney -= M;

}
}

}

////执行次数与设定次数比较
//if (currentNum == number)
//{

//   s = 0;

//    return;

//}
////当前余额是否足以取款
//if (balance + Money < 0)
//{

//    s = -1;

//    return;

//}

//if (Money < -5000 || Money > 5000)
//{

//    s = 2;

//    return;

//}
//smoney += System.Math.Abs(Money);

//if (Money > 5000)
//{

//  s = 2;

//    return;

//}

//currentMoney[currentNum] = Money;

//balance += Money;

//currentNum++;

//s = 1;
}

//    public static int Number
//    {
//        get { return Card.number; }

//        set { Card.number = value; }
//    }

//    public long CardNo1
//    {
//        get { return CardNo; }

//        set { CardNo = value; }
//    }
//}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: