private void btn_Save_Click(object sender, RoutedEventArgs e) { // Checks input for wrong information if (txtbx_City.Text == "" || txtbx_ContactInfo.Text == "" || txtbx_Income.Text == "" || txtbx_Name.Text == "" || txtbx_StreetNumber.Text == "" || txtbx_Zip.Text == "" || txt_SpokesPerson.Text == "") { CreateMessage.ShowInputNotValid(); } else if (check.CheckTextBoxInputChars(txt_SpokesPerson.Text) == true) { CreateMessage.ShowInputNotValid(); } else if (check.CheckTextBoxInputInteger(txtbx_Zip.Text) == true || check.CheckTextBoxInputInteger(txtbx_Income.Text) == true) { CreateMessage.ShowInputNotValid(); } else { bool wasSuccess = interaction.CreateCustomer(customer); if (wasSuccess) { CreateMessage.ShowCreateSuccesful("Customer"); } NavigationService.Navigate(new ViewCustomer()); if (!wasSuccess) { CreateMessage.ShowFailureMessage(); } } }
public bool CreateCustomer(Customer customer) { try { bool validationSucces = customerValidation.ZipCodeValidation(customer.ZipCode); validationSucces = customerValidation.AnnualIncomeValidation(customer.AnnualIncome); // makes sure the zip code and annual income isn't 0 if (!validationSucces) { CreateMessage.ShowInputNotValid(); return(false); } bool wasSuccess = DB.InsertCustomer(customer); if (wasSuccess) { throw new CustomerWasAdded(customer); // writes in log when customer is added } return(false); } //Only thrown if creating user was a succes catch (CustomerWasAdded ex) { ErrorHandler.Log.WriteEvent(ex); return(true); } }
private void btn_Save_Click(object sender, RoutedEventArgs e) { try { SaveInfo(); bool wasSuccess = interaction.EditProduct(product); if (wasSuccess) { CreateMessage.ShowEditSuccesful("Product"); } if (!wasSuccess) { CreateMessage.ShowFailureMessage(); } NavigationService.Navigate(new ViewProductDetails(product.ProductID)); } catch (Exception ex) { if (ex is FormatException) { CreateMessage.ShowInputNotValid(); } ErrorHandler.Log.WriteFail(ex); } }
private void btn_Save_Click(object sender, RoutedEventArgs e) { try { Categories chosenCategory = (Categories)lstbx_Categories.SelectedItem; product.CategoryID = chosenCategory.CategoryID; bool wasSuccess = interaction.CreateProduct(product); if (check.CheckTextBoxInputChars(txtbx_Price.Text) == true) { CreateMessage.ShowInputNotValid(); } else if (check.CheckTextBoxInputInteger(txtbx_Price.Text) == true) { CreateMessage.ShowInputNotValid(); } else { if (wasSuccess) { MessageBox.Show("Product was created successfully."); } if (!wasSuccess) { MessageBox.Show("Something went wrong, try again. If this problem persists contact admin."); } this.Content = null; NavigationService.Navigate(new ViewProducts()); } } catch (Exception ex) { ErrorHandler.Log.WriteFail(ex); CreateMessage.ShowInputNotValid(); } }
private void btn_Save_Click(object sender, RoutedEventArgs e) { try { SaveInfo(); bool wasSuccess = customerLogic.EditCustomer(customer); if (wasSuccess) { CreateMessage.ShowEditSuccesful("Customer"); } if (!wasSuccess) { CreateMessage.ShowFailureMessage(); } NavigationService.Navigate(new ViewCustomerDetails(customer.customerID)); } catch (Exception ex) { if (ex is FormatException) { CreateMessage.ShowInputNotValid(); } ErrorHandler.Log.WriteFail(ex); } }
private bool CreateSubscriptionWCategory(SubscribedToCategory subCat) { try { return(subscriptionLogic.CreateSubscriptionWCategory(subCat)); } catch (Exception ex) { ErrorHandler.Log.WriteFail(ex); CreateMessage.ShowInputNotValid(); return(false); } }
private void btn_Save_Click(object sender, RoutedEventArgs e) { int customerID = 0; List <int> selectedCustomersList = new List <int>(); for (int i = 0; i < lstbx_Customer.SelectedItems.Count; i++) { Customer chosenCustomer = (Customer)lstbx_Customer.Items[i]; customerID = chosenCustomer.customerID; selectedCustomersList.Add(customerID); } int[] arrayOfCustomerIDs = selectedCustomersList.ToArray(); foreach (int customerIDs in arrayOfCustomerIDs) { wasSuccess = CreateDeals(customerIDs); // Creates a deal for every customer selected } if (txtbx_Discount.Text == "" || txtbx_Name.Text == "") { CreateMessage.ShowInputNotValid(); } else if (check.CheckTextBoxInputInteger(txtbx_Discount.Text) == true) { CreateMessage.ShowInputNotValid(); } else { if (wasSuccess) { CreateMessage.ShowCreateSuccesful("Deal"); } if (!wasSuccess) { CreateMessage.ShowFailureMessage(); } NavigationService.Navigate(new ViewDeals()); } }
//Made by Mikkel E.R. Glerup private void btn_Save_Click(object sender, RoutedEventArgs e) { bool isAdmin = false; UserLogic userLogic = new UserLogic(); if (TxtBox_Name.Text == "") { CreateMessage.ShowInputNotValid(); } else if (check.CheckTextBoxInputChars(TxtBox_Name.Text) == false) { CreateMessage.ShowInputNotValid(); } else { if (CheckBox_IsAdmin.IsChecked == true) { isAdmin = true; } if (CheckBox_IsAdmin.IsChecked == false) { isAdmin = false; } //Databinding, would've, should've could've but didn't bool wasSuccess = userLogic.CreateUser(user.Name = TxtBox_Name.Text, user.IsAdmin = isAdmin); if (wasSuccess) { CreateMessage.ShowCreateSuccesful("User"); } if (!wasSuccess) { CreateMessage.ShowFailureMessage(); } NavigationService.Navigate(new ViewUser()); } }
private bool CreateDeals(int customerID) { try { deals.CustomerID = customerID; if (rdbtn_Category.IsChecked == true) //find out if the deal is made to product or category { Categories chosenCategory = (Categories)lstbx_ProductOrCategory.SelectedItem; deals.CategoryID = chosenCategory.CategoryID; } else if (rdbtn_Product.IsChecked == true) { Product chosenProduct = (Product)lstbx_ProductOrCategory.SelectedItem; deals.ProductID = chosenProduct.ProductID; } return(interaction.CreateDeal(deals)); } catch (Exception ex) { ErrorHandler.Log.WriteFail(ex); CreateMessage.ShowInputNotValid(); return(false); } }