private void ReturnBookButton_Click(object sender, RoutedEventArgs e)
 {
     LoanBookDataProvider.RemoveLoanBook(_currentLoanBook);
     LibraryBookDataProvider.LendReturnLibraryBook(_libraryBook);
     DialogResult = true;
     Close();
 }
Exemple #2
0
        private void LendBookButton_Click(object sender, RoutedEventArgs e)
        {
            if (MemberListBox.SelectedIndex > -1)
            {
                if ((DateTime)ReturnDatePicker.SelectedDate < DateTime.Now)
                {
                    MessageBox.Show("Please select a proper return date");
                }
                else
                {
                    var selectedmember = MemberListBox.SelectedItem as Member;

                    LoanBook loanBook = new LoanBook();
                    loanBook.LB_InventoryNumber = _currentbook.InventoryNumber;
                    loanBook.LB_MemberId        = selectedmember.MemberId;
                    loanBook.LoanDate           = DateTime.Now;
                    loanBook.ReturnDate         = (DateTime)ReturnDatePicker.SelectedDate;
                    LoanBookDataProvider.CreateLoanBook(loanBook);
                    LibraryBookDataProvider.LendReturnLibraryBook(_currentbook);

                    DialogResult = true;
                    Close();
                }
            }
            else
            {
                MessageBox.Show("Please select a member");
            }
        }
        private void AddNewCopyButton_Click(object sender, RoutedEventArgs e)
        {
            //ugliest code to generate some "random" inventory number
            var         inventorynumber = _currentbook.Title.Substring(0, _currentbook.Title.Length / 2) + _currentbook.ISBN + "_" + (InventoryListBox.Items.Count + 1);
            LibraryBook libraryBook     = new LibraryBook();

            libraryBook.InventoryNumber = inventorynumber;
            libraryBook.LB_BookId       = _currentbook.BookId;
            libraryBook.CurrentlyLoaned = false;
            LibraryBookDataProvider.CreateLibraryBook(libraryBook);
            UpdateLibraryBooks();
        }
        private void RemoveCopyButton_Click(object sender, RoutedEventArgs e)
        {
            var selectedCopy = InventoryListBox.SelectedItem as LibraryBook;

            if (selectedCopy.CurrentlyLoaned)
            {
                MessageBox.Show("Cannot remove a copy that is currently being borrowed");
            }
            else
            {
                LibraryBookDataProvider.RemoveCopy(selectedCopy);
                UpdateLibraryBooks();
            }
        }
 private void UpdateLibraryBooks()
 {
     InventoryListBox.ItemsSource = LibraryBookDataProvider.GetCopiesOfBook(_currentbook.BookId);
 }