Asp.net源码专业站
首页->新闻文章->jimmyNews(Asp.net新闻系统)1.0源码>>Admin/class/Delete.aspx.cs>>源码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:jimmyNews(Asp.net新闻系统)1.0源码
当前文件:文件类型 jimmyNews/Admin/class/Delete.aspx.cs[2K,2009-6-12 11:45:38]打开代码结构图
普通视图
		            
1using System; 2using System.Data; 3using System.Data.OleDb; 4using System.Configuration; 5using System.Collections; 6using System.Web; 7using System.Web.Security; 8using System.Web.UI; 9using System.Web.UI.WebControls; 10using System.Web.UI.WebControls.WebParts; 11using System.Web.UI.HtmlControls; 12using CFCHINA.TOOLS.COMM; 13using CFCHINA.TOOLS.ACCESS; 14 15public partial class Admin_Class_Delete : System.Web.UI.Page 16{ 17 Tools tl = new Tools(); 18 DataBase db = new DataBase(); 19 string strSql = ""; 20 21 protected void Page_Load(object sender, EventArgs e) 22 { 23 try 24 { 25 string id = Request["id"].ToString(); 26 id = tl.GetSafeStr(id); 27 28 id = "'" + id + "'"; 29 id = id.Replace(",", "','"); 30 31 //先删除新闻图片 32 strSql = "Select * From cf_news Where CF_ClsID in (" + id + ")"; 33 OleDbConnection conn = db.GetConn(); 34 OleDbDataReader sdr = db.RunSql(strSql, conn); 35 36 while (sdr.Read()) 37 { 38 DeleteNews(sdr[0].ToString()); 39 } 40 41 sdr.Close(); 42 db.Dispose(conn); 43 44 strSql = "Delete From cf_Class Where cf_Id in (" + id + ")"; 45 db.ExecuteNonQuery(strSql); 46 tl.Alert("分类删除成功!", "Default.aspx?page=" + Request["Page"].ToString()); 47 } 48 catch (Exception ex) 49 { 50 tl.Alert(ex.Message.ToString().Replace("'", ""), "javascript:window.history.back();"); 51 } 52 } 53 54 55 protected void DeleteNews(string newsId) { 56 try 57 { 58 OleDbConnection conn = db.GetConn(); 59 strSql = "select * from cf_News Where cf_Id='" + newsId + "'"; 60 OleDbDataReader dr = db.RunSql(strSql,conn); 61 if (dr.Read()) 62 { 63 //先删除图片 64 string fileList = dr["cf_SavePathFile"].ToString(); 65 String[] fileArr = fileList.Split('|'); 66 for (int i = 0; i <= fileArr.GetUpperBound(0); i++) 67 { 68 tl.DeleteFile(fileArr[i]); 69 } 70 71 //再删除tag 72 strSql = "Delete from cf_tags Where cf_NewsId='" + newsId + "'"; 73 db.ExecuteNonQuery(strSql); 74 75 //最后删除自己 76 strSql = "Delete from cf_News Where cf_Id='" + newsId + "'"; 77 db.ExecuteNonQuery(strSql); 78 db.Dispose(conn); 79 } 80 } 81 catch (Exception ex) 82 { 83 tl.Alert(ex.Message.ToString(), "javascript:window.history.back()"); 84 } 85 } 86 87 88 89} 90
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:jimmyNews(Asp.net新闻系统)1.0源码
51Aspx.com 版权所有 CopyRight © 2006-2010. 京ICP备06046876号 本站法律顾问:ITlaw-庄毅雄律师
返回顶部
客户服务:点击这里进行客户咨询 业务合作:点击这里洽谈业务合作 合作热线:010-68880146