public AddBook()
        {
            InitializeComponent();
            List <SachDTO> listBook = SachBUS.GetAll();

            dtgBook.ItemsSource = listBook;
        }
 private void BtnAdd_Click(object sender, RoutedEventArgs e)
 {
     if (selected == null)
     {
         string  name       = txtName.Text;
         string  author     = txtAuthor.Text;
         string  category   = txtCategory.Text;
         string  price      = txtPrice.Text;
         string  amount     = txtAmount.Text;
         string  idCategory = TheLoaiBUS.addCategory(category);
         string  idAuthor   = TacGiaBUS.addAuthor(author);
         SachDTO sach       = new SachDTO();
         sach.DonGia     = price;
         sach.LuongTon   = amount;
         sach.TenSach    = name;
         sach.TenTacGia  = idAuthor;
         sach.TenTheLoai = idCategory;
         int            result   = SachBUS.AddBook(sach);
         List <SachDTO> listBook = SachBUS.GetAll();
         dtgBook.ItemsSource = listBook;
         dtgBook.Items.Refresh();
         int Price  = int.Parse(price);
         int Amount = int.Parse(amount);
         TotalCost    += Price * Amount;
         lblTotal.Text = TotalCost.ToString();
     }
     else
     {
         selected.LuongTon = txtAmount.Text;
         int Price  = int.Parse(selected.DonGia);
         int Amount = int.Parse(selected.LuongTon);
         TotalCost    += Price * Amount;
         lblTotal.Text = TotalCost.ToString();
         int result = SachBUS.ChangeAmount(selected);
         if (result < 0)
         {
             MessageBox.Show("Thêm sách thất bại", "Lỗi", MessageBoxButton.OK, MessageBoxImage.Error);
         }
     }
 }