protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { #region --删除 if (e.CommandName == "cmdDelete") { Tz888.BLL.TPVideo bllobj = new Tz888.BLL.TPVideo(); Tz888.SQLServerDAL.TPVideo tpobj = new Tz888.SQLServerDAL.TPVideo(); DataSet ds = tpobj.GetOneVideoMess(e.CommandArgument.ToString()); if (ds.Tables[0].Rows.Count > 0) { try { string strHtmlURL = ds.Tables[0].Rows[0]["HtmlURL"].ToString(); Tz888.Common.FileManage.FileDelete(strHtmlURL); } catch { } } bool isSuccess = false; isSuccess = bllobj.DeleteVideoMess(e.CommandArgument.ToString()); if (isSuccess) { Response.Redirect(Request.RawUrl); } else { Response.Write("<script>alert('对编号为" + e.CommandArgument.ToString() + "的删除操作失败。'); </script>"); return; } } #endregion }
private void BathchDelete() { string idLst = Request.Form["chk"]; if (idLst.Length > 0) { Tz888.BLL.TPVideo bllobj = new Tz888.BLL.TPVideo(); string[] lst = idLst.Split(','); for (int i = 0; i < lst.Length; i++) { Tz888.SQLServerDAL.TPVideo tpobj = new Tz888.SQLServerDAL.TPVideo(); DataSet ds = tpobj.GetOneVideoMess(lst[i].ToString()); if (ds.Tables[0].Rows.Count > 0) { try { string strHtmlURL = ds.Tables[0].Rows[0]["HtmlURL"].ToString(); Tz888.Common.FileManage.FileDelete(strHtmlURL); } catch { } } } bool isSuccess = false; isSuccess = bllobj.DeleteVideoMess(idLst); if (isSuccess) { Response.Redirect(Request.RawUrl.Substring(0, Request.RawUrl.IndexOf("?"))); } else { Response.Write("<script>alert('部分删除操作失败。'); </script>"); } } }