public PageListResultBO <QL_PHONG_BO> GetDaTaByPage(int?depid, QLPHONGHOP_SEARCHBO searchModel, int pageSize = 20, int pageIndex = 1)
        {
            var query = from tblPhong in this.context.QL_PHONGHOP
                        where tblPhong.DEPID == depid
                        select new QL_PHONG_BO
            {
                ID        = tblPhong.ID,
                TENPHONG  = tblPhong.TENPHONG,
                MOTA      = tblPhong.MOTA,
                MAPHONG   = tblPhong.MAPHONG,
                DEPID     = tblPhong.DEPID,
                SOCHONGOI = tblPhong.SOCHONGOI,
            };

            if (searchModel != null)
            {
                if (!string.IsNullOrEmpty(searchModel.TenPhong))
                {
                    query = query.Where(a => a.TENPHONG.Contains(searchModel.TenPhong));
                }
                if (!string.IsNullOrEmpty(searchModel.MaPhong))
                {
                    query = query.Where(a => a.MAPHONG.Contains(searchModel.MaPhong));
                }

                //Lọc tìm kiếm
                if (!string.IsNullOrEmpty(searchModel.sortQuery))
                {
                    query = query.OrderBy(searchModel.sortQuery);
                }
                else
                {
                    query = query.OrderByDescending(a => a.ID);
                }
            }
            else
            {
                query = query.OrderByDescending(a => a.ID);
            }

            //Gán nội dung trả về

            var resultmodel = new PageListResultBO <QL_PHONG_BO>();

            if (pageSize == -1)
            {
                var dataPageList = query.ToList();
                resultmodel.Count     = dataPageList.Count;
                resultmodel.TotalPage = 1;
                resultmodel.ListItem  = dataPageList;
            }
            else
            {
                var dataPageList = query.ToPagedList(pageIndex, pageSize);
                resultmodel.Count     = dataPageList.TotalItemCount;
                resultmodel.TotalPage = dataPageList.PageCount;
                resultmodel.ListItem  = dataPageList.ToList();
            }
            return(resultmodel);
        }
示例#2
0
        public JsonResult searchData(FormCollection form)
        {
            AssignUserInfo();
            QL_PHONGHOPBusiness = Get <QL_PHONGHOPBusiness>();
            var searchModel = SessionManager.GetValue("TimKiemPhong") as QLPHONGHOP_SEARCHBO;

            if (searchModel == null)
            {
                searchModel          = new QLPHONGHOP_SEARCHBO();
                searchModel.pageSize = 20;
            }

            searchModel.TenPhong = form["sea_TenPhong"];
            searchModel.MaPhong  = form["sea_MaPhong"];;
            SessionManager.SetValue("TimKiemPhong", searchModel);

            var data = QL_PHONGHOPBusiness.GetDaTaByPage(currentUser.DeptParentID, searchModel, searchModel.pageSize, 1);

            return(Json(data));
        }
示例#3
0
        public JsonResult getData(int indexPage, string sortQuery, int pageSize)
        {
            AssignUserInfo();
            QL_PHONGHOPBusiness = Get <QL_PHONGHOPBusiness>();
            var searchModel = SessionManager.GetValue("TimKiemPhong") as QLPHONGHOP_SEARCHBO;

            if (!string.IsNullOrEmpty(sortQuery))
            {
                if (searchModel == null)
                {
                    searchModel = new QLPHONGHOP_SEARCHBO();
                }
                searchModel.sortQuery = sortQuery;
                if (pageSize > 0)
                {
                    searchModel.pageSize = pageSize;
                }
                SessionManager.SetValue("TimKiemPhong", searchModel);
            }

            var data = QL_PHONGHOPBusiness.GetDaTaByPage(currentUser.DeptParentID, searchModel, pageSize, indexPage);

            return(Json(data));
        }