/// <summary> /// Shows a BookDetails dialog window that displays the information of the new or found Book /// </summary> private void OpenBookDetails() { BookDetails bookDetails; if (Book != null) //open BookDetails with existing book { bookDetails = new BookDetails(Book, controller, false); bookDetails.ShowDialog(); } else //open BookDetails with newly created book { Book book = new Book { Title = string.Empty, Description = string.Empty, Language = string.Empty, NumPages = 0, Author = null, Publisher = string.Empty, Subject = string.Empty, YearPublished = 1400, ISBN = this.ISBN, NumberOfCopies = 0 }; //Add new Book to databse controller.AddBook(book); bookDetails = new BookDetails(book, controller, true); //if BookDetails Dialog returns false, meaning the user did not want to save changes, //remove the new book from the database and local collection. if (!(bool)bookDetails.ShowDialog()) { controller.RemoveBook(book); } } this.Close(); }
/// <summary> /// Opens a BookDetais window with the selectedBook as the Book to be displayed. /// </summary> private void ViewDetails() { BookDetails bookDetailsWindow = new BookDetails(selectedBook, controller, this); bookDetailsWindow.ShowDialog(); }