Exemplo n.º 1
0
        private void btnRegisterNewBook_Click(object sender, EventArgs e)
        {
            if (autor != null)
            {
                try
                {
                    Book b = new Book();

                    b.Title       = tbTitle.Text;
                    b.Author      = autor.Name;
                    b.Available   = Int32.Parse(tbQuantity.Text);
                    b.Quantity    = Int32.Parse(tbQuantity.Text);
                    b.Description = tbDescription.Text;
                    b.Genre       = cbGenre.SelectedItem.ToString();
                    b.Language    = cbLanguage.SelectedItem.ToString();
                    b.Pages       = Int32.Parse(tbPages.Text);
                    b.Year        = Int32.Parse(tbYear.Text);

                    if (Program.librarian.AddBook(b))
                    {
                        MessageBox.Show("Book added successfully.");
                    }
                    else
                    {
                        MessageBox.Show("Some error happened. Check again.");
                    }
                }
                catch
                {
                    MessageBox.Show("Fields are not correctly entered or something is empty.");
                }
            }
            else
            {
                DialogResult dialogResult = MessageBox.Show("Do you want to add new author?", "Author of this book is not set.", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.Yes)
                {
                    var aa = new AddAuthor();
                    aa.Show();
                }
                else if (dialogResult == DialogResult.No)
                {
                }
            }
        }
        private void btnAddAuthor_Click(object sender, EventArgs e)
        {
            var aa = new AddAuthor();

            aa.Show();
        }