コード例 #1
0
        public static Accounts ViewTransactions(int userID)
        {
            Console.Write("Which List of Transactions Would You Like to See? \n");
            var acc = GetAccounts.GetAccount(userID);

            Console.Clear();

            Console.Write("All Transactions for {0} - {1} \n\n", acc.accountID, acc.accountType);
            int count = 1;

            try
            {
                foreach (var i in acc.transactions)
                {
                    Console.WriteLine(count + ". " + i);
                    count++;
                }
            }
            catch (Exception)
            {
                Console.WriteLine("\nThere have not been any transactions on this account \n");
            }
            Console.WriteLine("");

            Console.WriteLine("\nPress <ENTER> to return to Main Menu...");
            Console.ReadLine();
            Console.Clear();

            return(null);
        }
コード例 #2
0
        public static void CloseAccount(int userID)
        {
            Console.WriteLine("Select Which Account You Would Like to Close");
            var acc      = GetAccounts.GetAccount(userID);
            var accExist = AccountsBL.CloseAccount(acc.userID, acc.accountID);

            if (accExist == null)
            {
                Console.WriteLine("Your Account Has Successfully Been Closed");
            }
            Console.WriteLine("\nPress <ENTER> to continue...");
            Console.ReadLine();
            Console.Clear();
        }
コード例 #3
0
        public static void Deposit(int userID)
        {
            Console.WriteLine("**You Can Deposit Into a Loan Account to Make a Payment**\n");
            var acc = GetAccounts.GetAccount(userID);

            Console.Clear();

            bool cond = true;

            do
            {
                if ((acc.accountType == "Term Deposit Account"))
                {
                    Console.Write("Cannot Deposit Into a {0}. \nPlease Choose a Valid Account: ", acc.accountType);
                    acc = GetAccounts.GetAccount(userID);
                }
                else
                {
                    cond = false;
                }
            } while (cond);

            Console.WriteLine("Depositing to {1} - {0} \nBalance of ${2}\n", acc.accountID, acc.accountType, acc.balance);
            double ammount = 0;

            cond = true;
            bool cond2 = true;

            do
            {
                try
                {
                    do
                    {
                        Console.Write("Deposit Amount: $");
                        ammount = Convert.ToDouble(Console.ReadLine());

                        if (ammount.ToString().Split(".")[1].Length != 2)
                        {
                            Console.WriteLine("****Please Enter a Valid Amount****\n");
                        }
                        else
                        {
                            cond2 = false;
                        }
                    } while (cond2);
                    cond = false;
                }
                catch (FormatException)
                {
                    Console.WriteLine("****Please Enter a Valid Amount****\n");
                }
                catch (IndexOutOfRangeException)
                {
                    cond = false;
                }
                catch (Exception ex)
                {
                    Console.WriteLine("A fatal error has been logged. Please try again\n");
                }
            } while (cond);

            double newBal      = ammount + acc.balance;
            string transaction = "Deposited " + ammount + " into account";

            acc = AccountsBL.UpdateBalance(acc.userID, acc.accountID, newBal);
            acc = AccountsBL.AddTransaction(acc.userID, acc.accountID, transaction);

            Console.WriteLine("\nYour New Balance is $" + newBal);
            Console.WriteLine("\nPress <ENTER> to continue...");
            Console.ReadLine();
            Console.Clear();
        }
コード例 #4
0
        public static void Transfer(int userID)
        {
            Console.WriteLine("Which Account Do You Want To Transfer From? \n");
            var  accFrom = GetAccounts.GetAccount(userID);
            bool cond    = true;

            do
            {
                if (accFrom.accountType == "Term Deposit Account" || accFrom.accountType == "Loan Account")
                {
                    Console.WriteLine("\nCannot Transfer From a {0}. \nPlease choose a Valid Account: ", accFrom.accountType);
                    accFrom = GetAccounts.GetAccount(userID);
                }
                else
                {
                    cond = false;
                }
            } while (cond);

            Console.WriteLine("\n**You Can Transfer Into a Loan Account to Make a Payment**");

            double ammount = -1;

            cond = true;
            bool cond2 = true;

            do
            {
                try
                {
                    do
                    {
                        Console.Write("\nAmount You Want to Transfer: $");
                        ammount = Convert.ToDouble(Console.ReadLine());

                        if (ammount.ToString().Split(".")[1].Length != 2)
                        {
                            Console.WriteLine("****Please Enter a Valid Amount****\n");
                        }
                        else
                        {
                            cond2 = false;
                        }
                    } while (cond2);
                    cond = false;
                }
                catch (FormatException)
                {
                    Console.WriteLine("****Please enter a valid ammount****\n");
                }
                catch (IndexOutOfRangeException)
                {
                    cond = false;
                }
                catch (Exception ex)
                {
                    Console.WriteLine("A fatal error has been logged. Please try again ");
                }
            } while (cond);



            cond  = true;
            cond2 = true;
            do
            {
                if (accFrom.accountType == "Checking Account" && (accFrom.balance - ammount) < 0)
                {
                    //This Do While Handles Exceptions
                    do
                    {
                        try
                        {
                            //This Do While Loops Handles The Decimal Places of the Entered Ammount
                            do
                            {
                                Console.Write("\nInsufficient Funds. \nPlease Enter a Valid Ammount: $");
                                ammount = Convert.ToDouble(Console.ReadLine());

                                if (ammount.ToString().Split(".")[1].Length != 2)
                                {
                                    Console.WriteLine("****Please Enter a Valid Amount****\n");
                                }
                                else
                                {
                                    cond2 = false;
                                }
                            } while (cond2);
                            cond = false;
                        }
                        catch (FormatException)
                        {
                            Console.WriteLine("****Please enter a valid ammount****\n");
                        }
                        catch (IndexOutOfRangeException)
                        {
                            cond = false;
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine("A fatal error has been logged. Please try again ");
                        }
                    } while (cond);
                    cond = true;
                }
                else
                {
                    cond = false;
                }
            } while (cond);

            Console.WriteLine("\nWhich Account Do You Want To Transfer the Money To?\n");
            var accTo = GetAccounts.GetAccount(userID);

            cond = true;
            do
            {
                if (accTo.accountType == "Term Deposit Account")
                {
                    Console.WriteLine("\nCannot Transfer To a {0}. \nPlease choose a Valid Account: ", accTo.accountType);
                    accTo = GetAccounts.GetAccount(userID);
                }
                else
                {
                    cond = false;
                }
            } while (cond);

            Console.WriteLine("\nTransfering {0} From {1}-{2} to {3}-{4}", ammount, accFrom.accountType, accFrom.accountID, accTo.accountType, accTo.accountID);

            //Withdrawing out funds from first account
            double newBal = accFrom.balance - ammount;

            accFrom = AccountsBL.UpdateBalance(accFrom.userID, accFrom.accountID, newBal);
            string transaction = "Transferred " + ammount + " into Account " + accTo.accountID + " from Account " + accFrom.accountID;

            accFrom = AccountsBL.AddTransaction(accFrom.userID, accFrom.accountID, transaction);

            //Depositing funds into second account
            newBal = ammount + accTo.balance;
            accTo  = AccountsBL.UpdateBalance(accTo.userID, accTo.accountID, newBal);
            accTo  = AccountsBL.AddTransaction(accTo.userID, accTo.accountID, transaction);

            Console.WriteLine("Transfer Complete!\n");

            Console.WriteLine("Your New Balance for {0}-{1} is ${2}", accFrom.accountType, accFrom.accountID, accFrom.balance);
            Console.WriteLine("Your New Balance for {0}-{1} is ${2}", accTo.accountType, accTo.accountID, accTo.balance);
            Console.WriteLine("\nPress <ENTER> to continue...");
            Console.ReadLine();
            Console.Clear();
        }
コード例 #5
0
        public static void Withdraw(int userID)
        {
            var acc = GetAccounts.GetAccount(userID);

            Console.Clear();

            bool cond = true;

            do
            {
                if ((acc.accountType == "Term Deposit Account") || (acc.accountType == "Loan Account"))
                {
                    Console.Write("Cannot Withdraw From a {0}. \nPlease Choose a Valid Account: ", acc.accountType);
                    acc = GetAccounts.GetAccount(userID);
                }
                else if (acc.accountType == "Business Account" && acc.balance <= -10000)
                {
                    Console.Write("Cannot Withdraw From {0}. Overdraft Limit Reached! \nPlease Choose a Valid Account: ", acc.accountType);
                    acc = GetAccounts.GetAccount(userID);
                }
                else
                {
                    cond = false;
                }
            } while (cond);
            Console.WriteLine("Withdrawing from {1} - {0} \nBalance of ${2}", acc.accountID, acc.accountType, acc.balance);
            double ammount = 0;

            cond = true;
            bool cond2 = true;

            do
            {
                try
                {
                    do
                    {
                        Console.Write("\nWithdraw Amount: $");
                        ammount = Convert.ToDouble(Console.ReadLine());

                        if (ammount.ToString().Split(".")[1].Length != 2)
                        {
                            Console.WriteLine("****Please Enter a Valid Amount****\n");
                        }
                        else
                        {
                            cond2 = false;
                        }
                    } while (cond2);
                    cond = false;
                }
                catch (FormatException)
                {
                    Console.WriteLine("****Please enter a valid ammount****");
                }
                catch (IndexOutOfRangeException)
                {
                    cond = false;
                }
                catch (Exception ex)
                {
                    Console.WriteLine("A fatal error has been logged. Please try again ");
                }
            } while (cond);

            cond = true;
            do
            {
                if ((acc.accountType == "Checking Account" && (acc.balance - ammount) < 0) || (acc.accountType == "Business Account" && (acc.balance - ammount) < -10000))
                {
                    try
                    {
                        Console.Write("\nInsufficient Funds. \nPlease Enter a Valid Ammount: $");
                        ammount = Convert.ToDouble(Console.ReadLine());
                        cond    = false;
                    }
                    catch (FormatException)
                    {
                        Console.WriteLine("****Please enter a valid ammount****\n");
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("A fatal error has been logged. Please try again ");
                    }
                }
                else
                {
                    cond = false;
                }
            } while (cond);

            double newBal      = acc.balance - ammount;
            string transaction = "Withdrew " + ammount + " into account";

            acc = AccountsBL.UpdateBalance(acc.userID, acc.accountID, newBal);
            acc = AccountsBL.AddTransaction(acc.userID, acc.accountID, transaction);

            Console.WriteLine("\nYour New Balance is $" + newBal);
            Console.WriteLine("\nPress <ENTER> to continue...");
            Console.ReadLine();
            Console.Clear();
        }