//static void AddAccount(ref List<Account> accounts)
        //{
        //    Console.WriteLine("Enter first name.");
        //    string fname = Console.ReadLine().Trim();
        //    Console.WriteLine("Enter last name.");
        //    string lname = Console.ReadLine().Trim();
        //    Console.WriteLine("Enter account type");
        //    int type;
        //    AccountType accountType;
        //    Console.WriteLine("Enter '1' for Savings account.\nEnter '2' for Current account.\nEnter '3' for DMAT account.\nDefault is Savings.");
        //    int.TryParse(Console.ReadLine(), out type);                                 //Used out
        //    switch (type)
        //    {
        //        case 1:
        //            accountType = AccountType.Savings;
        //            break;
        //        case 2:
        //            accountType = AccountType.Current;
        //            break;
        //        case 3:
        //            accountType = AccountType.DMAT;
        //            break;
        //        default:
        //            accountType = AccountType.Savings;
        //            break;
        //    }
        //    Console.WriteLine("Enter the starting balance.");
        //    double balance;
        //    double.TryParse(Console.ReadLine(), out balance);                           //Used out
        //    while (accountType == AccountType.Savings && balance < 1000)
        //    {
        //        Console.WriteLine("The minimum balance for a Savings account is 1000.");
        //        double.TryParse(Console.ReadLine(), out balance);
        //    }
        //    while (accountType == AccountType.Current && balance < 0)
        //    {
        //        Console.WriteLine("The minimum balance for a Current account is 0.");
        //        double.TryParse(Console.ReadLine(), out balance);
        //    }
        //    while (accountType == AccountType.DMAT && balance < -10000)
        //    {
        //        Console.WriteLine("The minimum balance for a DMAT account is -10000.");
        //        double.TryParse(Console.ReadLine(), out balance);
        //    }
        //    //accounts.Add(new Account(fname, lname, accountType, balance));

        //    //---------------------------ADO Code
        //    ADO ado = new ADO();
        //    ado.AddAccount(fname, lname, accountType, balance);
        //}


        //static Account ChooseAccount(int id, List<Account> accounts)                            //Implemented search by ID in this method
        //{
        //    foreach (Account account in accounts)
        //    {
        //        if (account.ID == id)
        //            return account;
        //    }
        //    return null;
        //}

        //static void PerformOperations(ref List<Account> accounts)
        //{
        //    Console.WriteLine("Enter account ID to choose account to perform operations");
        //    int id;
        //    int.TryParse(Console.ReadLine(), out id);                   //Used out
        //    Account chosenAccount = ChooseAccount(id, accounts);
        //    if (chosenAccount != null)
        //    {
        //        int operation;
        //        Console.WriteLine("Enter 1 to deposit.\nEnter 2 to withdraw.\nEnter 3 to display interest.");
        //        int.TryParse(Console.ReadLine(), out operation);                    //Used out
        //        switch (operation)
        //        {
        //            case 1:
        //                Console.WriteLine("Enter the amount to be deposited");
        //                chosenAccount.Deposit(double.Parse(Console.ReadLine()));
        //                break;
        //            case 2:
        //                Console.WriteLine("Enter the amount to be withdrawn");
        //                chosenAccount.Withdraw(double.Parse(Console.ReadLine()));
        //                break;
        //            case 3:
        //                Console.WriteLine(chosenAccount.CalculateInterest());
        //                break;
        //            default:
        //                break;
        //        }
        //    }
        //}

        static void Main(string[] args)
        {
            bool    flag = true;
            int     choice;
            int     id = 0;
            int     operation;
            double  amount;
            Account account = new Account();

            while (true)
            {
                Console.WriteLine("Enter 1 to to display accounts.\nEnter 2 to add an account.\nEnter 0 to exit.");
                int.TryParse(Console.ReadLine(), out choice);
                switch (choice)
                {
                case 1:
                    account.Display();
                    Console.WriteLine("Enter Account number to perform operations on account");
                    int.TryParse(Console.ReadLine(), out id);
                    Console.WriteLine("Enter 1 to deposit.\nEnter 2 to Withdraw.\nEnter 3 to get interest");
                    int.TryParse(Console.ReadLine(), out operation);
                    switch (operation)
                    {
                    case 1:
                        Console.WriteLine("Enter amount to deposit");
                        double.TryParse(Console.ReadLine(), out amount);
                        account.Deposit(id, amount);
                        break;

                    case 2:
                        Console.WriteLine("Enter amount to withdraw");
                        double.TryParse(Console.ReadLine(), out amount);
                        account.Withdraw(id, amount);
                        break;

                    case 3:
                        Console.WriteLine(Environment.NewLine + account.CalculateInterest(id));
                        break;

                    default: break;
                    }
                    break;

                case 2:
                    account.AddAccount();
                    break;

                case 0:
                    flag = false;
                    break;
                }
                if (flag == false)
                {
                    break;
                }
            }
        }
Example #2
0
        static void Main(string[] args)
        {
            Account test = new Account();
            bool    exit = false;

            while (!exit)
            {
                Console.WriteLine("[1] Add account \n[2] Deposit/Withdrawal \n[3] Transfer amount \n[6] Show accounts \n[7] Close account \n[8] Show bank vault \n[X] Close the program");
                Console.Write("\nChoose an option: \n");
                string option = Console.ReadLine();
                switch (option)
                {
                case "1":
                    Console.Clear();
                    test.AddAccount();
                    break;

                case "2":
                    Console.Write("Type D or W:\t");
                    string dw = Console.ReadLine();
                    switch (dw)
                    {
                    case "d":
                    case "D":   Transfer.Deposit();
                        break;

                    case "w":
                    case "W":   Transfer.Withdraw();
                        break;

                    default: Console.Clear();
                        break;
                    }
                    break;

                case "3":
                    Transfer.Transaction();
                    break;

                case "6":
                    Console.Clear();
                    test.Display();
                    break;

                case "7":
                    Console.Clear();
                    test.DeleteAccount();
                    break;

                case "8":
                    Console.Clear();
                    Transfer.Vault();
                    break;

                case "x":
                case "X":
                    exit = true;
                    break;

                default:
                    Console.Clear();
                    break;
                }
            }
            Console.ReadLine();
        }
Example #3
0
        static void Main(string[] args)
        {
            string            filepath = (@"C:\Users\Giannis\Documents\accounts.txt");
            Account           test     = new Account();
            Read_Write_toFile read     = new Read_Write_toFile();

            string[,] accountlist = read.ReadFile(filepath);
            bool exit = false;

            while (!exit)
            {
                Console.WriteLine("[1] Add account \n[3] Transfer amount \n[6] Show accounts \n[7] Close account \n[8] Show bank vault \n[X] Close the program");
                Console.Write("\nChoose an option: ");
                string option = Console.ReadLine();
                switch (option)
                {
                case "1":
                    Console.Clear();
                    test.AddAccount(accountlist);
                    break;

                case "3":
                    Console.Clear();
                    //Console.Write("From account number: \t");
                    //int from = int.Parse(Console.ReadLine());
                    //Console.Write("Enter amount: \t\t");
                    //double amount = double.Parse(Console.ReadLine());
                    //Console.Write("To account number: \t");
                    //int to = int.Parse(Console.ReadLine());
                    //foreach (Account acc in accountlist)
                    //{
                    //    if (acc.Number==from)
                    //    {
                    //        acc.Withdraw(amount);
                    //    }
                    //}
                    break;

                case "6":
                    Console.Clear();
                    test.Display();
                    break;

                case "7":
                    Console.Clear();
                    test.DeleteAccount();
                    break;

                case "8":
                    Console.Clear();

                    break;

                case "x":
                case "X":
                    exit = true;
                    break;

                default:
                    Console.Clear();
                    break;
                }
            }
            Console.ReadLine();
        }