protected void ImgBtnDelete_Click(object sender, ImageClickEventArgs e) { productManager objprodelete = new productManager(); ImageButton lnkRemove = (ImageButton)sender; objprodelete.productImagesId = Convert.ToInt32(lnkRemove.CommandArgument); string dtimgs = objprodelete.getProductImageName(); if (dtimgs != "") { string fullimagepath = string.Empty; string thumbimagepath = string.Empty; string mediumimagepath = string.Empty; string thumbrectimagepath = string.Empty; fullimagepath = Server.MapPath(AppSettings.PRODUCT_ACTULE_ROOTURL + dtimgs); thumbimagepath = Server.MapPath(AppSettings.PRODUCT_THUMB_ROOTURL + dtimgs); mediumimagepath = Server.MapPath(AppSettings.PRODUCT_MEDIUM_ROOTURL + dtimgs); thumbrectimagepath = Server.MapPath(AppSettings.PRODUCT_THUMBRECT_ROOTURL + dtimgs); CommonFunctions.DeleteFile(fullimagepath); CommonFunctions.DeleteFile(thumbimagepath); CommonFunctions.DeleteFile(mediumimagepath); CommonFunctions.DeleteFile(thumbrectimagepath); } objprodelete.DeleteProductImageByProductImageId(); BindProduct(); lblmsg.Visible = true; lblmsgs.Text = "Product image has been deleted successfully"; }
public string DeleteProductImage(string productimageid) { productManager objpro = new productManager(); if (productimageid != "0" || productimageid == "") { objpro.productImagesId = Convert.ToInt32(productimageid); string strImg = objpro.getProductImageName(); if (strImg != "") { string fullimagepath = string.Empty; string thumbimagepath = string.Empty; string mediumimagepath = string.Empty; string thumbrectimagepath = string.Empty; fullimagepath = Server.MapPath(AppSettings.PRODUCT_ACTULE_ROOTURL + strImg); thumbimagepath = Server.MapPath(AppSettings.PRODUCT_THUMB_ROOTURL + strImg); mediumimagepath = Server.MapPath(AppSettings.PRODUCT_MEDIUM_ROOTURL + strImg); thumbrectimagepath = Server.MapPath(AppSettings.PRODUCT_THUMBRECT_ROOTURL + strImg); CommonFunctions.DeleteFile(fullimagepath); CommonFunctions.DeleteFile(thumbimagepath); CommonFunctions.DeleteFile(mediumimagepath); CommonFunctions.DeleteFile(thumbrectimagepath); } objpro.DeleteProductImageByProductImageId(); return("success"); } else { return("fail"); } }
//handle delete event protected void btnDelete_Click(object sender, EventArgs e) { productManager objproduct = new productManager(); try { int con = 0; CheckBox chk = new CheckBox(); string ActImage = string.Empty; string ThumbImage = string.Empty; DataSet dsadmin = new DataSet(); for (int i = 0; i < gvAdmin.Rows.Count; i++) { chk = (CheckBox)(gvAdmin.Rows[i].FindControl("chkDelete")); if (chk.Checked == true) { con += 1; objproduct.productImagesId = Convert.ToInt32(gvAdmin.DataKeys[gvAdmin.Rows[i].RowIndex].Value.ToString()); string dtimgs = objproduct.getProductImageName(); if (dtimgs != "") { string fullimagepath = string.Empty; string thumbimagepath = string.Empty; string mediumimagepath = string.Empty; string thumbrectimagepath = string.Empty; fullimagepath = Server.MapPath(AppSettings.PRODUCT_ACTULE_ROOTURL + dtimgs); thumbimagepath = Server.MapPath(AppSettings.PRODUCT_THUMB_ROOTURL + dtimgs); mediumimagepath = Server.MapPath(AppSettings.PRODUCT_MEDIUM_ROOTURL + dtimgs); thumbrectimagepath = Server.MapPath(AppSettings.PRODUCT_THUMBRECT_ROOTURL + dtimgs); CommonFunctions.DeleteFile(fullimagepath); CommonFunctions.DeleteFile(thumbimagepath); CommonFunctions.DeleteFile(mediumimagepath); CommonFunctions.DeleteFile(thumbrectimagepath); } objproduct.DeleteProductImageByProductImageId(); } } Response.Redirect("ProductImageUpload.aspx?flag=delete&key=" + txtsearch.Text + " &pageSize=" + ddlpageSize.SelectedValue + ""); } catch (Exception ex) { throw ex; } finally { objproduct = null; } }