private void QuanLySach_Load(object sender, EventArgs e) { try { List <Sach> lst = sachService.GetSach(); foreach (Sach item in lst) { ListViewItem listViewItem = new ListViewItem(); listViewItem.SubItems.Add(item.MaSach.ToString()); listViewItem.SubItems.Add(item.TenSach); listViewItem.SubItems.Add(item.TheLoai); listViewItem.SubItems.Add(item.TacGia); listViewItem.SubItems.Add(item.NhaXuanBan); listViewItem.SubItems.Add(item.SoLuong.ToString()); lvwDanhSach_Sach.Items.Add(listViewItem); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void ManHinhChinh_Load(object sender, EventArgs e) { lvwDanhSach.MultiSelect = false; try { SachService sachService = new SachService(); List <Sach> lst = sachService.GetSach(); foreach (Sach item in lst) { ListViewItem listViewItem = new ListViewItem(); listViewItem.SubItems.Add(item.MaSach.ToString()); listViewItem.SubItems.Add(item.TenSach); listViewItem.SubItems.Add(item.SoLuong.ToString()); listViewItem.SubItems.Add(item.TacGia.ToString()); listViewItem.SubItems.Add(item.TheLoai.ToString()); lvwDanhSach.Items.Add(listViewItem); } } catch (Exception ex) { Console.WriteLine(ex.Message); } }
private void btnRefresh_Click(object sender, EventArgs e) { try { lvwDanhSach_Sach.Items.Clear(); SachService s = new SachService(); List <Sach> lst = s.GetSach(); foreach (Sach item in lst) { ListViewItem listViewItem = new ListViewItem(); listViewItem.SubItems.Add(item.MaSach.ToString()); listViewItem.SubItems.Add(item.TenSach); listViewItem.SubItems.Add(item.TheLoai); listViewItem.SubItems.Add(item.TacGia); listViewItem.SubItems.Add(item.NhaXuanBan); listViewItem.SubItems.Add(item.SoLuong.ToString()); lvwDanhSach_Sach.Items.Add(listViewItem); } } catch (Exception ex) { Console.WriteLine(ex.Message); } }