示例#1
0
 public Transactions()
 {
     Balance = new BankBalance();// Holds balance
     if (FileNameMissing())
     {
         SetFileName();
     }
 }
示例#2
0
 public Transactions(decimal StartingBalance)
 {
     Balance = new BankBalance(StartingBalance);
     if (FileNameMissing())
     {
         SetFileName();
     }
 }
示例#3
0
        //Remove the transaction in the list at the given index and add a new transaction at the same position
        public void UpdateTransaction(int Index, Transaction NewTransaction)
        {
            if (IndexIsValid(Index))
            {
                decimal NewAmount = BankBalance.CalculateTransactionAmount(NewTransaction.Amount, NewTransaction.Type);

                RemoveAt(Index);//This will update balance as well
                List.Insert(Index, NewTransaction);
                Balance.AdjustBalance(NewAmount, NewTransaction.Type);
            }
            else
            {
                throw new ApplicationException("Index is out of range, can't update transaction");
            }
        }