📄 login.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;
using System.Data.SqlClient;
public partial class login : System.Web.UI.Page
{
DB db = new DB();//初始化数据库类
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
string name, psword;
name = this.TextBox1.Text.ToString();
psword = this.TextBox2.Text.ToString();
//选择不同身份进行登陆,跳转到响应页面
if (this.RadioButton1.Checked)//第一个按钮响应
{ //管理员身份
string strsql = "select count(*) from admin where name='" + name + "'and psw='" + psword + "'";
int b = Convert.ToInt32(db.executeGetReturn(strsql));
if (b == 0)
{
Response.Write("<script> alert('用户名和密码错误!')</script>");
}
else
{
if (TextBox3.Text == Session["CheckCode"].ToString())
{
//Response.Write("<script> alert('管理员登陆成功!')</script>");
Response.Redirect("delete.aspx?admin="+this.TextBox1.Text.ToString());
}
else
{
Response.Write("<script> alert('验证码错误,请重新输入验证码!')</script>");
}
}
}
if (this.RadioButton2.Checked)
{ //客户身份
string str = "select count(*) from guest where name='" + name + "'and psw='" + psword + "'";
int b = Convert.ToInt32(db.executeGetReturn(str));
if (b == 0)
{
Response.Write("<script> alert('用户名和密码错误!')</script>");
}
else
{
if (TextBox3.Text == Session["CheckCode"].ToString())
{
//Response.Redirect("<script> alert('客户登陆成功!')</script>");
Response.Redirect("guest.aspx?guest="+this.TextBox1.Text.ToString());
}
else
{
Response.Write("<script> alert('验证码错误,请重新输入验证码!')</script>");
}
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -