温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:jimmyNews(Asp.net新闻系统)1.0源码
当前文件:
jimmyNews/Admin/class/Delete.aspx.cs[2K,2009-6-12 11:45:38],打开代码结构图
jimmyNews/Admin/class/Delete.aspx.cs[2K,2009-6-12 11:45:38],打开代码结构图1using System; 2
using System.Data; 3
using System.Data.OleDb; 4
using System.Configuration; 5
using System.Collections; 6
using System.Web; 7
using System.Web.Security; 8
using System.Web.UI; 9
using System.Web.UI.WebControls; 10
using System.Web.UI.WebControls.WebParts; 11
using System.Web.UI.HtmlControls; 12
using CFCHINA.TOOLS.COMM; 13
using CFCHINA.TOOLS.ACCESS; 14
15
public 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





Tools tl 
}
}