예제 #1
0
        public void MakeDeposit(int accNum, decimal amt, string note, AccountType type)
        {
            if (amt < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(amt), "Deposit amount must be positive");
            }

            // add a new deposit
            TransactionClass deposit = new TransactionClass(accNum, amt, note, type.ToString(), DateTime.Now);

            BankdatasClass.Transactions.Add(deposit);
        }
예제 #2
0
        public void MakeWithdrawal(int accNum, decimal amt, string note, AccountType type)
        {
            if (amt < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(amt), "Deposit amount must be positive");
            }

            if (type.ToString() == "Savings" && Balance - amt < 100)
            {
                throw new ArgumentOutOfRangeException("You don't have sufficient fund for this operation");
            }

            if (type.ToString() == "Current" && Balance - amt < 1000)
            {
                throw new InvalidOperationException("You don't have sufficient fund for this operation");
            }

            // add a new deposit
            TransactionClass withdrawal = new TransactionClass(accNum, -amt, note, type.ToString(), DateTime.Now);

            BankdatasClass.Transactions.Add(withdrawal);
        }