• 大小: 79KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-05-14
  • 语言: C#
  • 标签: C#  

资源简介

用C#模仿银行ATM自动取款机系统,边学边做的 登陆用户名 t ,p,x 密码和用户名相同

资源截图

代码片段和文件信息

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

using System.Collections;
using System.IO;

namespace Atm
{
    public partial class BussinessForm : Form
    {
        public BussinessForm()
        {
            InitializeComponent();
        }
        //确定
        private void btnConfirm_Click(object sender EventArgs e)
        {
            string name = txtName.Text;
            if (name == null)
            {
                MessageBox.Show(“请输入预转账卡号“);
                return;
            }
            string money = txtMoney.Text;
            if (money == null)
            {
                MessageBox.Show(“请输入转账金额“);
                return;
            }
            if (name.Equals(UserInfo.user.UserName))
            {
                MessageBox.Show(“转账卡号不能为当前卡号“);
                return;
            }
            double m = 0;
            try
            {
                m = Convert.ToDouble(money);
            }
            catch (Exception ex)
            {
                MessageBox.Show(“转账金额必须为数字“);
                return;
            }
            List listUser = new List();
            bool flag = true;       //查看预转账卡号是否存在
            //创建文件输出流
            FileStream fs = new FileStream(“login.txt“FileMode.Open);
            StreamReader sr = new StreamReader(fs);
            while (true)
            {
                string message = sr.ReadLine();
                if (message == null)
                {
                    break;
                }
                string[] info = message.Split(‘^‘);
                if (info[0].Equals(name))
                {
                    info[2] = (Convert.ToDouble(info[2]) + m).ToString();
                    flag = false;
                }
                if (info[0].Equals(UserInfo.user.UserName))
                {
                    if (Convert.ToDouble(info[2]) < m)
                    {
                        MessageBox.Show(“转账失败账户余额不足“);
                        sr.Close();
                        fs.Close();
                        return;
                    }
                    info[2] = (Convert.ToDouble(info[2]) - m).ToString();
                }
                User u = new User();
                u.UserName = info[0];
                u.Pass = info[1];
                u.Balance = Convert.ToDouble(info[2]);
            }
            sr.Close();
            fs.Close();
            if (flag)
            {
                MessageBox.Show(“预转账卡号不存在“);
                return;
            }
            //创建文件输入流
            fs = new FileStream(“login.txt“FileMode.Open);
            StreamWriter sw = new StreamWriter(fs);
            foreach (User u in listUser)
            {
                sw.WriteLine(u.UserName + “^“ + u.Pass + “^“ + u.Balance);
      

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件        898  2009-01-07 13:39  Atm\Atm.sln

    ..A..H.     18432  2009-01-07 20:41  Atm\Atm.suo

     文件       5270  2009-01-07 20:39  Atm\Atm\Atm.csproj

     文件       4764  2009-01-07 20:39  Atm\Atm\BussinessForm.cs

     文件       4780  2009-01-07 20:12  Atm\Atm\BussinessForm.Designer.cs

     文件        348  2009-01-07 14:17  Atm\Atm\FindBalanceForm.cs

     文件       1169  2009-01-07 14:17  Atm\Atm\FindBalanceForm.Designer.cs

     文件       4276  2009-01-07 20:06  Atm\Atm\GetForm.cs

     文件       3829  2009-01-07 19:53  Atm\Atm\GetForm.Designer.cs

     文件       5814  2009-01-07 19:53  Atm\Atm\GetForm.resx

     文件       2601  2009-01-07 19:22  Atm\Atm\LoginForm.cs

     文件       4773  2009-01-07 13:59  Atm\Atm\LoginForm.Designer.cs

     文件       5814  2009-01-07 13:59  Atm\Atm\LoginForm.resx

     文件       2092  2009-01-07 19:18  Atm\Atm\MainForm.cs

     文件       7056  2009-01-07 14:42  Atm\Atm\MainForm.Designer.cs

     文件      12133  2009-01-07 14:42  Atm\Atm\MainForm.resx

     文件        466  2009-01-07 13:39  Atm\Atm\Program.cs

     文件       4791  2009-01-07 19:49  Atm\Atm\SaveForm.cs

     文件       3842  2009-01-07 19:18  Atm\Atm\SaveForm.Designer.cs

     文件       2966  2009-01-07 15:01  Atm\Atm\UpdatePassForm.cs

     文件       5929  2009-01-07 14:29  Atm\Atm\UpdatePassForm.Designer.cs

     文件       5814  2009-01-07 14:29  Atm\Atm\UpdatePassForm.resx

     文件       1184  2009-01-07 13:39  Atm\Atm\Properties\AssemblyInfo.cs

     文件       2860  2009-01-07 13:39  Atm\Atm\Properties\Resources.Designer.cs

     文件       5612  2009-01-07 13:39  Atm\Atm\Properties\Resources.resx

     文件       1086  2009-01-07 13:39  Atm\Atm\Properties\Settings.Designer.cs

     文件        249  2009-01-07 13:39  Atm\Atm\Properties\Settings.settings

     文件        424  2009-01-07 20:41  Atm\Atm\obj\Atm.csproj.FileList.txt

     文件       1161  2009-01-07 20:39  Atm\Atm\obj\Debug\Atm.csproj.GenerateResource.Cache

     文件      40960  2009-01-07 20:39  Atm\Atm\obj\Debug\Atm.exe

............此处省略27个文件信息

评论

共有 条评论