private void btnTimKiem_Click(object sender, EventArgs e) { GiangDayFilter _filter = new GiangDayFilter(); _filter.GiangVienId = GlobalSettings.UserID; _filter.KhoaHocId = rdKhoaHoc.Checked ? O2S_Common.TypeConvert.Parse.ToInt32(cboKhoaHoc.SelectedValue.ToString()) : 0; _filter.NgayBatDau = rdKhoangThoiGian.Checked ? (DateTime?)dateTuNgay.Value : null; _filter.NgayKetThuc = rdKhoangThoiGian.Checked ? (DateTime?)dateDenNgay.Value : null; gridKetQuaTimKiem.DataSource = GiangDayLogic.Select(_filter); gridKetQuaTimKiem_Click(sender, e); }
public static List <GiangDay_PlusDTO> Select(GiangDayFilter _filter) { try { //List<GiangDay_PlusDTO> _result = null; var query = (from p in GlobalSettings.Database.GIANGDAYs select p).AsEnumerable().Select((obj, index) => new GiangDay_PlusDTO { Stt = index + 1, GiangDayId = obj.GiangDayId, LopHocId = obj.LopHocId, GiangVienId = obj.GiangVienId, IsRemove = obj.IsRemove, CreatedDate = obj.CreatedDate, CreatedBy = obj.CreatedBy, CreatedLog = obj.CreatedLog, ModifiedDate = obj.ModifiedDate, ModifiedBy = obj.ModifiedBy, ModifiedLog = obj.ModifiedLog, }); if (_filter.GiangDayId != null && _filter.GiangDayId != 0) { query = query.Where(o => o.GiangDayId == _filter.GiangDayId).ToList(); } if (_filter.LopHocId != null && _filter.LopHocId != 0) { query = query.Where(o => o.LopHocId == _filter.LopHocId).ToList(); } if (_filter.GiangVienId != null && _filter.GiangVienId != 0) { query = query.Where(o => o.GiangVienId == _filter.GiangVienId).ToList(); } if (_filter.KhoaHocId != null && _filter.KhoaHocId != 0) { query = query.Where(o => o.LOPHOC.KhoaHocId == _filter.KhoaHocId).ToList(); } if (_filter.NgayBatDau != null && _filter.NgayKetThuc != null) { query = query.Where(o => o.LOPHOC.NgayBatDau >= _filter.NgayBatDau && o.LOPHOC.NgayKetThuc <= _filter.NgayKetThuc).ToList(); } return(query.ToList()); } catch (System.Exception ex) { return(null); O2S_Common.Logging.LogSystem.Error(ex); } }