示例#1
0
        public void GenerateTransactionMenu()
        {
            while (true)
            {
                Console.WriteLine("=================WELCOME TO TRANSACTION HISTORY================");
                Console.WriteLine("1.Lich su 5 ngay gan nhat.");
                Console.WriteLine("2.Lich su 10 ngay gan nhat.");
                Console.WriteLine("3.Thoat.");
                Console.WriteLine("===============================================================");
                Console.WriteLine("Please enter you choose(1|2|3)");
                var choose = Utillty.GetInt32Number();
                switch (choose)
                {
                case 1:
                    Console.WriteLine("");
                    break;

                case 2:
                    Console.WriteLine("");
                    break;

                case 3:
                    Console.WriteLine("");
                    break;
                }

                if (Program.currentLoggedInYyAccount != null)
                {
                    break;
                }
            }
        }
示例#2
0
        public void Withdraw()
        {
            Console.WriteLine("Withdraw.");
            Console.WriteLine("---------------------------------");
            Console.WriteLine("Please enter amount to withdraw: ");
            var amount = Utillty.GetDecimalNumber();

            Console.WriteLine("Please enter message content: ");
            var content            = Console.ReadLine();
            var historyTransaction = new YYTransaction()
            {
                Id                    = Guid.NewGuid().ToString(),
                Type                  = YYTransaction.TransactionType.WITHDRAW,
                Amount                = amount,
                Content               = content,
                SenderAccountNumber   = Program.currentLoggedInYyAccount.AccountNumber,
                ReceiverAccountNumber = Program.currentLoggedInYyAccount.AccountNumber,
                Status                = YYTransaction.ActiveStatus.DONE
            };

            if (model.UpdateBalance(Program.currentLoggedInYyAccount, historyTransaction))
            {
                Console.WriteLine("Transaction success!");
            }
            else
            {
                Console.WriteLine("Transaction fails, please try again!");
            }

            Program.currentLoggedInYyAccount = model.GetByAccountNumber(Program.currentLoggedInYyAccount.AccountNumber);
            Console.WriteLine("Current balance: " + Program.currentLoggedInYyAccount.Balance);
        }
        public void Deposit()
        {
            Console.WriteLine("Deposit.");
            Console.WriteLine("---------------------------------");
            Console.WriteLine("Please enter amount to deposit: ");
            var amount = Utillty.GetDecimalNumber();

            Console.WriteLine("Please enter message content: ");
            var content = Console.ReadLine();
//            Program.currentLoggedIn = model.GetAccountByUserName(Program.currentLoggedIn.Username);
            var historyTransaction = new YYTransaction()
            {
                Id                    = Guid.NewGuid().ToString(),
                Type                  = YYTransaction.TransactionType.DEPOSIT,
                Amount                = amount,
                Content               = content,
                SenderAccountNumber   = Program.currentLoggedInYyAccount.AccountNumber,
                ReceiverAccountNumber = Program.currentLoggedInYyAccount.AccountNumber,
                Status                = YYTransaction.ActiveStatus.DONE
            };

            if (model.UpdateBalance(Program.currentLoggedInYyAccount, historyTransaction))
            {
                Console.WriteLine("Transaction success!");
            }
            else
            {
                Console.WriteLine("Transaction fails, please try again!");
            }
            Program.currentLoggedInYyAccount = model.Login(Program.currentLoggedInYyAccount.Username);
            Console.WriteLine("Current balance: " + Program.currentLoggedInYyAccount.Balance);
            Console.WriteLine("Press enter to continue!");
            Console.ReadLine();
        }
示例#4
0
        public void GenerateCustumerMennu()
        {
            while (true)
            {
                Console.WriteLine("============SPRING HELLO BANK CUSTUMER MAENU===========");
                Console.WriteLine("Welcome back " + Program.currentLoggedInYyAccount.Name + "!");
                Console.WriteLine("1. Check information.");
                Console.WriteLine("2. Withdraw.");
                Console.WriteLine("3. Deposit.");
                Console.WriteLine("4. Transfer.");
                Console.WriteLine("5. Transaction history.");
                Console.WriteLine("6. Logout.");
                Console.WriteLine("=======================================================");
                Console.WriteLine("Please enter you choose (1|2|3|4|5|6)");
                var choose = Utillty.GetInt32Number();
                switch (choose)
                {
                case 1:
                    cotrollerSpring.ShowAccountInformation();
                    break;

                case 2:

                    break;

                case 3:
                    cotrollerSpring.Deposit();
                    break;

                case 4:
                    cotrollerSpring.Transfer();
                    break;

                case 5:
                    cotrollerSpring.Whithdrow();
                    break;

                case 6:
                    GenerateTransactionMenu();
                    break;

                case 7:
//                        Program.currentLoggedInYyAccount == null;
//                        Console.WriteLine("Logout success");
                    break;
                }

                Console.WriteLine("Press enter to continue");
                Console.ReadLine();
                if (Program.currentLoggedInYyAccount == null)
                {
                    break;
                }
            }
        }
示例#5
0
 private YYAccount GetAccountInformation()
 {
     while (true)
     {
         Console.WriteLine("---------------Register  Information---------------: ");
         Console.WriteLine("Nhap Username: "******"Nhap Password: "******"Comfirm Password: "******"Nhap Balance: ");
         var balance = Utillty.GetDecimalNumber();
         Console.WriteLine("Nhap IdentityCard: ");
         var identityCard = Console.ReadLine();
         Console.WriteLine("Full Name: ");
         var fullName = Console.ReadLine();
         Console.WriteLine("Nhap Birdthday: ");
         var birdthday = Console.ReadLine();
         Console.WriteLine("Nhap Gender(1. male | 2.temale | 3. rather not say ): ");
         var gender = Utillty.GetInt32Number();
         Console.WriteLine("Nhap Email: ");
         var email = Console.ReadLine();
         Console.WriteLine("Nhap PhoneNumber: ");
         var phone = Console.ReadLine();
         Console.WriteLine("Nhap Address: ");
         var       address   = Console.ReadLine();
         YYAccount yyAccount = new YYAccount
         {
             Username     = username,
             Password     = password,
             Cpassword    = cpassword,
             IdentityCard = identityCard,
             Gender       = gender,
             Balance      = balance,
             Address      = address,
             Dob          = birdthday,
             Name         = fullName,
             Email        = email,
             PhoneNumber  = phone
         };
         return(yyAccount);
     }
 }
示例#6
0
        /*
         * Tiến hành chuyển khoản, mặc định là trong ngân hàng.
         * 1. Yêu cầu nhập số tài khoản cần chuyển.(số tài khoản của người nhận.)
         *     1.1. Xác minh thông tin tài khoản và hiển thị tên người cần chuyển.
         * 2. Nhập số tiền cần chuyển.
         *     2.1. Kiểm tra số dư tài khoản.
         * 3. Nhập nội dung chuyển tiền.
         *     3.1 Xác nhận nội dung chuyển tiền.
         * 4. Thực hiện chuyển tiền.
         *     4.1. Mở transaction. Mở block try catch.
         *     4.2. Trừ tiền người gửi.
         *         4.2.1. Lấy thông tin tài khoản gửi tiền một lần nữa. Đảm bảo thông tin là mới nhất.
         *         4.2.2. Kiểm tra lại một lần nữa số dư xem có đủ tiền để chuyển không.
         *             4.2.2.1. Nếu không đủ thì rollback.
         *             4.2.2.2. Nếu đủ thì trừ tiền và update vào bảng `accounts`.
         *     4.3. Cộng tiền người nhận.
         *         4.3.1. Lấy thông tin tài khoản nhận, đảm bảo tài khoản không bị khoá hoặc inactive.
         *         4.3.1.1. Nếu ok thì update số tiền cho người nhận.
         *         4.3.1.2. Nếu không ok thì rollback.
         *     4.4. Lưu lịch sử giao dịch.
         *     4.5. Kiểm tra lại trạng thái của 3 câu lệnh trên.
         *         4.5.1. Nếu cả 3 cùng thành công thì commit transaction.
         *         4.5.2. Nếu bất kỳ một câu lệnh nào bị lỗi thì rollback.
         *     4.x. Đóng, commit transaction.
         */
        public void Transfer()
        {
            Console.WriteLine("Enter the account number to transfer: ");
            var accountNumber   = Console.ReadLine();
            var receiverAccount = model.GetByAccountNumber(accountNumber);

            if (receiverAccount == null)
            {
                Console.WriteLine("Invalid account information");
                return;
            }

            Console.WriteLine("Name of person to transfer: " + receiverAccount.Name);
            Console.WriteLine("Enter amount to transfer: ");
            var amount = Utillty.GetDecimalNumber();

            Console.WriteLine("Please enter message content: ");
            var content = Console.ReadLine();
//            Program.currentLoggedIn = model.GetAccountByUserName(Program.currentLoggedIn.Username);
            var historyTransaction = new YYTransaction()
            {
                Id                    = Guid.NewGuid().ToString(),
                Type                  = YYTransaction.TransactionType.TRANSFER,
                Amount                = amount,
                Content               = content,
                SenderAccountNumber   = Program.currentLoggedInYyAccount.AccountNumber,
                ReceiverAccountNumber = accountNumber,
                Status                = YYTransaction.ActiveStatus.DONE
            };

            if (model.Transfer(Program.currentLoggedInYyAccount, historyTransaction))
            {
                Console.WriteLine("Transaction success!");
            }
            else
            {
                Console.WriteLine("Transaction fails, please try again!");
            }

            Program.currentLoggedInYyAccount = model.GetByAccountNumber(Program.currentLoggedInYyAccount.AccountNumber);
            Console.WriteLine("Current balance: " + Program.currentLoggedInYyAccount.Balance);
        }
示例#7
0
        private void GenerateTransactionMennu()
        {
            Console.WriteLine("Transaction history query");
            Console.WriteLine("Please select a transaction history view");
            Console.WriteLine("1. Retrieve all transaction history.");
            Console.WriteLine("2. Query transaction history according to AccountNumber.");
            Console.WriteLine("Please enter you choose (1|2)");
            var choose = Utillty.GetInt32Number();

            switch (choose)
            {
            case 1:
                transactionHistory.GetListTransactionHistory();
                break;

            case 2:
                transactionHistory.ListTransactionToAccountNumber();
                break;
            }
        }
示例#8
0
        public void GenerateDefaulMenu()
        {
            while (true)
            {
                Console.WriteLine("============WELCOME TO SPRING HELLO BANK===========");
                Console.WriteLine("1.Register for free.");
                Console.WriteLine("2.Login.");
                Console.WriteLine("3. Exit.");
                Console.WriteLine("===================================================");
                Console.WriteLine("Please enter you choose (1|2|3)");
                var choose = Utillty.GetInt32Number();
                switch (choose)
                {
                case 1:
                    Console.WriteLine(cotrollerSpring.Register()
                            ? "Register success!"
                            : "Register fails. Please try again later.");
                    Console.WriteLine("Press enter to continue");
                    Console.ReadLine();
                    break;

                case 2:
                    Console.WriteLine(cotrollerSpring.LoginAccount()
                            ? "Login success! Welcome back!"
                            : "Login fails. Please try again later.");
                    Console.WriteLine("Press enter to continue");
                    Console.ReadLine();
                    break;

                case 3:
                    Environment.Exit(1);
                    break;
                }

                if (Program.currentLoggedInYyAccount != null)
                {
                    break;
                }
            }
        }