Exemplo n.º 1
0
        private void LoginEventHandler(object sender, LoginEventArgs e)
        {
            bool   isRegister = bllUser.IsUserRegister(e.RoleID, e.UserName, e.Password);
            string roleName   = "一般用户";

            if (e.RoleID == 5)
            {
                roleName = "管理员";
            }
            else if (e.RoleID == 6)
            {
                roleName = "系统管理员";
            }
            string loginInfo = null;

            if (isRegister)
            {
                loginInfo = string.Format("用户:{0},角色:{1},登录系统,结果:成功!", e.UserName, roleName);
            }
            else
            {
                loginInfo = string.Format("用户:{0},角色:{1},登录系统,结果:失败!", e.UserName, e.RoleID);
            }
            LogModel logModel = new LogModel();

            logModel.logCategory = EnumLogCategory.管理层日志.ToString();
            logModel.logType     = EnumLogType.提示.ToString();
            logModel.logContent  = loginInfo;
            logModel.logTime     = System.DateTime.Now;
            logBll.Add(logModel);
            if (e.IsChangeUser == false)
            {
                if (isRegister == true)
                {
                    this.View.HideLoginForm();
                    this.View.ShowMainForm(e.RoleID);
                }
                else
                {
                    this.View.ShowDialog("登录失败!用户权限、用户名或密码错误!");
                }
            }
            else
            {
                if (isRegister == true)
                {
                    MainPresenter mainPre = (MainPresenter)this.View.GetPresenter(typeof(MainPresenter));
                    if (mainPre != null)
                    {
                        mainPre.View.ShowView();
                        mainPre.View.OnSetLimit(e.RoleID);
                        this.View.HideLoginForm();
                    }
                }
                else
                {
                    this.View.ShowDialog("登录失败!用户权限、用户名或密码错误!");
                }
            }
        }