using System; using System.Collections.Generic; using System.Web.Security; using iWareCommon.Common.Entity; using iWareCommon.Utils; using FineUIPro.iWareWms.Properties; using iWareDataCore.RBAC.Service; using iWareLog.LOG.Entity; using FineUIPro.iWareWms.Util; using iWareDataCore.RBAC.Entity; using iWareWms; using FineUIPro; namespace iWareWms { public partial class login : PageBase { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (User.Identity.IsAuthenticated) { Response.Redirect(FormsAuthentication.DefaultUrl); } } } private void LoadData() { if (User.Identity.IsAuthenticated) { Response.Redirect(FormsAuthentication.DefaultUrl); } } protected void btnLogin_Click(object sender, EventArgs e) { string msg; var res = UserService.GetInstance().Login(tbxUserName.Text, tbxPassword.Text, out msg); if (string.IsNullOrEmpty(msg)) { LoginSuccess(res); } else { Alert.ShowInTop(msg, MessageBoxIcon.Error); } } /// /// 登录到主页面 /// /// 包含登录用户信息的用户类 private void LoginSuccess(UserEntity user) { Session["UserInfo"] = user; CreateFormsAuthenticationTicket(user.Username, user.DisplayRoleNames, false, DateTime.Now.AddMinutes(120)); Response.Redirect(FormsAuthentication.DefaultUrl); } } }