public void GenerateTransactionMenu() { Console.WriteLine("---------Welcome to menu transaction history---------"); Console.WriteLine("1. Get the last 5 times."); Console.WriteLine("2. Get the last 10 times."); Console.WriteLine("3. Take the time."); Console.WriteLine("4. Logout."); Console.WriteLine("-----------------------------------------------------"); Console.WriteLine("Please enter your choice (1|2|3) "); var choice = ParseChoice.GetInputNumber(); switch (choice) { case 1: break; case 2: break; case 3: break; case 4: Program.currentLoggedIn = null; Console.WriteLine("See you again."); break; } }
// Hiển thị menu chính của chương trình. public void GenerateDefaultMenu() { while (true) { ParseChoice parseChoice = new ParseChoice(); Console.WriteLine("-------------- BANK CUSTOMER MENU--------------"); Console.WriteLine("Welcome back "); 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 choice (1|2|3|4|5|6): "); var choice = ParseChoice.GetInputNumber(); switch (choice) { case 1: Console.WriteLine(controller.Register() ? "Register success!" : "Register fails. Please try again later."); Console.WriteLine("Press enter to continue."); Console.ReadLine(); break; case 2: Console.WriteLine(controller.Login() ? "Login success! Welcome back " + Program.currentLoggedInYyAccount.FullName + "!" : "Login fails. Please try again later."); Console.WriteLine("Press enter to continue."); Console.ReadLine(); break; case 3: Console.WriteLine("See you later."); Environment.Exit(1); break; case 4: controller.Transfer(); break; case 5: break; case 6: break; } if (Program.currentLoggedInYyAccount != null) { break; } } }
public void Deposit() { Console.WriteLine("Deposit."); Console.WriteLine("---------------------------------"); Console.WriteLine("Please enter amount to deposit: "); var amount = ParseChoice.GetDecimalNumber(); Console.WriteLine("Please enter message content: "); var content = Console.ReadLine(); var historyTransaction = new HL_Transaction { Id = Guid.NewGuid().ToString(), Type = HL_Transaction.TransactionType.DEPOSIT, Amount = amount, Content = content, SenderAccountNumber = Program.currentLoggedIn.AccountNumber, ReceiverAccountNumber = Program.currentLoggedIn.AccountNumber, Status = HL_Transaction.ActiveStatus.DONE }; if (_accountModel.UpdateBalance(Program.currentLoggedIn, historyTransaction)) { Console.WriteLine("Transaction success!"); } else { Console.WriteLine("Transaction fails, please try again!"); } Program.currentLoggedIn = _accountModel.GetAccountByUserName(Program.currentLoggedIn.Username); Console.WriteLine("Current balance: " + Program.currentLoggedIn.Balance); Console.WriteLine("Press enter to continue!"); Console.ReadLine(); }
public void GenerateCustomerMenu() { while (true) { Console.WriteLine("--------------HUONG LY BANK CUSTOMER MENU--------------"); Console.WriteLine("Welcome back " + Program.currentLoggedIn.Fullname); 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 choice (1|2|3|4|5|6): "); var choice = ParseChoice.GetInputNumber(); switch (choice) { case 1: controller.ShowAccountInformation(); break; case 2: controller.Withdraw(); break; case 3: controller.Deposit(); break; case 4: controller.Transfer(); break; case 5: GenerateTransactionMenu(); break; case 6: Program.currentLoggedIn = null; Console.WriteLine("See you again."); break; } if (Program.currentLoggedIn == null) { break; } } }
public void GenerateDefaultMenu() { while (true) { Console.WriteLine("--------------WELCOME TO HUONG LY BANK--------------"); Console.WriteLine("1. Register for free."); Console.WriteLine("2. Login."); Console.WriteLine("3. Exit."); Console.WriteLine("---------------------------------------------------------"); Console.WriteLine("Please enter you choice (1|2|3): "); var choice = ParseChoice.GetInputNumber(); switch (choice) { case 1: Console.WriteLine(controller.AddAccount() ? "Register success!" : "Register fails. Please try again later."); Console.WriteLine("Press enter to continue."); Console.ReadLine(); break; case 2: Console.WriteLine(controller.CheckLogin() ? "Login success! Welcome back " + Program.currentLoggedIn.Fullname + "!" : "Login fails. Please try again later."); Console.WriteLine("Press enter to continue."); Console.ReadLine(); break; case 3: Console.WriteLine("See you later."); Environment.Exit(1); break; } if (Program.currentLoggedIn != null) { break; } } }
public void Transfer() { Console.WriteLine(Program.currentLoggedIn.Status); Console.WriteLine("Transfer."); Console.WriteLine("--------------------------------"); Console.WriteLine("Enter accountNumber to transfer: "); string accountNumber = Console.ReadLine(); var account = _accountModel.GetByAccountNumber(accountNumber); if (account == null) { Console.WriteLine("Invalid account info"); return; } Console.WriteLine("You are doing transaction with account: " + account.Fullname); Console.WriteLine("Enter amount to transfer: "); var amount = ParseChoice.GetDecimalNumber(); if (amount > Program.currentLoggedIn.Balance) { Console.WriteLine("Amount not enough to perform transaction."); return; } Console.WriteLine("Please enter message content: "); var content = Console.ReadLine(); Console.WriteLine("Are you sure you want to make a transaction with your account ? (y/n)"); var choice = Console.ReadLine(); if (choice.Equals("n")) { return; } var historyTransaction = new HL_Transaction() { Id = Guid.NewGuid().ToString(), Type = HL_Transaction.TransactionType.TRANSFER, Amount = amount, Content = content, SenderAccountNumber = Program.currentLoggedIn.AccountNumber, ReceiverAccountNumber = account.AccountNumber, Status = HL_Transaction.ActiveStatus.DONE }; if (_accountModel.TransferAmount(Program.currentLoggedIn, historyTransaction)) { Console.WriteLine("Transaction success!"); } else { Console.WriteLine("Transaction fails, please try again!"); } Program.currentLoggedIn = _accountModel.GetByUsername(Program.currentLoggedIn.Username); Console.WriteLine("Current balance: " + Program.currentLoggedIn.Balance); Console.WriteLine("Press enter to continue!"); Console.ReadLine(); }
public bool AddAccount() { Console.WriteLine("----Please enter information----"); Console.WriteLine("Enter username:"******"Username existed."); return(false); } Console.WriteLine("Enter password:"******"Enter confirm password:"******"Enter identityCard:"); string identityCard = Console.ReadLine(); Console.WriteLine("Enter fullname:"); string fullname = Console.ReadLine(); Console.WriteLine("Enter email:"); string email = Console.ReadLine(); Console.WriteLine("Enter birthday:"); string birthday = Console.ReadLine(); Console.WriteLine("Enter phoneNumber:"); string phoneNumber = Console.ReadLine(); Console.WriteLine("Enter address:"); string address = Console.ReadLine(); Console.WriteLine("Enter gender"); int gender = ParseChoice.GetInputNumber(); account = new HL_Account(username, password, cpassword, identityCard, fullname, email, birthday, phoneNumber, address, gender); var errors = account.CheckValid(); if (errors.Count == 0) { account.GetMD5WithSalt(); if (_accountModel.Save(account)) { Console.WriteLine("Save success!!!"); } else { Console.WriteLine("Not success. Please try again."); } } else { Console.Error.WriteLine("Please fix following errors and try again."); foreach (var messagErrorsValue in errors.Values) { Console.Error.WriteLine(messagErrorsValue); } } return(true); }