Esempio n. 1
0
        /// <summary>
        /// 删除员工
        /// </summary>
        /// <param name="employeeId">员工ID</param>
        /// <param name="tran">中间事务对象</param>
        public void Delete(string employeeId, ICTransaction tran)
        {
            EmployeeSearcher querySearcher = new EmployeeSearcher();

            querySearcher.EmployeeId.Equal(employeeId);
            this.Delete(querySearcher, tran);
        }
Esempio n. 2
0
        /// <summary>
        /// 查询员工数量
        /// </summary>
        /// <param name="employeeSearcher">员工查询对象</param>
        /// <param name="tran">中间事务对象</param>
        /// <returns>返回查询到的数量</returns>
        public long Count(EmployeeSearcher employeeSearcher, ICTransaction tran)
        {
            object           count         = 0;
            long             result        = 0;
            EmployeeSearcher querySearcher = null;
            MssqlQueryParser queryParser   = new MssqlQueryParser();
            StringBuilder    query         = new StringBuilder();

            query.AppendLine(@"SELECT ");
            query.AppendLine(@"   COUNT(E.EmployeeId) ");
            query.AppendLine(@"FROM ");
            query.AppendLine(@"   Employee E ");

            if (employeeSearcher != null)
            {
                querySearcher           = (EmployeeSearcher)employeeSearcher.Clone();
                querySearcher.TableName = "E";

                if (querySearcher.CurrCompany != null)
                {
                    querySearcher.CurrCompany.TableName = "C";
                    query.AppendLine(@"LEFT JOIN ");
                    query.AppendLine(@"   [Company] C ON(C.CompanyId = E.CompanyId) ");
                }

                if (querySearcher.CurrDepartment != null)
                {
                    querySearcher.CurrDepartment.TableName = "D";
                    query.AppendLine(@"LEFT JOIN ");
                    query.AppendLine(@"   [Department] D ON(D.DepartmentId = E.DepartmentId) ");
                }

                if (querySearcher.CurrPosition != null)
                {
                    querySearcher.CurrPosition.TableName = "P";
                    query.AppendLine(@"LEFT JOIN ");
                    query.AppendLine(@"   [Position] P ON(P.PositionId = E.PositionId) ");
                }
            }

            queryParser.SearcherParse(querySearcher);

            if (!string.IsNullOrEmpty(queryParser.ConditionString))
            {
                query.AppendLine(@"WHERE ");
                query.AppendLine(@"   " + queryParser.ConditionString);
            }

            if (tran != null)
            {
                DbTransaction dbTran = ((MssqlTransaction)tran).CurrentTransaction;
                count = MssqlHelper.ExecuteScalar(dbTran, CommandType.Text, query.ToString(), queryParser.ParamCollection);
            }
            else
            {
                count = MssqlHelper.ExecuteScalar(this.CurrentConnectionString, CommandType.Text, query.ToString(), queryParser.ParamCollection);
            }

            return(long.TryParse(count.ToString(), out result) ? result : 0);
        }
Esempio n. 3
0
        /// <summary>
        /// 查找指定ID的员工
        /// </summary>
        /// <param name="employeeId">员工ID</param>
        /// <param name="tran">中间事务对象</param>
        /// <returns>返回员工实体对象</returns>
        public Employee FindSingle(string employeeId, ICTransaction tran)
        {
            EmployeeSearcher employeeSearcher = new EmployeeSearcher();

            employeeSearcher.EmployeeId.Equal(employeeId);
            IList <Employee> employeeList = this.FindList(employeeSearcher);

            return((employeeList == null || employeeList.Count == 0) ? null : employeeList[0]);
        }
Esempio n. 4
0
        /// <summary>
        /// 根据指定条件查找员工分页集合
        /// </summary>
        /// <param name="employeeSearcher">员工查询对象</param>
        /// <param name="pager">分页对象</param>
        /// <param name="tran">中间事务对象</param>
        /// <returns>返回查找到的分页集合,包括按条件可查询到的所有记录数和当前分页的DataTable数据</returns>
        public PageDataTable FindDataTable(EmployeeSearcher employeeSearcher, Pager pager, ICTransaction tran)
        {
            PageDataTable       pDataTable   = null;
            PageList <Employee> employeeList = this.FindList(employeeSearcher, pager, tran);

            if (employeeList != null)
            {
                pDataTable.PageIndex  = employeeList.PageIndex;
                pDataTable.TotalCount = employeeList.TotalCount;
                pDataTable.RecordList = new DataTable("Employee");
                pDataTable.RecordList.Columns.AddRange(new DataColumn[] {
                    new DataColumn("EmployeeCode", typeof(String)),
                    new DataColumn("EmployeeId", typeof(String)),
                    new DataColumn("CompanyId", typeof(String)),
                    new DataColumn("DepartmentId", typeof(String)),
                    new DataColumn("PositionId", typeof(String)),
                    new DataColumn("CreaterId", typeof(String)),
                    new DataColumn("CreateTime", typeof(DateTime)),
                    new DataColumn("Name", typeof(String)),
                    new DataColumn("RVersion", typeof(Int32)),
                    new DataColumn("Status", typeof(Int32)),
                    new DataColumn("UpdateTime", typeof(DateTime)),
                    new DataColumn("UpdatorId", typeof(String)),
                    new DataColumn("Birthday", typeof(DateTime)),
                    new DataColumn("Sex", typeof(Int32)),
                    new DataColumn("Rand", typeof(Int32)),
                    new DataColumn("StartWorkDate", typeof(DateTime)),
                    new DataColumn("JoinDate", typeof(DateTime))
                });

                foreach (Employee employee in employeeList.RecordList)
                {
                    pDataTable.RecordList.Rows.Add(
                        employee.EmployeeCode,
                        employee.EmployeeId,
                        employee.CurrCompany.CompanyId,
                        employee.CurrDepartment.DepartmentId,
                        employee.CurrPosition.PositionId,
                        employee.CreaterId,
                        employee.CreateTime,
                        employee.Name,
                        employee.RVersion,
                        employee.Status,
                        employee.UpdateTime,
                        employee.UpdatorId,
                        employee.Birthday,
                        employee.Sex,
                        employee.Rand,
                        employee.StartWorkDate,
                        employee.JoinDate
                        );
                }
            }

            return(pDataTable);
        }
Esempio n. 5
0
 /// <summary>
 /// 根据指定条件删除员工
 /// </summary>
 /// <param name="employeeSearcher">员工查询对象</param>
 public void Delete(EmployeeSearcher employeeSearcher)
 {
     this.Delete(employeeSearcher, null);
 }
Esempio n. 6
0
        /// <summary>
        /// 根据指定条件删除员工
        /// </summary>
        /// <param name="employeeSearcher">员工查询对象</param>
        /// <param name="tran">中间事务对象</param>
        public void Delete(EmployeeSearcher employeeSearcher, ICTransaction tran)
        {
            EmployeeSearcher     querySearcher = null;
            HibernateTransaction hTran         = null;
            ISession             session       = null;
            HQLQueryParser       queryParser   = new HQLQueryParser();
            StringBuilder        query         = new StringBuilder();

            query.Append("DELETE FROM ");
            query.Append("  Employee  ");
            query.Append("WHERE ");
            query.Append("  EmployeeId IN (");
            query.Append("    SELECT ");
            query.Append("      E.EmployeeId ");
            query.Append("    FROM ");
            query.Append("      Employee E ");

            if (employeeSearcher != null)
            {
                querySearcher           = (EmployeeSearcher)employeeSearcher.Clone();
                querySearcher.TableName = "E";

                if (querySearcher.CurrCompany != null)
                {
                    querySearcher.CurrCompany.TableName = "C";
                    query.Append("LEFT JOIN ");
                    query.Append("  E.CurrCompany C ");
                }

                if (querySearcher.CurrDepartment != null)
                {
                    querySearcher.CurrDepartment.TableName = "D";
                    query.Append("LEFT JOIN ");
                    query.Append("  E.CurrDepartment D ");
                }

                if (querySearcher.CurrPosition != null)
                {
                    querySearcher.CurrPosition.TableName = "P";
                    query.Append("LEFT JOIN ");
                    query.Append("  E.CurrPosition P ");
                }
            }

            queryParser.SearcherParse(querySearcher);

            if (!string.IsNullOrEmpty(queryParser.ConditionString))
            {
                query.Append("WHERE ");
                query.Append("  " + queryParser.ConditionString);
            }

            query.Append(")");

            if (tran != null)
            {
                hTran   = (HibernateTransaction)tran;
                session = hTran.CurrentSession;
            }
            else
            {
                session = this.CurrentHibernateConfig.GetCurrentSession();
            }

            int effectCount = HibernateHelper.DeleteObjectByHQL(session, query.ToString(), queryParser.ParamCollection);
        }
Esempio n. 7
0
        /// <summary>
        /// 查找指定条件的员工分页集合
        /// </summary>
        /// <param name="employeeSearcher">员工查询对象</param>
        /// <param name="pager">分页对象</param>
        /// <param name="tran">中间事务对象</param>
        /// <returns>返回查找到的分页集合,包括按条件可查询到的所有记录数和当前分页的对象集合</returns>
        public PageList <Employee> FindList(EmployeeSearcher employeeSearcher, Pager pager, ICTransaction tran)
        {
            PageList <Employee> resultList    = new PageList <Employee>();
            PageDataTable       pageDataTable = this.FindDataTable(employeeSearcher, pager, tran);
            Employee            ele           = null;

            if (pageDataTable != null)
            {
                resultList            = new PageList <Employee>();
                resultList.PageIndex  = pageDataTable.PageIndex;
                resultList.TotalCount = pageDataTable.TotalCount;

                if (pageDataTable.RecordList != null && pageDataTable.RecordList.Rows.Count > 0)
                {
                    foreach (DataRow aRow in pageDataTable.RecordList.Rows)
                    {
                        ele = new Employee();

                        if (!(aRow["EmployeeId"] is DBNull))
                        {
                            ele.EmployeeId = aRow["EmployeeId"].ToString();
                        }

                        if (!(aRow["CompanyId"] is DBNull))
                        {
                            ele.CompanyId = aRow["CompanyId"].ToString();
                        }

                        if (!(aRow["DepartmentId"] is DBNull))
                        {
                            ele.DepartmentId = aRow["DepartmentId"].ToString();
                        }

                        if (!(aRow["PositionId"] is DBNull))
                        {
                            ele.PositionId = aRow["PositionId"].ToString();
                        }

                        if (!(aRow["EmployeeCode"] is DBNull))
                        {
                            ele.EmployeeCode = aRow["EmployeeCode"].ToString();
                        }

                        if (!(aRow["CreaterId"] is DBNull))
                        {
                            ele.CreaterId = aRow["CreaterId"].ToString();
                        }

                        if (!(aRow["CreateTime"] is DBNull))
                        {
                            ele.CreateTime = Convert.ToDateTime(aRow["CreateTime"]);
                        }

                        if (!(aRow["Name"] is DBNull))
                        {
                            ele.Name = aRow["Name"].ToString();
                        }

                        if (!(aRow["RVersion"] is DBNull))
                        {
                            ele.RVersion = Convert.ToInt32(aRow["RVersion"]);
                        }

                        if (!(aRow["Status"] is DBNull))
                        {
                            ele.Status = Convert.ToInt32(aRow["Status"]);
                        }

                        if (!(aRow["UpdateTime"] is DBNull))
                        {
                            ele.UpdateTime = Convert.ToDateTime(aRow["UpdateTime"]);
                        }

                        if (!(aRow["UpdatorId"] is DBNull))
                        {
                            ele.UpdatorId = aRow["UpdatorId"].ToString();
                        }

                        if (!(aRow["Birthday"] is DBNull))
                        {
                            ele.Birthday = Convert.ToDateTime(aRow["Birthday"]);
                        }

                        if (!(aRow["JoinDate"] is DBNull))
                        {
                            ele.JoinDate = Convert.ToDateTime(aRow["JoinDate"]);
                        }

                        if (!(aRow["Rand"] is DBNull))
                        {
                            ele.Rand = Convert.ToInt32(aRow["Rand"]);
                        }

                        if (!(aRow["Sex"] is DBNull))
                        {
                            ele.Sex = Convert.ToInt32(aRow["Sex"]);
                        }

                        if (!(aRow["StartWorkDate"] is DBNull))
                        {
                            ele.StartWorkDate = Convert.ToDateTime(aRow["StartWorkDate"]);
                        }

                        resultList.RecordList.Add(ele);
                    }
                }
            }

            return(resultList);
        }
Esempio n. 8
0
 /// <summary>
 /// 查询员工数量
 /// </summary>
 /// <param name="employeeSearcher">员工查询对象</param>
 /// <returns>返回查询到的数量</returns>
 public long Count(EmployeeSearcher employeeSearcher)
 {
     return(this.Count(employeeSearcher, null));
 }
Esempio n. 9
0
        /// <summary>
        /// 根据指定条件查找员工集合
        /// </summary>
        /// <param name="employeeSearcher">员工查询对象</param>
        /// <returns>返回一个DataTable对象</returns>
        public DataTable FindDataTable(EmployeeSearcher employeeSearcher)
        {
            PageDataTable pageDataTable = this.FindDataTable(employeeSearcher, null, null);

            return(pageDataTable == null ? null : pageDataTable.RecordList);
        }
Esempio n. 10
0
 /// <summary>
 /// 根据指定条件查找员工分页集合
 /// </summary>
 /// <param name="employeeSearcher">员工查询对象</param>
 /// <param name="pager">分页对象</param>
 /// <returns>返回查找到的分页集合,包括按条件可查询到的所有记录数和当前分页的DataTable数据</returns>
 public PageDataTable FindDataTable(EmployeeSearcher employeeSearcher, Pager pager)
 {
     return(this.FindDataTable(employeeSearcher, pager, null));
 }
Esempio n. 11
0
 /// <summary>
 /// 根据指定条件查找员工分页集合
 /// </summary>
 /// <param name="employeeSearcher">员工查询对象</param>
 /// <param name="pager">分页对象</param>
 /// <param name="tran">中间事务对象</param>
 /// <returns>返回查找到的分页集合,包括按条件可查询到的所有记录数和当前分页的DataTable数据</returns>
 public static PageDataTable FindEmployeeDataTable(EmployeeSearcher employeeSearcher, Pager pager, ICTransaction tran)
 {
     return(EmployeeDal.FindDataTable(employeeSearcher, pager, tran));
 }
Esempio n. 12
0
 /// <summary>
 /// 查找指定条件的员工分页集合
 /// </summary>
 /// <param name="employeeSearcher">员工查询对象</param>
 /// <param name="pager">分页对象</param>
 /// <returns>返回查找到的分页集合,包括按条件可查询到的所有记录数和当前分页的对象集合</returns>
 public PageList <Employee> FindList(EmployeeSearcher employeeSearcher, Pager pager)
 {
     return(this.FindList(employeeSearcher, pager, null));
 }
Esempio n. 13
0
 /// <summary>
 /// 查找指定条件的员工分页集合
 /// </summary>
 /// <param name="employeeSearcher">员工查询对象</param>
 /// <param name="pager">分页对象</param>
 /// <param name="tran">中间事务对象</param>
 /// <returns>返回查找到的分页集合,包括按条件可查询到的所有记录数和当前分页的对象集合</returns>
 public static PageList <Employee> FindEmployeeList(EmployeeSearcher employeeSearcher, Pager pager, ICTransaction tran)
 {
     return(EmployeeDal.FindList(employeeSearcher, pager, tran));
 }
Esempio n. 14
0
 /// <summary>
 /// 根据指定条件查找员工分页集合
 /// </summary>
 /// <param name="employeeSearcher">员工查询对象</param>
 /// <param name="pager">分页对象</param>
 /// <returns>返回查找到的分页集合,包括按条件可查询到的所有记录数和当前分页的DataTable数据</returns>
 public static PageDataTable FindEmployeeDataTable(EmployeeSearcher employeeSearcher, Pager pager)
 {
     return(EmployeeDal.FindDataTable(employeeSearcher, pager));
 }
Esempio n. 15
0
 /// <summary>
 /// 查找指定条件的员工分页集合
 /// </summary>
 /// <param name="employeeSearcher">员工查询对象</param>
 /// <param name="pager">分页对象</param>
 /// <returns>返回查找到的分页集合,包括按条件可查询到的所有记录数和当前分页的对象集合</returns>
 public static PageList <Employee> FindEmployeeList(EmployeeSearcher employeeSearcher, Pager pager)
 {
     return(EmployeeDal.FindList(employeeSearcher, pager));
 }
Esempio n. 16
0
 /// <summary>
 /// 查找指定条件的员工集合
 /// </summary>
 /// <param name="employeeSearcher">员工查询对象</param>
 /// <returns>返回员工实体对象集合</returns>
 public static IList <Employee> FindEmployeeList(EmployeeSearcher employeeSearcher)
 {
     return(EmployeeDal.FindList(employeeSearcher));
 }
Esempio n. 17
0
        /// <summary>
        /// 根据指定条件查找员工分页集合
        /// </summary>
        /// <param name="employeeSearcher">员工查询对象</param>
        /// <param name="pager">分页对象</param>
        /// <param name="tran">中间事务对象</param>
        /// <returns>返回查找到的分页集合,包括按条件可查询到的所有记录数和当前分页的DataTable数据</returns>
        public PageDataTable FindDataTable(EmployeeSearcher employeeSearcher, Pager pager, ICTransaction tran)
        {
            EmployeeSearcher querySearcher  = null;
            MysqlQueryParser queryParser    = new MysqlQueryParser();
            PageDataTable    pDataTable     = new PageDataTable();
            DataSet          resultSet      = null;
            StringBuilder    query          = new StringBuilder();
            StringBuilder    joinQuery      = new StringBuilder();
            StringBuilder    conditionQuery = new StringBuilder();
            StringBuilder    sortQuery      = new StringBuilder();

            if (employeeSearcher != null)
            {
                querySearcher           = (EmployeeSearcher)employeeSearcher.Clone();
                querySearcher.TableName = "E";

                if (querySearcher.CurrCompany != null)
                {
                    querySearcher.CurrCompany.TableName = "C";
                    joinQuery.AppendLine(@"LEFT JOIN ");
                    joinQuery.AppendLine(@"   `Company` C ON(C.CompanyId = E.CompanyId) ");
                }

                if (querySearcher.CurrDepartment != null)
                {
                    querySearcher.CurrDepartment.TableName = "D";
                    joinQuery.AppendLine(@"LEFT JOIN ");
                    joinQuery.AppendLine(@"   `Department` D ON(D.DepartmentId = E.DepartmentId) ");
                }

                if (querySearcher.CurrPosition != null)
                {
                    querySearcher.CurrPosition.TableName = "P";
                    joinQuery.AppendLine(@"LEFT JOIN ");
                    joinQuery.AppendLine(@"   `Position` P ON(P.PositionId = E.PositionId) ");
                }
            }

            queryParser.SearcherParse(querySearcher);

            if (!string.IsNullOrEmpty(queryParser.ConditionString))
            {
                conditionQuery.AppendLine(@"WHERE ");
                conditionQuery.AppendLine(@"   " + queryParser.ConditionString);
            }

            if (!string.IsNullOrEmpty(queryParser.SortString))
            {
                sortQuery.AppendLine(@"ORDER BY ");
                sortQuery.AppendLine(@"   " + queryParser.SortString);
            }

            query.AppendLine(@"SELECT ");
            query.AppendLine(@"   E.`EmployeeId` ");
            query.AppendLine(@"  ,E.`EmployeeCode` ");
            query.AppendLine(@"  ,E.`Name` ");
            query.AppendLine(@"  ,E.`Birthday` ");
            query.AppendLine(@"  ,E.`Sex` ");
            query.AppendLine(@"  ,E.`CompanyId` ");
            query.AppendLine(@"  ,E.`DepartmentId` ");
            query.AppendLine(@"  ,E.`PositionId` ");
            query.AppendLine(@"  ,E.`Rand` ");
            query.AppendLine(@"  ,E.`RVersion` ");
            query.AppendLine(@"  ,E.`Status` ");
            query.AppendLine(@"  ,E.`CreaterId` ");
            query.AppendLine(@"  ,E.`CreateTime` ");
            query.AppendLine(@"  ,E.`UpdatorId` ");
            query.AppendLine(@"  ,E.`UpdateTime` ");
            query.AppendLine(@"  ,E.`StartWorkDate` ");
            query.AppendLine(@"  ,E.`JoinDate` ");
            query.AppendLine(@"FROM ");
            query.AppendLine(@"  `Employee` E ");
            query.AppendLine(joinQuery.ToString());
            query.AppendLine(conditionQuery.ToString());
            query.AppendLine(sortQuery.ToString());

            if (pager != null && pager.PageSize != 0 && pager.StartRecord >= 0)
            {
                query.AppendLine(@" LIMIT " + pager.StartRecord.ToString() + "," + pager.PageSize + " ");
            }

            query.AppendLine(@"; ");

            if (tran != null)
            {
                resultSet = MySqlHelper.ExecuteDataset((MySqlConnection)tran.Connection, query.ToString(), queryParser.ParamCollection.ToArray());
            }
            else
            {
                resultSet = MySqlHelper.ExecuteDataset(this.CurrentConnectionString, query.ToString(), queryParser.ParamCollection.ToArray());
            }

            if (resultSet != null)
            {
                if (pager != null)
                {
                    pDataTable.PageIndex = pager.CurrentPage;
                }

                pDataTable.TotalCount = this.Count(employeeSearcher, tran);
                pDataTable.RecordList = resultSet.Tables[0];
            }

            return(pDataTable);
        }
Esempio n. 18
0
        /// <summary>
        /// 查找指定条件的员工集合
        /// </summary>
        /// <param name="employeeSearcher">员工查询对象</param>
        /// <returns>返回员工实体对象集合</returns>
        public IList <Employee> FindList(EmployeeSearcher employeeSearcher)
        {
            PageList <Employee> pageList = this.FindList(employeeSearcher, null, null);

            return(pageList == null ? null : pageList.RecordList);
        }
Esempio n. 19
0
        /// <summary>
        /// 查询员工数量
        /// </summary>
        /// <param name="employeeSearcher">员工查询对象</param>
        /// <returns>返回查询到的数量</returns>
        public static long CountEmployee(EmployeeSearcher employeeSearcher)
        {
            long count = EmployeeDal.Count(employeeSearcher);

            return(count);
        }
Esempio n. 20
0
        /// <summary>
        /// 查找指定条件的员工集合
        /// </summary>
        /// <param name="employeeSearcher">员工查询对象</param>
        /// <param name="tran">中间事务对象</param>
        /// <returns>返回员工实体对象集合</returns>
        public IList <Employee> FindList(EmployeeSearcher employeeSearcher, ICTransaction tran)
        {
            PageList <Employee> pageList = this.FindList(employeeSearcher, null, tran);

            return(pageList == null ? null : pageList.RecordList);
        }
Esempio n. 21
0
        /// <summary>
        /// 根据指定条件查找员工分页集合
        /// </summary>
        /// <param name="employeeSearcher">员工查询对象</param>
        /// <param name="pager">分页对象</param>
        /// <param name="tran">中间事务对象</param>
        /// <returns>返回查找到的分页集合,包括按条件可查询到的所有记录数和当前分页的DataTable数据</returns>
        public PageDataTable FindDataTable(EmployeeSearcher employeeSearcher, Pager pager, ICTransaction tran)
        {
            EmployeeSearcher querySearcher  = null;
            MssqlQueryParser queryParser    = new MssqlQueryParser();
            PageDataTable    pDataTable     = new PageDataTable();
            DataSet          resultSet      = null;
            StringBuilder    query          = new StringBuilder();
            StringBuilder    joinQuery      = new StringBuilder();
            StringBuilder    conditionQuery = new StringBuilder();
            StringBuilder    sortQuery      = new StringBuilder();

            if (employeeSearcher != null)
            {
                querySearcher           = (EmployeeSearcher)employeeSearcher.Clone();
                querySearcher.TableName = "E";

                if (querySearcher.CurrCompany != null)
                {
                    querySearcher.CurrCompany.TableName = "C";
                    joinQuery.AppendLine(@"LEFT JOIN ");
                    joinQuery.AppendLine(@"   [Company] C ON(C.CompanyId = E.CompanyId) ");
                }

                if (querySearcher.CurrDepartment != null)
                {
                    querySearcher.CurrDepartment.TableName = "D";
                    joinQuery.AppendLine(@"LEFT JOIN ");
                    joinQuery.AppendLine(@"   [Department] D ON(D.DepartmentId = E.DepartmentId) ");
                }

                if (querySearcher.CurrPosition != null)
                {
                    querySearcher.CurrPosition.TableName = "P";
                    joinQuery.AppendLine(@"LEFT JOIN ");
                    joinQuery.AppendLine(@"   [Position] P ON(P.PositionId = E.PositionId) ");
                }
            }

            queryParser.SearcherParse(querySearcher);

            if (!string.IsNullOrEmpty(queryParser.ConditionString))
            {
                conditionQuery.AppendLine(@"WHERE ");
                conditionQuery.AppendLine(@"   " + queryParser.ConditionString);
            }

            if (!string.IsNullOrEmpty(queryParser.SortString))
            {
                sortQuery.AppendLine(@"ORDER BY ");
                sortQuery.AppendLine(@"   " + queryParser.SortString);
            }

            query.AppendLine(@"SELECT ");
            query.AppendLine(@"   E.[EmployeeId] ");
            query.AppendLine(@"  ,E.[EmployeeCode] ");
            query.AppendLine(@"  ,E.[Name] ");
            query.AppendLine(@"  ,E.[Birthday] ");
            query.AppendLine(@"  ,E.[Sex] ");
            query.AppendLine(@"  ,E.[CompanyId] ");
            query.AppendLine(@"  ,E.[DepartmentId] ");
            query.AppendLine(@"  ,E.[PositionId] ");
            query.AppendLine(@"  ,E.[Rand] ");
            query.AppendLine(@"  ,E.[RVersion] ");
            query.AppendLine(@"  ,E.[Status] ");
            query.AppendLine(@"  ,E.[CreaterId] ");
            query.AppendLine(@"  ,E.[CreateTime] ");
            query.AppendLine(@"  ,E.[UpdatorId] ");
            query.AppendLine(@"  ,E.[UpdateTime] ");
            query.AppendLine(@"  ,E.[StartWorkDate] ");
            query.AppendLine(@"  ,E.[JoinDate] ");
            query.AppendLine(@"FROM ");
            query.AppendLine(@"  [Employee] E ");
            query.AppendLine(joinQuery.ToString());
            query.AppendLine(conditionQuery.ToString());
            query.AppendLine(sortQuery.ToString());
            query.AppendLine(@"; ");

            if (tran != null)
            {
                DbTransaction dbTran = ((MssqlTransaction)tran).CurrentTransaction;

                if (pager != null)
                {
                    resultSet = MssqlHelper.ExecuteDataSet(dbTran, CommandType.Text, query.ToString(), pager, "Employee", queryParser.ParamCollection);
                }
                else
                {
                    resultSet = MssqlHelper.ExecuteDataSet(dbTran, CommandType.Text, query.ToString(), queryParser.ParamCollection);
                }
            }
            else
            {
                if (pager != null)
                {
                    resultSet = MssqlHelper.ExecuteDataSet(this.CurrentConnectionString, CommandType.Text, query.ToString(), pager, "Employee", queryParser.ParamCollection);
                }
                else
                {
                    resultSet = MssqlHelper.ExecuteDataSet(this.CurrentConnectionString, CommandType.Text, query.ToString(), queryParser.ParamCollection);
                }
            }

            if (resultSet != null)
            {
                if (pager != null)
                {
                    pDataTable.PageIndex = pager.CurrentPage;
                }

                pDataTable.TotalCount = this.Count(employeeSearcher, tran);
                pDataTable.RecordList = resultSet.Tables[0];
            }

            return(pDataTable);
        }
Esempio n. 22
0
        /// <summary>
        /// 查找指定条件的员工分页集合
        /// </summary>
        /// <param name="employeeSearcher">员工查询对象</param>
        /// <param name="pager">分页对象</param>
        /// <param name="tran">中间事务对象</param>
        /// <returns>返回查找到的分页集合,包括按条件可查询到的所有记录数和当前分页的对象集合</returns>
        public PageList <Employee> FindList(EmployeeSearcher employeeSearcher, Pager pager, ICTransaction tran)
        {
            EmployeeSearcher     querySearcher = null;
            HibernateTransaction hTran         = null;
            ISession             session       = null;
            PageList <Employee>  pList         = new PageList <Employee>();
            HQLQueryParser       queryParser   = new HQLQueryParser();
            StringBuilder        query         = new StringBuilder();

            query.Append("SELECT ");
            query.Append(" E ");
            query.Append("FROM ");
            query.Append("  Employee E ");

            if (employeeSearcher != null)
            {
                querySearcher           = (EmployeeSearcher)employeeSearcher.Clone();
                querySearcher.TableName = "E";

                if (querySearcher.CurrCompany != null)
                {
                    querySearcher.CurrCompany.TableName = "C";
                    query.Append("LEFT JOIN ");
                    query.Append("  E.CurrCompany C ");
                }

                if (querySearcher.CurrDepartment != null)
                {
                    querySearcher.CurrDepartment.TableName = "D";
                    query.Append("LEFT JOIN ");
                    query.Append("  E.CurrDepartment D ");
                }

                if (querySearcher.CurrPosition != null)
                {
                    querySearcher.CurrPosition.TableName = "P";
                    query.Append("LEFT JOIN ");
                    query.Append("  E.CurrPosition P ");
                }
            }

            queryParser.SearcherParse(querySearcher);

            if (!string.IsNullOrEmpty(queryParser.ConditionString))
            {
                query.Append("WHERE ");
                query.Append("  " + queryParser.ConditionString);
            }

            if (!string.IsNullOrEmpty(queryParser.SortString))
            {
                query.Append("ORDER BY ");
                query.Append("  " + queryParser.SortString);
            }

            if (tran != null)
            {
                hTran            = (HibernateTransaction)tran;
                session          = hTran.CurrentSession;
                pList.TotalCount = this.Count(querySearcher, tran);
            }
            else
            {
                session          = this.CurrentHibernateConfig.GetCurrentSession();
                pList.TotalCount = this.Count(querySearcher);
            }

            if (pager != null)
            {
                pList.RecordList = HibernateHelper.FindObjectListByHQL <Employee>(session, query.ToString(), queryParser.ParamCollection, pager);
            }
            else
            {
                pList.RecordList = HibernateHelper.FindObjectListByHQL <Employee>(session, query.ToString(), queryParser.ParamCollection);
            }

            return(pList);
        }
Esempio n. 23
0
 /// <summary>
 /// 根据指定条件删除员工
 /// </summary>
 /// <param name="employeeSearcher">员工查询对象</param>
 public static void DeleteEmployee(EmployeeSearcher employeeSearcher)
 {
     EmployeeDal.Delete(employeeSearcher);
 }
Esempio n. 24
0
        /// <summary>
        /// 根据指定条件查找员工集合
        /// </summary>
        /// <param name="employeeSearcher">员工查询对象</param>
        /// <param name="tran">中间事务对象</param>
        /// <returns>返回一个DataTable对象</returns>
        public DataTable FindDataTable(EmployeeSearcher employeeSearcher, ICTransaction tran)
        {
            PageDataTable pageDataTable = this.FindDataTable(employeeSearcher, null, tran);

            return(pageDataTable == null ? null : pageDataTable.RecordList);
        }
Esempio n. 25
0
 /// <summary>
 /// 根据指定条件删除员工
 /// </summary>
 /// <param name="employeeSearcher">员工查询对象</param>
 /// <param name="tran">中间事务对象</param>
 public static void DeleteEmployee(EmployeeSearcher employeeSearcher, ICTransaction tran)
 {
     EmployeeDal.Delete(employeeSearcher, tran);
 }
Esempio n. 26
0
        /// <summary>
        /// 查询员工数量
        /// </summary>
        /// <param name="employeeSearcher">员工查询对象</param>
        /// <param name="tran">中间事务对象</param>
        /// <returns>返回查询到的数量</returns>
        public static long CountEmployee(EmployeeSearcher employeeSearcher, ICTransaction tran)
        {
            long count = EmployeeDal.Count(employeeSearcher, tran);

            return(count);
        }
Esempio n. 27
0
        /// <summary>
        /// 根据指定条件删除员工
        /// </summary>
        /// <param name="employeeSearcher">员工查询对象</param>
        /// <param name="tran">中间事务对象</param>
        public void Delete(EmployeeSearcher employeeSearcher, ICTransaction tran)
        {
            int effectCount = 0;
            EmployeeSearcher querySearcher = null;
            MysqlQueryParser queryParser   = new MysqlQueryParser();
            StringBuilder    query         = new StringBuilder();

            query.AppendLine(@"DELETE FROM ");
            query.AppendLine(@"   Employee ");
            query.AppendLine(@"WHERE ");
            query.AppendLine(@"   EmployeeId IN (");
            query.AppendLine(@"      SELECT ");
            query.AppendLine(@"         * ");
            query.AppendLine(@"      FROM ");
            query.AppendLine(@"         (SELECT ");
            query.AppendLine(@"             E.EmployeeId ");
            query.AppendLine(@"          FROM ");
            query.AppendLine(@"             Employee E ");

            if (employeeSearcher != null)
            {
                querySearcher           = (EmployeeSearcher)employeeSearcher.Clone();
                querySearcher.TableName = "E";

                if (querySearcher.CurrCompany != null)
                {
                    querySearcher.CurrCompany.TableName = "C";
                    query.AppendLine(@"LEFT JOIN ");
                    query.AppendLine(@"   `Company` C ON(C.CompanyId = E.CompanyId) ");
                }

                if (querySearcher.CurrDepartment != null)
                {
                    querySearcher.CurrDepartment.TableName = "D";
                    query.AppendLine(@"LEFT JOIN ");
                    query.AppendLine(@"   `Department` D ON(D.DepartmentId = E.DepartmentId) ");
                }

                if (querySearcher.CurrPosition != null)
                {
                    querySearcher.CurrPosition.TableName = "P";
                    query.AppendLine(@"LEFT JOIN ");
                    query.AppendLine(@"   `Position` P ON(P.PositionId = E.PositionId) ");
                }
            }

            queryParser.SearcherParse(querySearcher);

            if (!string.IsNullOrEmpty(queryParser.ConditionString))
            {
                query.AppendLine(@"WHERE ");
                query.AppendLine(@"   " + queryParser.ConditionString);
            }

            query.AppendLine(@") AS E1); ");

            try
            {
                if (tran != null)
                {
                    effectCount = MySqlHelper.ExecuteNonQuery((MySqlConnection)tran.Connection, query.ToString(), queryParser.ParamCollection.ToArray());
                }
                else
                {
                    effectCount = MySqlHelper.ExecuteNonQuery(this.CurrentConnectionString, query.ToString(), queryParser.ParamCollection.ToArray());
                }
            }
            catch (SqlException sex)
            {
                if (sex.ErrorCode == (int)ResultCode.FKError)
                {
                    throw new ResponseException((int)ResultCode.FKError, "DELETE Position");
                }
            }
        }