private void btnAdd_Click(object sender, EventArgs e) { try { string bookTitle = txtTitle.Text; string publisher = txtPublisher.Text; double price = double.Parse(txtPrice.Text); int year = int.Parse(txtYear.Text); int numOfPages = int.Parse(txtNumberPages.Text); iSBN = int.Parse(txtISBN.Text); switch (cmbBookType.SelectedIndex) { case 0: double fileSize = double.Parse(txtFileSize.Text); book = new EBook(bookTitle, price, publisher, year, iSBN, numOfPages, fileSize); break; case 1: EnumTextBookType textBookType = (EnumTextBookType)cmbTextBookType.SelectedItem; if (cmbTextBookType.SelectedIndex == 0) //HardCover { NumberOfHardCoverTextBook++; } else { NumberOfPaperTextBook++; } book = new TextBook(bookTitle, price, publisher, year, iSBN, numOfPages, textBookType); break; default: book = null; break; } bool result = AddBook(book); string message = result ? "Added" : "Not Added"; try { if (result == false) { throw new InvalidISBNExaption(); } } catch (Exception exept) { MessageBox.Show(exept.Message); } MessageBox.Show(message); } catch (Exception exept) { MessageBox.Show(exept.Message); } }
public TextBook(string bookTitle, double price, string publisher, int year, int iSBN, int numberOfPages, EnumTextBookType bookType) : base(bookTitle, price, publisher, year, iSBN, numberOfPages) { BookType = bookType; }