private void GetCategories()
 {
     MainLibrary k = new MainLibrary();
     DataTable dt = k.GetCategories();
     if (dt.Rows.Count > 0)
     {
         gvAvailableCategories.DataSource = dt;
         gvAvailableCategories.DataBind();
     }
 }
 protected void gvAvailableCategories_RowDeleting(object sender, GridViewDeleteEventArgs e)
 {
     int CategoryID = Int32.Parse(((Label)gvAvailableCategories.Rows[e.RowIndex].FindControl("lblCatId")).Text);
     MainLibrary k = new MainLibrary()
     {
         CategoryID = CategoryID
     };
     k.DeleteCategory();
     GetCategories();
 }
 private void GetCategories()
 {
     MainLibrary k = new MainLibrary();
     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("lblEdtCatId")).Text);
            string CategoryName = ((TextBox)gvAvailableCategories.Rows[e.RowIndex].FindControl("txtEdtCatName")).Text;
            MainLibrary k = new MainLibrary()
            {
                CategoryID = CategoryID,
                CategoryName = CategoryName

            };
            k.UpdateCategory();
            gvAvailableCategories.EditIndex = -1;
            GetCategories();
        }
 protected void btnSubmit_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty((txtCategoryName.Text).Trim()))
     {
         MainLibrary k = new MainLibrary
         {
             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();

                MainLibrary k = new MainLibrary()
                {
                    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>");
            }
        }