コード例 #1
0
        public void AccountDelete()
        {
            DrawScreen draw = new DrawScreen();

            draw.TopScreen();
            Console.WriteLine(" Delete Account ");
            draw.UnderTitleLine();

            long accountNum = 0;
            bool accountValid;

            Console.Write("Enter account number: ");
            //get input 6-8 digits account number
            do
            {
                accountNum   = Convert.ToInt64(Console.ReadLine());
                accountValid = SearchAccount.CheckInputValidity(accountNum);
            } while (!accountValid);

            //check if account exists with number provided
            bool existingAccount = SearchAccount.CheckAccountExists(accountNum);

            //if exists prompt account deletion
            if (existingAccount)
            {
                string   path   = $"{accountNum}.txt";
                string[] detail = System.IO.File.ReadAllLines(path);

                //display account details
                foreach (string set in detail)
                {
                    Console.WriteLine(set);
                }
                //get user confirmation to delete
                //if confirmed delete file from path and return to menu
                if (ConfirmDelete())
                {
                    File.Delete(path);
                    Screens.mainMenu();
                }
                //ask if user wants to search again or return to menu if they dont delete previous file
                else
                {
                    CheckAnother();
                }
            }
            else
            {
                Console.WriteLine("Account does not exist ");
                Screens.mainMenu();
            }
        }
コード例 #2
0
        //check if user wants to search for another account or exit to menu
        public static bool Confirmation()
        {
            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine("Do you want to search another account? (Y/N) ");
            Console.WriteLine("Press 'Y' to search again \nPress 'N' to return to main menu");
            Console.ForegroundColor = ConsoleColor.Cyan;

            //if Y pressed clear screen and search
            if (Console.ReadKey().Key == ConsoleKey.Y)
            {
                Console.Clear();
                return(true);
            }
            //if N pressed go to main menu
            else if (Console.ReadKey().Key == ConsoleKey.N)
            {
                Screens.mainMenu();
                return(false);
            }
            return(false);
        }
コード例 #3
0
        //get user confirmation for data inputted
        static bool ConfirmDetail(string firstName, string lastName, string address, long phoneNum, string email)
        {
            //show data inputted before by user
            Console.Clear();
            Console.WriteLine("First Name: " + firstName);
            Console.WriteLine("Last Name: " + lastName);
            Console.WriteLine("Address: " + address);
            Console.WriteLine("Phone Number: " + phoneNum);
            Console.WriteLine("Email: " + email);
            Console.WriteLine();
            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine("Are these details correct? Y/N ");
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("Press 'Y' to save \nPress 'N' to reenter details \nPress 'M' to procceed without saving");
            Console.ForegroundColor = ConsoleColor.Cyan;

            //if Y pressed detail is confirmed
            //if N pressed reenter details
            //if M pressed go to main menu without saving
            if (Console.ReadKey().Key == ConsoleKey.Y)
            {
                Console.Clear();
                return(true);
            }
            else if (Console.ReadKey().Key == ConsoleKey.N)
            {
                Console.Clear();
                return(false);
            }
            else if (Console.ReadKey().Key == ConsoleKey.M)
            {
                Console.Clear();
                Screens.mainMenu();
            }
            return(false);
        }
コード例 #4
0
        //check if user wants to check and delete another account
        static void CheckAnother()
        {
            Console.Clear();

            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine("Do you want to search another account? ");
            Console.WriteLine("Press 'Y' to search again ");
            Console.WriteLine("Press 'N' to return to menu ");
            Console.ForegroundColor = ConsoleColor.Cyan;

            //if yes start deletion process again from beginning
            if (Console.ReadKey().Key == ConsoleKey.Y)
            {
                Console.Clear();
                DeleteAccount restart = new DeleteAccount();
                restart.AccountDelete();
            }
            //else return to main menu
            else if (Console.ReadKey().Key == ConsoleKey.N)
            {
                Screens.mainMenu();
            }
            Screens.mainMenu();
        }
コード例 #5
0
ファイル: Statement.cs プロジェクト: hi10-b/.NET_development
        public void LastFiveTransaction()
        {
            DrawScreen draw = new DrawScreen();

            draw.TopScreen();
            Console.WriteLine(" A/C Statement ");
            draw.UnderTitleLine();

            long accountNum = 0;
            bool accountValid;

            Console.Write("Enter account number: ");
            //get input 6-8 digits account number
            do
            {
                accountNum   = Convert.ToInt64(Console.ReadLine());
                accountValid = SearchAccount.CheckInputValidity(accountNum);
            } while (!accountValid);

            //check if account exists with number provided
            bool existingAccount = SearchAccount.CheckAccountExists(accountNum);

            //if account exists prompt withdrawal money
            if (existingAccount)
            {
                Console.Clear();
                Console.WriteLine("Account Number: " + accountNum);

                string path = $"{accountNum}.txt";
                //all details from file
                string[] detail = System.IO.File.ReadAllLines(path);
                //last five transaction details
                string[] lastFive = new string[5];
                int      y        = 0;
                draw.OtherLine();
                //look at bottom five lines in file where all transactions are saved
                Console.WriteLine("upto 5 previous transactions shown: ");

                for (int x = (detail.Length - 5); x < detail.Length; x++)
                {
                    //only add transaction if it contains "transaction"
                    if (detail[x].Contains("Transaction"))
                    {
                        Console.WriteLine(detail[x]);
                        lastFive[y] = detail[x];
                        y++;
                    }
                }

                //check if user wants statement sent to email
                //YesNoEmail();
                //if user wants email statement then email last five trasnactions to their email
                draw.OtherLine();
                if (YesNoEmail())
                {
                    Console.WriteLine("Please enter your email address: ");
                    string email = Console.ReadLine();
                    EmailStatement(lastFive, email);
                    Screens.mainMenu();
                }
                //if no email then go to menu
                else
                {
                    Screens.mainMenu();
                }
            }
            //if account doesnt exist go to menu after message shown
            else
            {
                Console.WriteLine("Account does not exist ");
                Console.ReadKey();
                Screens.mainMenu();
            }
        }
コード例 #6
0
        public void NewUser()
        {
            DrawScreen draw = new DrawScreen();

            Console.ForegroundColor = ConsoleColor.Cyan;
            bool phoneValid   = false;
            bool emailValid   = false;
            bool detailsValid = false;

            //do until user exits
            do
            {
                draw.TopScreen();

                Console.WriteLine(" Please Fill Out Your Details Below ");

                draw.UnderTitleLine();

                //request users information
                Console.Write(" First Name: ");
                newFirstName = Console.ReadLine();

                Console.Write(" Last Name: ");
                newLastName = Console.ReadLine();

                Console.Write(" New Address: ");
                newAddress = Console.ReadLine();

                //enter a VALID phone number
                //number must contain 10 digits
                do
                {
                    try
                    {
                        Console.ForegroundColor = ConsoleColor.Cyan;
                        Console.Write(" New Phone: ");
                        newPhone = Convert.ToInt64(Console.ReadLine());

                        phoneValid = CheckPhoneValidity(newPhone);
                    }catch (FormatException)
                    {
                        ClearLineAbove();
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine("incorrect input");
                        Console.ForegroundColor = ConsoleColor.Cyan;
                    }
                } while (!phoneValid);

                //enter a VALID email address
                //email must contain '@' and either 'gmail.com' or 'outlook.com' or 'uts.edu.au'
                do
                {
                    Console.ForegroundColor = ConsoleColor.Cyan;
                    Console.Write(" New Email: ");
                    newEmail   = Console.ReadLine();
                    emailValid = CheckEmailValidity(newEmail);
                } while (!emailValid);

                //get user confirmation of details
                detailsValid = ConfirmDetail(newFirstName, newLastName, newAddress, newPhone, newEmail);
            } while (!detailsValid);

            //if all details are confirmed correct then create new account file and send email
            if (ConfirmDetail(newFirstName, newLastName, newAddress, newPhone, newEmail))
            {
                AccountFileCreate(newFirstName, newLastName, newAddress, newPhone, newEmail);
                SendEmail(newFirstName, newLastName, newAddress, newPhone, newEmail);
                //Console.ReadKey();
                Screens.mainMenu();
            }
            //else if (ConfirmDetail(newFirstName, newLastName, newAddress, newPhone, newEmail))
            {
                //  Console.WriteLine("go to main menu");
                //Screens restart = new Screens();
                //restart.MainMenu();
            }
        }
コード例 #7
0
        // CreateAccount accountNo = new CreateAccount();

        public void WithdrawMoney()
        {
            DrawScreen draw = new DrawScreen();

            draw.TopScreen();
            Console.WriteLine(" Withdrawal ");
            draw.UnderTitleLine();

            long   withdrawalAmount;
            long   accountNum   = 0;
            bool   accountValid = false;
            long   finalAmount  = 0;
            string firstName    = null;
            string lastName     = null;
            string address      = null;
            string phone        = null;
            string email        = null;

            //get VALID account number
            Console.Write("Enter account number: ");
            do
            {
                accountNum   = Convert.ToInt64(Console.ReadLine());
                accountValid = SearchAccount.CheckInputValidity(accountNum);
            } while (!accountValid);

            //check if account exists with number provided
            bool existingAccount = SearchAccount.CheckAccountExists(accountNum);

            //if account exists prompt withdrawal money
            if (existingAccount)
            {
                Console.Write("Enter withdrawal amount: ");
                withdrawalAmount = Convert.ToInt64(Console.ReadLine());

                string   path      = $"{accountNum}.txt";
                string[] detail    = System.IO.File.ReadAllLines(path);
                bool     withdrawn = false;

                // save all other details
                //add to final amount if it already exists
                foreach (string set in detail)
                {
                    string[] splits = set.Split(':');
                    if (set.Contains("First Name"))
                    {
                        firstName = splits[1];
                    }
                    if (set.Contains("Last Name"))
                    {
                        lastName = splits[1];
                    }
                    if (set.Contains("Address"))
                    {
                        address = splits[1];
                    }
                    if (set.Contains("Phone Number"))
                    {
                        phone = splits[1];
                    }
                    if (set.Contains("Email"))
                    {
                        email = splits[1];
                    }
                    //if there is previous value minus withdraw amount and set withdraw to true
                    if (set.Contains("Amount"))
                    {
                        withdrawn   = true;
                        finalAmount = (Convert.ToInt64(splits[1]) - withdrawalAmount);
                    }
                }

                //if withdraw amount more then funds in account show error message
                if (finalAmount < 0 || !withdrawn)
                {
                    Console.WriteLine("You do not have suffecient funds in your account!!");
                    Screens.mainMenu();
                }
                //if enough funds edit file
                else
                {
                    EditFile(firstName, lastName, address, phone, email, finalAmount, withdrawalAmount, accountNum, detail);
                    Screens.mainMenu();
                }
            }
            //if no file show error message and go to menu
            else
            {
                Console.WriteLine("Account does not exist ");
                Screens.mainMenu();
            }
        }
コード例 #8
0
        public void DepositMoney()
        {
            DrawScreen draw = new DrawScreen();

            draw.TopScreen();
            Console.WriteLine(" Deposit ");
            draw.UnderTitleLine();

            long   depositAmount;
            long   accountNum   = 0;
            bool   accountValid = false;
            long   finalAmount  = 0;
            string firstName    = null;
            string lastName     = null;
            string address      = null;
            string phone        = null;
            string email        = null;

            Console.Write("Enter account number: ");
            //get Valid account number 6-8 digits
            do
            {
                accountNum   = Convert.ToInt64(Console.ReadLine());
                accountValid = SearchAccount.CheckInputValidity(accountNum);
            } while (!accountValid);

            //check if account exists with number provided
            bool existingAccount = SearchAccount.CheckAccountExists(accountNum);

            //if account exists prompt deposit money
            if (existingAccount)
            {
                Console.Write("Enter deposit amount: ");
                depositAmount = Convert.ToInt64(Console.ReadLine());

                string   path      = $"{accountNum}.txt";
                string[] detail    = File.ReadAllLines(path);
                bool     deposited = false;

                //save all other details
                //add to final amount if it already exists
                foreach (string set in detail)
                {
                    string[] splits = set.Split(':');
                    if (set.Contains("First Name"))
                    {
                        firstName = splits[1];
                    }
                    if (set.Contains("Last Name"))
                    {
                        lastName = splits[1];
                    }
                    if (set.Contains("Address"))
                    {
                        address = splits[1];
                    }
                    if (set.Contains("Phone Number"))
                    {
                        phone = splits[1];
                    }
                    if (set.Contains("Email"))
                    {
                        email = splits[1];
                    }
                    if (set.Contains("Transaction"))
                    {
                        //make no changes if it contains 'transactions'
                    }
                    if (set.Contains("Amount"))
                    {
                        finalAmount = (Convert.ToInt64(splits[1]) + depositAmount);
                        deposited   = true;
                    }
                }
                //if amount doesnt exists in final then deposit amount = final amount
                if (!deposited)
                {
                    finalAmount = depositAmount;
                }
                //make appropriate changes to file and exit appropriately
                EditFile(firstName, lastName, address, phone, email, finalAmount, depositAmount, accountNum, detail);
                Screens.mainMenu();
            }
            //if account doesnt exist display error message and go to menu
            else
            {
                Console.WriteLine("Account does not exist ");
                Screens.mainMenu();
            }
        }