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 }
protected void Page_Load(object sender, EventArgs e) { if (Page.User.Identity.Name == "") { Response.Redirect("../Login.aspx"); } if (!IsPostBack) { //ViewState["strSavePath"] = "UploadVideo/y/"; ViewState["strSavePath"] = "UploadVideo/" + Page.User.Identity.Name + "/"; try { Tz888.SQLServerDAL.TPVideo objtp = new Tz888.SQLServerDAL.TPVideo(); string infoid = Request.QueryString["id"].ToString(); DataSet ds = objtp.GetOneVideoMess(infoid); this.txtTitle.Value = ds.Tables[0].Rows[0]["subTitle"].ToString(); this.txtContent.Value = Tz888.Common.Utility.PageValidate.HtmlToTxt(ds.Tables[0].Rows[0]["Content"].ToString()); this.txtAuthor.Value = ds.Tables[0].Rows[0]["Author"].ToString(); this.txtKeyWord.Value = ds.Tables[0].Rows[0]["KeyWord"].ToString(); string strOrigin = ds.Tables[0].Rows[0]["Origin"].ToString().Trim(); ZoneSelectControl1.ProvinceID = ds.Tables[0].Rows[0]["ProvinceID"].ToString().Trim(); ZoneSelectControl1.CityID = ds.Tables[0].Rows[0]["CityID"].ToString().Trim(); ZoneSelectControl1.CountyID = ds.Tables[0].Rows[0]["CountyID"].ToString().Trim(); switch (strOrigin) { case "转载": System.Web.UI.HtmlControls.HtmlInputRadioButton obj1 = (System.Web.UI.HtmlControls.HtmlInputRadioButton) this.Form.FindControl("radioType1"); if (obj1 != null) { obj1.Checked = true; } break; case "原创": System.Web.UI.HtmlControls.HtmlInputRadioButton obj2 = (System.Web.UI.HtmlControls.HtmlInputRadioButton) this.Form.FindControl("radioType2"); if (obj2 != null) { obj2.Checked = true; } break; default: break; } } catch { Response.Write("<script>alert('请重新选择要修改的数据!'); window.close();</script>"); } } this.BtnAddVideo.Attributes.Add("onclick", "return chkInput();"); }
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>"); } } }