Esempio n. 1
0
        private void LoadRepeater()
        {
            string page   = Request.QueryString["Page"];
            int    pIndex = 0;

            if (string.IsNullOrEmpty(page))
            {
                pIndex = 1;
            }
            else
            {
                int.TryParse(page, out pIndex);

                if (pIndex <= 0)
                {
                    pIndex = 1;
                }
            }

            string company      = Request.QueryString["company"];
            string minPriceText = Request.QueryString["minPrice"];
            string maxPriceText = Request.QueryString["maxPrice"];
            string R_EText      = Request.QueryString["R_E"];

            decimal?minPrice = null;
            decimal?maxPrice = null;

            if (!string.IsNullOrEmpty(minPriceText))
            {
                int temp;
                if (int.TryParse(minPriceText, out temp))
                {
                    minPrice = temp;
                }
            }

            if (!string.IsNullOrEmpty(maxPriceText))
            {
                int temp;
                if (int.TryParse(maxPriceText, out temp))
                {
                    maxPrice = temp;
                }
            }

            int?R_E = null;

            if (!string.IsNullOrEmpty(R_EText))
            {
                int temp;
                if (int.TryParse(R_EText, out temp))
                {
                    R_E = temp;
                }
            }

            int totalSize = 0;

            var manager = new ReceiptManager();
            var list    = manager.GetReceipts(company, minPrice, maxPrice, R_E, out totalSize, pIndex, _pageSize);

            this.repInvoice.DataSource = list;
            this.repInvoice.DataBind();

            var pagination = new PagingHelper();
            int pages      = pagination.CalculatePages(totalSize, _pageSize);

            this.firstPage.HRef = pagination.GetPageUrl(1);
            this.lastPage.HRef  = pagination.GetPageUrl(pages);
            var pagingList = pagination.RepPagingList(pages);

            this.repPaging.DataSource = pagingList;
            this.repPaging.DataBind();

            this.lblCurrentPage.Text = pIndex.ToString();
            this.lblTotalPage.Text   = pages.ToString();
        }