예제 #1
0
        private void borrowersBox_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            LibraryPatron borrower = borrowedBox.SelectedItem as LibraryPatron;

            if (borrower != null)
            {
                var confirmResult = MessageBox.Show(
                    string.Format("Are you sure you want to return '{0}', by {1}, from {2}", book.Title, book.Author, borrower.Name),
                    "Confirmation", MessageBoxButtons.YesNo);
                if (confirmResult == DialogResult.Yes && borrower.ReturnBook(book))
                {
                    listener.NotifyReturn();
                    this.Close();
                }
            }
        }
예제 #2
0
        private void returnBookButton_Click(object sender, EventArgs e)
        {
            Book bookToReturn = booksBorrowedList.SelectedItem as Book;

            if (bookToReturn != null)
            {
                var confirmResult = MessageBox.Show(
                    string.Format("Are you sure you want to return book: {0} by {1}", bookToReturn.Title, bookToReturn.Author),
                    "Confirmation",
                    MessageBoxButtons.YesNo);
                if (confirmResult == DialogResult.Yes && patron.ReturnBook(bookToReturn))
                {
                    //  Refresh the list ( = null is the cleanest way to force a refresh )
                    booksBorrowedList.DataSource = null;
                    booksBorrowedList.DataSource = patron.ToList();
                }
            }
        }