示例#1
0
 /// <summary>
 /// 加载指定系统用户
 /// <param name="userId">用户编号</param>
 /// </summary>
 public void Load(string userId)
 {
     try
     {
         TSUser tsUser = tsUserDAO.Get(userId);
         tsUser.status  = "1".Equals(tsUser.status) ? "on" : "off";
         tsUser.roleIds = "'" + tsUser.roleIds.Replace(",", "','") + "'";
         List <TSRole> listRole = new TSRoleDAO().GetList("select * from TSRole where status='1' and roleId in (" + tsUser.roleIds + ")", new Param());
         tsUser.roleIds = "";
         foreach (TSRole tsRole in listRole)
         {
             if (string.IsNullOrWhiteSpace(tsUser.roleIds))
             {
                 tsUser.roleIds = tsRole.roleId;
             }
             else
             {
                 tsUser.roleIds += "," + tsRole.roleId;
             }
         }
         WebJson.ToJson(context, tsUser);
     }
     catch (Exception e)
     {
         Message.error(context, e.Message);
     }
 }
示例#2
0
        /// <summary>
        /// 修改当前用户密码
        /// </summary>
        /// <param name="oldPwd">旧密码</param>
        /// <param name="newPwd">新密码</param>
        public void ChangePwd(string oldPwd, string newPwd)
        {
            TSUserDAO tsUserDao = new TSUserDAO();
            TSUser    user      = tsUserDao.Get(loginUser.UserId);

            if (user.userPwd.Equals(Encrypt.ConvertPwd(user.userId, oldPwd)) == false)
            {
                Message.error(context, "旧密码输入错误");
                return;
            }

            user.userPwd = Encrypt.ConvertPwd(user.userId, newPwd);
            try
            {
                tsUserDao.ChangePwd(user.userId, user.userPwd);
                Message.success(context, "密码修改成功");
                loginUser.Log("密码修改成功");
            }
            catch (Exception e)
            {
                Message.error(context, "密码修改失败");
                loginUser.Log("密码修改失败,错误:" + e.Message);
            }
        }