示例#1
0
        public ItemCategoryCollection GetItemCategories(int PageSize, int PageIndex, string SortField, bool DESC, out int retCnt)
        {
            ItemCategoryCollection retobjs = null;
            string _DESC = "DESC";

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

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

            retobjs = this._getItemCategories(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);
        }
示例#2
0
        private ItemCategoryCollection _getItemCategories(string sql, int pPageIndex, int pPageSize)
        {
            ItemCategoryCollection retobjs = new ItemCategoryCollection();
            SqlDataReader          sdr     = null;
            ItemCategory           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._buildItemCategory(ref sdr);
                    if (null != obj)
                    {
                        retobjs.Add(obj);
                    }
                }
                _curRecPos++;
            }
            sdr.Close();
            if (retobjs.Count > 0)
            {
                return(retobjs);
            }
            else
            {
                return(null);
            }
        }
示例#3
0
        private ItemCategoryCollection _getItemCategories(string sql)
        {
            ItemCategoryCollection retobjs = new ItemCategoryCollection();
            SqlDataReader          sdr     = null;

            m_db.RunSql(sql, out sdr);
            if (null == sdr)
            {
                return(null);
            }
            while (sdr.Read())
            {
                retobjs.Add(this._buildItemCategory(ref sdr));
            }
            sdr.Close();
            return(retobjs);
        }
示例#4
0
 public void DeleteItem(ItemCategoryViewModel itemView)
 {
     ItemCategoryCollection.Remove(itemView);
 }