Exemplo n.º 1
0
 /// <summary>
 /// 更新用户
 /// </summary>
 /// <param name="user"></param>
 /// <returns></returns>
 public ExecuteResult UpdateUser(UserDataContact data)
 {
     ExecuteResult resultInfo = new ExecuteResult();
     try
     {
         Model.User user = new User();
         user.GroupId = data.GroupId;
         user.Id = data.ID;
         user.PassWord = data.PassWord;
         if (string.IsNullOrEmpty(user.PassWord))
         {
             //表示密码没修改
             user.PassWord = userOperator.GetUserInfo(data.ID).PassWord;
         }
         else
         {
             user.PassWord = data.PassWord;
         }
         user.Status = data.Status;
         user.UserName = data.Name;
         if (userOperator.IsContainUser(user.UserName) && !userOperator.GetUserInfo(user.Id).Name.Equals(user.UserName))
         {
             resultInfo.Success = false;
             resultInfo.ExceptionMsg = "已有相同的用户名,请重新填写!";
             return resultInfo;
         }
         int count = userOperator.UpdateUser(user);
         if (count == 0)
         {
             resultInfo.Success = false;
             resultInfo.ExceptionMsg = "服务连接断开,请联系管理员!";
             return resultInfo;
         }
         resultInfo.Success = true;
         resultInfo.ExceptionMsg = string.Empty;
         return resultInfo;
     }
     catch (Exception ex)
     {
         resultInfo.Success = false;
         resultInfo.ExceptionMsg = ex.Message;
         return resultInfo;
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// 插入用户
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        public ExecuteResult InsertUser(UserDataContact data)
        {
            ExecuteResult resultInfo = new ExecuteResult();
            try
            {
                Model.User user = new User();
                user.GroupId = data.GroupId;
                user.Id = userOperator.GetMaxId() + 1;
                user.PassWord = data.PassWord;
                user.Status = data.Status;
                user.UserName = data.Name;

                if (userOperator.IsContainUser(user.UserName))
                {
                    resultInfo.Success = false;
                    resultInfo.ExceptionMsg = "已有相同的用户名,请重新填写!";
                    return resultInfo;
                }
                int count = userOperator.InsertUser(user);
                if (count == 0)
                {
                    resultInfo.Success = false;
                    resultInfo.ExceptionMsg = "服务连接断开,请联系管理员!";
                    return resultInfo;
                }
                resultInfo.Success = true;
                resultInfo.ExceptionMsg = string.Empty;
                return resultInfo;
            }
            catch (Exception ex)
            {
                resultInfo.Success = false;
                resultInfo.ExceptionMsg = ex.Message;
                return resultInfo;
            }
        }