private async void AddExtension() { SecurityFunctions.CheckForAccess(SecurityGroups.Add); if (!FieldsValid(this)) { return; } using (new WaitSpinner(this, "Adding extension...", 150)) { try { await extensionContext.InsertAsync(); } catch (MySql.Data.MySqlClient.MySqlException ex) { ExceptionHandler.MySqlException(this, ex); return; } this.DataContext = await extensionContext.FromDatabaseAsync(); InputEnabled = false; } UserPrompts.PopupMessage(this, "Extension added.", "Success!"); }
private async void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e) { if (e.Exception is InvalidAccessException) { var iae = (InvalidAccessException)e.Exception; UserPrompts.PopupMessage(iae.Message, "Access Denied"); e.Handled = true; } else if (e.Exception is MySql.Data.MySqlClient.MySqlException) { var mse = (MySql.Data.MySqlClient.MySqlException)e.Exception; switch ((MySql.Data.MySqlClient.MySqlErrorCode)mse.Number) { case MySql.Data.MySqlClient.MySqlErrorCode.UnableToConnectToHost: DBFactory.CacheMode = true; e.Handled = true; break; } } else { Logging.Exception(e.Exception); await UserPrompts.PopupMessage(e.Exception.ToString(), "UNHANDLED ERROR!"); e.Handled = true; Application.Current.Shutdown(-1); } }
public void Execute() { var prompts = new UserPrompts(); var ops = new OrderOperations(); EditOrderPrompts query; var response = new Response(); var slip = new OrderSlip(); bool tryAgain = false; do { tryAgain = false; slip = prompts.GetOrderInfoFromUser(); response = ops.GetOrder(slip.OrderNumber, slip.Date); if (!response.Success) { Console.WriteLine(response.Message); tryAgain = prompts.PromptUserToTryAgain(); } else { query = new EditOrderPrompts(response.Order); var queryResponse = query.EditOrder(); if (queryResponse.Updated) { ops.EditOrder(queryResponse.Order, slip.Date); } DisplayOrderInformation.DisplayEditOrderInfo(queryResponse.Order); } } while (tryAgain); }
private async void DeleteExtension() { SecurityFunctions.CheckForAccess(SecurityGroups.Delete); var result = (bool)await UserPrompts.PopupDialog(this, "Are you sure you want to delete this extension?", "Delete Extension", DialogButtons.YesNo); if (!result) { return; } var ctx = (Extension)this.DataContext; using (new WaitSpinner(this, "Deleting extension...", 150)) { try { await ctx.DeleteFromDatabaseAsync(); } catch (MySql.Data.MySqlClient.MySqlException ex) { ExceptionHandler.MySqlException(this, ex); return; } } await UserPrompts.PopupDialog(this, string.Format("Extension '{0}' deleted!", extensionContext.Number), "Success", DialogButtons.Default); OnExtensionDeleted(extensionContext); ((Extension)DataContext).Dispose(); extensionContext.Dispose(); this.Close(); }
private async void UpdateExtension() { SecurityFunctions.CheckForAccess(SecurityGroups.Modify); if (!FieldsValid(this)) { return; } using (var spinner = new WaitSpinner(this, "Updating extension...", 150)) { var ctx = (Extension)this.DataContext; try { await ctx.UpdateAsync(); } catch (MySql.Data.MySqlClient.MySqlException ex) { ExceptionHandler.MySqlException(this, ex); return; } // Copy new values to the original context to update the main window values. this.extensionContext.CopyValues(ctx); } UserPrompts.PopupMessage(this, "Extension updated.", "Success!"); }
public void Execute() { var prompts = new UserPrompts(); var ops = new OrderOperations(); var orderToCreate = prompts.GetNewOrderInfoFromUser(); var response = ops.CreateOrder(orderToCreate); DisplayOrderInformation.DisplayNewOrderInfo(response.Order); bool isSaving = prompts.AskUserToSave(); if (isSaving) { response.Slip = orderToCreate; ops.WriteNewOrderToRepository(response); DisplayOrderInformation.DisplayNewOrderConfirmation(response.Order); } else { Console.WriteLine("Returning to Main Menu."); Console.WriteLine("Press any key to continue..."); Console.ReadKey(); } }
public void Execute() { Console.Clear(); int accountNumber = UserPrompts.GetIntFromUser("Enter the account number that you would like to delete: "); DisplayAccountInformation(accountNumber); }
private void DisplayLookupMethod() { Console.ForegroundColor = ConsoleColor.White; do { Console.Clear(); Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("==================================================="); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Currently using the account of:"); Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine($"{_currentAccount.Name}"); Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("==================================================="); ShowAccountInfoToTeller(_currentAccount); Console.WriteLine("\n1. Deposit"); Console.WriteLine("2. Withdraw"); Console.WriteLine("3. Transfer"); Console.WriteLine("0. Delete Account"); Console.WriteLine("\nQ to return to main menu"); string input = UserPrompts.GetStringFromUser("\nEnter choice: "); if (input.Substring(0, 1).ToUpper() == "Q") { break; } ProcessChoice(input); } while (true); }
public void Execute(Account account, string message, bool transfer, Account transferAccount, bool deleting = false) { decimal amount; if (deleting == false) { amount = UserPrompts.GetDecimalFromUser(message); } else { amount = account.Balance; } var manager = new AccountManager(); var response = manager.Withdrawl(amount, account); if (response.Success) { AccountScreens.WithdrawlDetails(response.Data); if (transfer == true) { DepositWorkflow depositTransfer = new DepositWorkflow(); depositTransfer.Execute(transferAccount, amount); } } else { AccountScreens.WorkflowErrorScreen(response.Message); } }
public void Execute() { //TODO: Create a heading here so I can console.clear Console.ForegroundColor = ConsoleColor.White; int accountNumber = UserPrompts.GetIntFromUser("Please provide an account number: "); DisplayAccountInformation(accountNumber); }
public Order CreateEditOrder(Response <Order> editingOrder) { editingOrder.Data.OrderNumber = orderNumber; editingOrder.Data.CustomerName = UserPrompts.GetCustomerNameForEdit(editingOrder.Data.CustomerName); editingOrder.Data.ProductType = UserPrompts.GetProductTypeForEdit(editingOrder.Data.ProductType); editingOrder.Data.Area = UserPrompts.GetAreaForEdit(editingOrder.Data.Area); editingOrder.Data.State = UserPrompts.GetStateForEdit(editingOrder.Data.State); return(editingOrder.Data); }
public void Execute() { string type = UserPrompts.PromptForType(); StockQuoteOperations ops = new StockQuoteOperations(type); string symbols = UserPrompts.PromptForSymbols(); List <StockQuote> quotes = ops.RetrieveQuotes(symbols); DisplayQuotes(quotes); }
static void Main(string[] args) { bool run = false; do { Teller teller = new Teller(); teller = UserPrompts.AccessLevel(); MainMenu menu = new MainMenu(); menu.Execute(teller); } while (true); }
private bool FieldsValid(DependencyObject obj) { var valid = !Validation.GetHasError(obj) && LogicalTreeHelper.GetChildren(obj) .OfType <DependencyObject>() .All(FieldsValid); if (!valid) { UserPrompts.PopupMessage(this, "One or more required fields are empty or invalid.", "Invalid Data"); } return(valid); }
private void CreateAndSaveAccount() { Account newAccount = new Account(); newAccount.FirstName = UserPrompts.GetStringFromUser("Enter the First Name of the new account holder:"); newAccount.LastName = UserPrompts.GetStringFromUser("Enter the Last Name of the new account holder:"); newAccount.Balance = UserPrompts.GetDecimalFromUser("How much would you like to deposit to start the account?"); AccountManager manager = new AccountManager(); newAccount.AccountNumber = manager.GenerateNewAccountNumber(); manager.SaveNewAccount(newAccount); _currentAccount = newAccount; }
public void Execute() { var prompts = new UserPrompts(); var orderSlipFromUser = prompts.GetOrderInfoFromUser(); var ops = new OrderOperations(); bool goAgain = false; do { var orderResponse = ops.GetOrder(orderSlipFromUser.OrderNumber, orderSlipFromUser.Date); if (!orderResponse.Success) { Console.WriteLine(orderResponse.Message); Console.WriteLine("Do you want to try again?"); string tryAgainOrNot = Console.ReadLine().ToUpper(); Console.Clear(); switch (tryAgainOrNot) { case "Y": goAgain = true; break; case "N": goAgain = false; break; default: Console.WriteLine("That was not a valid input."); break; } } else { DisplayOrderInformation.DisplayRemoveOrderInfo(orderResponse.Order); var confirmation = prompts.RemovalConfirmation(); if (confirmation) { ops.RemoveOrder(orderSlipFromUser.OrderNumber, orderSlipFromUser.Date); Console.WriteLine(); Console.WriteLine("Order removed. press any key to return to Main menu."); Console.ReadKey(); goAgain = false; } } } while (goAgain); }
public void Execute() { Console.Clear(); Console.WriteLine("Welcome to SG Corp Bank"); Console.WriteLine("===================================="); Console.WriteLine("\n1. Create Account"); Console.WriteLine("2. Delete Account"); Console.WriteLine("3. Lookup Account"); Console.WriteLine("\n(Q) to Quit"); string input = UserPrompts.GetStringFromUser("\nEnter Choice: "); //if (input.Substring(0, 1).ToUpper() == "Q") ProcessChoice(input); }
public void Execute(Account account) { decimal amount = UserPrompts.GetDecimalFromUser("Please provide a deposit amount:"); var manager = new AccountManager(); var response = manager.Deposit(amount, account); if (response.Success) { AccountScreens.DepositDetails(response.Data); } else { AccountScreens.WorkflowErrorScreen(response.Message); } }
private async void InitConnection() { bool canReach = false; bool cacheVerified = false; using (var spinner = new WaitSpinner(this, "Connecting to database...", 2000)) { await Task.Run(() => { canReach = DBFactory.CanReachServer(); spinner.StatusText = "Checking cache..."; cacheVerified = CacheFunctions.VerifyCache(); if (canReach) { spinner.StatusText = "Loading data..."; CacheFunctions.RefreshCache(); } SecurityFunctions.PopulateUserAccess(); SecurityFunctions.PopulateAccessGroups(); }); } if (!cacheVerified && !canReach) { await UserPrompts.PopupMessage(this, "Cannot connect to the database and the local cache was not verified.", "Cannot Run"); Application.Current.Shutdown(); } else if (cacheVerified && !canReach) { WatchDogInstance.WatchDog.Start(true); } else { WatchDogInstance.WatchDog.Start(false); } // If current user can modify, add edit button column to grid. AddEditButton(); FieldsGrid.IsEnabled = true; }
private Account GetDataForNewAccount() { Account newAccount = new Account(); int newAccountNumberInt = GenerateNewRandomAccountNumber(); newAccount.AccountNumber = newAccountNumberInt; newAccount.Name = UserPrompts.GetStringFromUser("Please enter a name for the new account."); newAccount.Balance = UserPrompts.GetDecimalFromUser("Starting deposit: "); newAccount.Type = (AccountType) UserPrompts.GetIntFromUser("Please enter an acct type \n1 for Free, 2 for Basic, 3 for Premium"); return(newAccount); }
public void Execute() { var response = orderOps.GetOrders(editDate); do { editDate = displayWorkflow.GetOrderDateFromUser(); response = orderOps.GetOrders(editDate); if (response.Success == false) { Console.WriteLine("That was an invalid entry. Please enter a valid date. Press enter to continue."); Console.ReadLine(); } } while (response.Success == false); var orderNumber = UserPrompts.GetOrderNumber(); //PrintOrderToEdit(editDate, orderNumber); var editingOrder = orderOps.GetOrderToEdit(editDate, orderNumber); Order OrderBeingEdited = CreateEditOrder(editingOrder); orderOps.NewOrderCalculations(OrderBeingEdited); OrderBeingEdited.OrderNumber = orderNumber; orderOps.AddNewOrder(OrderBeingEdited, editDate); orderOps.RemovePreEditedOrder(OrderBeingEdited, editDate); Console.WriteLine("Here is your updated order information: "); Console.WriteLine("========| Updated Order Confirmation | ========"); Console.WriteLine("Order number: {0}", OrderBeingEdited.OrderNumber); Console.WriteLine("Customer Name: {0}", OrderBeingEdited.CustomerName); Console.WriteLine("Product Type: {0}", OrderBeingEdited.ProductType); Console.WriteLine("Product Cost Per Square Foot: {0:c}", OrderBeingEdited.CostPerSquareFoot); Console.WriteLine("Labor Cost Per Square Foot: {0:c}", OrderBeingEdited.LaborCostPerSquareFoot); Console.WriteLine("Amount Ordered: {0}sqft", OrderBeingEdited.Area); Console.WriteLine("Total Material Cost: {0:c}", OrderBeingEdited.MaterialCost); Console.WriteLine("Total Labor Cost: {0:c}", OrderBeingEdited.LaborCost); Console.WriteLine("Tax: {0:c}", OrderBeingEdited.Tax); Console.WriteLine("Total: {0:c}", OrderBeingEdited.Total); Console.ReadLine(); }
private void DisplayDeleteMenu(Account account, int accountNumber) { do { Console.WriteLine("\n1. Process Delete Request"); Console.WriteLine("2. Cancel Delete Request"); Console.WriteLine("\n(Q) to return to main menu"); string input = UserPrompts.GetStringFromUser("\nEnter choice: "); if (input.Substring(0, 1).ToUpper() == "Q") { break; } ProcessInput(input, accountNumber); } while (true); Console.Clear(); }
private void DisplayLookupMenu() { do { Console.WriteLine("\n1. Deposit"); Console.WriteLine("2. Withdraw"); Console.WriteLine("3. Transfer"); Console.WriteLine("\n(Q) to return to main menu"); string input = UserPrompts.GetStringFromUser("\nEnter Choice: "); if (input.Substring(0, 1).ToUpper() == "Q") { break; } ProcessChoice(input); } while (true); }
public void Execute(Account account, decimal amount) { Console.ForegroundColor = ConsoleColor.White; if (amount <= 0) { amount = UserPrompts.GetDecimalFromUser("Please enter a deposit amount."); } var manager = new AccountManager(); var response = manager.Deposit(amount, account); if (response.Success) { AccountScreens.DepositDetails(response.Data); } else { AccountScreens.WorkflowErrorScreen(response.Message); } }
public void Execute() { Console.Clear(); Account newAccount = new Account(); newAccount.FirstName = UserPrompts.GetStringFromUser("Enter the First Name of the new account holder:"); newAccount.LastName = UserPrompts.GetStringFromUser("Enter the Last Name of the new account holder:"); newAccount.Balance = UserPrompts.GetDecimalFromUser("How much would you like to deposit to start the account?"); AccountManager manager = new AccountManager(); newAccount.AccountNumber = manager.GenerateNewAccountNumber(); manager.SaveNewAccount(newAccount); Console.Clear(); Console.WriteLine("Here are your new account details: \n"); AccountScreens.PrintAccountDetails(newAccount); Console.ReadLine(); }
public void Execute(Account account) { Console.Clear(); decimal amount = UserPrompts.GetDecimalFromUser($"Make a deposit to Account #{account.AccountNumber}" + $"\n===============================================================" + $"\nCurrent Account Balance: {account.Balance:C}" + $"\nHow much would you like to deposit? Please enter decimal amount."); var manager = new AccountManager(); var response = manager.Deposit(amount, account); if (response.Success) { AccountScreens.DepositDetails(response.Data); } else { AccountScreens.WorkflowErrorScreen(response.Message); } }
public void Execute(Teller teller) { Console.ForegroundColor = ConsoleColor.White; do { Console.Clear(); DrawSeperatorBar(); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Welcome to The Software Bank of Code"); DrawSeperatorBar(); Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("Please enter an action."); DrawSeperatorBar(); Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("\n1. Create Account"); Console.WriteLine("2. Lookup Account"); if (teller.Accesslevel > 2) { Console.WriteLine("3. List all accounts"); } if (teller.Accesslevel == 5) { Console.WriteLine("6. List all tellers"); Console.WriteLine("9. Add Tellers"); } Console.WriteLine("\nQ to quit"); string input = UserPrompts.GetStringFromUser("\nEnter Choice: "); if (input.Substring(0, 1).ToUpper() == "Q") { Console.Clear(); Console.WriteLine("Thanks for banking with The Software Bank of Code!\nPlease come again!"); Thread.Sleep(2600); Environment.Exit(0); } ProcessChoice(input, teller); } while (true); }//end of execute
public void Execute(Account account) { Console.ForegroundColor = ConsoleColor.White; Account nullAccount = new Account(); // because I goofed with all of my parameters earlier and need to pass in a blank Console.Clear(); string input = UserPrompts.GetStringFromUser( $"Are you sure you would like to delete {account.Name}'s account?\n(Yes) - (N)o").ToUpper(); if (input.Substring(0, 1) == "Y" || input == "YES") { WithdrawlWorkflow wd = new WithdrawlWorkflow(); wd.Execute(account, "The balance is being drained and returned.", false, nullAccount, true); //Delete the account AccountManager manager = new AccountManager(); manager.DeleteAccount(account); } else { Console.WriteLine("Account was not deleted."); } }
public void Execute(Account currentAccount) { Console.Clear(); decimal amount = UserPrompts.GetDecimalFromUser($"Make a withdrawal from Account #{currentAccount.AccountNumber}" + $"\n===============================================================" + $"\nCurrent Account Balance: {currentAccount.Balance:C}" + $"\nHow much would you like to withdraw? Please enter decimal amount."); AccountManager manager = new AccountManager(); var response = manager.Withdraw(amount, currentAccount); if (response.Success) { AccountScreens.WithdrawalDetails(response.Data); } else { AccountScreens.WorkflowErrorScreen(response.Message); } }
public void Execute(Account currentAccount, decimal amount) { Console.Clear(); DisplayHeading(); int transferAccountNumber = UserPrompts.GetIntFromUser("Please enter the account number you would like to transfer to."); var transferAccount = new AccountManager(); var transferToAccount = transferAccount.GetAccount(transferAccountNumber); if (transferToAccount.Success) { Account MoveThatMoneyAcct = new Account(); MoveThatMoneyAcct = transferToAccount.Data; WithdrawlWorkflow transferFrom = new WithdrawlWorkflow(); transferFrom.Execute(currentAccount, "Please enter an amount to transfer.", true, MoveThatMoneyAcct); Console.WriteLine($"You successfully transfered money to {MoveThatMoneyAcct.Name}"); } }
public void Execute() { var prompts = new UserPrompts(); var orderQuery = prompts.GetDateInfoFromUser(); DisplayOrderInformation.DisplayRepoInfo(orderQuery); }
static void Main(string[] args) { ITestRepository testRepository = new TestRepository(); UserPrompts userPrompts = new UserPrompts(testRepository); Console.WriteLine("***Welcome to PBK 1.0 test platform!***\n"); Console.WriteLine(@"In this application you can: *Take tests *Create tests *Change tests "); var userAnsw = true; do { Console.WriteLine("Please, enter the following number:\n" + "1)Take test\n" + "2)Create test\n" + "3)Change test\n" + "4)Show statistics\n "); int userChoise; string Userline; bool parsed; do { /* || Возвращает true, если хотя бы один из операндов возвращает true. */ Userline = Console.ReadLine(); parsed = int.TryParse(Userline, out userChoise); if (string.IsNullOrWhiteSpace(Userline)) { Console.WriteLine("!!!Alert!!!\n Empty input, please choose something"); } else { if (!parsed) { Console.WriteLine($"!!!Alert!!!\n {Userline} is not a number, please, try again.."); } else { if ((userChoise > 4 || userChoise < 1)) { Console.WriteLine("Incorrect number, try a different"); } } } } while (!parsed || (userChoise > 4 || userChoise < 1)); switch (userChoise) { case 1: string testTopic = userPrompts.PromptForTargetRandomTestId(); var test = testRepository.GetRandomTestByTopic(testTopic); TestService service = new TestService(test); service.TakeTest(); break; case 2: var newTest = Test.CreateTest(); testRepository.AddTest(newTest); break; case 3: var testId = userPrompts.PromptsForUpdatingTestById(); var updatedTest = Test.UpdateTest(testId); testRepository.UpdateTest(updatedTest); break; case 4: userPrompts.PromptForShowStatistics(); break; } Console.WriteLine("Exit from programm? y/n"); var userEnter = Console.ReadLine(); if (userEnter == "y") { userAnsw = false; } else { if (userEnter == "n") { userAnsw = true; } else { Console.WriteLine("Uncorrect enter"); } } } while (userAnsw != false); }
public void Execute() { int accountNumber = UserPrompts.GetIntFromUser("Please provide account number: "); DisplayAccountInformation(accountNumber); }