📄 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 text : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Random rnd = new Random();
TextBox1.Text = rnd.Next(1000, 8000).ToString();
}
protected void Button2_Click(object sender, EventArgs e)
{
clean();
}
private void ShowMassage(string msg,int i)
{
Response.Write("<script>window.alert('" + msg + "')</script>");
if (i == 1)
{
Response.Redirect("admin.aspx");
}
}
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection sqlcon = new SqlConnection("data source=localhost;uid=sa;pwd=;database=Ebusiness");
sqlcon.Open();
SqlCommand objsqlcomm = new SqlCommand();
objsqlcomm.Connection = sqlcon;
objsqlcomm.CommandText = "mp_verifyuser";
objsqlcomm.CommandType = CommandType.StoredProcedure;
SqlParameter par1 = new SqlParameter("@username", SqlDbType.VarChar, 50);
par1.Direction = ParameterDirection.Input;
SqlParameter par2 = new SqlParameter("@password", SqlDbType.VarChar, 50);
par2.Direction = ParameterDirection.Input;
objsqlcomm.Parameters.Add(par1);
objsqlcomm.Parameters.Add(par2);
par1.Value = TextBox2.Text;
Session["user"] = par1.Value;
par2.Value = TextBox3.Text;
SqlDataReader reader = objsqlcomm.ExecuteReader();
if (reader.Read())
{
int i, a;
i = reader.GetInt32(0);
a = reader.GetInt32(1);
if (i == 1 && a == 1)
{
ShowMassage("登陆成功...管理员,你好!",1);
reader.Close();
clean();
return ;
}
else
{
if (i == 0 && a == 1)
{
ShowMassage("登陆失败!",0);
reader.Close();
clean();
return ;
}
}
}
else
{
ShowMassage("登陆失败",-1);
clean();
return ;
}
sqlcon.Close();
Response.Redirect("admin.aspx");
}
private void clean()
{
TextBox2.Text = "";
TextBox3.Text = "";
TextBox4.Text = "";
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -