Esempio n. 1
0
        private void removeProduct()
        {
            try
            {
                if (ProductTo.SelectedItem != null)
                {
                    List <Products>    removeList  = new List <Products>();
                    ClientProductProxy thisRecord  = (ClientProductProxy)ProductTo.SelectedItem;
                    Products           thisProduct = ProductFunctions.GetProductByID(thisRecord.ProductID);
                    removeList.Add(thisProduct);

                    bool success = ClientFunctions.ToggleClientProducts(removeList, false, Globals.SelectedClient);
                    if (success)
                    {
                        refreshProductSummaries(false);
                        CommitButton.IsEnabled = true;
                    }
                }
                else
                {
                    MessageFunctions.Error("Error removing products from client: no product selected.", null);
                }
            }
            catch (Exception generalException)
            {
                MessageFunctions.Error("Error removing products from client", generalException);
            }
        }
        // ---------------------- //
        // -- Data Management --- //
        // ---------------------- //

        // Data updates //
        private void refreshProductCombo(bool includeAll)
        {
            try
            {
                productComboList          = ProductFunctions.ProductsList("", includeAll);
                ProductCombo.ItemsSource  = productComboList;
                ProductCombo.SelectedItem = productComboList.FirstOrDefault(p => p.ID == selectedProductID);
            }
            catch (Exception generalException) { MessageFunctions.Error("Error populating product filter list", generalException); }
        }
Esempio n. 3
0
        private void CommitButton_Click(object sender, RoutedEventArgs e)
        {
            if (editMode)
            {
                if (selectedProduct != null)
                {
                    bool success = ProductFunctions.AmendProduct(selectedProduct.ID, ProductName.Text, Description.Text, Version.Text);
                    if (success)
                    {
                        MessageFunctions.SuccessAlert("Your changes have been saved successfully.", "Product Amended");
                        refreshProductGrid();
                        amendmentSetup();
                    }
                }
                else
                {
                    int newID = ProductFunctions.NewProduct(ProductName.Text, Description.Text, Version.Text);
                    if (newID > 0)
                    {
                        additionMade = true;
                        refreshProductGrid();
                        if (pageMode == PageFunctions.Amend)
                        {
                            MessageFunctions.SuccessAlert("New product '" + ProductName.Text + "' saved successfully.", "Product Created");
                            amendmentSetup();
                            ProductGrid.SelectedValue = gridList.First(s => s.ID == newID);
                            ProductGrid.ScrollIntoView(ProductGrid.SelectedItem);
                        }
                        else
                        {
                            MessageFunctions.SuccessAlert("New product '" + ProductName.Text + "' saved successfully. You can create further products using the 'Add Another' button.", "Product Created");
                            ProductName.IsEnabled = Description.IsEnabled = Version.IsEnabled = false;
                            editMode = false;
                            CommitButton.IsEnabled = false;

                            AddButton.Visibility    = Visibility.Visible;
                            AddButton.IsEnabled     = true;
                            AddImage.Visibility     = Visibility.Visible;
                            ReturnImage2.Visibility = Visibility.Collapsed;
                        }
                        AddButtonText.Text = "Add Another";
                    }
                }
            }
            else
            {
                MessageFunctions.Error("Saving should not be possible.", null);
            }
        }
Esempio n. 4
0
        // ---------------------- //
        // -- Data Management --- //
        // ---------------------- //

        // Data updates //
        private void refreshProductGrid()
        {
            gridList = ProductFunctions.ProductsList(descContains);
            ProductGrid.ItemsSource = gridList;
        }