Exemple #1
0
 /// <summary>
 /// 新增用户信息
 /// </summary>
 /// <param name="userInfo">用户信息</param>
 public void Add(UserInfo userInfo)
 {
     try
     {
         user.Add(userInfo);
     }
     catch (Exception ex)
     {
         BusinessExceptionHandler.HandlerException("新增用户信息失败!", ex);
     }
 }
Exemple #2
0
        /// <summary>
        /// 新增用户信息
        /// </summary>
        /// <param name="userInfo">用户信息对象</param>
        public void Add(UserInfo userInfo)
        {
            string commandText = "INSERT INTO User(Id,UserName,Password,EmployeeNumber,Tel,Mobile,Dept,"
                + "CreateDate,UpdateDate,Creator,Updator,Valid)VALUES(@Id,@UserName,@Password,@EmployeeNumber,"
                + "@Tel,@Mobile,@Dept,@CreateDate,@UpdateDate,@Creator,@Updator,@Valid)";

            try
            {
                base.Execute(commandText, connectionString: CarManageConfig.Instance.ConnectionString,
                    param: userInfo);
            }
            catch (Exception ex)
            {
                DataAccessExceptionHandler.HandlerException("新增用户信息失败!", ex);
            }
        }
Exemple #3
0
 /// <summary>
 /// 更新用户信息
 /// </summary>
 /// <param name="userInfo">用户信息信息对象</param>
 public void Update(UserInfo userInfo)
 {
     try
     {
         user.Update(userInfo);
     }
     catch (Exception ex)
     {
         BusinessExceptionHandler.HandlerException("更新用户信息失败!", ex);
     }
 }
Exemple #4
0
        /// <summary>
        /// 查询用户信息
        /// </summary>
        /// <returns>用户信息集合</returns>
        public List<UserInfo> Search(UserInfo queryInfo)
        {
            List<UserInfo> userList = new List<UserInfo>();

            try
            {
                userList = user.Search(queryInfo);
            }
            catch (Exception ex)
            {
                BusinessExceptionHandler.HandlerException("查询用户信息失败!", ex);
            }

            return userList;
        }
Exemple #5
0
        /// <summary>
        /// 更新用户信息
        /// </summary>
        /// <param name="userInfo">用户信息对象</param>
        public void Update(UserInfo userInfo)
        {
            string commandText = "UPDATE User SET "
                + "UserName=@UserName,Password=@Password,EmployeeNumber=@EmployeeNumber,Tel=@Tel,"
                + "Mobile=@Mobile,Dept=@Dept,CreateDate=@CreateDate,UpdateDate=@UpdateDate,Creator=@Creator,"
                + "Updator=@Updator,Valid=@Valid WHERE Id=@Id";

            try
            {
                base.Execute(commandText, connectionString: CarManageConfig.Instance.ConnectionString,
                    param: userInfo);
            }
            catch (Exception ex)
            {
                DataAccessExceptionHandler.HandlerException("更新用户信息失败!", ex);
            }
        }
Exemple #6
0
        /// <summary>
        /// 获得所有用户信息集合
        /// </summary>
        /// <returns>用户信息集合</returns>
        public List<UserInfo> Search(UserInfo queryInfo)
        {
            IDbConnection connection = null;

            List<UserInfo> userList = new List<UserInfo>();

            try
            {
                string field = "*";

                string table = "User";
                string order = "ORDER BY Id";

                StringBuilder filter = new StringBuilder();

                #region 查询条件

                #endregion

                string filterText = string.Empty;

                if (filter.Length > 0)
                {
                    filterText = filter.ToString().TrimStart(' ').Remove(0, 3).Insert(0, " WHERE ");
                }

                string commandText = string.Format("SELECT COUNT(*) FROM User {0}", filterText);

                connection = base.CreateConnection(CarManageConfig.Instance.ConnectionString);

                queryInfo.TotalCount = base.ExecuteObject<int>(commandText: commandText, connection: connection, param: queryInfo);

                if (queryInfo.TotalCount.Equals(0))
                    return userList;

                int pageCount = queryInfo.TotalCount / queryInfo.PageSize + 1;

                if (queryInfo.TotalCount % queryInfo.PageSize != 0)
                    pageCount++;

                int startIndex = queryInfo.PageIndex * queryInfo.PageSize;

                commandText = string.Format("SELECT {0} FROM {1} WHERE {2} ORDER BY {3} LIMIT {4},{5}",
                    field, table, filterText, order, startIndex, queryInfo.PageSize);

                userList = base.Query<UserInfo>(commandText, connection, param: queryInfo).ToList();
            }
            catch (Exception ex)
            {
                DataAccessExceptionHandler.HandlerException(
                    "查询用户信息失败!", ex);
            }
            finally
            {
                CloseConnection(connection);
            }

            return userList;
        }