Exemplo n.º 1
0
        private void linkLabel_editProduct_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            Category selectedCategory = comboBox_existingProductCategories.SelectedItem as Category;
              Product selectedProduct = comboBox_ProductsInCategory.SelectedItem as Product;

            if (selectedCategory != null && selectedProduct != null)
            {
                Product editProduct = db.Products.Where(x => x.CategoryId == selectedCategory.CategoryId && x.ProductId == selectedProduct.ProductId).Single();

                Hashtable productDetails = new Hashtable();
                productDetails["CategoryId"] = selectedCategory.CategoryId ;
                productDetails["ProductId"] = selectedProduct.ProductId;
                productDetails["ProductName"] = selectedProduct.ProductName;
                productDetails["ToEdit"] = true;

                ProductDetails details = new ProductDetails();
                details.setProductName(productDetails);

                details.Show();
            }
        }
Exemplo n.º 2
0
        private void checkBox_addProductDetails_CheckedChanged(object sender, EventArgs e)
        {
            if (checkBox_addProductDetails.Checked)
            {
                if (textBox_newProduct.Text.Trim().Length == 0)
                {
                    CommonUtilities.showErrorPopUp("Please Enter a Product Name");
                    checkBox_addProductDetails.Checked = false;
                    return;
                }

                 Category selectedCategory = comboBox_existingProductCategories.SelectedItem as Category;
                 Product selectedProduct = comboBox_ProductsInCategory.SelectedItem as Product;

                List<String> productNames = db.Products.Where(x => x.CategoryId == selectedCategory.CategoryId).Select(x => x.ProductName).ToList();

                if (productNames.Contains(textBox_newProduct.Text.Trim().ToLower()))
                {
                    CommonUtilities.showErrorPopUp(textBox_newProduct.Text.Trim().ToLower() + " Already Exists");
                    return;
                }

                Hashtable productInfo = new Hashtable();
                productInfo["CategoryId"] = selectedCategory.CategoryId;
                productInfo["ProductName"] = textBox_newProduct.Text.Trim().ToLower();

                ProductDetails productDetails = new ProductDetails();
                productDetails.setProductName(productInfo);

                productDetails.Show();
            }
        }