private bool tryValidate(Model.Resetpwd model, out string errMsg) { errMsg = ""; bool re = true; if (model.NewPassword == null || model.NewPassword.Length == 0 || model.NewPassword.Length > 20) { errMsg = "输入数据不合法"; re = false; } return(re); }
private bool tryPost(ref Model.Resetpwd model, out string errMsg) { errMsg = ""; bool re = false; model.NewPassword = Function.Encrypt(model.NewPassword.Trim(), 2); if (UserManager.Resetpwd(ref model, out errMsg)) { re = true; } return(re); }
/// <summary> /// 密码重置 /// </summary> /// <param name="Model.User"></param> /// <returns></returns> public static bool Resetpwd(ref Model.Resetpwd model, out string errMsg) { errMsg = ""; try { SqlParameter[] para = new SqlParameter[] { new SqlParameter("@User", model.User), new SqlParameter("@NewPassword", model.NewPassword.Trim()) }; int i = DBHelper.ExecuteNonQuery(CommandType.StoredProcedure, "proc_UserResetpwd", para); if (i > 0) { EventLog e = new EventLog(); e.TargetIds = model.User.ToString(); e.CodeTag = "Resetpwd"; e.LogName = "密码重置"; EventLogService.AddEventLog <Model.Resetpwd>(e, model); return(true); } else { errMsg = "该记录已被删除,不能执行密码重置"; return(false); } } catch (Exception ex) { errMsg = ex.Message; ErrorLog e = new ErrorLog(); e.TargetIds = model.User.ToString(); e.CodeTag = "Resetpwd"; e.LogName = "密码重置"; e.ErrorMsg = ex.Message.ToString(); ErrorLogService.AddErrorLog <Model.Resetpwd>(e, model); return(false); } }
/// <summary> /// 重置用户密码 /// </summary> /// <returns></returns> public static bool Resetpwd(ref Model.Resetpwd model, out string errMsg) { return(UserService.Resetpwd(ref model, out errMsg)); }