📄 default.aspx.cs
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class login : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.RadioButtonList1.Items[0].Selected = true;
this.RadioButtonList1.Items[1].Selected = false;
}
}
protected void Button1_Click(object sender, EventArgs e)
{
if (this.RadioButtonList1.Items[0].Selected == true)
{
string Uid = this.TextBox1.Text.Trim();
string Upwd = this.TextBox2.Text.Trim();
string sql = "SELECT * FROM Userlist WHERE Uid='" + Uid + "' and Upwd='" + Upwd + "'";
DBClass db = new DBClass();
DataTable dt = db.GetDataTable(sql);
if (dt.Rows.Count > 0)
{
Session["Uid"] = dt.Rows[0]["Uid"].ToString();
Session["Uname"] = dt.Rows[0]["Uname"].ToString();
Response.Redirect("modifyuser.aspx?name='" + dt.Rows[0]["Uname"] + "'");
}
else
Response.Write("<script> alert('您输入的用户名或者密码错误,请重新输入');</script>");
this.TextBox2.Text = "";
}
if (this.RadioButtonList1.Items[1].Selected == true)
{
string Aname = this.TextBox1.Text.Trim();
string Apwd = this.TextBox2.Text.Trim();
string sql = "select * from Admin where Aname='" + Aname + "'and Apwd='" + Apwd + "'";
DBClass db = new DBClass();
DataTable dt = db.GetDataTable(sql);
if (dt.Rows.Count > 0)
{
Session["Aname"] = dt.Rows[0]["Aname"].ToString();
Response.Redirect("AModify.aspx?Aname='"+Session["Aname"]+"'");
Response.Write("<script> alert('你已登录了管理员!');</script>");
}
else
{
Response.Write("<script> alert('您输入的管理员名或者密码错误,请重新输入');</script>");
this.TextBox2.Text = "";
}
}
}
protected void Button2_Click(object sender, EventArgs e)
{
this.TextBox1.Text = "";
this.TextBox2.Text = "";
}
protected void Button3_Click(object sender, EventArgs e)
{
Response.Redirect("Reg.aspx");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -