Esempio n. 1
0
        private void btnAddBook_Click(object sender, EventArgs e)
        {
            try
            {
                if ((bookController.CheckBook((int)nudBookISBN.Value)) == null)
                {
                    Editorial editorial = new Editorial(editorialID, editorialName);
                    Author    author    = new Author(authorID, authorName);
                    Book      book      = new Book(bookID, ISBN, title, editorial, edition, year, editionYear, author, deterioration);
                    book.ISBN          = (int)nudBookISBN.Value;
                    book.Title         = txbBookName.Text;
                    book.Year          = (int)nudBookYear.Value;
                    book.EditionYear   = (int)nudBookEditionYear.Value;
                    book.Deterioration = txbBookDeterioration.Text;
                    book.Author        = (Author)cmbBookAuthor.SelectedItem;
                    book.Editorial     = (Editorial)cmbBookEditorial.SelectedItem;
                    book.Edition       = (int)nudBookEdition.Value;

                    if (bookController.AddBook(book) != null)
                    {
                        MessageBox.Show("Se agregó un libro con éxito.");
                    }
                }
                else
                {
                    MessageBox.Show("Ya existe un libro con ese ISBN.");
                }

                updateAll();
            }
            catch (Exception ex)
            {
                error = ex.Message;
                MessageBox.Show(error);
            }
        }