Ejemplo n.º 1
0
    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        try
        {
            if (e.CommandName == "Addimage")
            {
                long Pono = long.Parse(e.CommandArgument.ToString());
                Session["id"] = Pono;
                Response.Redirect("ProductPictures.aspx");
            }

            else if (e.CommandName == "Addspec")
            {
                GridViewRow gvr      = (GridViewRow)(((ImageButton)e.CommandSource).NamingContainer);
                int         RemoveAt = gvr.RowIndex;
                string      sValue   = ((HiddenField)GridView1.Rows[RemoveAt].Cells[5].FindControl("hidenpcid")).Value;
                string      pname    = ((Label)GridView1.Rows[RemoveAt].Cells[2].FindControl("lblpn")).Text;
                Session["PplantName"] = pname;
                long   Poid = long.Parse(e.CommandArgument.ToString());
                string pcid = sValue;
                Session["id"]   = Poid;
                Session["pcid"] = pcid;
                Response.Redirect("SpecificationValues.aspx");
            }
            else if (e.CommandName == "EditProduct")
            {
                long productid = long.Parse(e.CommandArgument.ToString());
                Session["productid"] = productid;
                List <Products> lstpr = objProducts.GetProductData(productid);

                foreach (Products pitem in lstpr)
                {
                    string PCName = pitem.ProductCategoryName;
                    ddlProductCategoryu.SelectedItem.Text = PCName;
                    ddlProductCategoryu.SelectedValue     = pitem.ProductCategoryID.ToString();
                    TextProductName.Text    = pitem.ProductName;
                    TextDescription.Text    = pitem.Description;
                    txtproductprice.Text    = pitem.Price.ToString();
                    textGemSize.Text        = pitem.GemSize.ToString();
                    txtdeliverycharges.Text = pitem.DeliveryCharges;
                }
                mpebtnEdit.Show();
            }
            else if (e.CommandName == "DeleteProduct")
            {
                long productid = long.Parse(e.CommandArgument.ToString());

                objspec.DeleteProductSpec(productid);
                objprodpic.DeleteProductPic(productid);
                objProducts.DeleteRecord(productid);
                BindData();
                DivMsg.Style.Add("display", "inline-table");
                lblMsg.Text = "Deleted Successfully !";
            }
        }
        catch (Exception ex)
        {
            // Response.Write("<script  type=text/javascript''>alert('You don't have Permission to perform this operation...Please try again..!')</script>");
            //throw ex;
            DivMsg.Style.Add("display", "inline-table");
            lblMsg.Text = "Cannot delete product !";
        }
    }