private void Page_Loaded(object sender, RoutedEventArgs e) { try { //Set up screen ResetFields(); usernameLabel.Content = user.LoginMessage(); patronLabel.Content = "Patron: " + patron.ToString(); //Set fields books = ((MainWindow)App.Current.MainWindow).Books; logs = ((MainWindow)App.Current.MainWindow).Logs; people = ((MainWindow)App.Current.MainWindow).People; //Get list of checked out logs and the list of overdue logs SetListBox(); //Check for good standing, report if bad goodStanding = IsInGoodStanding(); } catch (Exception ex) { errorLabel.Content = ErrorHandler.InnermostExceptionMessage(ex); } }
private void Page_Loaded(object sender, RoutedEventArgs e) { try { bookDetailTextBox.Text = ""; books = ((MainWindow)App.Current.MainWindow).Books; logs = ((MainWindow)App.Current.MainWindow).Logs; people = ((MainWindow)App.Current.MainWindow).People; //If in patron mode (no user is logged in) remove books with no copies if (user == null) { foundBooksFiltered = new List <BookBLL>(); foreach (BookBLL b in searchResults.FoundBooks) { if (b.NumberOfCopies > 0) { foundBooksFiltered.Add(b); } } } else { //Librarian Mode foundBooksFiltered = searchResults.FoundBooks; } //Reports if no books were found. if (foundBooksFiltered.Count == 0) { resultsLabel.Content = $"No books matched query: {searchResults.QueryTerms}"; } else { //Populates the listBox with the found books. string resultsLabelString = $"{foundBooksFiltered.Count} book"; if (foundBooksFiltered.Count == 0 || foundBooksFiltered.Count > 1) { resultsLabelString += "s"; } resultsLabelString += $" matched query: {searchResults.QueryTerms}"; resultsLabel.Content = resultsLabelString; listboxBookstrings = new List <string>(); foreach (BookBLL b in foundBooksFiltered) { string infoString = AvailabilityBuilder(b); listboxBookstrings.Add(infoString); } resultsListBox.DataContext = listboxBookstrings; } } catch (Exception ex) { errorLabel.Content = ErrorHandler.InnermostExceptionMessage(ex); } }
private void Page_Loaded(object sender, RoutedEventArgs e) { try { books = ((MainWindow)App.Current.MainWindow).Books; Reset(); } catch (Exception ex) { errorLabel.Content = ErrorHandler.InnermostExceptionMessage(ex); } }
public void TestAvailableCopiesOfCheckedOutBook() { //Arrange CheckOutLogBLLCollection logs = CreateCheckOutLogCollection(); BookBLLCollection books = CreateBookCollection(); int availableCopies; //Act availableCopies = logs.AvailableCopies(books[1]); //Assert Assert.AreEqual(1, availableCopies); }
public void TestSearchAllFieldsForISBN() { //Arrange PersonBLLCollection people = CreatePersonBLLCollection(); BookBLLCollection books = CreateBookCollection(); string query = "3003"; //Act BookSearch search = new BookSearch(books, people, query); search.SearchAllFields(); //Assert Assert.AreEqual(1, search.FoundBooks.Count); }
private void Page_Loaded(object sender, RoutedEventArgs e) { try { //Sets up the collection references and sets the page books = ((MainWindow)App.Current.MainWindow).Books; logs = ((MainWindow)App.Current.MainWindow).Logs; people = ((MainWindow)App.Current.MainWindow).People; Reset(); } catch (Exception ex) { errorLabel.Content = ErrorHandler.InnermostExceptionMessage(ex); } }
public void TestSearchForOnlyISBN() { //Arrange PersonBLLCollection people = CreatePersonBLLCollection(); BookBLLCollection books = CreateBookCollection(); string query = "4004"; //Act BookSearch search = new BookSearch(books, people, query); search.ISBNSearch(); //Assert Assert.AreEqual(1, search.FoundBooks.Count); }
public void TestSearchForWordNotThere() { //Arrange PersonBLLCollection people = CreatePersonBLLCollection(); BookBLLCollection books = CreateBookCollection(); string query = "Zebra"; //Act BookSearch search = new BookSearch(books, people, query); search.SearchAllFields(); //Assert Assert.AreEqual(0, search.FoundBooks.Count); }
private void Page_Loaded(object sender, RoutedEventArgs e) { try { ResetFields(); greetingLabel.Content = "Greetings! You may search the catalog for books using key terms\nfrom the title, ISBN, subject, or author's name."; searchTextBox.Focus(); books = ((MainWindow)App.Current.MainWindow).Books; logs = ((MainWindow)App.Current.MainWindow).Logs; people = ((MainWindow)App.Current.MainWindow).People; } catch (Exception ex) { errorLabel.Content = ErrorHandler.InnermostExceptionMessage(ex); } }
private void Page_Loaded(object sender, RoutedEventArgs e) { try { ResetFields(); books = ((MainWindow)App.Current.MainWindow).Books; logs = ((MainWindow)App.Current.MainWindow).Logs; people = ((MainWindow)App.Current.MainWindow).People; librarianMenuLists = new LibrarianMenuLists(people, books, logs); usernameLabel.Content = User.LoginMessage(); } catch (Exception ex) { errorLabel.Content = ErrorHandler.InnermostExceptionMessage(ex); } }
private void Window_Loaded(object sender, RoutedEventArgs e) { //If no database exists this will create it with Code First, otherwise this does nothing. CreateCodeFirstDatabase.CreateAndInitializeDatabase(); //The datamanger will handle locating and creating the XML files when the program ends. dataManager = new DataManager(); //Populate the three collections (books, people, checkoutlogs) Books = new BookBLLCollection(); Books.PopulateBooks(); People = new PersonBLLCollection(); People.PopulatePeople(); Logs = new CheckOutLogBLLCollection(); Logs.PopulateLogs(); Main.Content = new StartingPage(); }
BookBLLCollection CreateBookCollection() { BookBLLCollection books = new BookBLLCollection(); BookBLL book1 = new BookBLL() { BookID = 1, ISBN = "1001", Title = "Tom Goes To The Doctor", AuthorID = 1, NumberOfCopies = 3 }; BookBLL book2 = new BookBLL() { BookID = 2, ISBN = "2002", Title = "Mary Goes To The Dentist", AuthorID = 2, NumberOfCopies = 3 }; BookBLL book3 = new BookBLL() { BookID = 3, ISBN = "3003", Title = "Max Goes To The Barber", AuthorID = 3, NumberOfCopies = 3 }; BookBLL book4 = new BookBLL() { BookID = 4, ISBN = "4004", Title = "Susan Goes To The Cabal", AuthorID = 4, NumberOfCopies = 3 }; books.Add(book1); books.Add(book2); books.Add(book3); books.Add(book4); return(books); }
private void Page_Loaded(object sender, RoutedEventArgs e) { try { errorLabel.Content = ""; books = ((MainWindow)App.Current.MainWindow).Books; logs = ((MainWindow)App.Current.MainWindow).Logs; people = ((MainWindow)App.Current.MainWindow).People; if (updater.RemoveCopies == true) { instructionsLabel.Content = "You may remove copies from the selected book."; } GetBookLongDetails(); } catch (Exception ex) { errorLabel.Content = ErrorHandler.InnermostExceptionMessage(ex); } }
private void Page_Loaded(object sender, RoutedEventArgs e) { try { errorLabel.Content = ""; books = ((MainWindow)App.Current.MainWindow).Books; people = ((MainWindow)App.Current.MainWindow).People; //Set the author detail box if (builder.AuthorBuilder == null) { //There is already in author, load the text with the info List <PersonBLL> personBLLs = (from x in people where x.ID == builder.Book.AuthorID select x).ToList(); foreach (PersonBLL p in personBLLs) { if (p is AuthorBLL a) { authorDetailTextBox.Text = a.ToString(); } } } else { //A new author will be created at the end of the process, just report their first and last name string output = $"{builder.AuthorBuilder.Author.FirstName} {builder.AuthorBuilder.Author.LastName}"; authorDetailTextBox.Text = output; } //Set the given ISBN givenISBN.Content = builder.Book.ISBN; } catch (Exception ex) { errorLabel.Content = ErrorHandler.InnermostExceptionMessage(ex); } }