📄 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.Sql;
using System.Data.SqlClient;
//该源码下载自www.51aspx.com(51aspx.com)
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
string strconn = ConfigurationManager.AppSettings["dsn"];
//连接本地计算机的LMS数据库
SqlConnection cn = new SqlConnection(strconn);
cn.Open();
//构造SQL语句,该语句在Users表中检查用户名和密码是否正确
string mysql = "select * from yhxx where yonghuname='" + TextBox1.Text + "'and mima='" + TextBox2.Text + "'";
//创建Command对象
SqlCommand cm = new SqlCommand(mysql, cn);
//执行ExecuteReader ()方法
SqlDataReader dr = cm.ExecuteReader();
if (dr.Read())
{
//保存当前用户名及用户权限
Session["uid"] = dr["yonghuID"].ToString();
Session["leibie"] = RadioButtonList1.SelectedItem.Text;
Response.Redirect("main.aspx");
}
else
{
this.TextBox1.Text = "";
this.TextBox2.Text = "";
}
//关闭连接
cn.Close();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -