Exemple #1
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;
                }
            }
        }
Exemple #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
                    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;
                }
            }
        }
        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;
                }
            }
        }