Default.aspx.cs
(开头部分) 4KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Text;
public partial class _Default : System.Web.UI.Page
{
private readonly string ConnectionString = ConfigurationManager.AppSettings["ConnectionString"].ToString();
protected void Page_Load(object sender,EventArgs e)
{
///添加页面初始化代码
if(!Page.IsPostBack)
{
Session["UserID"] = this.UserName.Text.Trim();
}
}
protected void LoginBtn_Click(object sender, EventArgs e)
{
//创建连接字符串
string sqlstr;
sqlstr = "select Password,IsAdmin,UserID from Users where UserName=@adminname ";
SqlConnection scon = new SqlConnection(ConnectionString);
SqlCommand scm = new SqlCommand(sqlstr, scon);
scm.Parameters.Add("@adminname", SqlDbType.VarChar, 20);
scm.Parameters["@adminname"].Value = this.UserName.Text.Trim();
scon.Open();
SqlDataReader reader = scm.ExecuteReader();
if (reader.Read())
{
string strPwd = reader[0].ToString();
string stradmin = reader[1].ToString().Trim();
Session["UID"] = reader[2].ToString().Trim();
reader.Close();
if (strPwd != Password.Text.Trim())
{
this.Message.Text = "密码错误!";
}
else
{
if (this.DropDownList1.SelectedValue == "1")//下拉列表的值 1代表1是管理员 2为分析员 填写分析报告3为普通用户 填写问卷
{ //stradmin为1是管理员 2为分析员 填写分析报告3为普通用户 填写问卷
//if (stradmin == "1")
if (stradmin == "系统管理员")
{
Response.Redirect("ManageList.aspx");//管理页面
}
else
{
this.Message.Text = "对不起,您暂时没有权限!请与管理员联系!";
}
后面还有 55 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读 AI
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
