Ejemplo n.º 1
0
 public void PopulatePendingTransaction(ref ShowPendingTransactionDialog spt, Transaction t)
 {
     spt.AddDisplayItems(t.Cart.ToArray());
     spt.AddDisplayItems("====================================================");
     spt.AddDisplayItems("Total Price: $" + t.Price);
 }
Ejemplo n.º 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();
                    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;
                }
            }
        }