예제 #1
0
 public void printBookToBookdialog(ListBooksDialog lbd)
 {
     foreach (Book displayBook in listOfBooks)
     {
         lbd.AddDisplayItems(displayBook.ToString());
     }
 }
예제 #2
0
        private void bnListBooks_Click(object sender, EventArgs e)
        {
            // XXX List Books button event handler

            while (true)
            {
                try
                {                                                                         // to capture an exception from SelectedItem/SelectedIndex of listBooksDialog
                    listBooksDialog.ClearDisplayItems();
                    listBooksDialog.AddDisplayItems(_attachedControl.BookList.ToArray()); //null is a dummy argument
                    if (listBooksDialog.Display() == DialogReturn.Done)
                    {
                        return;
                    }
                    // select is pressed
                    Book selectedBook = (Book)listBooksDialog.SelectedItem;
                    _attachedControl.PopulateBookDialog(selectedBook, bookDialog);
                    while (true)
                    {
                        try
                        { // to capture an exception from Price/Stock of bookDialog
                            if (bookDialog.Display() == DialogReturn.Cancel)
                            {
                                break;
                            }
                            // XXX Edit Done is Pressed
                            selectedBook.EditBook(bookDialog.BookTitle, bookDialog.Author, bookDialog.Publisher, bookDialog.ISBN, bookDialog.Date, bookDialog.Price, bookDialog.Stock);
                            break;
                        }
                        catch (BookShopException bsex)
                        {
                            MessageBox.Show(this, bsex.ErrorMessage);
                            continue;
                        }
                    }
                }
                catch (BookShopException bsex)
                {
                    MessageBox.Show(this, bsex.ErrorMessage);
                    continue;
                }
            }
        }
예제 #3
0
        private void bnBook_Click(object sender, EventArgs e)
        {
            // XXX List Books buton is pressed

            while (true)
            {
                try
                {                                                                         // to capture an exception from SelectedItem/SelectedIndex of listBooksDialog
                    listBooksDialog.ClearDisplayItems();
                    listBooksDialog.AddDisplayItems(_attachedControl.BookList.ToArray()); // XXX null is a dummy argument
                    if (listBooksDialog.Display() == DialogReturn.Done)
                    {
                        return;
                    }
                    // select is pressed
                    Book selectedBook = (Book)listBooksDialog.SelectedItem;
                    _attachedControl.PopulateBookDialog(selectedBook, bookInformationDialog);
                    switch (bookInformationDialog.Display())
                    {
                    case DialogReturn.AddToCart:     // Add to Cart
                                                     // XXX
                        _attachedControl.CurrentCustomer.AddBookToCart(selectedBook);
                        continue;

                    case DialogReturn.AddToWishList:     // Add to Wishlist
                        // XXX
                        _attachedControl.CurrentCustomer.AddToWishList(selectedBook);
                        continue;

                    case DialogReturn.Done:     // cancel
                        continue;

                    default: return;
                    }
                }
                catch (BookShopException bsex)
                {
                    MessageBox.Show(this, bsex.ErrorMessage);
                    continue;
                }
            }
        }
예제 #4
0
 public void ListBooks(ref ListBooksDialog lb)
 {
     lb.AddDisplayItems(books.ToArray());
 }