Exemplo n.º 1
0
        public ActionResult Province_PriceIndex(int?page, string ProvincePrice, string ProvinceID)
        {
            #region [view drop search]
            var Province = db.Provinces.ToList();
            for (int i = 0; i < Province.Count; i++)
            {
                ViewBag.Province = new SelectList(Province, "Id", "Name");
            }
            #endregion
            if (Request.HttpMethod == "GET")
            {
                if (Session["ProvincePrice"] != null)
                {
                    ProvincePrice            = Session["ProvincePrice"].ToString();
                    Session["ProvincePrice"] = null;
                }
            }
            else
            {
                page = 1;
            }

            ViewBag.ProvincePrice = ProvincePrice;

            var all = db.sp_Province_Price_GetByAll().OrderBy(o => o.ProvinceId).ToList();
            if (!String.IsNullOrEmpty(ProvincePrice))
            {
                int ProvinceId = Int32.Parse(ProvincePrice);
                all = all.Where(p => p.ProvinceId == ProvinceId).OrderByDescending(p => p.Id).ToList();
            }
            if (!String.IsNullOrEmpty(ProvinceID))
            {
                int ProvinceId = Int32.Parse(ProvinceID);
                all = all.Where(p => p.ProvinceId == ProvinceId).OrderByDescending(p => p.Id).ToList();
            }
            int pageSize   = 25;
            int pageNumber = (page ?? 1);

            // Thiết lập phân trang
            PagedListRenderOptions ship = new PagedListRenderOptions();

            ship.DisplayLinkToFirstPage                      = PagedListDisplayMode.Always;
            ship.DisplayLinkToLastPage                       = PagedListDisplayMode.Always;
            ship.DisplayLinkToPreviousPage                   = PagedListDisplayMode.Always;
            ship.DisplayLinkToNextPage                       = PagedListDisplayMode.Always;
            ship.DisplayLinkToIndividualPages                = true;
            ship.DisplayPageCountAndCurrentLocation          = false;
            ship.MaximumPageNumbersToDisplay                 = 5;
            ship.DisplayEllipsesWhenNotShowingAllPageNumbers = true;
            ship.EllipsesFormat                     = "&#8230;";
            ship.LinkToFirstPageFormat              = "Trang đầu";
            ship.LinkToPreviousPageFormat           = "«";
            ship.LinkToIndividualPageFormat         = "{0}";
            ship.LinkToNextPageFormat               = "»";
            ship.LinkToLastPageFormat               = "Trang cuối";
            ship.PageCountAndCurrentLocationFormat  = "Page {0} of {1}.";
            ship.ItemSliceAndTotalFormat            = "Showing items {0} through {1} of {2}.";
            ship.FunctionToDisplayEachPageNumber    = null;
            ship.ClassToApplyToFirstListItemInPager = null;
            ship.ClassToApplyToLastListItemInPager  = null;
            ship.ContainerDivClasses                = new[] { "pagination-container" };
            ship.UlElementClasses                   = new[] { "pagination" };
            ship.LiElementClasses                   = Enumerable.Empty <string>();

            ViewBag.ship = ship;
            return(View(all.ToPagedList(pageNumber, pageSize)));
        }