银行存取款业务实现(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; }
    //    }
    //}
}


转载于:https://my.oschina.net/u/2538590/blog/537218

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值