private void LoadGridView() { //----- Get Query string parameters ----- 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 name = Request.QueryString["name"]; string levelText = Request.QueryString["level"]; int?level = null; if (!string.IsNullOrEmpty(levelText)) { int temp; if (int.TryParse(levelText, out temp)) { level = temp; } } //----- Get Query string parameters ----- int totalSize = 0; var manager = new AccountManager(); var list = manager.GetAccountViewModels(name, level, out totalSize, pIndex, _pageSize); int pages = PagingHelper.CalculatePages(totalSize, _pageSize); List <PagingLink> pagingList = new List <PagingLink>(); for (var i = 1; i <= pages; i++) { pagingList.Add(new PagingLink() { Link = $"MamberList.aspx{this.GetQueryString(false, i)}", Name = $"{i}", Title = $"前往第 {i} 頁" }); } this.repPaging.DataSource = pagingList; this.repPaging.DataBind(); this.GridView1.DataSource = list; this.GridView1.DataBind(); }
//一般:從DB抓總表資料出來根據PAGE進行分頁 搜尋:抓取Keyword資料,進DB後將篩選的資料依據PAGE進行分頁 private void LoadPettyCashView() { //----- Get Query string parameters ----- string page = Request.QueryString["Page"]; int pIndex = 0; //當頁面不為0時,進入預設第一頁 if (string.IsNullOrEmpty(page)) { pIndex = 1; } else { //將PAGE轉為數字,回傳pIndex int.TryParse(page, out pIndex); //如果回傳值小於0,強制轉成1 if (pIndex <= 0) { pIndex = 1; } } //----- Get Query string parameters ----- //設定關鍵搜尋網址 string Keyword_DD = Request.QueryString["Keyword_DD"]; string Keyword_txt = Request.QueryString["Keyword_txt"]; int totalSize = 0; var manager = new PettyCashmanager(); var list = manager.ViewAllPettyCash(Keyword_DD, Keyword_txt, out totalSize, pIndex, _pageSize); int pages = PagingHelper.CalculatePages(totalSize, _pageSize); List <PagingLink> pagingList = new List <PagingLink>(); for (var i = 1; i <= pages; i++) { pagingList.Add(new PagingLink() { Link = $"PettyCashList.aspx{this.GetQueryString(false, i)}", Name = $"{i}", Title = $"前往第 {i} 頁", Color = (i == pIndex) ? "BLACK" : "" }); } this.repPaging.DataSource = pagingList; this.repPaging.DataBind(); this.tableRepeater.DataSource = list; this.tableRepeater.DataBind(); }
private void LoadGridView() { ////----- Get Query string parameters ----- 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 caption = Request.QueryString["caption"]; string productTypeText = Request.QueryString["productType"]; string minPriceText = Request.QueryString["minPrice"]; string maxPriceText = Request.QueryString["maxPrice"]; int?productType = null; if (!string.IsNullOrEmpty(productTypeText)) { int temp; if (int.TryParse(productTypeText, out temp)) { productType = temp; } } 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; } } //----- Get Query string parameters ----- int totalSize = 0; var manager = new ProductManager(); var list = manager.GetAdminProducts(caption, productType, minPrice, maxPrice, out totalSize, pIndex, _pageSize); int pages = PagingHelper.CalculatePages(totalSize, _pageSize); List <PagingLink> pagingList = new List <PagingLink>(); for (var i = 1; i <= pages; i++) { pagingList.Add(new PagingLink() { Link = $"MamberList.aspx{this.GetQueryString(false, i)}", Name = $"{i}", Title = $"前往第 {i} 頁" }); } //this.repPaging.DataSource = pagingList; //this.repPaging.DataBind(); this.GridView1.DataSource = list; this.GridView1.DataBind(); }
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(); }