Ejemplo n.º 1
0
 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();
         }
     }
 }
Ejemplo n.º 2
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();
            }
        }
Ejemplo n.º 3
0
        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());
            }
        }
Ejemplo n.º 4
0
        //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());
            }
        }