コード例 #1
0
        public ActionResult Index(int page=1)
        {
            //controller
            SanPhamController ctr=new SanPhamController();
            HangSXController ctr_hangsx = new HangSXController();
            //varibles
            int gia_from = TextLibrary.ToInt(_timkiem_sanpham["gia_from"]);
            int gia_to = TextLibrary.ToInt(_timkiem_sanpham["gia_to"]);
            Boolean order_desc = TextLibrary.ToBoolean(_timkiem_sanpham["order_desc"]);
            int max_item_per_page= TextLibrary.ToInt(_timkiem_sanpham["max_item_per_page"]);
            int hang_sx_id = TextLibrary.ToInt(_timkiem_sanpham["hangsx_id"]);
            HangSX hangsx = ctr_hangsx.get_by_id(
                hang_sx_id
            );
            //pagination
            PaginationLibrary pagination = new PaginationLibrary();
            pagination.set_current_page(page);
            pagination.set_max_item_per_page(
                max_item_per_page
            );

            pagination.set_total_item(
                ctr.timkiem_count(
                "",
                "",
                _timkiem_sanpham["ten"],
                "",
                gia_from,
                gia_to,
                hangsx,
                "1"
                )
            );
            pagination.update();
            //View data
            ViewBag.SanPham_List = ctr.timkiem(
                "",
                "",
                _timkiem_sanpham["ten"],
                "",
                gia_from,
                gia_to,
                hangsx,
                "1",
                _timkiem_sanpham["order_by"],
                order_desc,
                pagination.start_point,
                pagination.max_item_per_page
            );
            ViewBag.pagination = pagination;
            return View();
        }
コード例 #2
0
 /*
  * Hiển thị danh sách sản phẩm theo hãng SX có phân trang
  * Có nút Add to Cart => redirect đến trang Sản phẩm chi tiết để chọn
  * SL và màu sắc cần đặt
  */
 public ActionResult Index(int hangsx_id=0, int page=1)
 {
     SanPhamController ctr = new SanPhamController();
     HangSXController ctr_hangsx = new HangSXController();
     HangSX hangsx = ctr_hangsx.get_by_id(hangsx_id);
     //check
     if (hangsx==null || hangsx.active==false)
     {
         return RedirectToAction("Index","FrontHome");
     }
     //pagination
     int max_item_per_page=4;//will get from setting
     //pagination
         PaginationLibrary pg = new PaginationLibrary();
         pg.set_current_page(page);
         pg.set_max_item_per_page(max_item_per_page);
         pg.set_total_item(
             ctr.timkiem_count(
             "",
             "",
             "",
             "",
             0,
             0,
             hangsx,
             "1")
         );
     pg.update();
     ViewBag.SanPham_List = ctr.timkiem(
         "",
         "",
         "",
         "",
         -1,
         -1,
         hangsx,
         "1",
         _timkiem_sanpham["order_by"],
         TextLibrary.ToBoolean(_timkiem_sanpham["order_desc"])
         ,pg.start_point,
         max_item_per_page);
     ViewBag.pagination = pg;
     ViewBag.hangsx = hangsx;
     return View();
 }