public ReturnBorrowEventForm() { _studentRepository = new StudentRepository(); _borrowEventRepository = new BorrowEventRepository(); InitializeComponent(); LoadStudentTextBox(); }
private void RefreshBooksListBox() { _studentRepository = new StudentRepository(); _bookRepository = new BookRepository(); _bookCopyRepository = new BookCopyRepository(); _borrowEventRepository = new BorrowEventRepository(); BooksListBox.Items.Clear(); var studentBooksBorrowed = _borrowEventRepository.GetBorrowEventsByStudent(StudentComboBox.Text).ToList(); var readOnlyBookCopies = _bookCopyRepository.GetAllBookCopies().Where(bookCopy => bookCopy.Status == BookStatus.ReadOnly) .GroupBy(bookCopy => bookCopy.Book.ToString()).ToList(); var readOnlyBooks = new List <Book>(); foreach (var bookCopy in readOnlyBookCopies) { readOnlyBooks.Add(_bookRepository.GetAllBooks().First(book => book.ToString() == bookCopy.Key)); } foreach (var book in _bookRepository.GetAllBooks().OrderBy(book => book.Name).ThenBy(book => book.Publisher.ToString())) { if (studentBooksBorrowed.Any(borrowEvent => borrowEvent.BookCopy.Book.ToString() == book.ToString()) || readOnlyBooks.Contains(book)) { continue; } BooksListBox.Items.Add(book); } }
public AddBorrowEventForm() { _studentRepository = new StudentRepository(); _bookRepository = new BookRepository(); _bookCopyRepository = new BookCopyRepository(); _borrowEventRepository = new BorrowEventRepository(); InitializeComponent(); LoadStudentComboBox(); DateOfRentPicker.MaxDate = DateTime.Now.Date; }
private void RefreshStudentsListBox() { _studentRepository = new StudentRepository(); _borrowEventRepository = new BorrowEventRepository(); StudentsListBox.Items.Clear(); foreach (var student in _studentRepository.GetAllStudents().OrderBy(student => student.LastName).ThenBy(student => student.Name)) { StudentsListBox.Items.Add(student.ToString()); } }
private void RefreshDateOfBorrowTextBox() { _borrowEventRepository = new BorrowEventRepository(); var selected = BooksListBox.SelectedItem.ToString(); var checkedBorrowEvent = _borrowEventRepository.GetAllBorrowEvents().First(borrowEvent => borrowEvent.Student.ToString() == StudentComboBox.Text && borrowEvent.BookCopy.Book.ToString() == selected && borrowEvent.DateOfReturn == null); DateOfRentTextBox.Text = $@"{checkedBorrowEvent.DateOfBorrow :dd MMMM yyyy}"; }
private void RefreshStudentRentInfo() { _borrowEventRepository = new BorrowEventRepository(); DateOfRentTextBox.Text = ""; BooksListBox.Items.Clear(); var studentBorrowEvents = _borrowEventRepository.GetBorrowEventsByStudent(StudentComboBox.Text); foreach (var borrowEvent in studentBorrowEvents) { BooksListBox.Items.Add(borrowEvent.BookCopy.Book); } }
private void RefreshBooksListBox() { _bookCopyRepository = new BookCopyRepository(); _borrowEventRepository = new BorrowEventRepository(); BooksListBox.Items.Clear(); var borrowedBookCopiesByBook = _bookCopyRepository.GetAllBookCopies() .Where(bookCopy => bookCopy.Status == BookStatus.Borrowed) .GroupBy(bookCopy => bookCopy.Book.ToString()); foreach (var bookCopy in borrowedBookCopiesByBook) { BooksListBox.Items.Add(bookCopy.Key); } }
public ViewOverdueBorrowEventsForm() { InitializeComponent(); _borrowEventRepository = new BorrowEventRepository(); LoadOverdueBorrowEventsListBox(); }