Exemplo n.º 1
0
        /// <summary>
        /// 创建分页链接
        /// </summary>
        /// <param name="c"></param>
        /// <param name="page"></param>
        /// <returns></returns>
        public string BuildPagerLink(Class c, int page)
        {
            int recordCount = c.CountItem();
            int tmpid = 0;
            TemplateList temp = GetListTemplate(c);

            int pagecount = @int.GetPageCount(recordCount, temp.ShowRecordCount.ToInt32()); //(Convert.ToDouble(recordCount) / Convert.ToDouble(temp.ShowRecordCount)).YueShu();

            string str_first = string.Format("<a href=\"{0}\">首页</a>", page > 1 ? BasePage.GetClassUrl(c,1) : "javascript:void(0)");
            string str_pre = string.Format("<a href=\"{0}\">上页</a>", page > 1 ? BasePage.GetClassUrl(c, page-1) : "javascript:void(0)");
            string str_next = string.Format("<a href=\"{0}\">下页</a>", page < pagecount ? BasePage.GetClassUrl(c, page+1) : "javascript:void(0)");
            string str_end = string.Format("<a href=\"{0}\">尾页</a>", page != pagecount ? BasePage.GetClassUrl(c, pagecount) : "javascript:void(0)");
            return string.Format("{0} {1} {2} {3}", str_first, str_pre, str_next, str_end);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 创建跳转下拉菜单
        /// </summary>
        /// <param name="c"></param>
        /// <param name="page"></param>
        /// <returns></returns>
        public string BuidPagerOption(Class c, int page)
        {
            int recordCount = c.CountItem();
            TemplateList temp = GetListTemplate(c);

            int pagecount = (Convert.ToDouble(recordCount) / Convert.ToDouble(temp.ShowRecordCount)).YueShu();

            StringBuilder sb = new StringBuilder();
            sb.AppendLine("<select onchange='location.href=this.value'>");
            for (int i = 1; i <= pagecount; i++)
            {
                if (page == i)
                {
                    sb.AppendLine(string.Format("<option value='{0}' selected>{1}</option>", BasePage.GetClassUrl(c,i) , i.ToS()));
                }
                else
                {
                    sb.AppendLine(string.Format("<option value='{0}'>{1}</option>",  BasePage.GetClassUrl(c, i) , i.ToS()));
                }
            }
            sb.AppendLine("</select>");
            return sb.ToS();
        }
Exemplo n.º 3
0
        /// <summary>
        /// 创建类似google的数字分页
        /// </summary>
        /// <param name="c">类</param>
        /// <param name="page">页</param>
        /// <returns></returns>
        public string CreateNumPager(Class c, int page)
        {
            string str = "";

            int recordCount = c.CountItem();
            int tmpid = 0;
            TemplateList temp = GetListTemplate(c);

            int pageCount = (Convert.ToDouble(recordCount) / Convert.ToDouble(temp.ShowRecordCount)).YueShu();

            int lastPage = page + 2 > pageCount ? pageCount : page + 2;
            int prePage = page - 1 == 0 ? 1 : page - 1;
            int nextPage = page + 1 > pageCount ? pageCount : page + 1;

            str += string.Format("<a title=\"{0}第{1}页\" href=\"index_{1}.htm\"><</a> ", c.ClassName, prePage);
            for (int i = 0; i < 5; i++)
            {
                if (lastPage == 0)
                {
                    break;
                }
                str = str + string.Format("<a title=\"{0}第{1}页\" href=\"index_{1}.htm\">{1}</a> ", c.ClassName, lastPage);

                lastPage--;
            }
            str += string.Format("<a title=\"{0}第{1}页\" href=\"index_{1}.htm\">></a> ", c.ClassName, nextPage);
            return str;
        }