private void bnEditSelfInfo_Click(object sender, EventArgs e) { // XXX Edit Self Info button event handler BookShopControl.populateCustomerDialog(customerDialog); try { if (BookShopControl.LoggedinCustomer != null) { switch (customerDialog.Display()) { case DialogReturn.Cancel: return; case DialogReturn.Done: BookShopControl.editCurrentCustomer(customerDialog.FirstName, customerDialog.LastName, customerDialog.UserName, customerDialog.Password, customerDialog.EMailAddress, customerDialog.Address, customerDialog.TelephoneNumber); break; default: return; } } else { throw new BookShopException("There is no user logged in."); } } catch (BookShopException bsex) { MessageBox.Show(this, bsex.ErrorMessage); } }
private void bnListCustomers_Click(object sender, EventArgs e) { // XXX List Customers button event handler while (true) { try { // to capture an exception from SelectedIndex/SelectedItem of listCustomersDialog listCustomersDialog.ClearDisplayItems(); //listCustomersDialog.AddDisplayItems(null); // null is a dummy argument foreach (Customer cust in BookShopControl.listOfCustomers) //print all the customers { listCustomersDialog.AddDisplayItems(cust.ToString()); } if (listCustomersDialog.Display() == DialogReturn.Done) { return; } // select button is pressed BookShopControl.updateCustomerDialog(customerDialog, listCustomersDialog); if (customerDialog.Display() == DialogReturn.Cancel) { continue; } // XXX Edit Done button is pressed BookShopControl.editCurrentCustomer(customerDialog.FirstName, customerDialog.LastName, customerDialog.UserName, customerDialog.Password, customerDialog.EMailAddress, customerDialog.Address, customerDialog.TelephoneNumber); } catch (BookShopException bsex) { MessageBox.Show(this, bsex.ErrorMessage); continue; } } }