private static void TermDepositWithdraw(ITermDeposit termDeposit) { while (true) { try { Console.Write("\n\nEnter withdrawal amount: "); double amount = Convert.ToDouble(Console.ReadLine()); bool status = FinancialOperations.Withdraw(termDeposit, amount); if (status == true) { Console.WriteLine("WITHDRAWAL WAS SUCCESSFUL!!\n\nPress any key to continue..."); Console.ReadKey(); break; } else { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("\nWITHDRAWAL WAS UNSUCCESSFUL! THE WITHDRAWAL AMOUNT EXCEEDS THE ACCOUNT BALANCE"); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("\nPress any key to continue..."); Console.ReadKey(); break; } } catch (Exception e) { CatchHandler(e); } } }
public static bool Withdraw(ITermDeposit termDeposit, double amount) { bool status; ITransaction transaction = new BankTransaction(amount, TypeFactory.WithdrawalTransaction, DateTime.Now, TypeFactory.GenerateTransactionID()); status = termDeposit.Withdraw(transaction); return(status); }
private static void TermDepositTransactionList(ITermDeposit termDeposit) { var transactions = termDeposit.AccountTransactions; if (transactions.Count == 0) { Console.WriteLine("\n\nTHERE HAVE BEEN NO TRANSACTIONS MADE ON THIS ACCOUNT."); } foreach (ITransaction t in transactions) { Console.WriteLine(); Console.WriteLine(t.Type + "\n" + "$ " + String.Format("{0:n}", t.Amount) + "\n" + t.TimeOfTransaction.ToString("F") + "\n"); } Console.WriteLine("Press any key to continue"); Console.ReadKey(); }
private static void TermDepositMenu(IBankCustomer bankCustomer) { ITermDeposit termDeposit = TermDepositSelectionMenu(bankCustomer); if (termDeposit == null) { Console.WriteLine("\nYOU HAVE NO TREM DEPOSITS AT THIS TIME.\n\nPress ENTER to continue..."); Console.ReadKey(); return; } int option = 0; while (option != 5) { Console.Clear(); Console.WriteLine(" " + bankCustomer.FirstName + " " + bankCustomer.LastName + "\n"); Console.WriteLine("=================================================================================================="); Console.WriteLine("║ ║"); Console.WriteLine("║ PICK AN OPTION FROM THE TERM DEOPSIT MENU ║"); Console.WriteLine("║ ║"); Console.WriteLine("==================================================================================================\n"); Console.WriteLine("1) Widthdraw 2) Transactions 3 ) Back 4) Logout\n\n"); Console.WriteLine(termDeposit.Type + "\nTerm Deposit issued on: " + termDeposit.DateCreated.ToString("F") + "\nTerm Deposit matures on: " + termDeposit.DateOfMaturity.ToString("F") + "\nAccount number: " + termDeposit.AccountNumber + "\n" + "TermDeposit: $ " + String.Format("{0:n}", termDeposit.Amount) + "\nMaturity Interest Rate: " + termDeposit.InterestRate * 100 + "% APR\n" + "Penalty Rate is: " + termDeposit.PenaltyInterestRate * 100 + "% of Withdrawal Amount\n" + "Balance: $ " + String.Format("{0:n}", termDeposit.Balance)); if (termDeposit.TotalPenalty > 0) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("\nTotal Penalty Amount: $ " + String.Format("{0:n}", termDeposit.TotalPenalty)); Console.ForegroundColor = ConsoleColor.Green; } Console.WriteLine("\n\n"); try { Console.Write("Enter:"); option = Convert.ToInt32(Console.ReadLine()); if (option == 1) { TermDepositWithdraw(termDeposit); } else if (option == 2) { TermDepositTransactionList(termDeposit); } else if (option == 3) { break; } else if (option == 4) { Logout(); } else { ErrorHandler(); } } catch (Exception e) { CatchHandler(e); } } }
private static void OpenNewAccount(IBankCustomer bankCustomer) { while (true) { try { Console.Clear(); Console.WriteLine(" " + bankCustomer.FirstName + " " + bankCustomer.LastName + "\n"); Console.WriteLine("=========================================================================================="); Console.WriteLine("║ ║"); Console.WriteLine("║ PICK AN OPTION FROM THE NEW ACOUNTS MENU ║"); Console.WriteLine("║ ║"); Console.WriteLine("==========================================================================================\n"); Console.WriteLine("1) Open Checking Account 2) Open Business Account 3) Request Loan 4) Open Term Deposit 5) back 6) Logout\n\n"); Console.Write("Enter:"); int option = Convert.ToInt32(Console.ReadLine()); if (option == 1) { IAccount account = AdministrativeOperations.OpenAccount(bankCustomer, "Checking Account"); if (account != null) { Console.WriteLine("CHECKING ACCOUNT WITH ACCOUNT NUMBER " + account.AccountNumber + " WAS SUCCESSFULLY CREATED!\n"); } else { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("CHECKING ACCOUNT CREATION FAILED!!!\n"); Console.ForegroundColor = ConsoleColor.Green; } Console.WriteLine("\nPress any key to continue..."); Console.ReadKey(); } else if (option == 2) { IAccount account = AdministrativeOperations.OpenAccount(bankCustomer, "Business Account"); if (account != null) { Console.WriteLine("BUSINESS ACCOUNT WITH ACCOUNT NUMBER " + account.AccountNumber + " WAS SUCCESSFULLY CREATED!\n"); } else { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("BUSINESS ACCOUNT CREATION FAILED!!!\n"); Console.ForegroundColor = ConsoleColor.Green; } Console.WriteLine("\nPress any key to continue..."); Console.ReadKey(); } else if (option == 3) { ILoan loan = null; while (true) { try { Console.Write("1) Personal Loan\n2) Business loan"); Console.Write("\n\nEnter Choice:"); int value = Convert.ToInt32(Console.ReadLine()); Console.Write("\n\nEnter loan amount (must be greater zero):"); double amount = Convert.ToDouble(Console.ReadLine()); if (value == 1 && amount > 0) { loan = AdministrativeOperations.RequestLoan(bankCustomer, amount, "personal loan"); break; } else if (value == 2 && amount > 0) { loan = AdministrativeOperations.RequestLoan(bankCustomer, amount, "business loan"); break; } else { ErrorHandler(); } } catch (Exception e) { CatchHandler(e); } } if (loan != null) { Console.WriteLine("\nLOAN REQUEST FOR $" + loan.Amount + " WAS APPROVED!\nTHE INTEREST RATE ON THE LOAN IS :" + (loan.InterestRate * 100) + "% APR\n"); } else { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("LOAN REQUEST FAILED!!!\n"); Console.ForegroundColor = ConsoleColor.Green; } Console.WriteLine("\nPress any key to continue..."); Console.ReadKey(); } else if (option == 4) { double amount = 0; try { Console.Write("\n\nEnter Term Deposit amount:"); amount = Convert.ToDouble(Console.ReadLine()); } catch (Exception e) { CatchHandler(e); } ITermDeposit termDeposit = AdministrativeOperations.OpenTermDeposit(bankCustomer, amount); if (termDeposit != null) { Console.WriteLine("\nTERM DEPOSIT OF $" + String.Format("{0:n}", amount) + " WAS APPROVED!\nTHE YIELD ON THE ACCOUNT IS " + (termDeposit.InterestRate * 100) + "% APR\n"); } else { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("TERM DEPOSIT REQUEST FAILED!!!\n"); Console.ForegroundColor = ConsoleColor.Green; } Console.WriteLine("\nPress any key to continue..."); Console.ReadKey(); } else if (option == 5) { break; } else if (option == 6) { Logout(); } else { ErrorHandler(); } } catch (Exception e) { CatchHandler(e); } } }