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); } }
public void TestAvailableCopiesOfCheckedOutBook() { //Arrange CheckOutLogBLLCollection logs = CreateCheckOutLogCollection(); BookBLLCollection books = CreateBookCollection(); int availableCopies; //Act availableCopies = logs.AvailableCopies(books[1]); //Assert Assert.AreEqual(1, availableCopies); }
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); } }
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(); }
//Helper Methods CheckOutLogBLLCollection CreateCheckOutLogCollection() { CheckOutLogBLLCollection logs = new CheckOutLogBLLCollection(); Book book1 = new Book() { BookID = 1, Title = "Tom Goes To The Doctor" }; Book book2 = new Book() { BookID = 2, Title = "Mary Goes To The Dentist" }; CheckOutLogBLL l1 = new CheckOutLogBLL() { CheckOutLogID = 1, BookID = 1, CheckOutDate = DateTime.Now, Book = book1 }; CheckOutLogBLL l2 = new CheckOutLogBLL() { CheckOutLogID = 2, BookID = 1, CheckOutDate = DateTime.Now, Book = book1 }; CheckOutLogBLL l3 = new CheckOutLogBLL() { CheckOutLogID = 3, BookID = 2, CheckOutDate = DateTime.Now, Book = book2 }; logs.Add(l1); logs.Add(l2); logs.Add(l3); return(logs); }
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); } }