예제 #1
0
        public DataTable StartPage()
        {
            if (this.pageCount == 0)
            {
                return(null);
            }

            this.statusStackBackWard.Clear();
            this.statusStackForward.Clear();

            string  select = this.ConstructSelectString(true, true, null);
            DataSet ds     = this.adoBase.DoQuery(select);

            PageStatus sta = new PageStatus();

            sta.curIDValueEnd  = ds.Tables[0].Rows[ds.Tables[0].Rows.Count - 1]["ID"].ToString();
            sta.preIDValueHead = ds.Tables[0].Rows[0]["ID"].ToString();
            sta.curTable       = ds.Tables[0];
            this.statusStackForward.Push(sta);

            this.curPageIndex = 0;
            this.currentPage  = sta.curTable;
            this.ActivePageIndexChanged(this.curPageIndex);

            return(this.currentPage);
        }
예제 #2
0
        private string ConstructSelectString(bool first, bool forward, PageStatus curSta)
        {
            if (this.curParas.Ascending)
            {
                if (first)
                {
                    return(this.curParas.SelectString);
                }


                string comp       = " >= ";
                string curIDValue = curSta.preIDValueHead;
                if (forward)
                {
                    comp       = " > ";
                    curIDValue = curSta.curIDValueEnd;
                }

                if (-1 == this.curParas.SelectString.IndexOf("where"))
                {
                    return(this.curParas.SelectString + string.Format(" where {0} {1} '{2}'", this.curParas.ComplexIDName, comp, curIDValue));
                }

                return(this.curParas.SelectString + string.Format(" and {0} {1} '{2}'", this.curParas.ComplexIDName, comp, curIDValue));
            }
            else
            {
                if (first)
                {
                    return(string.Format(this.curParas.SelectString + " order by {0} desc ", this.curParas.ComplexIDName));
                }


                string comp       = " <= ";
                string curIDValue = curSta.preIDValueHead;
                if (forward)
                {
                    comp       = " < ";
                    curIDValue = curSta.curIDValueEnd;
                }

                if (-1 == this.curParas.SelectString.IndexOf("where"))
                {
                    return(this.curParas.SelectString + string.Format(" where {0} {1} '{2}' order by {0} desc", this.curParas.ComplexIDName, comp, curIDValue));
                }

                return(this.curParas.SelectString + string.Format(" and {0} {1} '{2}' order by {0} desc", this.curParas.ComplexIDName, comp, curIDValue));
            }
        }
예제 #3
0
        public DataTable PrePage()
        {
            if (this.curPageIndex < 1)
            {
                return(null);
            }

            PageStatus oldSta = (PageStatus)this.statusStackForward.Pop();

            this.statusStackBackWard.Push(oldSta);

            if (this.preForward)
            {
                if (this.statusStackForward.Count > 0)
                {
                    oldSta = (PageStatus)this.statusStackForward.Pop();
                    this.statusStackBackWard.Push(oldSta);
                }
            }

            return(this.ReturnCurrentPage(oldSta.curTable, false));
        }
예제 #4
0
        public DataTable NextPage()
        {
            if (this.curPageIndex >= this.pageCount - 1)
            {
                return(null);
            }

            if (this.statusStackBackWard.Count > 0)
            {
                PageStatus staRes = (PageStatus)this.statusStackBackWard.Pop();
                this.statusStackForward.Push(staRes);
                if (!this.preForward)
                {
                    if (this.statusStackBackWard.Count > 0)
                    {
                        staRes = (PageStatus)this.statusStackBackWard.Pop();
                        this.statusStackForward.Push(staRes);
                    }
                }

                return(this.ReturnCurrentPage(staRes.curTable, true));
            }

            PageStatus curSta = (PageStatus)this.statusStackForward.Peek();
            string     select = this.ConstructSelectString(false, true, curSta);
            DataSet    ds     = this.adoBase.DoQuery(select);

            PageStatus sta = new PageStatus();

            sta.curIDValueEnd  = ds.Tables[0].Rows[ds.Tables[0].Rows.Count - 1]["ID"].ToString();
            sta.preIDValueHead = curSta.curTable.Rows[0]["ID"].ToString();
            sta.curTable       = ds.Tables[0];
            this.statusStackForward.Push(sta);

            return(this.ReturnCurrentPage(sta.curTable, true));
        }