Пример #1
0
 private void FillCustomerListBox()
 {
     lstCustomers.Items.Clear();
     for (int i = 0; i < customers.Count; i++)
     {
         Customer c = customers[i];
         lstCustomers.Items.Add(c.GetDisplayText());
     }
 }
Пример #2
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            frmAddCustomer addCustomerForm = new frmAddCustomer();
            Customer       customer        = addCustomerForm.GetCustomer();

            if (customer != null)
            {
                MessageBox.Show(customer.GetDisplayText("\t"));
                customers.Add(customer);
                CustomerDB.SaveCustomers(customers);
                FillCustomerListBox();
            }
        }
Пример #3
0
        // Step 12
        private void btnDelete_Click(object sender, EventArgs e)
        {
            int i = lstCustomers.SelectedIndex;

            if (i != -1)
            {
                Customer customer = customers[i];
                string   message  = "Are you sure you want to delete "
                                    + customer.GetDisplayText() + "?";
                DialogResult button =
                    MessageBox.Show(message, "Confirm Delete", MessageBoxButtons.YesNo);
                if (button == DialogResult.Yes)
                {
                    customers.Remove(customer);
                    CustomerDB.SaveCustomers(customers);
                    FillCustomerListBox();
                }
            }
        }