default.aspx.cs
来自「本套软件适用于各大高校、中小学、幼儿园、培训机构等单位的教学管理软件。」· CS 代码 · 共 87 行
CS
87 行
using System;
using System.Data;
using System.Configuration;
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;
using jianke;
public partial class Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button2_Click(object sender, EventArgs e)
{
this.TextBox1.Text = "";
this.TextBox2.Text = "";
}
protected void Button1_Click(object sender, EventArgs e)
{
if (this.TextBox1.Text == "")
{
Response.Write("<script>alert(' 请输入用户名!');</script>");
}
else
{
SqlConnection Conn = DB.creatconnection();
Conn.Open();
string mysql = "select Users_id from Users where Users_id='" + TextBox1.Text + "'";
SqlCommand cm = new SqlCommand(mysql, Conn);
SqlDataReader dr = cm.ExecuteReader();
if (dr.Read())
{
dr.Close();
string password = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(TextBox2.Text, "MD5");
string mysql1 = "select * from Users where Users_id='" + TextBox1.Text + "'and Users_password='" + password + "'";
SqlCommand cm1 = new SqlCommand(mysql1, Conn);
SqlDataReader dr1 = cm1.ExecuteReader();
if (dr1.Read())
{
Session["Users_id"] = dr1["Users_id"].ToString();
Session["Users_class"] = dr1["Users_class"].ToString();
Session["Users_password"] = dr1["Users_password"].ToString();
if (Session["Users_class"].ToString() == "1")
{
Response.Redirect("admin/Main.aspx");
}
else if (Session["Users_class"].ToString() == "2")
{
Response.Redirect("admin2/Main.aspx");
}
if (Session["Users_class"].ToString() == "3")
{
Response.Redirect("admin3/Main.aspx");
}
dr1.Close();
}
else
{
Response.Write("<script>alert(' 密码错误!');</script>");
dr1.Close();
}
}
else
{
dr.Close();
Response.Write("<script>alert(' 该用户不存在!');</script>");
}
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?