Ejemplo n.º 1
0
        public ActionResult ChangePassword(ChangePasswordModel model)
        {
            string currentPerson = GetCurrentPerson();
            ViewBag.PersonNamea = currentPerson;
            if (string.IsNullOrWhiteSpace(currentPerson))
            {
                ModelState.AddModelError("", "对不起,请重新登陆");
                return View();
            }
            if (ModelState.IsValid)
            {
                IAccountBLL accountBLL = new AccountBLL();

                if (null != (accountBLL.ValidateUser(currentPerson, EncryptAndDecrypte.EncryptString(model.OldPassword))))
                {
                    if (accountBLL.ChangePassword(currentPerson, model.OldPassword,  model.NewPassword))
                    {
                        ModelState.AddModelError("", "修改密码成功");
                        return View();
                    }
                }
            }
            ModelState.AddModelError("", "修改密码不成功,请核实数据");
            return View();
        }
Ejemplo n.º 2
0
        public ActionResult Edit(string id, SysPerson entity)
        {
            if (entity != null && ModelState.IsValid)
            {   //数据校验

                string oldPic = Request.Form["OldPic"];
                if (entity.HDpic != oldPic)//修改头像删除老的头像文件
                {
                    DirFile.DeleteFile(oldPic);
                }
                string currentPerson = GetCurrentPerson();
                entity.UpdateTime = DateTime.Now;
                entity.UpdatePerson = currentPerson;

                //如果修改了密码,就将密码加密 2016830
                IBLL.IAccountBLL accountBLL = new AccountBLL();
                if (null == (accountBLL.ValidateUser(entity.Name, entity.Password)))
                {
                    entity.Password = EncryptAndDecrypte.EncryptString(entity.Password);
                    entity.SurePassword = EncryptAndDecrypte.EncryptString(entity.SurePassword);
                }
                string returnValue = string.Empty;
                if (m_BLL.Edit(ref validationErrors, entity))
                {
                    LogClassModels.WriteServiceLog(Suggestion.UpdateSucceed + ",人员信息的Id为" + id, "人员"
                        );//写入日志
                    App.Codes.MenuCaching.ClearCache(id);   //清除缓存
                    return Json(Suggestion.UpdateSucceed); //提示更新成功
                }
                else
                {
                    if (validationErrors != null && validationErrors.Count > 0)
                    {
                        validationErrors.All(a =>
                        {
                            returnValue += a.ErrorMessage;
                            return true;
                        });
                    }
                    LogClassModels.WriteServiceLog(Suggestion.UpdateFail + ",人员信息的Id为" + id + "," + returnValue, "人员"
                        );//写入日志
                    return Json(Suggestion.UpdateFail + returnValue); //提示更新失败
                }
            }
            return Json(Suggestion.UpdateFail + "请核对输入的数据的格式"); //提示输入的数据的格式不对
        }