Exemplo n.º 1
0
        private void bnAddCustomer_Click(object sender, EventArgs e)
        {
            try
            {
                customerDialog.ClearDisplayItems();

                //BookShopControl.findDuplicateCustomers(customerDialog.UserName);
                switch (customerDialog.Display())
                {
                case DialogReturn.Cancel:
                    return;

                case DialogReturn.Done:
                    BookShopControl.addNewCustomer(customerDialog.FirstName, customerDialog.LastName, customerDialog.UserName,
                                                   customerDialog.Password, customerDialog.EMailAddress, customerDialog.Address, customerDialog.TelephoneNumber);
                    break;

                default:
                    return;
                }
            }
            catch (BookShopException bsex)
            {
                MessageBox.Show(this, bsex.ErrorMessage);
            }
        }
Exemplo n.º 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
                    controller.ListCustomers(ref listCustomersDialog);
                    if (listCustomersDialog.Display() == DialogReturn.Done)
                    {
                        return;
                    }
                    // select button is pressed
                    controller.PopulateCustomerDialog(ref customerDialog, controller.Customers[listCustomersDialog.SelectedIndex]);


                    if (customerDialog.Display() == DialogReturn.Cancel)
                    {
                        continue;
                    }
                    // XXX Edit Done button is pressed
                    controller.EditCustomerInfo(ref customerDialog, controller.Customers[listCustomersDialog.SelectedIndex]);
                }
                catch (BookShopException bsex)
                {
                    MessageBox.Show(this, bsex.ErrorMessage);
                    continue;
                }
            }
        }
Exemplo n.º 3
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(_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;
                }
            }
        }
Exemplo n.º 4
0
 private void bnAddCustomer_Click(object sender, EventArgs e)
 {
     // XXX Register Button event handler
     customerDialog.ClearDisplayItems();
     if (customerDialog.Display() == DialogReturn.Cancel)
     {
         return;
     }
     // XXX pick up information from customerDialog by calling its properties
     // and register a new customer
     try
     {
         controller.RegisterNewCustomer(customerDialog.FirstName, customerDialog.LastName, customerDialog.UserName, customerDialog.Password, customerDialog.EMailAddress, customerDialog.Address, customerDialog.TelephoneNumber);
     }
     catch (BookShopException bsex)
     {
         MessageBox.Show(this, bsex.ErrorMessage);
     }
 }
Exemplo n.º 5
0
        private void bnAddCustomer_Click(object sender, EventArgs e)
        {
            try
            {
                // throw exception if the customer id is already registered
                // ZTM : Throws exception inside Control
                // XXX Register Button event handler

                customerDialog.ClearDisplayItems();

                switch (customerDialog.Display())
                {
                case DialogReturn.Cancel:
                    return;

                case DialogReturn.Done:
                    _attachedControl.RegisterCustomer(customerDialog.FirstName, customerDialog.LastName, customerDialog.UserName, customerDialog.Password, customerDialog.EMailAddress, customerDialog.Address, customerDialog.TelephoneNumber);
                    break;

                default:
                    return;
                }

                //if (customerDialog.Display() == DialogReturn.Cancel) return;
                //// XXX pick up information from customerDialog by calling its properties
                //// and register a new customer
                //if (customerDialog.Display() == DialogReturn.Done)
                //{
                //    _attachedControl.RegisterCustomer(customerDialog.FirstName, customerDialog.LastName, customerDialog.UserName, customerDialog.Password, customerDialog.EMailAddress, customerDialog.Address, Convert.ToInt32(customerDialog.TelephoneNumber));
                //}
            }
            catch (BookShopException bsex)
            {
                MessageBox.Show(this, bsex.ErrorMessage);
            }
        }
Exemplo n.º 6
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;
                }
            }
        }