schangxiang@126.com
2025-09-23 1ec17ce75f4e4324e9756a91c74f3f52928c9351
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
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);
            }
           
       
        }
        /// <summary>
        /// 登录到主页面
        /// </summary>
        /// <param name="user">包含登录用户信息的用户类</param>
        private void LoginSuccess(UserEntity user)
        {
            Session["UserInfo"] = user;
 
            CreateFormsAuthenticationTicket(user.Username, user.DisplayRoleNames, false, DateTime.Now.AddMinutes(120));
 
            Response.Redirect(FormsAuthentication.DefaultUrl);
        }
 
 
    }
}