public double WithdrawAmount(int accno, decimal amt) { foreach (SBAccount item in salist) { if (item.AccountNumber == accno) { if (item.CurrentBalance < Convert.ToDouble(amt)) { throw new BankingException("Not Enough Money"); } else { item.CurrentBalance -= Convert.ToDouble(amt); SBTransaction t = new SBTransaction(); t.TransactionId = ctr + 1; t.TransactionDate = DateTime.Now; t.TransactionType = "Savings"; t.AccountNumber = accno; t.Amount = Convert.ToDouble(amt); stlist.Add(t); return(item.CurrentBalance); } } } return(0); }
public double DepositAmount(int accno, decimal amt) { foreach (SBAccount item in salist) { if (item.AccountNumber == accno) { item.CurrentBalance += Convert.ToDouble(amt); SBTransaction t = new SBTransaction(); t.TransactionId = ctr + 1; t.TransactionDate = DateTime.Now; t.TransactionType = "Savings"; t.AccountNumber = accno; t.Amount = Convert.ToDouble(amt); stlist.Add(t); return(item.CurrentBalance); } } return(0); }