コード例 #1
0
        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}";
        }
コード例 #2
0
        private void SaveButton_Click(object sender, EventArgs e)
        {
            if (!CheckForErrors())
            {
                return;
            }
            var selected           = BooksListBox.SelectedItem.ToString();
            var checkedBorrowEvent = _borrowEventRepository.GetAllBorrowEvents().First(borrowEvent =>
                                                                                       borrowEvent.Student.ToString() == StudentComboBox.Text &&
                                                                                       borrowEvent.BookCopy.Book.ToString() == selected && borrowEvent.DateOfReturn == null);

            _borrowEventRepository.ReturnBookEvent(checkedBorrowEvent, DateOfReturnPicker.Value);
            LoadStudentTextBox();
            RefreshStudentRentInfo();
        }
コード例 #3
0
        private void LoadCurrentBorrowEventsListBox()
        {
            var currentBorrowEvents = _borrowEventRepository.GetAllBorrowEvents()
                .Where(borrowEvent => borrowEvent.DateOfReturn == null)
                .OrderBy(borrowEvent => borrowEvent.Student.LastName).ThenBy(borrowEvent => borrowEvent.Student.Name)
                .ThenBy(borrowEvent => borrowEvent.BookCopy.Book.ToString())
                .GroupBy(borrowEvent => borrowEvent.Student.ToString()).ToList();
            foreach (var borrowEvent in currentBorrowEvents)
            {
                CurrentBorrowEventsListBox.Items.Add(borrowEvent.Key);
                foreach (var item in borrowEvent)
                {
                    CurrentBorrowEventsListBox.Items.Add(
                        $"\t {item.BookCopy.Book}");
                    CurrentBorrowEventsListBox.Items.Add($"\t\tRented on: {item.DateOfBorrow :dd/MM/yyyy}");
                }

                CurrentBorrowEventsListBox.Items.Add("");
            }
        }