Exemplo n.º 1
0
 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);
     }
 }
Exemplo n.º 2
0
        //Made by Mikkel E.R. Glerup
        private void Btn_Save_Click(object sender, RoutedEventArgs e)
        {
            user.Name     = TxtBox_Name.Text;
            user.Username = TxtBox_Username.Text;
            user.Password = TxtBox_Password.Text;
            if (CheckBox_IsAdmin.IsChecked == true)
            {
                user.IsAdmin = true;
            }
            if (CheckBox_IsAdmin.IsChecked == false)
            {
                user.IsAdmin = false;
            }
            bool wasSuccess = userLogic.EditUser(user);

            if (wasSuccess)
            {
                CreateMessage.ShowEditSuccesful("User");
            }
            if (!wasSuccess)
            {
                CreateMessage.ShowFailureMessage();
            }
            NavigationService.Navigate(new ViewUsersDetail(user.ID));
        }
Exemplo n.º 3
0
 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);
     }
 }
Exemplo n.º 4
0
        private void CheckEditOrCreate()
        {
            bool     wasCreate = false;
            DateTime now       = DateTime.Now;

            // had to cast because DatePicker_EndDate.SelectedDate is DateTime?
            subscription.EndDate     = (DateTime)DatePicker_EndDate.SelectedDate;
            subscription.RenewLength = (subscription.EndDate.Month - DateTime.Now.Month);
            if (CheckBox_AutoRenew.IsChecked == true)
            {
                subscription.Renew = true;
            }
            if (CheckBox_AutoRenew.IsChecked == false)
            {
                subscription.Renew = false;
            }
            if (subscription.SubscriptionID == 0)
            {
                wasCreate = true;
            }
            bool wasSuccess = subscriptionLogic.CheckEditOrCreate(subscription, subCat);

            if (wasSuccess == true)
            {
                if (wasCreate == true)
                {
                    CreateMessage.ShowCreateSuccesful("Subscription");
                    NavigationService.Navigate(new ViewSubscriptionsDetails(subscription.CustomerID));
                    Subscription updated = new Subscription();
                    updated = DB.SelectSubcription(subscription.CustomerID);
                    subCat.SubscriptionID = updated.SubscriptionID;
                    int        categoryID             = 0;
                    List <int> selectedCategoriesList = new List <int>();
                    for (int i = 0; i < ListBox_CategoriesSubscripeTo.SelectedItems.Count; i++)
                    {
                        Categories chosenCategory = (Categories)ListBox_CategoriesSubscripeTo.Items[i];
                        categoryID = chosenCategory.CategoryID;
                        selectedCategoriesList.Add(categoryID);
                    }
                    int[] arrayOfCategoryIDs = selectedCategoriesList.ToArray();
                    foreach (int categoryIDs in arrayOfCategoryIDs)
                    {
                        subCat.CategoryID     = categoryID;
                        subCat.SubscriptionID = updated.SubscriptionID;
                        wasSuccess            = CreateSubscriptionWCategory(subCat); // Creates a subscription for every category subscribed to
                    }
                }
                if (wasCreate == false)
                {
                    CreateMessage.ShowEditSuccesful("Subscription");
                    NavigationService.Navigate(new ViewSubscriptionsDetails(subscription.CustomerID));
                }
            }
            if (wasSuccess == false)
            {
                CreateMessage.ShowFailureMessage();
            }
        }
Exemplo n.º 5
0
 private void Button_Click_Save(object sender, RoutedEventArgs e)
 {
     foreach (int productIDs in productList)
     {
         Product product = DB.SelectProduct(productIDs);
         // will break if input is anything else than numbers
         // to fix use regex, not enough time in devolpment
         product.Price = double.Parse(TextBox_Price.Text);
         wasSuccess    = DB.EditProduct(product);
     }
     if (wasSuccess == true)
     {
         CreateMessage.ShowEditSuccesful("Product");
         NavigationService.Navigate(new ViewCatalogue());
     }
     if (wasSuccess == false)
     {
         CreateMessage.ShowFailureMessage();
         NavigationService.Navigate(new ViewCatalogue());
     }
 }