Example #1
0
        private void bnShowWishlist_Click(object sender, EventArgs e)
        {
            // XXX Show WishList Button event handler

            while (true)
            {
                try
                {
                    // to capture an excepton by SelectedItem/SelectedIndex of wishListDialog
                    wishListDialog.ClearDisplayItems();
                    //wishListDialog.AddDisplayItems(null); // XXX null is a dummy argument

                    if (!BookShopControl.isCustomerLoggedIn)
                    {
                        throw new BookShopException("You are not logged in.");
                    }
                    if (BookShopControl.LoggedinCustomer.howManyItemsOnWishList <= 0)
                    {
                        throw new BookShopException("There are no items on your wishlist.");
                    }

                    BookShopControl.updateWishListDialog(wishListDialog);

                    if (wishListDialog.Display() == DialogReturn.Done)
                    {
                        return;
                    }
                    // select is pressed
                    //XXX
                    BookShopControl.updateWishListDialog(bookInWishListDialog, wishListDialog);

                    switch (bookInWishListDialog.Display())
                    {
                    case DialogReturn.AddToCart:
                        // XXX
                        BookShopControl.addBookToCustomerCart(BookShopControl.LoggedinCustomer.wishList[wishListDialog.SelectedIndex].isbn);
                        continue;

                    case DialogReturn.Remove:
                        // XXX
                        BookShopControl.removeBookFromCustomerWishList(BookShopControl.LoggedinCustomer.wishList[wishListDialog.SelectedIndex].isbn);
                        continue;

                    case DialogReturn.Done:     // Done
                        continue;
                    }
                }
                catch (BookShopException bsex)
                {
                    MessageBox.Show(this, bsex.ErrorMessage);
                    return;
                }
                catch (NullReferenceException nex)
                {
                    //throw new BookShopException("There are no items on your wishlist.");
                    return;
                }
            }
        }
Example #2
0
        private void bnShowWishlist_Click(object sender, EventArgs e)
        {
            // XXX Show WishList Button event handler

            if (!_attachedControl.IsLoggedIn())
            {
                MessageBox.Show("Customer not logged in.");
                return;
            }

            while (true)
            {
                try
                {                                                                                        // to capture an excepton by SelectedItem/SelectedIndex of wishListDialog
                    wishListDialog.ClearDisplayItems();
                    wishListDialog.AddDisplayItems(_attachedControl.CurrentCustomer.WishList.ToArray()); // XXX null is a dummy argument
                    if (wishListDialog.Display() == DialogReturn.Done)
                    {
                        return;
                    }
                    //// select is pressed
                    WishListItem selectedWishListItem = (WishListItem)wishListDialog.SelectedItem;
                    _attachedControl.PopulateBookDialog(selectedWishListItem.AttachedBook, bookInWishListDialog);
                    //XXX
                    switch (bookInWishListDialog.Display())
                    {
                    case DialogReturn.AddToCart:
                        // XXX
                        _attachedControl.CurrentCustomer.AddToCartFromWishList(selectedWishListItem);

                        continue;

                    case DialogReturn.Remove:
                        // XXX
                        _attachedControl.CurrentCustomer.RemoveFromWishList(selectedWishListItem);

                        continue;

                    case DialogReturn.Done:     // Done
                        continue;
                    }
                }
                catch (BookShopException bsex)
                {
                    MessageBox.Show(this, bsex.ErrorMessage);
                    continue;
                }
            }
        }
Example #3
0
        private void bnShowWishlist_Click(object sender, EventArgs e)
        {
            // XXX Show WishList Button event handler

            while (true)
            {
                try
                { // to capture an excepton by SelectedItem/SelectedIndex of wishListDialog
                    wishListDialog.ClearDisplayItems();
                    controller.DisplayWishlist(ref wishListDialog);
                    //wishListDialog.AddDisplayItems(null);  // XXX null is a dummy argument
                    if (wishListDialog.Display() == DialogReturn.Done)
                    {
                        return;
                    }
                    // select is pressed
                    controller.PopulateBookInfo(ref bookInWishListDialog, controller.CurrentCustomer.Wishlist[wishListDialog.SelectedIndex]);

                    switch (bookInWishListDialog.Display())
                    {
                    case DialogReturn.AddToCart:
                        // XXX
                        controller.AddToCart(controller.CurrentCustomer.Wishlist[wishListDialog.SelectedIndex].ISBN);
                        controller.RemoveFromWishlist(controller.CurrentCustomer.Wishlist[wishListDialog.SelectedIndex].ISBN);
                        continue;

                    case DialogReturn.Remove:
                        // XXX
                        controller.RemoveFromWishlist(controller.CurrentCustomer.Wishlist[wishListDialog.SelectedIndex].ISBN);

                        continue;

                    case DialogReturn.Done:     // Done
                        continue;
                    }
                }
                catch (BookShopException bsex)
                {
                    MessageBox.Show(this, bsex.ErrorMessage);
                    return;
                }
            }
        }