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(_attachedControl.CustomerList.ToArray()); // null is a dummy argument
                    if (listCustomersDialog.Display() == DialogReturn.Done)
                    {
                        return;
                    }
                    // select button is pressed
                    Customer selectedCustomer = (Customer)listCustomersDialog.SelectedItem;
                    _attachedControl.PopulateCustomerDialog(selectedCustomer, customerDialog);
                    if (customerDialog.Display() == DialogReturn.Cancel)
                    {
                        continue;
                    }
                    // XXX Edit Done button is pressed
                    _attachedControl.EditCustomer(selectedCustomer, customerDialog.FirstName, customerDialog.LastName, customerDialog.UserName, customerDialog.Password, customerDialog.EMailAddress, customerDialog.Address, customerDialog.TelephoneNumber);
                }
                catch (BookShopException bsex)
                {
                    MessageBox.Show(this, bsex.ErrorMessage);
                    continue;
                }
            }
        }
Example #2
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;
                }
            }
        }
 public void ListCustomers(ref ListCustomersDialog lc)
 {
     lc.AddDisplayItems(customers.ToArray());
 }