private void locationsDeleteButton_Click(object sender, EventArgs e) { databaseController dbc = new databaseController(); string selectedLocation = locationslistBox.SelectedItem.ToString();//exception needs to be handled selectedLocation = selectedLocation.Trim(); string[] LocationID = selectedLocation.Split('|'); selectedLocation = LocationID[1].Trim(); string postalcode = LocationID[2].Trim(); int id_l = Convert.ToInt32(LocationID[0].Trim()); string name1 = locationsNameTextBox.Text; string postal = postalLocationsTextBox.Text; Locations loc = new Locations(id_l, name1, postal); dbc.DeleteLocations(loc); locationslistBox.Items.Clear(); OutputLocations(); }