📄 st_login.aspx.cs.bak
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Web.Security;
namespace STGROUP.ST_WebBook
{
/// <summary>
/// WebForm1 的摘要说明。
/// </summary>
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
}
#endregion
protected void btnOK_Click(object sender, System.EventArgs e)
{
//判断用户是否登录成功,如果成功,转到ST_Main.aspx,如果失败,提示失败
STGROUP.ST_BookBiz.ST_Auth st_auth = new STGROUP.ST_BookBiz.ST_Auth();
int userid=0;
if(st_auth.ST_Login(txtName.Text, txtPass.Text, out userid))
{
string[] role = st_auth.ST_LoginType(txtName.Text);
ST_BookBiz.ST_Identity identity = new ST_BookBiz.ST_Identity(txtName.Text.Trim(), userid);
Context.User = new ST_BookBiz.ST_Principal(identity,role);
identity.Name = txtName.Text;
identity.Roles = role[0];
identity.Save();
FormsAuthentication.SetAuthCookie(txtName.Text, false);
Response.Redirect("ST_Common/ST_Main.aspx");
}
else
{
Response.Write("<script language='javascript'>alert('登陆失败!');</script>");
}
}
protected void btnReg_Click(object sender, System.EventArgs e)
{
Response.Redirect("ST_User/ST_UserAdd.aspx?Action=add");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -