コード例 #1
0
        public void BindingData()
        {
            CinemaLINQDataContext dt      = new CinemaLINQDataContext();
            List <Phim>           _dsPhim = (from _phim in dt.Phims
                                             where _phim.TenPhim.Contains(Session["TenPhimTimKiem"].ToString())
                                             orderby _phim.TenPhim ascending
                                             select _phim).ToList();

            if (_dsPhim.Count == 0)
            {
                lb_KetQuaTraCuu.Text = "Không tìm thấy kết quả nào";
                return;
            }
            else
            {
                lb_KetQuaTraCuu.Text = "Kết quả tra cứu";
                PagedDataSource pds = new PagedDataSource();
                pds.DataSource       = _dsPhim;
                pds.AllowPaging      = true;
                pds.PageSize         = _pageSize;
                pds.CurrentPageIndex = CurrentIndex;

                Th_KetQuaTraCuu.DataSource = pds;
                Th_KetQuaTraCuu.DataBind();

                if (Session["NguoiDung"] == null || ((NguoiDung)Session["NguoiDung"]).MaDanhMucNguoiDung != 1)
                {
                    int _temp      = _dsPhim.Count - (CurrentIndex * _pageSize);
                    int _itemCount = 0;
                    if (_temp >= _pageSize)
                    {
                        _itemCount = _pageSize;
                    }
                    else
                    {
                        _itemCount = _temp;
                    }
                    for (int i = 0; i < _itemCount; i++)
                    {
                        ((LinkButton)Th_KetQuaTraCuu.Items[i].FindControl("lbt_ChinhSuaPhim")).Visible = false;
                    }
                }

                Pagging_CountPage(_dsPhim.Count);
            }
        }
コード例 #2
0
ファイル: Default.aspx.cs プロジェクト: ndphu/ptudw-h5-cinema
        public void BindingData()
        {
            CinemaLINQDataContext dt      = new CinemaLINQDataContext();
            List <Phim>           _dsPhim = (from _phim in dt.Phims
                                             where _phim.SuatChieus.Where(sc => sc.LichChieuPhim.NgayChieu.Date >= DateTime.Now.Date).Count() > 0
                                             orderby _phim.TenPhim ascending
                                             select _phim).ToList();

            if (_dsPhim.Count == 0)
            {
                return;
            }
            else
            {
                PagedDataSource pds = new PagedDataSource();
                pds.DataSource       = _dsPhim;
                pds.AllowPaging      = true;
                pds.PageSize         = _pageSize;
                pds.CurrentPageIndex = CurrentIndex;

                Th_KetQuaTraCuu.DataSource = pds;
                Th_KetQuaTraCuu.DataBind();

                if (Session["NguoiDung"] == null || ((NguoiDung)Session["NguoiDung"]).MaDanhMucNguoiDung != 1)
                {
                    int _temp      = _dsPhim.Count - (CurrentIndex * _pageSize);
                    int _itemCount = 0;
                    if (_temp >= _pageSize)
                    {
                        _itemCount = _pageSize;
                    }
                    else
                    {
                        _itemCount = _temp;
                    }

                    for (int i = 0; i < _itemCount; i++)
                    {
                        ((LinkButton)Th_KetQuaTraCuu.Items[i].FindControl("lbt_ChinhSuaPhim")).Visible = false;
                    }
                }

                Pagging_CountPage(_dsPhim.Count);
            }
        }