private void LoadDanhSachTaiKhoan() { try { TaiKhoanFilter _filter = new TaiKhoanFilter(); _filter.LoaiTaiKhoanId = O2S_Common.TypeConvert.Parse.ToInt32(cboLoaiTaiKhoan.SelectedValue.ToString()); List <TaiKhoan_PlusDTO> _lstTaiKhoan = TaiKhoanLogic.SelectFilter(_filter); gridControlTaiKhoan.DataSource = _lstTaiKhoan; } catch (Exception ex) { O2S_Common.Logging.LogSystem.Error(ex); } }
public static List <TaiKhoan_PlusDTO> SelectFilter(TaiKhoanFilter _filter) { try { if (_filter.LoaiTaiKhoanId != null) { if (_filter.LoaiTaiKhoanId == KeySetting.LOAITAIKHOAN_NhanVien) { return((from p in Database.NHANVIENs where (_filter.TenDangNhap == null ? true : p.TAIKHOAN.TenDangNhap.Contains(_filter.TenDangNhap)) && p.LoaiNhanVienId != KeySetting.LOAINHANVIEN_QuanTri && p.TAIKHOAN.IsRemove == 0 select new TaiKhoan_PlusDTO { TaiKhoanId = p.TAIKHOAN.TaiKhoanId, LoaiTaiKhoanId = p.TAIKHOAN.LoaiTaiKhoanId, TenNguoiDung = p.TenNhanVien, TenLoaiTaiKhoan = p.TAIKHOAN.LOAITAIKHOAN.TenLoaiTaiKhoan, TenDangNhap = p.TAIKHOAN.TenDangNhap, MatKhau = p.TAIKHOAN.MatKhau, IsRemove = p.TAIKHOAN.IsRemove, CreatedDate = p.TAIKHOAN.CreatedDate, CreatedBy = p.TAIKHOAN.CreatedBy, CreatedLog = p.TAIKHOAN.CreatedLog, ModifiedDate = p.TAIKHOAN.ModifiedDate, ModifiedBy = p.TAIKHOAN.ModifiedBy, ModifiedLog = p.TAIKHOAN.ModifiedLog, }).ToList()); } else if (_filter.LoaiTaiKhoanId == KeySetting.LOAITAIKHOAN_HocVien) { return((from p in Database.HOCVIENs where p.TAIKHOAN.TenDangNhap != null && (_filter.TenDangNhap == null ? true : p.TAIKHOAN.TenDangNhap.Contains(_filter.TenDangNhap)) && p.TAIKHOAN.IsRemove == 0 select new TaiKhoan_PlusDTO { TaiKhoanId = p.TAIKHOAN.TaiKhoanId, LoaiTaiKhoanId = p.TAIKHOAN.LoaiTaiKhoanId, TenNguoiDung = p.TenHocVien, TenLoaiTaiKhoan = p.TAIKHOAN.LOAITAIKHOAN.TenLoaiTaiKhoan, TenDangNhap = p.TAIKHOAN.TenDangNhap, MatKhau = p.TAIKHOAN.MatKhau, IsRemove = p.TAIKHOAN.IsRemove, CreatedDate = p.TAIKHOAN.CreatedDate, CreatedBy = p.TAIKHOAN.CreatedBy, CreatedLog = p.TAIKHOAN.CreatedLog, ModifiedDate = p.TAIKHOAN.ModifiedDate, ModifiedBy = p.TAIKHOAN.ModifiedBy, ModifiedLog = p.TAIKHOAN.ModifiedLog, }).ToList()); } else if (_filter.LoaiTaiKhoanId == KeySetting.LOAITAIKHOAN_GiangVien) { return((from p in Database.GIANGVIENs where (_filter.TenDangNhap == null ? true : p.TAIKHOAN.TenDangNhap.Contains(_filter.TenDangNhap)) && p.TAIKHOAN.IsRemove == 0 select new TaiKhoan_PlusDTO { TaiKhoanId = p.TAIKHOAN.TaiKhoanId, LoaiTaiKhoanId = p.TAIKHOAN.LoaiTaiKhoanId, TenNguoiDung = p.TenGiangVien, TenLoaiTaiKhoan = p.TAIKHOAN.LOAITAIKHOAN.TenLoaiTaiKhoan, TenDangNhap = p.TAIKHOAN.TenDangNhap, MatKhau = p.TAIKHOAN.MatKhau, IsRemove = p.TAIKHOAN.IsRemove, CreatedDate = p.TAIKHOAN.CreatedDate, CreatedBy = p.TAIKHOAN.CreatedBy, CreatedLog = p.TAIKHOAN.CreatedLog, ModifiedDate = p.TAIKHOAN.ModifiedDate, ModifiedBy = p.TAIKHOAN.ModifiedBy, ModifiedLog = p.TAIKHOAN.ModifiedLog, }).ToList()); } else if (_filter.LoaiTaiKhoanId == KeySetting.LOAITAIKHOAN_QuanTri) { return((from p in Database.NHANVIENs where (_filter.TenDangNhap == null ? true : p.TAIKHOAN.TenDangNhap.Contains(_filter.TenDangNhap)) && p.LoaiNhanVienId == KeySetting.LOAINHANVIEN_QuanTri && p.TAIKHOAN.IsRemove == 0 select new TaiKhoan_PlusDTO { TaiKhoanId = p.TAIKHOAN.TaiKhoanId, LoaiTaiKhoanId = p.TAIKHOAN.LoaiTaiKhoanId, TenNguoiDung = p.TenNhanVien, TenLoaiTaiKhoan = p.TAIKHOAN.LOAITAIKHOAN.TenLoaiTaiKhoan, TenDangNhap = p.TAIKHOAN.TenDangNhap, MatKhau = p.TAIKHOAN.MatKhau, IsRemove = p.TAIKHOAN.IsRemove, CreatedDate = p.TAIKHOAN.CreatedDate, CreatedBy = p.TAIKHOAN.CreatedBy, CreatedLog = p.TAIKHOAN.CreatedLog, ModifiedDate = p.TAIKHOAN.ModifiedDate, ModifiedBy = p.TAIKHOAN.ModifiedBy, ModifiedLog = p.TAIKHOAN.ModifiedLog, }).ToList()); } else { return(null); } } else { return((from p in Database.TAIKHOANs where (_filter.TenDangNhap == null ? true : p.TenDangNhap.Contains(_filter.TenDangNhap)) && p.IsRemove == 0 select new TaiKhoan_PlusDTO { TaiKhoanId = p.TaiKhoanId, LoaiTaiKhoanId = p.LoaiTaiKhoanId, TenNguoiDung = p.TenDangNhap, TenLoaiTaiKhoan = p.LOAITAIKHOAN.TenLoaiTaiKhoan, TenDangNhap = p.TenDangNhap, MatKhau = p.MatKhau, IsRemove = p.IsRemove, CreatedDate = p.CreatedDate, CreatedBy = p.CreatedBy, CreatedLog = p.CreatedLog, ModifiedDate = p.ModifiedDate, ModifiedBy = p.ModifiedBy, ModifiedLog = p.ModifiedLog, }).ToList()); } } catch (System.Exception ex) { return(null); O2S_Common.Logging.LogSystem.Error(ex); } }