Exemplo n.º 1
0
        private static void AccountMenu()
        {
            if (a != null && a.isLogged)
            {

                while (true)
                {
                    Console.Clear();
                    Console.Out.Flush();
                    Console.WriteLine("---------SPRING HERO BANK---------");
                    Console.WriteLine("\t| Chào mừng, {0}! |", a.Name.ToUpper());
                    Console.WriteLine("1. Truy vấn thông tin tài khoản.");
                    Console.WriteLine("2. Rút tiền.");
                    Console.WriteLine("3. Gửi tiền.");
                    Console.WriteLine("4. Chuyển khoản.");
                    Console.WriteLine("5. Lịch sử giao dịch.");
                    Console.WriteLine("6. Đăng xuất.");
                    Console.WriteLine("-----------------------------------");
                    Console.WriteLine("Vui lòng nhập lựa chọn (1|2|3|4|5|6): ");
                    // resync tài khoản trước
                    Model md = new Model();
                    md.ResyncAccountMoney(a);
                    // Yêu cầu người dùng nhập lựa chọn
                    Utility ult = new Utility();
                    var choice = ult.GetIntNum();
                    switch (choice)
                    {
                        case 1:
                            {
                                AccountController ac = new AccountController();
                                ac.AccountInformation();
                                break;
                            }
                        case 2:
                            {
                                // TransactionController tc = new TransactionController();
                                if (tc.AccountWithdraw())
                                {
                                    Console.WriteLine("Rút tiền thành công!");
                                    // Console.WriteLine("Số tiền trong tài khoản hiện tại:")
                                    // thành công
                                    // Console.WriteLine("");

                                }
                                // else {
                                //     Console.WriteLine("Có lỗi xảy ra trong quá trình giao dịch! Vui lòng thử lại sau.");
                                //     // không thành công
                                // }
                                // rút tiền
                                break;
                            }
                        case 3:
                            {
                                // gửi tiền
                                // var amount = ult.GetDecimalNum();

                                if (tc.AccountDeposit())
                                {
                                    // thành công
                                    // Console.WriteLine("");
                                    Console.WriteLine("Gửi tiền thành công!");

                                }
                                // else {
                                //     // không thành công
                                //     Console.WriteLine("Có lỗi xảy ra trong quá trình giao dịch! Vui lòng thử lại sau.");
                                // }
                                break;
                            }
                        case 4:
                            {
                                // chuyển tiền
                                if (tc.AccountTransfer())
                                {
                                    // thành công
                                    // Console.WriteLine("");
                                    Console.WriteLine("Gửi tiền thành công!");

                                }
                                // else {
                                //     // không thành công
                                //     Console.WriteLine("Có lỗi xảy ra trong quá trình giao dịch! Vui lòng thử lại sau.");
                                // }
                                break;
                            }
                        case 5:
                            {
                                // lịch sử giao dịch
                                if (tc.GetAccountTransactionHistoryMain())
                                {
                                    // thành công
                                    // Console.WriteLine("");
                                    Console.WriteLine("Đã kiểm tra lịch sử!");

                                }
                                // else Console.WriteLine("Lấy lịch sử giao dịch thất bại!");
                                break;
                            }
                        case 6:
                            {
                                // thoát
                                Console.Clear();
                                Console.Out.Flush();
                                Console.WriteLine("Đã đăng xuất! Ấn ENTER để quay trở về màn hình chính..");
                                Console.ReadLine();
                                // a.isLogged = !a.isLogged;
                                a = new Account();
                                a.isLogged = false;
                                break;
                            }
                        default:
                            {
                                Console.WriteLine("Bạn đã nhập lựa chọn không phù hợp! Vui lòng chọn lại..");
                                break;
                            }
                    }

                    if (a != null && !a.isLogged)
                    {
                        MainMenu();
                        break;
                    }
                    else
                    {
                        Console.WriteLine("\tBấm ENTER để quay lại...");
                        Console.ReadLine();
                    }
                }
            }
            else MainMenu();
        }