コード例 #1
0
        public void Transfer(int accountNo)
        {
            //create variables for values to get user input in
            string recAccountNo      = default;
            int    recieverAccountNo = default;
            int    accountNoRe       = default;
            int    amount            = default;

            bool transferred = false;

            Console.Write("Enter amount in multiples of 500 : ");
            try
            {
                amount = System.Convert.ToInt32(Console.ReadLine());
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            if (amount % 500 != 0)
            {
                Console.WriteLine("Please make sure to enter the amount in MULTIPLES OF 500!");
            }
            else
            {
                Console.Write("Enter the account number to which you want to transfer : ");
                try
                {
                    recAccountNo      = Console.ReadLine();
                    recieverAccountNo = System.Convert.ToInt32(recAccountNo);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
                //create a list to hold customer business objects
                List <Customer_BO> found = new List <Customer_BO>();
                //create a list to hold arguments to pass to search function
                List <string> list = new List <string>();
                //add only accountnumber so it can search based on only that
                list.Add("AccountNumber");
                Admin_BLL adminBLL = new Admin_BLL();
                found = adminBLL.SearchAccount(recAccountNo, "", "", "", "", "", list);
                if (found.Count != 0)
                {
                    Customer_BO recieverObj = found.First();
                    Console.Write($"You wish to deposit Rs {amount} in account held by Mr. {recieverObj.Name} ; If this information is correct then please re-enter the account number: ");
                    try
                    {
                        accountNoRe = System.Convert.ToInt32(Console.ReadLine());
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                    if (recieverAccountNo == accountNoRe)
                    {
                        //call transaction function
                        transferred = cBLL.Transfer(accountNo, recieverAccountNo, amount);
                    }
                    if (transferred)
                    {
                        Console.WriteLine("Transaction confirmed");

                        Console.Write("do you wish to print a receipt (Y/N) ? : ");
                        string confirm = Console.ReadLine();
                        if (confirm == "Y")
                        {
                            List <Customer_BO> senderlist = new List <Customer_BO>();
                            List <string>      listTemp   = new List <string>();
                            listTemp.Add("AccountNumber");

                            senderlist = adminBLL.SearchAccount(accountNo.ToString(), "", "", "", "", "", listTemp);
                            Customer_BO sender = senderlist.First();

                            Console.WriteLine("\n");

                            //Display account number
                            Console.Write($"Account # {sender.AccountNumber}");
                            string date = sender.datetime.ToString("dd/MM/yyyy");
                            Console.WriteLine("\n");
                            Console.Write(date);
                            Console.WriteLine("\n");
                            Console.WriteLine($"Depostited : {amount }");
                            Console.Write($"Balance : {sender.Balance}\n");
                            //Display Deposited amount:amount
                            //Display balance
                        }
                        else if (confirm == "N")
                        {
                            Console.WriteLine("Receipt will not be printed!");
                        }
                        else
                        {
                            Console.WriteLine("No valid option chosen");
                        }
                    }


                    else if (transferred == false)
                    {
                        Console.WriteLine("Transfer failed");
                    }
                }
                else
                {
                    Console.WriteLine("No record found");
                }
            }
            //return to main menu
            MainMenu(accountNo);
        }
コード例 #2
0
ファイル: Admin_View.cs プロジェクト: umair-j/ATM-system-EAD-
        public void Search()
        {
            //initialize input variables with default value
            string balanceInput   = default;
            string accountIdInput = default;
            string userIdInput    = default;
            string nameInput      = default;
            string typeInput      = default;
            string statusInput    = default;

            //create list of arguments to be sent that will have non empty values
            List <string> arguments = new List <string>();

            //get inputs from user and store in input variables
            Console.WriteLine("SEARCH MENU\n");
            Console.Write("Account ID : ");
            accountIdInput = Console.ReadLine();

            Console.Write("User ID : ");
            userIdInput = Console.ReadLine();

            Console.Write("Holder's Name : ");
            nameInput = Console.ReadLine();

            Console.Write("Type (savings/current) : ");
            typeInput = Console.ReadLine();

            Console.Write("Balance : ");
            balanceInput = Console.ReadLine();


            Console.Write("Status : ");
            statusInput = Console.ReadLine();

            //add only non empty string values to list i.e if some account number is entered then put "AccountNumber" string in list
            if (accountIdInput != "")
            {
                arguments.Add("AccountNumber");
            }

            if (userIdInput != "")
            {
                arguments.Add("Login");
            }

            if (nameInput != "")
            {
                arguments.Add("Name");
            }

            if (typeInput != "")
            {
                arguments.Add("AccountType");
            }

            if (balanceInput != "")
            {
                arguments.Add("Balance");
            }

            if (statusInput != "")
            {
                arguments.Add("AccountStatus");
            }

            //call search function with input variables and list as argument
            List <Customer_BO> list = adminBLL.SearchAccount(accountIdInput, userIdInput, nameInput, typeInput, balanceInput, statusInput, arguments);

            Console.WriteLine("\n==== SEARCH RESULTS ====\n");
            //display users' data in required format
            Console.WriteLine("Account ID \t\t User ID \t\t Holder's Name \t\t Type \t\tBalance \t\tStatus\n");
            foreach (Customer_BO b in list)
            {
                Console.WriteLine($"{b.AccountNumber}\t\t\t{b.Login}\t\t\t{b.Name}\t\t\t{b.AccountType}\t\t\t{b.Balance}\t\t\t{b.AccountStatus}\n");
            }
            //return to admin main menu
            Admin_menu();
        }