예제 #1
0
        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;
                }
            }
        }