1 Star 0 Fork 2

Nan/asp.net学生成绩管理系统

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
Main.aspx.cs 3.65 KB
一键复制 编辑 原始数据 按行查看 历史
Administrator 提交于 2023-02-12 22:31 . 更新添加项目文件。
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace GradeMis
{
public partial class Main : System.Web.UI.Page
{
protected SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["GradeSys"]);
public string promiseUrl;
protected string promise;
protected string username;
protected void Page_Load(object sender, EventArgs e)
{
try
{
username = Session["username"].ToString();
}
catch
{
Response.Redirect("Login.aspx");
}
if (!Page.IsPostBack)
{
GetPromise();
GetUrlByPromise();
}
}
#region 取得权限ID
protected void GetPromise()
{
string sql = string.Empty;
sql = string.Format("select promise from Admin inner join AdminGroup on Admin.[Group] = AdminGroup.[Group] where username = '{0}'", username);
//Response.Write(sql);
SqlDataReader dr;
SqlCommand cmd = new SqlCommand(sql, conn);
try
{
conn.Open();
dr = cmd.ExecuteReader();
if (dr.Read())
{
//promiseUrl = dr["promise"].ToString();
//sb.Append(dr["url"].ToString());
this.promise = dr["promise"].ToString();
}
//promiseUrl = sb.ToString();
}
catch (Exception ex)
{
Response.Write(ex);
}
finally
{
conn.Close();
}
}
#endregion
#region 取得权限ID
protected void GetUrlByPromise()
{
string sql = string.Empty;
System.Text.StringBuilder sb = new System.Text.StringBuilder();
try
{
sql = string.Format("select url,urlname from AdminUrl where id in ({0})", promise.Substring(0, promise.Length - 1));
}
catch
{
//Response.Write("你输入的用户名不存在任何组,请与管理员联系!");
}
//Response.Write(sql);
SqlDataReader dr;
SqlCommand cmd = new SqlCommand(sql, conn);
try
{
conn.Open();
try
{
dr = cmd.ExecuteReader();
if (dr.Read())
{
sb.Append("<table width=\"207\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">");
do
{
sb.Append("<tr><td width=\"207\" height=\"33\" background=\"images/Sys_menu.jpg\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a target=\"main\" href=\"" + dr["url"].ToString() + "\">" + dr["urlname"].ToString() + "</a></td></tr>\n");
} while (dr.Read());
sb.Append("</table>");
}
}
catch
{
Response.Write("你输入的用户名尚未分组,或者分组信息丢失,请与管理员联系!");
}
promiseUrl = sb.ToString();
}
catch (Exception ex)
{
Response.Write(ex);
}
finally
{
conn.Close();
}
}
#endregion
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/x369/GradeMis.git
git@gitee.com:x369/GradeMis.git
x369
GradeMis
asp.net学生成绩管理系统
master

搜索帮助