Пример #1
0
        public DataTable GetMembers(int pageSize, int pageIndex, string where, out int allCount)
        {
            allCount = 0;
            if (pageSize <= 0 || pageIndex < 1)
            {
                return(null);
            }
            DataTable dt = null;
            string    w  = "where (1=1)";

            if (!string.IsNullOrEmpty(where))
            {
                w = where.Trim().ToLower();
                if (!w.StartsWith("where "))
                {
                    w = "where " + w;
                }
            }
            object o = sqlHelper.GetSingle("select COUNT(*) from TF_View_Member " + w);

            if (o != null && o != DBNull.Value)
            {
                allCount = Convert.ToInt32(o);
            }
            string sql = "select top " + pageSize + " * from TF_View_Member " + w + " and ID not in (select top " + (pageSize * (pageIndex - 1)) + " ID from TF_View_Member " + w + " order by ID desc) order by ID desc";

            dt = sqlHelper.Query(sql);
            return(dt);
        }