예제 #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;
                }
            }
        }
예제 #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(null); //null is a dummy argument

                    BookShopControl.printBookToBookdialog(listBooksDialog);

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

                    while (true)
                    {
                        try
                        { // to capture an exception from Price/Stock of bookDialog
                            if (bookDialog.Display() == DialogReturn.Cancel)
                            {
                                break;
                            }
                            // XXX
                            BookShopControl.updateBookInformationStaff(bookDialog, listBooksDialog);
                            break;
                        }
                        catch (BookShopException bsex)
                        {
                            MessageBox.Show(this, bsex.ErrorMessage);
                            continue;
                        }
                    }
                }
                catch (BookShopException bsex)
                {
                    MessageBox.Show(this, bsex.ErrorMessage);
                    continue;
                }
            }
        }
예제 #3
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(null); //null is a dummy argument
                    controller.ListBooks(ref listBooksDialog);
                    if (listBooksDialog.Display() == DialogReturn.Done)
                    {
                        return;
                    }
                    // select is pressed
                    controller.PopulateBookInfo(ref bookDialog, controller.Books[listBooksDialog.SelectedIndex]);

                    while (true)
                    {
                        try
                        { // to capture an exception from Price/Stock of bookDialog
                            if (bookDialog.Display() == DialogReturn.Cancel)
                            {
                                break;
                            }
                            // XXX
                            controller.EditBookInfo(ref bookDialog, controller.Books[listBooksDialog.SelectedIndex]);
                            break;
                        }
                        catch (BookShopException bsex)
                        {
                            MessageBox.Show(this, bsex.ErrorMessage);
                            continue;
                        }
                    }
                }
                catch (BookShopException bsex)
                {
                    MessageBox.Show(this, bsex.ErrorMessage);
                    continue;
                }
            }
        }
예제 #4
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;
                }
            }
        }
예제 #5
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(null); // XXX null is a dummy argument
                    controller.ListBooks(ref listBooksDialog);
                    if (listBooksDialog.Display() == DialogReturn.Done)
                    {
                        return;
                    }
                    // select is pressed
                    controller.PopulateBookInfo(ref bookInformationDialog, controller.Books[listBooksDialog.SelectedIndex]);

                    switch (bookInformationDialog.Display())
                    {
                    case DialogReturn.AddToCart:     // Add to Cart
                        controller.AddToCart(controller.Books[listBooksDialog.SelectedIndex].ISBN);
                        continue;

                    case DialogReturn.AddToWishList:     // Add to Wishlist
                        controller.AddToWishList(controller.Books[listBooksDialog.SelectedIndex].ISBN);

                        continue;

                    case DialogReturn.Done:     // cancel
                        continue;

                    default: return;
                    }
                }
                catch (BookShopException bsex)
                {
                    MessageBox.Show(this, bsex.ErrorMessage);
                    return;
                }
            }
        }
예제 #6
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;
                }
            }
        }