private void AddItem(string Item) { if (Item == book) { if (CheckIfAllFieldsAreFilled(book) == true) { int languageIndex = BookLanguageComboBox.SelectedIndex; int pages = Convert.ToInt32(BookPagestextbox.Text); int genreIndex = BookGenreComboBox.SelectedIndex; string publisher = BookPublishertextbox.Text; Library newBook = new Books(languageIndex, pages, genreIndex, publisher); newBook.Title = BookTitletextbox.Text; newBook.Creator = BookAuthortextbox.Text; newBook.ProductNumber = Convert.ToInt64(BookISBNtextbox.Text); newBook.ReserveStudentID = -1; libraryRepository.CreateLibraryItem(newBook); } } else if (Item == cd) { if (CheckIfAllFieldsAreFilled(cd) == true) { int duration = Convert.ToInt32(CdDurationTextbox.Text); int genreIndex = CdGenreComboBox.SelectedIndex; Library newCD = new CD(duration, genreIndex); newCD.Title = CdTitleTextbox.Text; newCD.Creator = CdArtistTextbox.Text; newCD.ProductNumber = Convert.ToInt64(CdEANTextbox.Text); newCD.ReserveStudentID = -1; libraryRepository.CreateLibraryItem(newCD); } } else if (Item == dvd) { if (CheckIfAllFieldsAreFilled(dvd) == true) { int languagIndex = DvdLanguageComboBox.SelectedIndex; int duration = Convert.ToInt32(DvdDurationTextbox.Text); int genreIndex = DvdGenreComboBox.SelectedIndex; Library newDVD = new DVD(languagIndex, duration, genreIndex); newDVD.Title = DvdTitleTextbox.Text; newDVD.Creator = DvdDirectorTextbox.Text; newDVD.ProductNumber = Convert.ToInt64(DvdEANTextbox.Text); newDVD.ReserveStudentID = -1; libraryRepository.CreateLibraryItem(newDVD); } } }