温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:BugTrack51aspx汉化改造版V2.1.7
当前文件:
14RFAMJDWSL814/delete_attachment.aspx[2K,2009-6-12 11:30:42],打开代码结构图
14RFAMJDWSL814/delete_attachment.aspx[2K,2009-6-12 11:30:42],打开代码结构图1<%@ Page language="C#"%> 2
<!-- 3
Copyright 2002-2005 Corey Trager 4
刘岛 汉化于2006年2月 5
--> 6
<!-- #include file = "inc.aspx" --> 7
8
<script language="C#" runat="server"> 9
10
String sql; 11
DbUtil dbutil; 12
Security security; 13
14
string attachment_id_string; 15
string bug_id_string; 16
17
18
/////////////////////////////////////////////////////////////////////// 19
void Page_Load(Object sender, EventArgs e) 20
{ 21
22
Util.do_not_cache(Response); 23
dbutil = new DbUtil(); 24
security = new Security(); 25
security.check_security(dbutil, Request, Response, Security.MUST_BE_ADMIN); 26
27
string attachment_id_string = Util.sanitize_integer(Request["id"]); 28
string bug_id_string = Util.sanitize_integer(Request["bug_id"]); 29
string confirm = Request.QueryString["confirm"]; 30
31
if (confirm == "y") 32
{ 33
// save the filename before deleting the row 34
sql = @"select ba_file from bug_attachments where ba_id = $ba"; 35
sql = sql.Replace("$ba", attachment_id_string); 36
string filename = (string) dbutil.execute_scalar(sql); 37
38
// delete the row representing the attachment 39
sql = @"delete bug_attachments where ba_id = $ba"; 40
sql = sql.Replace("$ba", attachment_id_string); 41
dbutil.execute_nonquery(sql); 42
43
// delete the file too 44
string upload_folder = Util.get_setting("UploadFolder","c:\\"); 45
StringBuilder path = new StringBuilder(upload_folder); 46
path.Append("\\"); 47
path.Append(bug_id_string); 48
path.Append("_"); 49
path.Append(attachment_id_string); 50
path.Append("_"); 51
path.Append(filename); 52
if (System.IO.File.Exists(path.ToString())) 53
{ 54
System.IO.File.Delete(path.ToString()); 55
} 56
57
58
Response.Redirect("edit_bug.aspx?id=" + bug_id_string); 59
} 60
else 61
{ 62
back_href.HRef = 63
"edit_bug.aspx?id=" + bug_id_string; 64
65
confirm_href.HRef = 66
"delete_attachment.aspx?confirm=y&id=" + attachment_id_string 67
+ "&bug_id=" + bug_id_string; 68
69
70
sql = @"select ba_desc from bug_attachments where ba_id = $1"; 71
sql = sql.Replace("$1", attachment_id_string); 72
73
DataRow dr = dbutil.get_datarow(sql); 74
75
string s = Convert.ToString(dr["ba_desc"]); 76
if (s == "") {s = "(no description)";} 77
78
confirm_href.InnerText = "确认删除附件: " + s; 79
80
81
} 82
83
} 84
85
void Page_Unload(Object sender, EventArgs e) 86
{ 87
if (dbutil != null) {dbutil.close();} 88
} 89
90
91
92
</script> 93
94
<html> 95
<head> 96
<title id="title" runat="server">删除附件</title> 97
<link rel="StyleSheet" href="btnet.css" type="text/css"> 98
</head> 99
<body> 100
<% security.write_menu(Response, Util.get_setting("PluralBugLabel","bugs")); %> 101
<p> 102
<div class=align> 103
104
<p> </p> 105
<a id="back_href" runat="server" href=""> 106
返回 <% Response.Write(Util.get_setting("SingularBugLabel","Bug")); %> 107
</a> 108
109
<p> 110
或 111
<p> 112
<a id="confirm_href" runat="server" href="">确认删除</a> 113
</div> 114
</body> 115
</html> 116
117
118







}
