//Adds a new customer when the 'Add' button is clicked private void btnCustomerAdd_Click(object sender, EventArgs e) { CustomerWindow cw = new CustomerWindow(); cw.ShowDialog(); cmbBoxCustomerType.SelectedIndex = 0; ShowCustomers(Convert.ToString(cmbBoxCustomerType.SelectedIndex)); }
//Edit a selected customer record when the 'Edit' button is clicked private void btnCustomerEdit_Click(object sender, EventArgs e) { string customerRecord = Convert.ToString(listBoxCustomer.SelectedItem); //Reads the selected item from the listbox as a string string[] customerID = customerRecord.Split(' '); //Split the strings into an array of strings, assuming the first array would be the customer's ID //Check is there any customer records in the listbox if (listBoxCustomer.Items.Count != 0) { CustomerWindow cw = new CustomerWindow(acc.AccountType, "Edit", customerID[1]); cw.ShowDialog(); ShowCustomers(Convert.ToString(cmbBoxCustomerType.SelectedIndex)); } else { MessageBox.Show("No Customer Selected !!", "Edit Customer Details", MessageBoxButtons.OK, MessageBoxIcon.Error); } }