private void bookAdd_click(object sender, MouseEventArgs e) { BookDAO addBook = new BookDAOImpl(); Book book = new Book(); book.setBookName(tbBookName.Text); book.setYear(Int32.Parse(tbBookYear.Text)); book.setTimeRead(UInt16.Parse(tbTimeRead.Text)); foreach (Author a in authors) { if (cbBookAuthor.Text.Equals(a.getAuthorName() + " " + a.getAuthorFamily())) { book.setAuthorID(a.getAuthorID()); } } foreach (Genre g in genres) { if (cbGenre.Text.Equals(g.getGenre())) { book.setGenreID(g.getGenreID()); } } addBook.add(book); }
private void SearchResult_Load(object sender, EventArgs e) { BookDAO dao = new BookDAOImpl(); foreach (Book book in books) { dataGridViewResult.Rows.Add(book.getBookName(), book.getYear(), book.getTimeRead(), book.getAuthorName(), book.getGenre()); } }
private void AllToolStripMenuItem_Click(object sender, EventArgs e) { BookDAO bookDao = new BookDAOImpl(); List <Book> books = bookDao.searchAll(); this.Hide(); SearchResult result = new SearchResult(books); result.Show(); }
private void searchByAuthor_click(object sender, MouseEventArgs e) { foreach (Author author in authors) { if (cbAuthor.SelectedItem.Equals(author.getAuthorName() + " " + author.getAuthorFamily())) { BookDAO bookDao = new BookDAOImpl(); List <Book> books = bookDao.searchByAuthorID(author.getAuthorID()); this.Hide(); SearchResult result = new SearchResult(books); result.Show(); } } }
private void searchByGenre_click(object sender, MouseEventArgs e) { foreach (Genre genre in genres) { if (cbGenre.SelectedItem.Equals(genre.getGenre())) { BookDAO bookDao = new BookDAOImpl(); List <Book> books = bookDao.searchByGenreID(genre.getGenreID()); this.Hide(); SearchResult result = new SearchResult(books); result.Show(); } } }