Example #1
0
 private void BtnDeleteProduct_Click(object sender, EventArgs e)
 {
     if (DialogResult.Yes == MessageBox.Show("Do You Want Delete This Product?", "Confirmation",
                                             MessageBoxButtons.YesNo, MessageBoxIcon.Warning))
     {
         Product             selectedProduct = (Product)dgProducts.CurrentRow.DataBoundItem;
         ProductConnectedDao productDao      = new ProductConnectedDao();
         pcd.DeleteProduct(selectedProduct.ProductId);
         ShowProductList();
     }
 }
Example #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            ProductConnectedDao productConnectedDao = new ProductConnectedDao();

            _products = productConnectedDao.ReadAll();
            //Session["ProductList"] = concatImage();
            Session["ProductList"] = _products;
            if (!IsPostBack)
            {
                GvProducts.DataSource = (List <Product>)Session["ProductList"];
                GvProducts.DataBind();
            }
        }
Example #3
0
        private void BtnAddProduct_Click(object sender, EventArgs e)
        {
            ProductConnectedDao productDao = new ProductConnectedDao();

            try
            {
                CheckImage();
                Product product = new Product(1, TxtProdName.Text, TxtProdDescription.Text, imageName,
                                              Double.Parse(TxtProdPrice.Text), ((Category)CmbProdCategory.SelectedItem).CategoryId);
                if (imageDir != null)
                {
                    File.Copy(imageDir, Path.Combine(
                                  @"C:\Users\diljo\Desktop\C# Project\OnlineShoppingSystem\OnlineShoppingSystem\ClassLibrary\Images\ProductImages\",
                                  imageName), true);
                }
                productDao.AddProduct(product);
                MessageBox.Show("Product has been added!");
                ClearFields();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error is: " + ex);
            }
        }