Exemple #1
0
        public ShopListCollection GetAllShopLists(int PageSize, int PageIndex, string SortField, bool DESC, out int retCnt)
        {
            ShopListCollection retobjs = null;
            string             _DESC   = "DESC";

            if (DESC)
            {
                _DESC = "DESC";
            }
            else
            {
                _DESC = "ASC";
            }

            string sql = "select * from " + this.m_shopListTablename
                         + " order by " + SortField + " " + _DESC;

            retobjs = this._getShopLists(sql, PageIndex, PageSize);
            //try
            //{
            sql    = sql.Replace("*", "count(*)");
            sql    = sql.Replace("order", "");
            sql    = sql.Replace("by", "");
            sql    = sql.Replace(_DESC, "");
            sql    = sql.Replace(SortField, "");
            retCnt = this.m_db.GetRecordCount(sql);
            //}
            //catch
            //{
            retCnt = 0;
            //}
            return(retobjs);
        }
Exemple #2
0
        private ShopListCollection _getShopLists(string sql, int pPageIndex, int pPageSize)
        {
            ShopListCollection retobjs = new ShopListCollection();
            SqlDataReader      sdr     = null;
            ShopList           obj     = null;

            m_db.RunSql(sql, out sdr);
            if (null == sdr)
            {
                return(null);
            }
            int _curRecPos = 0;
            //计算页记录///
            long _startpos = 0;
            long _endpos   = 0;

            if (pPageIndex > -1)
            {
                _startpos = pPageIndex * pPageSize;
                _endpos   = _startpos + pPageSize;
            }
            while (sdr.Read())
            {
                if (_curRecPos > _endpos)
                {
                    break;
                }
                if (_curRecPos >= _startpos && _curRecPos < _endpos)
                {
                    obj = this._buildShopList(ref sdr);
                    if (null != obj)
                    {
                        retobjs.Add(obj);
                    }
                }
                _curRecPos++;
            }
            sdr.Close();
            if (retobjs.Count > 0)
            {
                return(retobjs);
            }
            else
            {
                return(null);
            }
        }
Exemple #3
0
        private ShopListCollection _getShopLists(string sql)
        {
            ShopListCollection retobjs = new ShopListCollection();
            SqlDataReader      sdr     = null;

            m_db.RunSql(sql, out sdr);
            if (null == sdr)
            {
                return(null);
            }
            while (sdr.Read())
            {
                retobjs.Add(this._buildShopList(ref sdr));
            }
            sdr.Close();
            return(retobjs);
        }