protected void btnDeleteSelect_Click(object sender, EventArgs e) { if (Session["ZT_ADMIN"] == null) { Response.Redirect("Login.aspx"); } else { if (!Communal.CheckQx("ProductDelete.aspx")) { Response.Redirect("RightsWarn.aspx"); } else { string DeleteTitle = ""; foreach (GridViewRow gr in this.GridView1.Rows) { CheckBox cb = (CheckBox)gr.Cells[1].FindControl("Select"); if (cb.Checked) { //删除数据库信息 Label ll = (Label)gr.Cells[1].FindControl("lblProductID"); int ProductID = Convert.ToInt32(ll.Text); WebProject.BLL.BaseData.ZT_COM_Product bll_Product = new WebProject.BLL.BaseData.ZT_COM_Product(); DeleteTitle += bll_Product.GetModel(ProductID).ProductName + ","; bll_Product.Delete(ProductID); //删除文件夹的图片 Label l2 = (Label)gr.Cells[0].FindControl("lblProductImgUrl"); if (l2.Text != "onlinenone.jpg") { System.IO.File.Delete(Server.MapPath("IMG/" + l2.Text)); } } } LogManage.WriteLog(Request.UserHostAddress, "产品管理", "删除产品信息", "成功", "产品名称:" + DeleteTitle.TrimEnd(',') + ", 操作人:" + SessionUtil.GetAdminSession().AdminNo); ShowData(); } } }
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { if (Session["ZT_ADMIN"] == null) { Response.Redirect("Login.aspx"); } else { if (!Communal.CheckQx("ProductDelete.aspx")) { Response.Redirect("RightsWarn.aspx"); } else { //删除数据库的信息 Label ll = (Label)this.GridView1.Rows[e.RowIndex].Cells[1].FindControl("lblProductID"); int ProductID = Convert.ToInt32(ll.Text); WebProject.BLL.BaseData.ZT_COM_Product bll_Product = new WebProject.BLL.BaseData.ZT_COM_Product(); LogManage.WriteLog(Request.UserHostAddress, "产品管理", "删除产品信息", "成功", "产品名称:" + bll_Product.GetModel(ProductID).ProductName + ", 操作人:" + SessionUtil.GetAdminSession().AdminNo); bll_Product.Delete(ProductID); //删除文件夹的图片 Label l2 = (Label)this.GridView1.Rows[e.RowIndex].Cells[0].FindControl("lblProductImgUrl"); if (l2.Text != "onlinenone.jpg") { System.IO.File.Delete(Server.MapPath("IMG/" + l2.Text)); } //重新加载信息 ShowData(); } } }