void LoadData() { List<TacGia> _tacGia = new List<TacGia>(); TacGiaBUS _busTacGia = new TacGiaBUS(); _tacGia = _busTacGia.GetList(); dataGrid.Items.Clear(); id = 1; foreach (TacGia i in _tacGia) { ThongTinTacGia _thongTinTacGia = new ThongTinTacGia(); _thongTinTacGia.MaTacGia = i.MaTG; _thongTinTacGia.TenTacGia = i.TenTG; dataGrid.IsReadOnly = true; dataGrid.Items.Add(_thongTinTacGia); if (id < int.Parse(i.MaTG)) { id = int.Parse(i.MaTG); } } }
private void btTim_Click(object sender, RoutedEventArgs e) { List<Sach> _sach = new List<Sach>(); SachBUS _busSach = new SachBUS(); dataGrid.Items.Clear(); _sach = _busSach.GetList(); string _maTheLoai = ""; foreach(TheLoai i in _theLoai) { if (i.TenTheLoai == cbbTheLoai.Text) { _maTheLoai = i.MaTheLoai; break; } } List<TacGia> _tacGia = new List<TacGia>(); TacGiaBUS _busTacGia = new TacGiaBUS(); _tacGia = _busTacGia.GetList(); List<NhaXuatBan> _nhaXuatBan = new List<NhaXuatBan>(); NhaXuatBanBUS _busNhaXuatBan = new NhaXuatBanBUS(); _nhaXuatBan = _busNhaXuatBan.GetList(); int stt = 1; if (tbTenSach.Text == "") { foreach (Sach i in _sach) { if (i.TheLoai == _maTheLoai) { ThongTinSach _thongTinSach = new ThongTinSach(); _thongTinSach.Stt = stt++; _thongTinSach.TenSach = i.TenSach; _thongTinSach.TheLoai = cbbTheLoai.Text; _thongTinSach.TacGia = LayTenTacGia(_tacGia, i.TacGia); _thongTinSach.NhaXuatBan = LayTenNhaXuatBan(_nhaXuatBan, i.NhaXuatBan); _thongTinSach.NamXuatBan = i.NamXuatBan; _thongTinSach.GiaBan = i.GiaBan.ToString(); _thongTinSach.SoLuong = i.SoLuong; dataGrid.Items.Add(_thongTinSach); } } } else if (tbTenSach.Text != "" && cbbTheLoai.Text != "") { foreach (Sach i in _sach) { if (String.Compare(i.TenSach, tbTenSach.Text, true) == 0 && i.TheLoai==_maTheLoai) { ThongTinSach _thongTinSach = new ThongTinSach(); _thongTinSach.Stt = stt++; _thongTinSach.TenSach = i.TenSach; _thongTinSach.TheLoai = cbbTheLoai.Text; _thongTinSach.TacGia = LayTenTacGia(_tacGia, i.TacGia); _thongTinSach.NhaXuatBan = LayTenNhaXuatBan(_nhaXuatBan, i.NhaXuatBan); _thongTinSach.NamXuatBan = i.NamXuatBan; _thongTinSach.GiaBan = i.GiaBan.ToString(); _thongTinSach.SoLuong = i.SoLuong; dataGrid.Items.Add(_thongTinSach); } } } else if(tbTenSach.Text!="") { foreach (Sach i in _sach) { if (String.Compare(i.TenSach, tbTenSach.Text, true) == 0) { ThongTinSach _thongTinSach = new ThongTinSach(); _thongTinSach.Stt = stt++; _thongTinSach.TenSach = i.TenSach; _thongTinSach.TheLoai = LayTenTheLoai(_theLoai,i.TheLoai); _thongTinSach.TacGia = LayTenTacGia(_tacGia, i.TacGia); _thongTinSach.NhaXuatBan = LayTenNhaXuatBan(_nhaXuatBan, i.NhaXuatBan); _thongTinSach.NamXuatBan = i.NamXuatBan; _thongTinSach.GiaBan = i.GiaBan.ToString(); _thongTinSach.SoLuong = i.SoLuong; dataGrid.Items.Add(_thongTinSach); } } } }
private void UserControl_Loaded(object sender, RoutedEventArgs e) { List<Sach> _sach = new List<Sach>(); SachBUS _busSach = new SachBUS(); dataGrid.Items.Clear(); _sach = _busSach.GetList(); List<TacGia> _tacGia = new List<TacGia>(); TacGiaBUS _busTacGia = new TacGiaBUS(); _tacGia = _busTacGia.GetList(); List<NhaXuatBan> _nhaXuatBan = new List<NhaXuatBan>(); NhaXuatBanBUS _busNhaXuatBan = new NhaXuatBanBUS(); _nhaXuatBan = _busNhaXuatBan.GetList(); List<TheLoai> _theLoai = new List<TheLoai>(); TheLoaiBUS _busTheLoai = new TheLoaiBUS(); _theLoai = _busTheLoai.GetList(); foreach (Sach i in _sach) { ThongTinSach _thongTinSach = new ThongTinSach(); _thongTinSach.MaSach = i.MaSach; _thongTinSach.TenSach = i.TenSach; _thongTinSach.TheLoai = LayTenTheLoai(_theLoai, i.TheLoai); _thongTinSach.TacGia = LayTenTacGia(_tacGia, i.TacGia); _thongTinSach.NhaXuatBan = LayTenNhaXuatBan(_nhaXuatBan, i.NhaXuatBan); _thongTinSach.NamXuatBan = i.NamXuatBan; _thongTinSach.GiaBan = i.GiaBan.ToString(); _thongTinSach.SoLuong = i.SoLuong; dataGrid.Items.Add(_thongTinSach); } }