Esempio n. 1
0
        public PageDataTable GetEntitiesForDt(GenericFilter <Kuponlar> filter)
        {
            using (var context = new BitirmeProjemContext())
            {
                var query = context.Kuponlars.Where(filter.Filter)
                            .AsQueryable();
                var result = new PageDataTable();
                if (!string.IsNullOrEmpty(filter.Sort) && filter.Sort != "0")
                {
                    query = query.OrderByField(filter.Sort, filter.Order.ToLower() == "asc");
                }

                result.total = query.Count();

                if (filter.Limit != null)
                {
                    if (filter.Offset != null)
                    {
                        result.rows = query.Skip(filter.Offset.Value).Take(filter.Limit.Value).ToList();
                    }
                }
                else
                {
                    result.rows = query.ToList();
                }
                return(result);
            }
        }
Esempio n. 2
0
        public PageDataTable GetEntitiesForDt(GenericFilter <Urunler> filter)
        {
            using (var context = new BitirmeProjemContext())
            {
                var query = context.Urunlers.Include(x => x.Kategoriler).Where(filter.Filter)
                            .Select(x => new { x.ID, x.Adi, x.Stok, x.Fiyat, Kategori = x.Kategoriler.Adi })
                            .AsQueryable();
                var result = new PageDataTable();
                if (!string.IsNullOrEmpty(filter.Sort) && filter.Sort != "0")
                {
                    query = query.OrderByField(filter.Sort, filter.Order.ToLower() == "asc");
                }

                result.total = query.Count();

                if (filter.Limit != null)
                {
                    if (filter.Offset != null)
                    {
                        result.rows = query.Skip(filter.Offset.Value).Take(filter.Limit.Value).ToList();
                    }
                }
                else
                {
                    result.rows = query.ToList();
                }
                return(result);
            }
        }
Esempio n. 3
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. 4
0
        /// <summary>
        /// 根据指定条件查找职位分页集合
        /// </summary>
        /// <param name="positionSearcher">职位查询对象</param>
        /// <param name="pager">分页对象</param>
        /// <param name="tran">中间事务对象</param>
        /// <returns>返回查找到的分页集合,包括按条件可查询到的所有记录数和当前分页的DataTable数据</returns>
        public PageDataTable FindDataTable(PositionSearcher positionSearcher, Pager pager, ICTransaction tran)
        {
            PageDataTable       pDataTable   = null;
            PageList <Position> positionList = this.FindList(positionSearcher, pager, tran);

            if (positionList != null)
            {
                pDataTable.PageIndex  = positionList.PageIndex;
                pDataTable.TotalCount = positionList.TotalCount;
                pDataTable.RecordList = new DataTable("Position");
                pDataTable.RecordList.Columns.AddRange(new DataColumn[] {
                    new DataColumn("PositionCode", typeof(String)),
                    new DataColumn("PositionId", typeof(String)),
                    new DataColumn("CompanyId", typeof(String)),
                    new DataColumn("DepartmentId", 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))
                });

                foreach (Position position in positionList.RecordList)
                {
                    pDataTable.RecordList.Rows.Add(
                        position.PositionCode,
                        position.PositionId,
                        position.CurrCompany.CompanyId,
                        position.CurrDepartment.DepartmentId,
                        position.CreaterId,
                        position.CreateTime,
                        position.Name,
                        position.RVersion,
                        position.Status,
                        position.UpdateTime,
                        position.UpdatorId
                        );
                }
            }

            return(pDataTable);
        }
Esempio n. 5
0
        /// <summary>
        /// 根据指定条件查找公司分页集合
        /// </summary>
        /// <param name="companySearcher">公司查询对象</param>
        /// <param name="pager">分页对象</param>
        /// <param name="tran">中间事务对象</param>
        /// <returns>返回查找到的分页集合,包括按条件可查询到的所有记录数和当前分页的DataTable数据</returns>
        public PageDataTable FindDataTable(CompanySearcher companySearcher, Pager pager, ICTransaction tran)
        {
            PageDataTable      pDataTable  = null;
            PageList <Company> companyList = this.FindList(companySearcher, pager, tran);

            if (companyList != null)
            {
                pDataTable.PageIndex  = companyList.PageIndex;
                pDataTable.TotalCount = companyList.TotalCount;
                pDataTable.RecordList = new DataTable("Company");
                pDataTable.RecordList.Columns.AddRange(new DataColumn[] {
                    new DataColumn("Address", typeof(String)),
                    new DataColumn("CompanyCode", typeof(String)),
                    new DataColumn("CompanyId", typeof(String)),
                    new DataColumn("CreaterId", typeof(String)),
                    new DataColumn("CreateTime", typeof(DateTime)),
                    new DataColumn("Name", typeof(String)),
                    new DataColumn("ParentCompanyId", typeof(String)),
                    new DataColumn("RVersion", typeof(Int32)),
                    new DataColumn("Status", typeof(Int32)),
                    new DataColumn("UpdateTime", typeof(DateTime)),
                    new DataColumn("UpdatorId", typeof(String))
                });

                foreach (Company company in companyList.RecordList)
                {
                    pDataTable.RecordList.Rows.Add(
                        company.Address,
                        company.CompanyCode,
                        company.CompanyId,
                        company.CreaterId,
                        company.CreateTime,
                        company.Name,
                        company.ParentCompany == null ? null : company.ParentCompany.CompanyId,
                        company.RVersion,
                        company.Status,
                        company.UpdateTime,
                        company.UpdatorId
                        );
                }
            }

            return(pDataTable);
        }
Esempio n. 6
0
        /// <summary>
        /// 根据指定条件查找部门分页集合
        /// </summary>
        /// <param name="departmentSearcher">部门查询对象</param>
        /// <param name="pager">分页对象</param>
        /// <param name="tran">中间事务对象</param>
        /// <returns>返回查找到的分页集合,包括按条件可查询到的所有记录数和当前分页的DataTable数据</returns>
        public PageDataTable FindDataTable(DepartmentSearcher departmentSearcher, Pager pager, ICTransaction tran)
        {
            PageDataTable         pDataTable     = null;
            PageList <Department> departmentList = this.FindList(departmentSearcher, pager, tran);

            if (departmentList != null)
            {
                pDataTable.PageIndex  = departmentList.PageIndex;
                pDataTable.TotalCount = departmentList.TotalCount;
                pDataTable.RecordList = new DataTable("Department");
                pDataTable.RecordList.Columns.AddRange(new DataColumn[] {
                    new DataColumn("DepartmentCode", typeof(String)),
                    new DataColumn("DepartmentId", typeof(String)),
                    new DataColumn("CompanyId", 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))
                });

                foreach (Department department in departmentList.RecordList)
                {
                    pDataTable.RecordList.Rows.Add(
                        department.DepartmentCode,
                        department.DepartmentId,
                        department.CurrCompany.CompanyId,
                        department.CreaterId,
                        department.CreateTime,
                        department.Name,
                        department.RVersion,
                        department.Status,
                        department.UpdateTime,
                        department.UpdatorId
                        );
                }
            }

            return(pDataTable);
        }
Esempio n. 7
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. 8
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. 9
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. 10
0
        /// <summary>
        /// 根据指定条件查找公司分页集合
        /// </summary>
        /// <param name="companySearcher">公司查询对象</param>
        /// <param name="pager">分页对象</param>
        /// <param name="tran">中间事务对象</param>
        /// <returns>返回查找到的分页集合,包括按条件可查询到的所有记录数和当前分页的DataTable数据</returns>
        public PageDataTable FindDataTable(CompanySearcher companySearcher, Pager pager, ICTransaction tran)
        {
            CompanySearcher  querySearcher  = null;
            MysqlQueryParser queryParser    = new MysqlQueryParser();
            PageDataTable    pDataTable     = new PageDataTable();
            DataSet          resultSet      = null;
            StringBuilder    query          = new StringBuilder();
            StringBuilder    conditionQuery = new StringBuilder();
            StringBuilder    sortQuery      = new StringBuilder();

            if (companySearcher != null)
            {
                querySearcher           = (CompanySearcher)companySearcher.Clone();
                querySearcher.TableName = "C";
            }

            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(@"   C.`CompanyId` ");
            query.AppendLine(@"  ,C.`CompanyCode` ");
            query.AppendLine(@"  ,C.`Name` ");
            query.AppendLine(@"  ,C.`Address` ");
            query.AppendLine(@"  ,C.`ParentCompanyId` ");
            query.AppendLine(@"  ,C.`RVersion` ");
            query.AppendLine(@"  ,C.`Status` ");
            query.AppendLine(@"  ,C.`CreaterId` ");
            query.AppendLine(@"  ,C.`CreateTime` ");
            query.AppendLine(@"  ,C.`UpdatorId` ");
            query.AppendLine(@"  ,C.`UpdateTime` ");
            query.AppendLine(@"FROM ");
            query.AppendLine(@"   `Company` C ");
            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(companySearcher, tran);
                pDataTable.RecordList = resultSet.Tables[0];
            }

            return(pDataTable);
        }
Esempio n. 11
0
        /// <summary>
        /// 根据指定条件查找公司集合
        /// </summary>
        /// <param name="companySearcher">公司查询对象</param>
        /// <returns>返回一个DataTable对象</returns>
        public DataTable FindDataTable(CompanySearcher companySearcher)
        {
            PageDataTable pageDataTable = this.FindDataTable(companySearcher, null, null);

            return(pageDataTable == null ? null : pageDataTable.RecordList);
        }
Esempio n. 12
0
        /// <summary>
        /// 根据指定条件查找部门集合
        /// </summary>
        /// <param name="departmentSearcher">部门查询对象</param>
        /// <param name="tran">中间事务对象</param>
        /// <returns>返回一个DataTable对象</returns>
        public DataTable FindDataTable(DepartmentSearcher departmentSearcher, ICTransaction tran)
        {
            PageDataTable pageDataTable = this.FindDataTable(departmentSearcher, null, tran);

            return(pageDataTable == null ? null : pageDataTable.RecordList);
        }
Esempio n. 13
0
        /// <summary>
        /// 根据指定条件查找部门集合
        /// </summary>
        /// <param name="departmentSearcher">部门查询对象</param>
        /// <returns>返回一个DataTable对象</returns>
        public DataTable FindDataTable(DepartmentSearcher departmentSearcher)
        {
            PageDataTable pageDataTable = this.FindDataTable(departmentSearcher, null, null);

            return(pageDataTable == null ? null : pageDataTable.RecordList);
        }
Esempio n. 14
0
        /// <summary>
        /// 根据指定条件查找职位分页集合
        /// </summary>
        /// <param name="positionSearcher">职位查询对象</param>
        /// <param name="pager">分页对象</param>
        /// <param name="tran">中间事务对象</param>
        /// <returns>返回查找到的分页集合,包括按条件可查询到的所有记录数和当前分页的DataTable数据</returns>
        public PageDataTable FindDataTable(PositionSearcher positionSearcher, Pager pager, ICTransaction tran)
        {
            PositionSearcher 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 (positionSearcher != null)
            {
                querySearcher = (PositionSearcher)positionSearcher.Clone();
                querySearcher.TableName = "P";

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

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

            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(@"   P.`PositionId`");
            query.AppendLine(@"  ,P.`PositionCode`");
            query.AppendLine(@"  ,P.`CompanyId`");
            query.AppendLine(@"  ,P.`DepartmentId`");
            query.AppendLine(@"  ,P.`Name`");
            query.AppendLine(@"  ,P.`RVersion`");
            query.AppendLine(@"  ,P.`Status`");
            query.AppendLine(@"  ,P.`CreaterId`");
            query.AppendLine(@"  ,P.`CreateTime`");
            query.AppendLine(@"  ,P.`UpdatorId`");
            query.AppendLine(@"  ,P.`UpdateTime`");
            query.AppendLine(@"FROM ");
            query.AppendLine(@"   `Position] P ");
            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(positionSearcher);
                pDataTable.RecordList = resultSet.Tables[0];
            }

            return pDataTable;
        }
Esempio n. 15
0
        /// <summary>
        /// 根据指定条件查找职位集合
        /// </summary>
        /// <param name="positionSearcher">职位查询对象</param>
        /// <param name="tran">中间事务对象</param>
        /// <returns>返回一个DataTable对象</returns>
        public DataTable FindDataTable(PositionSearcher positionSearcher, ICTransaction tran)
        {
            PageDataTable pageDataTable = this.FindDataTable(positionSearcher, null, tran);

            return(pageDataTable == null ? null : pageDataTable.RecordList);
        }
Esempio n. 16
0
        /// <summary>
        /// 查找指定条件的公司分页集合
        /// </summary>
        /// <param name="companySearcher">公司查询对象</param>
        /// <param name="pager">分页对象</param>
        /// <param name="tran">中间事务对象</param>
        /// <returns>返回查找到的分页集合,包括按条件可查询到的所有记录数和当前分页的对象集合</returns>
        public PageList <Company> FindList(CompanySearcher companySearcher, Pager pager, ICTransaction tran)
        {
            PageList <Company> resultList    = new PageList <Company>();
            PageDataTable      pageDataTable = this.FindDataTable(companySearcher, pager, tran);
            Company            ele           = null;

            if (pageDataTable != null)
            {
                resultList            = new PageList <Company>();
                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 Company();

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

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

                        if (!(aRow["CompanyCode"] is DBNull))
                        {
                            ele.CompanyCode = aRow["CompanyCode"].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["ParentCompanyId"] is DBNull))
                        {
                            ele.ParentCompanyId = aRow["ParentCompanyId"].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();
                        }

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

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

            if (companySearcher != null)
            {
                querySearcher           = (CompanySearcher)companySearcher.Clone();
                querySearcher.TableName = "C";
            }

            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(@"   C.[CompanyId] ");
            query.AppendLine(@"  ,C.[CompanyCode] ");
            query.AppendLine(@"  ,C.[Name] ");
            query.AppendLine(@"  ,C.[Address] ");
            query.AppendLine(@"  ,C.[ParentCompanyId] ");
            query.AppendLine(@"  ,C.[RVersion] ");
            query.AppendLine(@"  ,C.[Status] ");
            query.AppendLine(@"  ,C.[CreaterId] ");
            query.AppendLine(@"  ,C.[CreateTime] ");
            query.AppendLine(@"  ,C.[UpdatorId] ");
            query.AppendLine(@"  ,C.[UpdateTime] ");
            query.AppendLine(@"FROM ");
            query.AppendLine(@"   [Company] C ");
            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, "Company", 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, "Company", 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(companySearcher, tran);
                pDataTable.RecordList = resultSet.Tables[0];
            }

            return(pDataTable);
        }
Esempio n. 18
0
        /// <summary>
        /// 根据指定条件查找公司集合
        /// </summary>
        /// <param name="companySearcher">公司查询对象</param>
        /// <param name="tran">中间事务对象</param>
        /// <returns>返回一个DataTable对象</returns>
        public DataTable FindDataTable(CompanySearcher companySearcher, ICTransaction tran)
        {
            PageDataTable pageDataTable = this.FindDataTable(companySearcher, null, tran);

            return(pageDataTable == null ? null : pageDataTable.RecordList);
        }
Esempio n. 19
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. 20
0
        /// <summary>
        /// 根据指定条件查找部门分页集合
        /// </summary>
        /// <param name="departmentSearcher">部门查询对象</param>
        /// <param name="pager">分页对象</param>
        /// <param name="tran">中间事务对象</param>
        /// <returns>返回查找到的分页集合,包括按条件可查询到的所有记录数和当前分页的DataTable数据</returns>
        public PageDataTable FindDataTable(DepartmentSearcher departmentSearcher, Pager pager, ICTransaction tran)
        {
            DepartmentSearcher 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 (departmentSearcher != null)
            {
                querySearcher = (DepartmentSearcher)departmentSearcher.Clone();
                querySearcher.TableName = "D";

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

            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(@"   D.[DepartmentId] ");
            query.AppendLine(@"  ,D.[DepartmentCode] ");
            query.AppendLine(@"  ,D.[CompanyId] ");
            query.AppendLine(@"  ,D.[Name] ");
            query.AppendLine(@"  ,D.[RVersion] ");
            query.AppendLine(@"  ,D.[Status] ");
            query.AppendLine(@"  ,D.[CreaterId] ");
            query.AppendLine(@"  ,D.[CreateTime] ");
            query.AppendLine(@"  ,D.[UpdatorId] ");
            query.AppendLine(@"  ,D.[UpdateTime] ");
            query.AppendLine(@"FROM ");
            query.AppendLine(@"   [Department] D ");
            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, "Department", 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, "Department", 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(departmentSearcher, tran);
                pDataTable.RecordList = resultSet.Tables[0];
            }

            return pDataTable;
        }
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);
        }