📄 login.ascx.cs
字号:
namespace HKeBookshop.usercontrol
{
using System;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
/// <summary>
/// login 的摘要说明。
/// </summary>
public class login : System.Web.UI.UserControl
{
protected System.Web.UI.WebControls.TextBox userid;
protected System.Web.UI.WebControls.TextBox userpassword;
protected System.Web.UI.WebControls.Button sub;
string strsql="";
myclass MyClass = new myclass();
protected System.Web.UI.WebControls.Label Label2;
protected System.Web.UI.WebControls.Label Label3;
protected System.Web.UI.WebControls.Button rest;
protected System.Web.UI.WebControls.Label success;
DataSet ds = new DataSet();
protected System.Web.UI.WebControls.Button regist;
protected System.Web.UI.WebControls.Image Image1;
protected System.Web.UI.WebControls.Button loginout;
protected System.Web.UI.WebControls.HyperLink shopcar;
protected System.Web.UI.WebControls.HyperLink changepassword;
protected System.Web.UI.WebControls.HyperLink info;
string sessinname;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
if (Session["name"]!="")
{
sessinname = Session["name"].ToString();
Label2.Visible=false;
Label3.Visible=false;
sub.Visible = false;
rest.Visible = false;
userid.Visible=false;
userpassword.Visible=false;
changepassword.Visible = true;
info.Visible=true;
success.Text="登录成功<br>" + userid.Text + "欢迎您!";
}
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器
/// 修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.sub.Click += new System.EventHandler(this.sub_Click);
this.rest.Click += new System.EventHandler(this.rest_Click);
this.regist.Click += new System.EventHandler(this.Button1_Click);
this.loginout.Click += new System.EventHandler(this.loginout_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void sub_Click(object sender, System.EventArgs e)
{
strsql="select userpassword from T_user where userid='" + userid.Text + "'";
ds=MyClass.Readdate(strsql);
if (ds.Tables["myDB"].Rows.Count!=0)
{
string Userpassword = ds.Tables["myDB"].Rows[0][0].ToString();
string sure = MyClass.md5(userpassword.Text);
if (sure == Userpassword)
{
Session["name"]=userid.Text;
Label2.Visible=false;
Label3.Visible=false;
sub.Visible = false;
rest.Visible = false;
userid.Visible=false;
userpassword.Visible=false;
shopcar.Visible=true;
loginout.Visible = true;
regist.Visible = false;
changepassword.Visible = true;
info.Visible =true;
success.Text="登录成功 " + userid.Text + "欢迎您!";
}
else
{
Response.Write("<script>alert('密码输入错误')</script>");
}
}
else
{
Response.Write("<script>alert('用户名不存在')</script>");
}
}
private void rest_Click(object sender, System.EventArgs e)
{
userid.Text = "";
userpassword.Text = "";
}
private void loginout_Click(object sender, System.EventArgs e)
{
Session["name"]="";
Response.Redirect("index.aspx");
}
private void Button1_Click(object sender, System.EventArgs e)
{
Response.Redirect("userregist.aspx");
}
private void shopcar_Click(object sender, System.EventArgs e)
{
//Response.Redirect();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -