Ejemplo n.º 1
0
    protected void gvProduct_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "DeleteRecord")
        {
            if (e.CommandArgument != null)
            {
                ProductBAL balProduct = new ProductBAL();
                ProductENT entProduct = new ProductENT();

                #region Delete image from folder
                entProduct = balProduct.SelectByPK(Convert.ToInt32(e.CommandArgument.ToString()));
                FileInfo path = new FileInfo(Server.MapPath(entProduct.ProductImage.Value.ToString()));
                path.Delete();
                #endregion Delete image from folder

                if (balProduct.Delete(Convert.ToInt32(e.CommandArgument.ToString().Trim())))
                {
                    FillProductGridView();
                }
                else
                {
                    lblMessage.Text    = balProduct.Message;
                    divMessage.Visible = true;
                }
            }
        }
    }
Ejemplo n.º 2
0
 protected void gvProduct_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName == "DeleteRecord" && e.CommandArgument != null)
     {
         ProductBAL balProduct = new ProductBAL();
         if (balProduct.Delete(Convert.ToInt32(e.CommandArgument)))
         {
             FillProductGridView(Convert.ToInt32(Session["UserID"]));
         }
         else
         {
             lblMessage.Text = balProduct.Message;
         }
     }
 }