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

📄 print_bugs.aspx

📁 Bug管理系统
💻 ASPX
字号:
<%@ Page language="C#"%>
<!-- #include file = "inc.aspx" -->

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

int id;
String sql;
DbUtil dbutil;
Security security;
DataSet ds;
DataView dv;


///////////////////////////////////////////////////////////////////////
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.ANY_USER_OK);


	// fetch the sql
	string qu_id_string = Util.sanitize_integer(Request["qu_id"]);

	ds = null;
	dv = null;

	if (qu_id_string != null)
	{
		
		// use sql specified in query string
		int qu_id = Convert.ToInt32(qu_id_string);
		sql = @"select qu_sql from queries where qu_id = $1";
		sql = sql.Replace("$1", qu_id_string);
		string bug_sql = (string)dbutil.execute_scalar(sql);

		// replace magic variables
		bug_sql = bug_sql.Replace("$ME", Convert.ToString(security.this_usid));
	
		bug_sql = Util.alter_sql_per_project_permissions(bug_sql,security.this_usid);
		
		ds = dbutil.get_dataset (bug_sql);
	}
	else
	{
		dv = (DataView) Session["bugs"];
	}
	
	
	string format = Request["format"];
	if (format != null && format == "excel")
	{
		print_as_excel();
	}
	else
	{
		print_as_html();
	}
	
}


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




void print_as_excel()
{

	Response.ContentType = "application/x-msexcel";

	int col;
	int row;
	bool first_column;

	if (ds != null)
	{
		// column names
		first_column = true;
		for (col = 1; col < ds.Tables[0].Columns.Count; col++)
		{
			if (!first_column)
			{
				Response.Write ("\t");
			}
			Response.Write (ds.Tables[0].Columns[col].ColumnName);
			first_column = false;
		}
		Response.Write ("\n");
		
		// bug rows
		foreach (DataRow dr in ds.Tables[0].Rows)
		{
			first_column = true;
			for (col = 1; col < ds.Tables[0].Columns.Count; col++)
			{
				if (!first_column)
				{
					Response.Write ("\t");
				}

				Response.Write (dr[col].ToString());
				first_column = false;

			}
			Response.Write ("\n");
		}
	}
	else
	{
		// column names
		first_column = true;
		for (col = 1; col < dv.Table.Columns.Count; col++)
		{
			if (!first_column)
			{
				Response.Write ("\t");
			}
			Response.Write (dv.Table.Columns[col].ColumnName);
			first_column = false;
		}
		Response.Write ("\n");

		// bug rows
		foreach (DataRowView drv in dv)
		{
			first_column = true;
			for (col = 1; col < dv.Table.Columns.Count; col++)
			{
				if (!first_column)
				{
					Response.Write ("\t");
				}
				Response.Write (drv[col].ToString());
				first_column = false;
			}
			Response.Write ("\n");
		}
	}
}




void print_as_html()
{

	Response.Write ("<head><link rel='StyleSheet' href='btnet.css' type='text/css'></head>");

	Response.Write ("<table border=1 cellspacing=0 cellpadding=3>");
	int col;
	int row;

	if (ds != null)
	{
		for (col = 1; col < ds.Tables[0].Columns.Count; col++)
		{
			Response.Write ("<td class=datah>\n");
			Response.Write (ds.Tables[0].Columns[col].ColumnName);
			Response.Write ("</td>");
		}

		foreach (DataRow dr in ds.Tables[0].Rows)
		{
			Response.Write ("<tr>");
			for (col = 1; col < ds.Tables[0].Columns.Count; col++)
			{
				string datatype = ds.Tables[0].Columns[col].DataType.ToString();

				if (Util.is_numeric_datatype(datatype))
				{
					Response.Write ("<td class=datad align=right>");
				}
				else
				{
					Response.Write ("<td class=datad>");
				}

				// write the data
				if (dr[col].ToString() == "")
				{
					Response.Write ("&nbsp;");
				}
				else
				{
					Response.Write (Server.HtmlEncode(dr[col].ToString()));
				}

				Response.Write ("</td>");
			}
			Response.Write ("</tr>");
		}
	}
	else
	{
		for (col = 1; col < dv.Table.Columns.Count; col++)
		{
			Response.Write ("<td class=datah>\n");
			Response.Write (dv.Table.Columns[col].ColumnName);
			Response.Write ("</td>");
		}

		foreach (DataRowView drv in dv)
		{
			Response.Write ("<tr>");
			for (col = 1; col < dv.Table.Columns.Count; col++)
			{
				string datatype = dv.Table.Columns[col].DataType.ToString();

				if (Util.is_numeric_datatype(datatype))
				{
					Response.Write ("<td class=datad align=right>");
				}
				else
				{
					Response.Write ("<td class=datad>");
				}

				// write the data
				if (drv[col].ToString() == "")
				{
					Response.Write ("&nbsp;");
				}
				else
				{
					Response.Write (Server.HtmlEncode(drv[col].ToString()));
				}

				Response.Write ("</td>");
			}
			Response.Write ("</tr>");
		}
	}

	Response.Write ("</table>");
}


</script>


⌨️ 快捷键说明

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