⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 delete_attachment.aspx

📁 Bug管理系统
💻 ASPX
字号:
<%@ Page language="C#"%>
<!--
Copyright 2002-2005 Corey Trager
Distributed under the terms of the GNU General Public License
-->
<!-- #include file = "inc.aspx" -->

<script language="C#" runat="server">

String sql;
DbUtil dbutil;
Security security;

string attachment_id_string;
string bug_id_string;


///////////////////////////////////////////////////////////////////////
void Page_Load(Object sender, EventArgs e)
{

	Util.do_not_cache(Response);
	dbutil = new DbUtil();
	security = new Security();
	security.check_security(dbutil, Request, Response, Security.MUST_BE_ADMIN);

	string attachment_id_string = Util.sanitize_integer(Request["id"]);
	string bug_id_string = Util.sanitize_integer(Request["bug_id"]);
	string confirm = Request.QueryString["confirm"];

	if (confirm == "y")
	{
		// save the filename before deleting the row
		sql = @"select ba_file from bug_attachments where ba_id = $ba";
		sql = sql.Replace("$ba", attachment_id_string);
		string filename = (string) dbutil.execute_scalar(sql);

		// delete the row representing the attachment
		sql = @"delete bug_attachments where ba_id = $ba";
		sql = sql.Replace("$ba", attachment_id_string);
		dbutil.execute_nonquery(sql);

		// delete the file too
		string upload_folder = Util.get_setting("UploadFolder","c:\\");
		StringBuilder path = new StringBuilder(upload_folder);
		path.Append("\\");
		path.Append(bug_id_string);
		path.Append("_");
		path.Append(attachment_id_string);
		path.Append("_");
		path.Append(filename);
		if (System.IO.File.Exists(path.ToString()))
		{
			System.IO.File.Delete(path.ToString());
		}

		
		Response.Redirect("edit_bug.aspx?id=" + bug_id_string);
	}
	else
	{
		back_href.HRef = 
			"edit_bug.aspx?id=" + bug_id_string;

		confirm_href.HRef = 
			"delete_attachment.aspx?confirm=y&id=" 	+ attachment_id_string
			+ "&bug_id=" + bug_id_string;
			
	
		sql = @"select ba_desc from bug_attachments where ba_id = $1";
		sql = sql.Replace("$1", attachment_id_string);
			
		DataRow dr = dbutil.get_datarow(sql);
		
		string s = Convert.ToString(dr["ba_desc"]);
		if (s == "") {s = "(no description)";}
		
		confirm_href.InnerText = "confirm delete of attachment: " + s;

			
	}

}

void Page_Unload(Object sender, EventArgs e)
{
	if (dbutil != null) {dbutil.close();}
}



</script>

<html>
<head>
<title id="title" runat="server">btnet delete attachment</title>
<link rel="StyleSheet" href="btnet.css" type="text/css">
</head>
<body>
<% security.write_menu(Response, Util.get_setting("PluralBugLabel","bugs")); %>
<p>
<div class=align>

<p>&nbsp</p>
<a id="back_href" runat="server" href="">
back to <% Response.Write(Util.get_setting("SingularBugLabel","bug")); %>
</a>

<p>
or
<p>
<a id="confirm_href" runat="server" href="">confirm delete</a>
</div>
</body>
</html>


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -