Beispiel #1
0
        /// <summary>
        /// 修改账户密码
        /// </summary>
        /// <param name="Model.User"></param>
        /// <returns></returns>
        public static bool Updatepwd(ref Model.Accountpwd model, out string errMsg)
        {
            int outState = 0;

            errMsg = "";
            try
            {
                SqlParameter[] para = new SqlParameter[]
                {
                    new SqlParameter("@User", model.User),
                    new SqlParameter("@OldPassword", model.OldPassword.Trim()),
                    new SqlParameter("@NewPassword", model.NewPassword.Trim()),
                    new SqlParameter("@OutState", outState)
                };
                para[3].Direction = ParameterDirection.Output;
                int i = DBHelper.ExecuteNonQuery(CommandType.StoredProcedure, "proc_AccountpwdUpdate", para);
                if (i > 0)
                {
                    EventLog e = new EventLog();
                    e.TargetIds = model.User.ToString();
                    e.CodeTag   = "Updatepwd";
                    e.LogName   = "修改账户密码";
                    EventLogService.AddEventLog <Model.Accountpwd>(e, model);
                    return(true);
                }
                else
                {
                    outState = (int)para[3].Value;
                    if (outState == -1)
                    {
                        errMsg = "用户已被其他用户删除,不能修改密码";
                    }
                    else if (outState == -2)
                    {
                        errMsg = "密码错误";
                    }
                    else
                    {
                        errMsg = "未知错误";
                    }
                    return(false);
                }
            }
            catch (Exception ex)
            {
                errMsg = ex.Message;
                ErrorLog e = new ErrorLog();
                e.TargetIds = model.User.ToString();
                e.CodeTag   = "Updatepwd";
                e.LogName   = "修改密码";
                e.ErrorMsg  = ex.Message.ToString();
                ErrorLogService.AddErrorLog <Model.Accountpwd>(e, model);
                return(false);
            }
        }
Beispiel #2
0
 private bool tryPost(ref Model.Accountpwd model, out string errMsg)
 {
     errMsg            = "";
     model.OldPassword = Function.Encrypt(model.OldPassword.Trim(), 2);
     model.NewPassword = Function.Encrypt(model.NewPassword.Trim(), 2);
     if (UserManager.Updatepwd(ref model, out errMsg))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Beispiel #3
0
        private bool tryValidate(Model.Accountpwd model, out string errMsg)
        {
            errMsg = "";
            bool re = true;

            if (model.NewPassword == null ||
                model.NewPassword.Length == 0 ||
                model.NewPassword != model.ConfirmPassword)
            {
                errMsg = "输入数据不合法";
                re     = false;
            }
            return(re);
        }
Beispiel #4
0
 /// <summary>
 /// 修改密码
 /// </summary>
 /// <returns></returns>
 public static bool Updatepwd(ref Model.Accountpwd model, out string errMsg)
 {
     return(UserService.Updatepwd(ref model, out errMsg));
 }