protected void LinkButton1_Click(object sender, EventArgs e) { ShoppingCart k = new ShoppingCart(); int ProductID = Convert.ToInt32((((LinkButton)sender).CommandArgument)); DataTable dt= k.GetProductDetails(ProductID); dlProductDetails.DataSource = dt; dlProductDetails.DataBind(); pnlProducts.Visible = false; pnlDetails.Visible = true; }
//private void AddSubmitEvent() //{ // UpdatePanel updatepanel = Page.Master.FindControl("AdminUpdatePanel1") as UpdatePanel; // UpdatePanelControlTrigger trigger = new PostBackTrigger(); // trigger.ControlID = btnProductSubmit.UniqueID; // updatepanel.Triggers.Add(trigger); //} private void LoadCategories() { ShoppingCart k = new ShoppingCart(); DataTable dt = k.GetCategories(); if (dt.Rows.Count > 0) { ddlCategory.DataValueField = "CategoryID"; ddlCategory.DataTextField = "CategoryName"; ddlCategory.DataSource = dt; ddlCategory.DataBind(); } }
protected void btnRemoveFromCart_Click(object sender, EventArgs e) { int id = Convert.ToInt16((((Button)sender).CommandArgument)); List<int> lst = (List<int>)Session["CartItems[]"]; foreach (int i in lst) { if (i == id) { lst.Remove(i); break; } } Session["CartItems"] = lst; ShoppingCart k = new ShoppingCart(); dtCart = k.GetProductsWithProductId(lst); dlCart.DataSource = dtCart; dlCart.DataBind(); tbTotalProducts.Text = dlCart.Items.Count.ToString(); }
protected void btnProductSubmit_Click(object sender, EventArgs e) { if (UploadProductImage.PostedFile != null) { SaveProductImage(); ShoppingCart k = new ShoppingCart() { ProductName = tbProductName.Text, ProductImage = "~/ProductImages/" + UploadProductImage.FileName, ProductPrice = tbProductPrice.Text, ProductDescription = tbProductDescription.Text, CategoryId = Convert.ToInt32(ddlCategory.SelectedValue), TotalProducts = Convert.ToInt32(tbProductQuantity.Text) }; k.AddNewProduct(); ClearText(); Response.Redirect("~/Admin/AddProducts.aspx?alert=success"); } else { Response.Write("<script>alert('Please upload image');</script>"); } }
private void GetCategory() { ShoppingCart k = new ShoppingCart(); dlCategories.DataSource = k.GetCategories(); dlCategories.DataBind(); }
private void GetProducts(int CategoryID) { ShoppingCart k = new ShoppingCart() { CategoryId = CategoryID }; dlProducts.DataSource = null; dlProducts.DataSource = k.GetAllProducts(); dlProducts.DataBind(); }
private void LoadMyCart() { ShoppingCart k = new ShoppingCart(); pnlMyCart.Visible = true; //pnlCheckOut.Visible = true; if (lstMyCart.Count == 0) { Response.Write("<script>alert('There are no items in the cart');</script>"); } else { dtCart = k.GetProductsWithProductId(lstMyCart); dlCart.DataSource = dtCart; dlCart.DataBind(); tbTotalProducts.Text = dlCart.Items.Count.ToString(); } }