public ActionResult Index() { HOSOCANBOBusiness = Get <HOSOCANBOBusiness>(); var searchmodel = new HoSoCanBoSearch(); SessionManager.SetValue("hosocanboSearchModel", null); DanhSachHoSoVM model = new DanhSachHoSoVM(); model.ListResult = HOSOCANBOBusiness.GetDataByPage(null); return(View(model)); }
public JsonResult searchData(FormCollection form) { HOSOCANBOBusiness = Get <HOSOCANBOBusiness>(); var searchModel = SessionManager.GetValue("hosocanboSearchModel") as HoSoCanBoSearch; if (searchModel == null) { searchModel = new HoSoCanBoSearch(); searchModel.pageSize = 20; } searchModel.HOTEN = form["HOTEN"]; searchModel.MANGACH_BAC = form["MANGACH_BAC"]; searchModel.STRCHUCVU = form["STRCHUCVU"]; searchModel.TENDANGNHAP = form["TENDANGNHAP"]; SessionManager.SetValue("hosocanboSearchModel", searchModel); var data = HOSOCANBOBusiness.GetDataByPage(searchModel, 1, searchModel.pageSize); return(Json(data)); }
public PageListResultBO <HOSOCANBOCUSTOMBO> GetDataByPage(HoSoCanBoSearch searchModel, int pageIndex = 1, int pageSize = 20) { var query = from hoso in this.context.HOSO_CANBO_THONGTINCHUNG join datadanhmuc in this.context.DM_DANHMUC_DATA on hoso.GIOITINH equals datadanhmuc.ID into group1 from gioitinh in group1.DefaultIfEmpty() join ndung in this.context.DM_NGUOIDUNG on hoso.USER_ID equals ndung.ID into group2 from nguoidung in group2.DefaultIfEmpty() join datadanhmuc in this.context.DM_DANHMUC_DATA on hoso.NGACHCONGCHUCVIENCHUC equals datadanhmuc.ID into group3 from ngachcc in group3.DefaultIfEmpty() join datadanhmuc in this.context.DM_DANHMUC_DATA on hoso.CHUCVUHIENTAI equals datadanhmuc.ID into group4 from chucvu in group4.DefaultIfEmpty() join cocau in this.context.CCTC_THANHPHAN on hoso.DONVI_ID equals cocau.ID into group5 from cocautochuc in group5.DefaultIfEmpty() select new HOSOCANBOCUSTOMBO { ID = hoso.ID, HOTEN = hoso.HOTEN, TENGOIKHAC = hoso.TENGOIKHAC, NGAYSINH = hoso.NGAYSINH, GIOITINH = hoso.GIOITINH, NOISINH_XA = hoso.NOISINH_XA, NOISINH_HUYEN = hoso.NOISINH_HUYEN, NOISINH_TINH = hoso.NOISINH_TINH, QUEQUAN_XA = hoso.QUEQUAN_XA, QUEQUAN_HUYEN = hoso.QUEQUAN_HUYEN, QUEQUAN_TINH = hoso.QUEQUAN_TINH, DANTOC = hoso.DANTOC, TONGIAO = hoso.TONGIAO, NOIDANGKYHOKHAUTHUONGTRU = hoso.NOIDANGKYHOKHAUTHUONGTRU, NOIOHIENNAY = hoso.NOIOHIENNAY, NGHENGHIEPKHIDUOCTUYENDUNG = hoso.NGHENGHIEPKHIDUOCTUYENDUNG, NGAYTRUNGTUYEN = hoso.NGAYTRUNGTUYEN, COQUANTUYENDUNG = hoso.COQUANTUYENDUNG, CHUCVUHIENTAI = hoso.CHUCVUHIENTAI, NGACHCONGCHUCVIENCHUC = hoso.NGACHCONGCHUCVIENCHUC, MANGACH = hoso.MANGACH, BACLUONG = hoso.BACLUONG, HESO = hoso.HESO, TRINHDOGIAODUC = hoso.TRINHDOGIAODUC, TRINHDOCHUYENMONCAONHAT = hoso.TRINHDOCHUYENMONCAONHAT, STRGIOITINH = gioitinh.TEXT, TENDANGNHAP = nguoidung.TENDANGNHAP, STRNGACH = ngachcc.TEXT, STRCHUCVU = chucvu.TEXT, STRDONVI = cocautochuc.NAME }; if (searchModel != null) { if (!string.IsNullOrEmpty(searchModel.HOTEN)) { query = query.Where(x => x.HOTEN.Contains(searchModel.HOTEN)); } if (!string.IsNullOrEmpty(searchModel.MANGACH_BAC)) { query = query.Where(x => x.MANGACH.Contains(searchModel.MANGACH_BAC)); } if (!string.IsNullOrEmpty(searchModel.STRCHUCVU)) { query = query.Where(x => x.STRCHUCVU.Contains(searchModel.STRCHUCVU)); } if (!string.IsNullOrEmpty(searchModel.TENDANGNHAP)) { query = query.Where(x => x.TENDANGNHAP.Contains(searchModel.TENDANGNHAP)); } if (!string.IsNullOrEmpty(searchModel.sortQuery)) { query = query.OrderBy(searchModel.sortQuery); } else { query = query.OrderByDescending(x => x.ID); } } else { query = query.OrderByDescending(x => x.ID); } var resultmodel = new PageListResultBO <HOSOCANBOCUSTOMBO>(); 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); }