ATM银行转账系统之数据库存储过程学习

           在网上下了一个关于ATM银行转账系统,里面用到了大量的存储过程,觉得挺好的,对于学习存储过程有很大的帮助!把整个代码粘贴下来!以供以后写存储过程时参考。

  • 4
    点赞
  • 17
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
这是ASP.NET的文档using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ATM { class Bank { private List<Account> accounts; public List<Account> Accounts { get { return accounts; } set { accounts = value; } } private int currentAccountNumber; public int CurrentAccountNumber { get { return currentAccountNumber; } set { currentAccountNumber = value; } } public Bank() { accounts = new List<Account>(); } public Account OpenAccount(string password, string confirmationPassword, string name, string personId, string email, int typeOfAccount) { Account newAccount; if (!password.Equals(confirmationPassword)) { throw new InvalidOperationException("两次密码输入的不一致!"); } switch (typeOfAccount) { case 1: newAccount = new SavingAccount(password, name, personId, email); break; case 2: newAccount = new CreditAccount(password, name, personId, email); break; default:throw new ArgumentOutOfRangeException("账户类型是1到2之间的整数"); } accounts.Add(newAccount); return newAccount; } private Account GetAccountByID(long id) { foreach (Account account in accounts) { if(account.ID==id) { return account; } } return null; } public Account SignIn(long id, string password) { foreach (Account account in accounts) { if (account.ID == id && account.Password.Equals(password)) { return account; } } throw new InvalidOperationException("用户名或者密码不正确,请重试!"); } public Account Deposit(long id, double sum) { Account account = GetAccountByID(id); if (account != null) { account.Deposit(sum); return account; } throw new InvalidOperationException("非法账号!"); } public Account Withdraw(long id, double sum) { Account account = GetAccountByID(id); if (account != null) { account.Withdraw(sum); return account; } throw new InvalidOperationException("非法账号!"); } public Account SetCeiling(long id, double newCeiling) { Account account = GetAccountByID(id); try { (account as CreditAccount).Ceiling = newCeiling; return account; } catch (Exception ex) { throw new InvalidOperationException("此账户不是信用账户!"); } throw new InvalidOperationException("非法账号!"); } public double GetTotalBalance() { double totalBalance = 0; foreach (Account account in accounts) { totalBalance += account.Balance; } return totalBalance; } public double GetTotalCeiling() { double totalCeiling = 0; foreach (Account account in accounts) { if (account is CreditAccount) { totalCeiling += (account as CreditAccount).Ceiling; } } return totalCeiling; } } }

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值