int DoWithdrawing(int withdraw_amount, string currentUserId)
        {
            char?choiceYN = InputHandlerFromConsole.GetYN($"Are you sure you want to withdraw Rs.{withdraw_amount} (Y/N)? ");

            if (choiceYN == 'y' || choiceYN == 'Y')
            {
                if (bll.feasibleToWithdraw(withdraw_amount, currentUserId))  //// true is have enough balance
                {
                    if (bll.checkWithdrawLimit(withdraw_amount, currentUserId))
                    {
                        // if acoount have enough balance
                        bll.withdrawAmount(withdraw_amount, currentUserId);
                        Console.WriteLine($"Cash Successfully Withdrawm, {withdraw_amount}!");
                        return(1);
                    }
                    else // you crossed per day limit
                    {
                        return(-11);
                    }
                }
                else    // false: if don't have enough balance
                {
                    return(-1);
                }
            }
            return(0);
        }
Exemplo n.º 2
0
        public void ContinueToViewTransactionReports()
        {
            string startingDate = InputHandlerFromConsole.GetDate("Enter the starting date (dd/mm/yyyy): ");
            string endingDate   = InputHandlerFromConsole.GetDate("Enter the ending date (dd/mm/yyyy): ");

            Console.WriteLine(startingDate);
            Console.WriteLine(endingDate);

            List <string> result = new List <string>();

            WriteLine("\n==== SEARCH RESULTs ====");
            ForegroundColor = ConsoleColor.DarkGreen;
            WriteLine("Transaction Type, User ID, Holder Name, Type, Amount, Date, TO whom: if Transfer");
            ForegroundColor = ConsoleColor.White;
            result          = bll.getSearchResultBTdates(startingDate, endingDate);
            if (result == null)
            {
                WriteLine("==== No Found ====");
                return;
            }
            foreach (string res in result)
            {
                WriteLine(res);
            }
        }
/////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////

        /////// transfer cash
        public void ContinueToTransferCash(string currentUserId)
        {
enterAgmin:
            int amountToTransfer = Convert.ToInt32(InputHandlerFromConsole.GetNumberInRange(1, int.MaxValue, "Enter amount in multiple of 500: "));

            if (amountToTransfer % 500 != 0)
            {
                goto enterAgmin;
            }

            int accountNo1 = Convert.ToInt32(InputHandlerFromConsole.GetNumberInRange(1, int.MaxValue, "Enter the account number to which you want to transfer: "));

            string name = bll.getAccountHolderNameWithAccountNo(accountNo1);

            if (name == "")
            {
                WriteLine("No such Account Number exits.");
                return;
            }

            int accountNo2 = Convert.ToInt32(InputHandlerFromConsole.GetNumberInRange(1, int.MaxValue, $"You wish to deposit Rs. {amountToTransfer} in account held by Mr. {name}; If this information is correct please re-enter the account number: "));

            if (accountNo1 == accountNo2)
            {
                string msg = bll.TransferAmountTo(accountNo1, amountToTransfer, currentUserId) ? "Transaction Confirmed Successfully" : "Some Error has occurred while performing the operation.";
                WriteLine(msg);
                printRecipt(amountToTransfer, currentUserId, "Cash Transfer");
            }
            else
            {
                WriteLine("Alas! You re-entered account number doesn't match. Press Any Key to go to main menu.");
            }
        }
Exemplo n.º 4
0
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
        public void ContinueToUpdateAccount()
        {
            int      accountNo = Convert.ToInt32(InputHandlerFromConsole.GetNumberInRange(1, int.MaxValue, "Enter the Account Number: "));
            Customer c         = bll.getCustomer(accountNo);

            if (c == null)
            {
                WriteLine("Invalid Account Number!");
                return;
            }
            OutputHandlerToConsole.DisplayCustoemr(c);

            ForegroundColor = ConsoleColor.DarkMagenta;
            Write("Please enter in the fields you wish to update(leave blank otherwise): ");
            ForegroundColor = ConsoleColor.White;

            Customer updatedCustomer = InputHandlerFromConsole.GetFieldsForUpdatingAccount(accountNo);

            updatedCustomer.AccountNo = accountNo;
            if (updatedCustomer.UserId == "")
            {
                updatedCustomer.UserId = c.UserId;
            }

            if (updatedCustomer.PinCode == "")
            {
                updatedCustomer.PinCode = c.PinCode;
            }

            if (updatedCustomer.AccountHolderName == "")
            {
                updatedCustomer.AccountHolderName = c.AccountHolderName;
            }

            if (updatedCustomer.AccountType == "")
            {
                updatedCustomer.AccountType = c.AccountType;
            }

            updatedCustomer.AccountBalance = c.AccountBalance;

            if (updatedCustomer.Status == "")
            {
                updatedCustomer.Status = c.Status;
            }

            OutputHandlerToConsole.DisplayCustoemr(updatedCustomer);

            if (bll.UpdateCustomer(updatedCustomer))
            {
                WriteLine("Your account have been successfully been updated!");
            }
            else
            {
                ForegroundColor = ConsoleColor.DarkMagenta;
                WriteLine("There is some problem while updating the account information!");
                ForegroundColor = ConsoleColor.White;
            }
        }
Exemplo n.º 5
0
        /// <summary>
        ///     Admin functionality for ATM_VIEW Layer
        /// </summary>
        ///
        public void continueToCreateNewAccount()
        {
            Customer cust = InputHandlerFromConsole.GetCreateNewAccountInput();

            char?choiceYN = InputHandlerFromConsole.GetYN($"Are you sure you want to Create New Account (Y/N)? ");

            if (choiceYN == 'y' || choiceYN == 'Y')
            {
                int accountNo = bll.createNewAccount(cust);
                WriteLine($"Account Successfully Created! - the account number assigned is: {accountNo}");
            }
        }
        public void printRecipt(int amount, string userId, string msg)
        {
            char?choicePrinting = InputHandlerFromConsole.GetYN($"Are you want to print Recipt (Y/N)? ");

            if (choicePrinting == 'Y' || choicePrinting == 'y')
            {
                WriteLine("\n\n=======================================");
                WriteLine("\t---- Print Recipt ----");
                WriteLine($"\t---- {msg} ----");
                WriteLine($"\tDate: {DateTime.Now}");
                WriteLine($"\tAmount: {amount}");
                WriteLine("=======================================");
            }
        }
/////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////

        public void ContinueToDespositAmount(string currentUserId)
        {
            int amountTodeposit = Convert.ToInt32(InputHandlerFromConsole.GetNumberInRange(1, int.MaxValue, "Enter the cash amount to deposit: "));
            int accountNo       = bll.getAccountNo(currentUserId);

            if (bll.depositAmount(accountNo, amountTodeposit))
            {
                WriteLine("Cash Deposited Successfully!");
                printRecipt(amountTodeposit, currentUserId, "Cash Deposit");
            }
            else
            {
                WriteLine("Cash Deposited unsuccessfully");
            }
        }
Exemplo n.º 8
0
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
        public void ContinueToSearchAccount()
        {
            Customer      c = InputHandlerFromConsole.GetFieldsForSearchingAccounts();
            List <string> result;

            WriteLine("\n==== SEARCH RESULTs ====");
            WriteLine("Account ID  User ID  Holder Name \t Type \t Balance  Status");
            result = bll.getSearchResult(c);
            if (result == null)
            {
                WriteLine("==== No Found ====");
                return;
            }
            foreach (string res in result)
            {
                WriteLine(res);
            }
        }
        ///// withdraw through Normal Mode
        public void ContinueToWithdrawThroughNormalMode(string currentUserId)
        {
            int withdraw_amount = Convert.ToInt32(InputHandlerFromConsole.GetNumberInRange(int.MinValue, int.MaxValue, "Enter the withdrawal amount: "));

            int r = DoWithdrawing(withdraw_amount, currentUserId); // common method to deduct amount from account balance

            if (r == 1)
            {
                printRecipt(withdraw_amount, currentUserId, "Cash Withdrawn");
            }
            else if (r == -1)
            {
                WriteLine("No Enough Balance is in the Account.");
            }
            else if (r == -11)
            {
                WriteLine("You crossed your per day @Limit");
            }
        }
Exemplo n.º 10
0
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
        public void ContinueToViewCustomersReports()
        {
            int minBalance = Convert.ToInt32(InputHandlerFromConsole.GetNumberInRange(0, int.MaxValue, "Enter minimum amount: "));
            int maxBalance = Convert.ToInt32(InputHandlerFromConsole.GetNumberInRange(minBalance, int.MaxValue, "Enter minimum amount: "));

            List <string> result = new List <string>();

            WriteLine("\n==== SEARCH RESULTs ====");
            WriteLine("Account ID \t User ID \t Holder Name \t\t Type \t\t Balance \t Status");
            result = bll.getSearchResultBTbalance(minBalance, maxBalance);
            if (result == null)
            {
                WriteLine("==== No Found ====");
                return;
            }
            foreach (string res in result)
            {
                WriteLine(res);
            }
        }
Exemplo n.º 11
0
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
        public void ContinueToDeleteAccount()
        {
            int    accountNo1 = Convert.ToInt32(InputHandlerFromConsole.GetNumberInRange(1, int.MaxValue, "Enter the account number to which you want to delete: "));
            string name       = bll.getAccountHolderNameWithAccountNo(accountNo1);

            if (name == "")
            {
                WriteLine("No such Account Number exits.");
                return;
            }
            int accountNo2 = Convert.ToInt32(InputHandlerFromConsole.GetNumberInRange(1, int.MaxValue, $"You wish to delete the account held by Mr. {name}; If this information is correct please re-enter the account number: "));

            if (accountNo1 == accountNo2)
            {
                string msg = bll.deleteAccount(accountNo1) ? "Account Deleted Successfully" : "Some Error has occurred while performing the operation.";
                WriteLine(msg);
            }
            else
            {
                WriteLine("Alas! You re-entered account number doesn't match. Press Any Key to go to main menu.");
            }
        }
        ///// withdraw through Fast Mode
        public void ContinueToWithdrawThroughFastMode(string currentUserId)
        {
            menus.FastCashMenu();
            int?withdrawChoice  = InputHandlerFromConsole.GetNumberInRange(1, 7, "Select one of the denominations of money: ");
            int?withdraw_amount = 500;

            setAmount(ref withdraw_amount, withdrawChoice);

            int r = DoWithdrawing(Convert.ToInt32(withdraw_amount), currentUserId); // common method to deduct amount from account balance

            if (r == 1)
            {
                printRecipt(Convert.ToInt32(withdraw_amount), currentUserId, "Cash Withdrawn <Fast Mode>");
            }
            else if (r == -1)
            {
                WriteLine("No Enough Balance is in the Account.");
            }
            else if (r == -11)
            {
                WriteLine("You crossed your per day @Limit");
            }
        }
Exemplo n.º 13
0
        /*
         * First Activity
         */
        public void loginToProceed()
        {
            Console.WriteLine("Setting up the Storage System...!");
            bll.settingUp();
again:

            menus.LogInScreen();                                                       // display LOGIN
            (string userId, string pinCode) = InputHandlerFromConsole.GetLogInInput(); // Take login credantials from user


            // business Object to transfer information among layers
            Users loginUser = new Users();

            currentUserId     = loginUser.UserId = userId;
            loginUser.PinCode = pinCode;


            // Business Logic Layer => BLL layer functions come in...
            int c = bll.VerifyLoginWith(loginUser);     //


            /////////////////////// Accordingly Change the View ///////////////////////
            if (c == -1)         ////////////////////< -1=Three number of turn over >////////////////////
            {
                ForegroundColor = ConsoleColor.DarkRed;
                InputHandlerFromConsole.DisplayMsgAndWaitForUserResponse("Account is Disabled!" +
                                                                         "\nIncorrect Credentials Entered for consecutive 3 times for the same account...." +
                                                                         "\nContact Admin\n Press Enter to goto Login Page");
                ForegroundColor = ConsoleColor.White;
                goto again;
            }
            else if (c == 0)       ////////////////////< 0-NotUserExists for given userId >////////////////////
            {
                ForegroundColor = ConsoleColor.Red;
                InputHandlerFromConsole.DisplayMsgAndWaitForUserResponse("Not a correct Account Login!" +
                                                                         "\nIncorrect Credentials Entered" +
                                                                         "\nContact Admin\n Press Enter to goto Login Page");
                ForegroundColor = ConsoleColor.White;
                goto again;
            }
            else if (c == 3)       ////////////////////< 3-Incorrect Credentials >////////////////////
            {
                ForegroundColor = ConsoleColor.Yellow;
                InputHandlerFromConsole.DisplayMsgAndWaitForUserResponse("Incorrect Account Credentials!" +
                                                                         "\nContact Admin in case you forgot.\n Press Enter to goto Login Page");
                ForegroundColor = ConsoleColor.White;
                goto again;
            }
            else if (c == 1)    ////////////////////< 1-Customer >////////////////////
            {
CustomerAgain:
                menus.MenuHeader();   // display header
                menus.CustomerMenu(); // display Customer Menu

                int?choice = InputHandlerFromConsole.GetNumberInRange(1, 5, "Please select one of the above options: ");

                if (choice == 1)   // withdraw cash
                {
                    menus.WithdrawCashMenu();
                    int?withdrawChoice = InputHandlerFromConsole.GetNumberInRange(1, 2, "Please select a mode of widthdraw: ");
                    if (withdrawChoice == 1)    // fast Mode
                    {
                        ContinueToWithdrawThroughFastMode(currentUserId);
                        ReadKey();
                        goto CustomerAgain;
                    }
                    else if (withdrawChoice == 2)   // normal mode
                    {
                        ContinueToWithdrawThroughNormalMode(currentUserId);
                        ReadKey();
                        goto CustomerAgain;
                    }
                }
                else if (choice == 2) // cash transfer
                {
                    ContinueToTransferCash(currentUserId);
                    ReadKey();
                    goto CustomerAgain;
                }
                else if (choice == 3) // deposit cash
                {
                    ContinueToDespositAmount(currentUserId);
                    ReadKey();
                    goto CustomerAgain;
                }
                else if (choice == 4)    // display balance
                {
                    ContinueToViewBalance(currentUserId);
                    ReadKey();
                    goto CustomerAgain;
                }
                else if (choice == 5) // logout- EXIt
                {
                    goto again;
                }
            }
            else if (c == 2)       ////////////////////< 2-Admin >////////////////////
            {
AdminAgain:
                menus.MenuHeader(); // display header
                menus.AdminMenu();  // display Admin Menu

                int?choice = InputHandlerFromConsole.GetNumberInRange(1, 6, "Please select one of the above options: ");

                if (choice == 1)   // create new Account
                {
                    continueToCreateNewAccount();
                    ReadKey();
                    goto AdminAgain;
                }
                else if (choice == 2) // Delete Existing Account
                {
                    ContinueToDeleteAccount();
                    ReadKey();
                    goto AdminAgain;
                }
                else if (choice == 3) // Update Account Information
                {
                    ContinueToUpdateAccount();
                    ReadKey();
                    goto AdminAgain;
                }
                else if (choice == 4)    // Search for Account
                {
                    ContinueToSearchAccount();
                    ReadKey();
                    goto AdminAgain;
                }
                else if (choice == 5)    // View Reports
                {
                    menus.ViewReportMenu();
                    int?viewChoice = InputHandlerFromConsole.GetNumberInRange(1, 2, "Select one of the choice: ");
                    if (viewChoice == 1)    // by Balance amount
                    {
                        ContinueToViewCustomersReports();
                        ReadKey();
                        goto AdminAgain;
                    }
                    else if (viewChoice == 2)   // by date
                    {
                        ContinueToViewTransactionReports();
                        ReadKey();
                        goto AdminAgain;
                    }
                }
                else if (choice == 6) // logout- EXit
                {
                    goto again;
                }
            }
        }