Ejemplo n.º 1
0
        private void bnTransactionHistory_Click(object sender, EventArgs e)
        {
            // XXX Transaction History button handler
            while (true)
            {
                try
                {
                    if (!BookShopControl.isCustomerLoggedIn)
                    {
                        throw new BookShopException("There is no customer logged in.");
                    }
                    if (BookShopControl.LoggedinCustomer.pastTransactions.Count <= 0)
                    {
                        throw new NullReferenceException("There are no past transactions.");
                    }
                    // to capture an exception from SelectedIndex/SelectedItem of listTransactionHistoryDialog
                    listTransactionHistoryDialog.ClearDisplayItems();
                    //listTransactionHistoryDialog.AddDisplayItems(null); // null is a dummy argument

                    foreach (Transaction tran in BookShopControl.LoggedinCustomer.pastTransactions)
                    {
                        listTransactionHistoryDialog.AddDisplayItems(tran.ToString());
                    }
                    if (listTransactionHistoryDialog.Display() == DialogReturn.Done)
                    {
                        return;
                    }
                    // Select is pressed


                    showTransactionDialog.ClearDisplayItems();
                    //showTransactionDialog.AddDisplayItems(null); // null is a dummy argument
                    BookShopControl.showPastCartInformation(showTransactionDialog, BookShopControl.LoggedinCustomer.pastTransactions[listTransactionHistoryDialog.SelectedIndex]);
                    showTransactionDialog.ShowDialog();
                }
                catch (BookShopException bsex)
                {
                    MessageBox.Show(this, bsex.ErrorMessage);
                    return;

                    ;
                }
                catch (NullReferenceException nex)
                {
                    MessageBox.Show(this, nex.Message);
                    return;
                }
            }
        }