Exemplo n.º 1
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();
                    // XXX null is a dummy argument

                    BookShopControl.printBookToBookdialog(listBooksDialog);

                    //listBooksDialog.AddDisplayItems(BookShopControl.listOfBooks.ToArray().ToString());

                    if (listBooksDialog.Display() == DialogReturn.Done)
                    {
                        return;
                    }
                    // select is pressed

                    BookShopControl.updateBookInformationDialog(bookInformationDialog, listBooksDialog);

                    switch (bookInformationDialog.Display())
                    {
                    case DialogReturn.AddToCart:     // Add to Cart
                        // XXX
                        BookShopControl.addBookToCustomerCart(BookShopControl.listOfBooks[listBooksDialog.SelectedIndex].isbn);
                        continue;

                    case DialogReturn.AddToWishList:     // Add to Wishlist
                        // XXX
                        BookShopControl.addBookToCustomerWishList(BookShopControl.listOfBooks[listBooksDialog.SelectedIndex].isbn);
                        continue;

                    case DialogReturn.Done:     // cancel
                        continue;

                    default:
                        return;
                    }
                }
                catch (BookShopException bsex)
                {
                    MessageBox.Show(this, bsex.ErrorMessage);
                    continue;
                }
            }
        }