예제 #1
0
        private void bnPendingTransactions_Click(object sender, EventArgs e)
        {
            // XXX List Pending Transactions button event handl

            while (true)
            {
                try
                {  // to capture an exception from SelectedIndex/SelectedItem of listPendingTransactionsDialog
                    listPendingTransactionsDialog.ClearDisplayItems();
                    //listPendingTransactionsDialog.AddDisplayItems(null);  // null is a dummy argument
                    foreach (Transaction tran in BookShopControl.listOfPendingTransactions)
                    {
                        //TODO move into new method
                        listPendingTransactionsDialog.AddDisplayItems(tran.customerName.userName + " : " + tran.ToString());
                    }
                    if (listPendingTransactionsDialog.Display() == DialogReturn.Done)
                    {
                        return;
                    }
                    // select button is pressed

                    while (true)
                    {
                        try
                        {  // to capture an exception from SelectedItem/SelectedTransaction of showPendingTransactionDialog
                            showPendingTransactionDialog.ClearDisplayItems();
                            //showPendingTransactionDialog.AddDisplayItems(null); // null is a dummy argument

                            BookShopControl.listTransactionDetails((SelectDialog)showPendingTransactionDialog, BookShopControl.listOfPendingTransactions[listPendingTransactionsDialog.SelectedIndex]);

                            switch (showPendingTransactionDialog.Display())
                            {
                            case DialogReturn.Approve:      // Transaction Processed
                                // XXX
                                BookShopControl.approveTransaction(BookShopControl.listOfPendingTransactions[listPendingTransactionsDialog.SelectedIndex]);
                                if (BookShopControl.amountOfPendingTransactions <= 0)
                                {
                                    return;
                                }
                                break;

                            case DialogReturn.ReturnBook:     // Return Book
                                // XXX
                                BookShopControl.listOfPendingTransactions[listPendingTransactionsDialog.SelectedIndex].
                                removeSubTransaction(BookShopControl.listOfPendingTransactions[listPendingTransactionsDialog.SelectedIndex].itemsPurchased[showPendingTransactionDialog.SelectedIndex].purchaseBook.isbn, 1);
                                continue;

                            case DialogReturn.Remove:     // Remove transaction
                                // XXX
                                BookShopControl.removeTransactionFromPending(BookShopControl.listOfPendingTransactions[listPendingTransactionsDialog.SelectedIndex]);
                                break;
                            }
                            break; //for "transaction processed"
                        }
                        catch (BookShopException bsex)
                        {
                            MessageBox.Show(this, bsex.ErrorMessage);
                            return;
                        }
                    }
                }
                catch (BookShopException bsex)
                {
                    MessageBox.Show(this, bsex.ErrorMessage);
                    continue;
                }
            }
        }
예제 #2
0
        private void bnPendingTransactions_Click(object sender, EventArgs e)
        {
            // XXX List Pending Transactions button event handl

            while (true)
            {
                try
                {  // to capture an exception from SelectedIndex/SelectedItem of listPendingTransactionsDialog
                    listPendingTransactionsDialog.ClearDisplayItems();
                    controller.ListPendingTransactions(ref listPendingTransactionsDialog);
                    //listPendingTransactionsDialog.AddDisplayItems(null);  // null is a dummy argument
                    if (listPendingTransactionsDialog.Display() == DialogReturn.Done)
                    {
                        return;
                    }
                    // select button is pressed


                    while (true)
                    {
                        try
                        {  // to capture an exception from SelectedItem/SelectedTransaction of showPendingTransactionDialog
                            showPendingTransactionDialog.ClearDisplayItems();
                            controller.PopulatePendingTransaction(ref showPendingTransactionDialog, controller.PendingTransactions[listPendingTransactionsDialog.SelectedIndex]);
                            //showPendingTransactionDialog.AddDisplayItems(null); // null is a dummy argument
                            switch (showPendingTransactionDialog.Display())
                            {
                            case DialogReturn.Approve:      // Transaction Processed
                                // XXX
                                controller.ApproveTransaction(controller.PendingTransactions[listPendingTransactionsDialog.SelectedIndex]);
                                break;

                            case DialogReturn.ReturnBook:     // Return Book
                                // XXX
                                controller.RemoveFromPending(controller.PendingTransactions[listPendingTransactionsDialog.SelectedIndex].Customer,
                                                             controller.PendingTransactions[listPendingTransactionsDialog.SelectedIndex].Cart[showPendingTransactionDialog.SelectedIndex],
                                                             controller.PendingTransactions[listPendingTransactionsDialog.SelectedIndex]);
                                continue;

                            case DialogReturn.Remove:     // Remove transaction
                                // XXX
                                controller.RemovePendingTransaction(controller.PendingTransactions[listPendingTransactionsDialog.SelectedIndex]);

                                break;
                            }
                            break; //for "transaction processed"
                        }
                        catch (BookShopException bsex)
                        {
                            MessageBox.Show(this, bsex.ErrorMessage);
                            continue;
                        }
                    }
                }
                catch (BookShopException bsex)
                {
                    MessageBox.Show(this, bsex.ErrorMessage);
                    continue;
                }
            }
        }
예제 #3
0
        private void bnPendingTransactions_Click(object sender, EventArgs e)
        {
            // XXX List Pending Transactions button event handl

            while (true)
            {
                try
                {                                                                                            // to capture an exception from SelectedIndex/SelectedItem of listPendingTransactionsDialog
                    listPendingTransactionsDialog.ClearDisplayItems();
                    listPendingTransactionsDialog.AddDisplayItems(_attachedControl.PendingOrders.ToArray()); // null is a dummy argument
                    if (listPendingTransactionsDialog.Display() == DialogReturn.Done)
                    {
                        return;
                    }
                    // select button is pressed
                    Transaction selectedTransaction = (Transaction)listPendingTransactionsDialog.SelectedItem;
                    while (true)
                    {
                        try
                        {                                                                                         // to capture an exception from SelectedItem/SelectedTransaction of showPendingTransactionDialog
                            showPendingTransactionDialog.ClearDisplayItems();
                            showPendingTransactionDialog.AddDisplayItems(selectedTransaction.BookList.ToArray()); // null is a dummy argument
                            showPendingTransactionDialog.AddDisplayItems(selectedTransaction.CartTotalArray());
                            switch (showPendingTransactionDialog.Display())
                            {
                            case DialogReturn.Approve:      // Transaction Processed
                                // XXX
                                _attachedControl.ProcessPendingTransaction(listPendingTransactionsDialog.SelectedIndex);
                                break;

                            case DialogReturn.ReturnBook:                                          // Return Book
                                // XXX
                                object selectedObject = showPendingTransactionDialog.SelectedItem; // picked up a string or an OrderItem object
                                if (!(selectedObject is OrderItem))
                                {
                                    MessageBox.Show(this, "an extra line was selected");
                                    continue;
                                }
                                OrderItem targetObject = (OrderItem)selectedObject;
                                _attachedControl.ReturnBook(selectedTransaction.Customer, selectedTransaction, targetObject);
                                continue;

                            case DialogReturn.Remove:     // Remove transaction
                                                          // XXX
                                _attachedControl.PendingOrders.Remove(selectedTransaction);
                                break;
                            }
                            break; //for "transaction processed"
                        }
                        catch (BookShopException bsex)
                        {
                            MessageBox.Show(this, bsex.ErrorMessage);
                            continue;
                        }
                    }
                }
                catch (BookShopException bsex)
                {
                    MessageBox.Show(this, bsex.ErrorMessage);
                    continue;
                }
            }
        }