public ActionResult Login(UserBaseModel model)
        {
            // var user = iUserBaseService.GetUserBase(model.UserName, model.Password);
            string pwd  = EncodeStrToMd5.String32ToMD5(model.Password);
            var    user = iUserLoginService.GetUserLoginDto(model.UserName, pwd);

            if (user == null)
            {
                return(Json(new { success = false, msg = "用户名或密码错误" }));
            }
            var result = iUserLoginService.InsertSingleEntity(new LogUserLoginModel {
                UserID = user.UserID, LoginTime = DateTime.Now, NickName = user.UserName
            });

            Session["UserBase"] = user;
            //Session["Role"] = user == null ? null : user.Role;

            UserManagement.CurrentUser = user;

            return(Json(new { success = true, msg = "Find the User" }));
        }
예제 #2
0
        public void Login()
        {
            if (string.IsNullOrEmpty(LoginName))
            {
                MessageBox.Show("请输入用户名");
                return;
            }
            string userPwd = Upwd.PasswordStr;

            if (string.IsNullOrEmpty(Password))
            {
                MessageBox.Show("请输入用户密码");
                return;
            }
            string name = LoginName;
            string pwd  = EncodeStrToMd5.String32ToMD5(userPwd);
            var    user = _user.GetUserLoginDto(name, pwd);

            var win = GetView() as System.Windows.Window;

            if (win != null)
            {
                if (user != null)
                {
                    UserManagement.CurrentUser = user;
                    var company = new CompanyModel {
                        CompanyID = user.CompanyId, CompanyName = user.CompanyName
                    };
                    UserManagement.CurrentCompany = company;
                    LoadUserMenuNavi();
                    win.DialogResult = true;
                    win.Close();
                }
                else
                {
                    MessageBox.Show("用户名密码错误");
                }
            }
        }