예제 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pageSize"></param>
        /// <param name="pageIndex"></param>
        /// <returns></returns>
        public PagerData GetPagerData(int pageSize, int pageIndex)
        {
            SqlPager queryEr = new SqlPager();

            queryEr.FirstResult = pageSize * pageIndex;
            queryEr.MaxResults  = pageSize;
            DataTable dt = GetData(queryEr);

            ExecSqlQuery countQuery = new ExecSqlQuery();

            if (SimpleCount)
            {
                countQuery.Sql = @"select count(1) as total " + FromSqlPart + " " + WhereAndOtherExpress;
            }
            else
            {
                countQuery.Sql = @"select count(1) as total " + string.Format(" from ({0}) t22 ", @"select 1 as id23 " + FromSqlPart + " " + WhereAndOtherExpress);
            }
            countQuery.ParamerList.AddRange(queryEr.ParamerList);
            IList listCountData = Ht.ExecuteFind(countQuery);
            int   total         = dt.Rows.Count;

            if (listCountData != null && listCountData.Count > 0)
            {
                int.TryParse(Convert.ToString((listCountData[0] as Hashtable)["total"]), out total);
            }
            PagerData returnData = new PagerData {
                Data = dt, Total = total
            };

            return(returnData);
        }
예제 #2
0
        /// <summary>
        /// 把sql和条件装载到queryEr,然后执行queryEr上的方法获得数据
        /// </summary>
        /// <param name="queryEr"></param>
        /// <returns></returns>
        public DataTable GetData(ExecSqlQuery queryEr)
        {
            //下面查询是导案板中的一条记录*一个卡主一条记录
            queryEr.Sql = FieldsSqlPart + " " + FromSqlPart + " " + WhereAndOtherExpress + " " + OrderSqlPart;
            queryEr.ParamerList.AddRange(this.ParamerList);
            IList     listData = Ht.ExecuteFind(queryEr);
            DataTable dt       = HashTableListToDataTable.ToDataTable(listData);

            return(dt);
        }