private void GetCategories() { ShoppingCart k = new ShoppingCart(); DataTable dt = k.GetCategories(); if (dt.Rows.Count > 0) { gvAvailableCategories.DataSource = dt; gvAvailableCategories.DataBind(); } }
protected void gvAvailableProducts_RowDeleting(object sender, GridViewDeleteEventArgs e) { int ProductID = Int32.Parse(((Label)gvAvailableProducts.Rows[e.RowIndex].FindControl("Label4")).Text); ShoppingCart k = new ShoppingCart() { ProductID = ProductID }; k.DeleteProduct(); GetProducts(0); }
protected void gvAvailableCategories_RowDeleting(object sender, GridViewDeleteEventArgs e) { int CategoryID = Int32.Parse(((Label)gvAvailableCategories.Rows[e.RowIndex].FindControl("Label1")).Text); ShoppingCart k = new ShoppingCart() { CategoryID = CategoryID }; k.DeleteCategory(); GetCategories(); }
private void GetCategories() { 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 gvAvailableCategories_RowUpdating(object sender, GridViewUpdateEventArgs e) { int CategoryID = Convert.ToInt32(((Label)gvAvailableCategories.Rows[e.RowIndex].FindControl("Label3")).Text); string CategoryName = ((TextBox)gvAvailableCategories.Rows[e.RowIndex].FindControl("TextBox1")).Text; ShoppingCart k = new ShoppingCart() { CategoryID = CategoryID, CategoryName = CategoryName }; k.UpdateCategory(); gvAvailableCategories.EditIndex = -1; GetCategories(); }
protected void btnSubmit_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty((txtCategoryName.Text).Trim())) { ShoppingCart k = new ShoppingCart { CategoryName = txtCategoryName.Text }; k.AddNewCategory(); txtCategoryName.Text = string.Empty; Response.Redirect("~/Admin/AddEditCategory.aspx"); } else { Response.Redirect("~/Admin/AddEditCategory.aspx"); } }
protected void btnSubmit_Click(object sender, EventArgs e) { if (uploadProductPhoto.PostedFile != null) { SaveProductPoto(); ShoppingCart k = new ShoppingCart() { ProductName = txtProductName.Text, ProductImage = "~/ProductImages/" + uploadProductPhoto.FileName, ProductPrice = Int32.Parse( txtProductPrice.Text), ProductDescription = txtProductDescription.Text, CategoryID = Convert.ToInt32(ddlCategory.SelectedValue) }; k.AddNewProduct(); ClearText(); Response.Redirect("~/Admin/AddNewProducts.aspx?alert=success"); } else { Response.Redirect("<script>alert('Please Upload Photo');</script>"); } }
protected void gvAvailableProducts_RowDataBound(object sender, GridViewRowEventArgs e) { DataRowView drv = e.Row.DataItem as DataRowView; if (e.Row.RowType == DataControlRowType.DataRow) { if ((e.Row.RowState & DataControlRowState.Edit) > 0) { ContentPlaceHolder cpl = Page.Master.FindControl("ContentPlaceHolder1") as ContentPlaceHolder; ScriptManager scriptmanager1 = Page.Master.FindControl("ScriptManager1") as ScriptManager; scriptmanager1.RegisterPostBackControl(cpl); ShoppingCart k = new ShoppingCart(); DropDownList dp = (DropDownList)e.Row.FindControl("DropDownList1"); DataTable dt = k.GetCategories(); for (int i = 0; i < dt.Rows.Count; i++) { ListItem lt = new ListItem(); lt.Value = dt.Rows[i][0].ToString(); lt.Text = dt.Rows[i][1].ToString(); dp.Items.Add(lt); } } } }
protected void btnPlaceOrder_Click(object sender, EventArgs e) { //string productids = string.Empty; int ProductID = Convert.ToInt32(hfProductID.Value); //DataTable dt; if (txtCustomerName.Text != null && txtCustomerEmailID.Text != null) { //dt = (DataTable)Session["MyCart"]; ShoppingCart k = new ShoppingCart() { CustomerName = txtCustomerName.Text, CustomerEmailID = txtCustomerEmailID.Text, CustomerPhoneNo = txtCustomerPhoneNo.Text, CustomerMessage = txtCustomerMessage.Text, ProductID = ProductID //TotalProducts = Convert.ToInt32(txtTotalProducts.Text), //TotalPrice = Convert.ToInt32(txtTotalPrice.Text), //ProductList = productids //PaymentMethod = rblPaymentMethod.SelectedItem.Text }; DataTable dtResult = k.SaveCustomerDetails(); //for (int i = 0; i < dt.Rows.Count; i++) //{ // ShoppingCart SaveProducts = new ShoppingCart() // { // CustomerID = Convert.ToInt32(dtResult.Rows[0][0]), // ProductID = Convert.ToInt32(dt.Rows[i]["ProductID"]), // TotalProducts = Convert.ToInt32(dt.Rows[i]["ProductQuantity"]) // }; // SaveProducts.SaveCustomerProducts(); //} Session.Clear(); pnlCheckOut.Visible = false; pnlCategories.Visible = false; pnlProducts.Visible = false; SendOrderPlacedAlert(txtCustomerName.Text, txtCustomerEmailID.Text, ProductID); txtCustomerName.Text = string.Empty; txtCustomerEmailID.Text = string.Empty; txtCustomerPhoneNo.Text = string.Empty; txtCustomerMessage.Text = string.Empty; pnlProducts.Visible = true; pnlCategories.Visible = true; pnlCheckOut.Visible = false; pnlDetails.Visible = false; // Response.Redirect("~/Default.aspx"); } }
private void GetProducts(int CategoryIDs) { pageall.Visible = true; ShoppingCart k = new ShoppingCart() { CategoryID = CategoryIDs }; dlProducts.DataSource = null; adsource = new PagedDataSource(); adsource.DataSource = (k.GetAllProducts()).DefaultView; if (CategoryIDs != 0 && pnlProducts.Visible == true) { DataTable dtable = k.GetCategory(); if (dtable.Rows.Count > 0) { lblCategoryName.Text = " > " + (k.GetCategory()).Rows[0]["CategoryName"].ToString() + " >"; } } else lblCategoryName.Text = ""; adsource.AllowPaging = true; adsource.PageSize = 9; adsource.CurrentPageIndex = pos; //btnfirst.Enabled = !adsource.IsFirstPage; //btnlast.Enabled = !adsource.IsLastPage; last = adsource.PageCount - 1; this.ViewState["vf"] = last; btnprevious.Visible = btnnext.Visible = btnLastPage.Visible = btnFirstPage.Visible = true; btnFirstPage.Text = "1"; btnLastPage.Text = Convert.ToString(last + 1); btnprevious.Enabled = !adsource.IsFirstPage; btnnext.Enabled = !adsource.IsLastPage; if (adsource.IsLastPage) { btnLastPage.ForeColor = System.Drawing.Color.White; btnLastPage.Font.Bold = true; } else { btnLastPage.ForeColor = System.Drawing.Color.Black; btnLastPage.Font.Bold = false; } if (adsource.IsFirstPage) { btnFirstPage.ForeColor = System.Drawing.Color.White; btnFirstPage.Font.Bold = true; } else { btnFirstPage.ForeColor = System.Drawing.Color.Black; btnFirstPage.Font.Bold = false; } if (adsource.PageCount == 1) { pageall.Visible = false; btnFirstPage.Visible = false; btnLastPage.Visible = false; btnprevious.Visible = false; btnnext.Visible = false; } else { btnFirstPage.Visible = true; btnFirstPage.Enabled = !adsource.IsFirstPage; btnLastPage.Visible = true; btnLastPage.Enabled = !adsource.IsLastPage; } dlProducts.DataSource = adsource; dlProducts.DataBind(); }
private void GetCategory() { ShoppingCart k = new ShoppingCart(); dlCategories.DataSource = null; dlCategories.DataSource = k.GetCategories(); dlCategories.DataBind(); }
protected void ImageButton1_Click(object sender, ImageClickEventArgs e) { pnlProducts.Visible = false; lblCategoryName.Text = ""; pnlDetails.Visible = true; int ProductID = (int)Convert.ToInt32(((((ImageButton)sender).CommandArgument)).ToString()); ScriptManager1.AddHistoryPoint(deltaKey, Convert.ToString(ProductID)); ShoppingCart k = new ShoppingCart() { ProductID = ProductID }; DataTable dtResult = k.GetProductInfo(); lblProductName.Text = Convert.ToString(dtResult.Rows[0]["Name"]); lblProductDescription.Text = Convert.ToString(dtResult.Rows[0]["Description"]); lblPrice.Text = Convert.ToString(dtResult.Rows[0]["Price"]); lblTelefon2.Text = ConfigurationManager.AppSettings["Telefon"]; //HiddenField1.Value = ProductID.ToString(); btnWriteMessage.CommandArgument = ProductID.ToString(); Image2.ImageUrl = Convert.ToString(dtResult.Rows[0]["ImageUrl"]); // ProductID = Convert.ToInt32(dt.Rows[i]["ProductID"]), // TotalProducts = Convert.ToInt32(dt.Rows[i]["ProductQuantity"]) // }; }
protected void gvAvailableProducts_RowUpdating(object sender, GridViewUpdateEventArgs e) { FileUpload fileupload1 = (FileUpload)gvAvailableProducts.Rows[e.RowIndex].FindControl("FileUpload1"); int ProductID = Int32.Parse(((Label)gvAvailableProducts.Rows[e.RowIndex].FindControl("Label5")).Text); string Name = ((TextBox)gvAvailableProducts.Rows[e.RowIndex].FindControl("TextBox1")).Text; string Description= ((TextBox)gvAvailableProducts.Rows[e.RowIndex].FindControl("TextBox4")).Text; int CategoryID = Int32.Parse(((DropDownList)gvAvailableProducts.Rows[e.RowIndex].FindControl("DropDownList1")).SelectedValue.ToString()); int ProductPrice = Int32.Parse(((TextBox)gvAvailableProducts.Rows[e.RowIndex].FindControl("TextBox2")).Text); string ProductImage = ((TextBox)gvAvailableProducts.Rows[e.RowIndex].FindControl("txtImg")).Text; if (fileupload1.PostedFile != null && fileupload1.HasFile) { SaveProductPoto(fileupload1); ProductImage = "~/ProductImages/" + fileupload1.FileName; } ShoppingCart k = new ShoppingCart() { ProductID = ProductID, ProductName = Name, ProductPrice = ProductPrice, ProductImage = ProductImage, ProductDescription = Description, CategoryID = CategoryID }; k.UpdateProduct(); gvAvailableProducts.EditIndex = -1; GetProducts(0); }
private void GetProducts(int CategoryID) { ShoppingCart k = new ShoppingCart() { CategoryID = CategoryID }; gvAvailableProducts.DataSource = null; gvAvailableProducts.DataSource = k.GetAllProducts(); gvAvailableProducts.DataBind(); }