private void bnTransactionHistory_Click(object sender, EventArgs e) { // XXX Transaction History button handler while (true) { try { // to capture an exception from SelectedIndex/SelectedItem of listTransactionHistoryDialog if (_attachedControl.IsLoggedIn()) { listTransactionHistoryDialog.ClearDisplayItems(); listTransactionHistoryDialog.AddDisplayItems(_attachedControl.CurrentCustomer.OrderHistory.ToArray()); // null is a dummy argument if (listTransactionHistoryDialog.Display() == DialogReturn.Done) { return; } // Select is pressed Transaction selectedTransaction = (Transaction)listTransactionHistoryDialog.SelectedItem; showTransactionDialog.ClearDisplayItems(); showTransactionDialog.AddDisplayItems(selectedTransaction.BookList.ToArray()); // null is a dummy argument showTransactionDialog.AddDisplayItems(selectedTransaction.CartTotalArray()); showTransactionDialog.ShowDialog(); } else { throw new BookShopException("Customer not logged in."); } } catch (BookShopException bsex) { MessageBox.Show(this, bsex.ErrorMessage); } } }
private void bnTransactionHistory_Click(object sender, EventArgs e) { // XXX Transaction History button handler while (true) { try { // to capture an exception from SelectedIndex/SelectedItem of listTransactionHistoryDialog listTransactionHistoryDialog.ClearDisplayItems(); controller.ShowCustomerHistory(ref listTransactionHistoryDialog); //listTransactionHistoryDialog.AddDisplayItems(null); // null is a dummy argument if (listTransactionHistoryDialog.Display() == DialogReturn.Done) { return; } // Select is pressed showTransactionDialog.ClearDisplayItems(); showTransactionDialog.AddDisplayItems(controller.CurrentCustomer.History[listTransactionHistoryDialog.SelectedIndex].Cart.ToArray()); showTransactionDialog.AddDisplayItems("===================================================="); showTransactionDialog.AddDisplayItems("Total Price: $" + controller.CurrentCustomer.History[listTransactionHistoryDialog.SelectedIndex].Price); //showTransactionDialog.AddDisplayItems(null); // null is a dummy argument showTransactionDialog.ShowDialog(); } catch (BookShopException bsex) { MessageBox.Show(this, bsex.ErrorMessage); return; } } }
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; } } }