protected void btnDeleteSelect_Click(object sender, EventArgs e) { if (Session["ZT_ADMIN"] == null) { Response.Redirect("Login.aspx"); } else { if (!Communal.CheckQx("RongYuDelete.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("lblRongYuID"); int RongYuID = Convert.ToInt32(ll.Text); WebProject.BLL.BaseData.ZT_COM_RongYu bll_RongYu = new WebProject.BLL.BaseData.ZT_COM_RongYu(); DeleteTitle += bll_RongYu.GetModel(RongYuID).Title + ","; bll_RongYu.Delete(RongYuID); //删除文件夹的图片 Label l2 = (Label)gr.Cells[0].FindControl("lblImgUrl"); if (l2.Text != "onlinenone.jpg") { System.IO.File.Delete(Server.MapPath("IMG/" + l2.Text)); } } } LogManage.WriteLog(Request.UserHostAddress, "荣誉管理", "删除荣誉", "成功", "荣誉标题:" + DeleteTitle.TrimEnd(',') + ", 操作人:" + SessionUtil.GetAdminSession().AdminNo); ShowData(txtRongYuType.SelectedValue.ToString()); } } }
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { if (Session["ZT_ADMIN"] == null) { Response.Redirect("Login.aspx"); } else { if (!Communal.CheckQx("RongYuDelete.aspx")) { Response.Redirect("RightsWarn.aspx"); } else { //删除数据库的信息 Label ll = (Label)this.GridView1.Rows[e.RowIndex].Cells[1].FindControl("lblRongYuID"); int RongYuID = Convert.ToInt32(ll.Text); WebProject.BLL.BaseData.ZT_COM_RongYu bll_RongYu = new WebProject.BLL.BaseData.ZT_COM_RongYu(); LogManage.WriteLog(Request.UserHostAddress, "荣誉管理", "删除荣誉", "成功", "荣誉标题:" + bll_RongYu.GetModel(RongYuID).Title + ", 操作人:" + SessionUtil.GetAdminSession().AdminNo); bll_RongYu.Delete(RongYuID); //删除文件夹的图片 Label l2 = (Label)this.GridView1.Rows[e.RowIndex].Cells[0].FindControl("lblImgUrl"); if (l2.Text != "onlinenone.jpg") { System.IO.File.Delete(Server.MapPath("IMG/" + l2.Text)); } //重新加载信息 ShowData(txtRongYuType.SelectedValue.ToString()); } } }