Ejemplo n.º 1
0
        public SystemAdmin GetByNameAndPassword(string SAName, string SAPwd)
        {
            string      pwd      = StrUtil.EncryptPassword(SAPwd, "MD5");
            SystemAdmin sysAdmin = _repository.GetByCondition(new DirectSpecification <SystemAdmin>(sa => sa.SAName == SAName && sa.SAPwd == pwd), true);

            return(sysAdmin);
        }
Ejemplo n.º 2
0
        public void ChangePwd(SystemAdmin admin, string newPwd, string oldPwd)
        {
            string newPassWord = StrUtil.EncryptPassword(newPwd, "MD5");
            string oldPassWord = StrUtil.EncryptPassword(oldPwd, "MD5");

            if (!admin.SAPwd.Equals(oldPassWord))
            {
                throw new Exception("旧密码错误!");
            }
            _repository.ChangePwd(admin, newPassWord);
        }
Ejemplo n.º 3
0
        public ActionResult Edit(SystemAdminUpdate sa, string CheckRoleIds, string oldPassword)
        {
            if (!Request.IsAjaxRequest())
            {
                return(Content("操作失败,你的浏览器禁用了Javascript脚本!"));
            }
            ShowResultModel srm = new ShowResultModel();

            if (ModelState.IsValid)
            {
                try
                {
                    string pwd = string.Empty;
                    if (oldPassword.Equals(sa.Password))
                    {
                        pwd = sa.Password;
                    }
                    else
                    {
                        pwd = StrUtil.EncryptPassword(sa.Password, "MD5");
                    }

                    SystemAdmin sad = new SystemAdmin()
                    {
                        Email = sa.Email, SANickName = sa.SANickName, SAName = sa.SAName, SAPwd = pwd, SASex = sa.SASex, SAMobileNo = sa.SAMobileNo, LoginTimes = 0, CurrentIP = "null", LastIP = "null", SAID = sa.SAID, IsEnable = sa.IsEnable
                    };
                    _sysadminService.UpdateSysAdmin(sad, CheckRoleIds);
                    srm.TipMsg    = "修改管理员成功!";
                    srm.IsSuccess = true;
                }
                catch (InvalidOperationException ex)
                {
                    srm.TipMsg = ex.Message;
                }
                catch (Exception ex)
                {
                    srm.TipMsg = ex.Message;
                }
            }
            else
            {
                srm.TipMsg = "数据有效性验证失败!";
            }
            return(Json(srm));
        }
Ejemplo n.º 4
0
        public ActionResult Add(SystemAdminRegister sa, string CheckRoleIds)
        {
            if (!Request.IsAjaxRequest())
            {
                return(Content("操作失败,你的浏览器禁用了Javascript脚本!"));
            }
            ShowResultModel srm = new ShowResultModel();

            if (ModelState.IsValid)
            {
                try
                {
                    SystemAdmin sad = new SystemAdmin()
                    {
                        Email = sa.Email, SANickName = sa.SANickName, SAName = sa.SAName, SAPwd = StrUtil.EncryptPassword(sa.Password, "MD5"), SASex = sa.SASex, SAMobileNo = sa.SAMobileNo, LoginTimes = 0, CurrentIP = "未登录", LastIP = "未登录", IsEnable = sa.IsEnable
                    };
                    _sysadminService.AddSysAdmin(sad, CheckRoleIds);
                    srm.TipMsg    = "新增管理员成功!<br/><br/><input type='button' class='box-buttonadd' value='继续添加'  onclick='window.document.getElementById(&#34;lhgfrm_divaddSysAdmin&#34;).contentWindow.Goon();'/><input type='button' class='box-buttonclose' value='取消' onclick='window.document.getElementById(&#34;lhgfrm_divaddSysAdmin&#34;).contentWindow.Undo()'/>";
                    srm.IsSuccess = true;
                }
                catch (InvalidOperationException ex)
                {
                    srm.TipMsg = ex.Message;
                }
                catch (Exception ex)
                {
                    srm.TipMsg = ex.Message;
                }
            }
            else
            {
                srm.TipMsg = "数据有效性验证失败!";
            }
            return(Json(srm));
        }