Ejemplo n.º 1
0
 public bool AddProduct(Product prod)
 {
     if (IsValidProduct(prod))
     {
         _productControl.AddProduct(prod);
         return(true);
     }
     else
     {
         return(false);
     }
 }
Ejemplo n.º 2
0
        private void AddBtn_Click(object sender, RoutedEventArgs e)
        {
            Brand    selectedBrand    = (Brand)BrandCombo.SelectedItem;
            Category selectedCategory = (Category)CategoryCombo.SelectedItem;

            if (CheckForInput())
            {
                Product product = new Product
                {
                    Name          = NameTxt.Text,
                    Price         = Convert.ToDecimal(PriceTxt.Text),
                    Description   = DescriptionTxt.Text,
                    AmountOnStock = Convert.ToInt32(AmountOnStockTxt.Text),
                    BrandId       = selectedBrand.BrandId,
                    CategoryId    = selectedCategory.CategoryId
                };
                productControl.AddProduct(product);
                MessageBox.Show(product.Name + " Successfully added to database");
            }
            else
            {
                MessageBox.Show("Please fill out all the text fields");
            }
        }