private void btnAddLocation_Click(object sender, EventArgs e) { Location location = new Location(); location.id = int.Parse(tbox_addLocation_id.Text); location.name = tbox_addLocation_name.Text; location.zipCode = tbox_addLocation_zipCode.Text; location.adress = tbox_addLocation_adress.Text; try { DeliveryHolder.locations.Add(location); DeliveryClient.InsertLocation(location); clearTab(tabPageLocation); tbox_addLocation_id.Text = DeliveryHolder.locations.Count == 0 ? "1" : (DeliveryHolder.locations.Count + 1).ToString(); setupRouteCmb(); } catch (Exception) { MessageBox.Show("Failed to add location"); } }