private void buttonDelete_Click(object sender, EventArgs e) { if (listBoxCurrentJobs.SelectedItem != null) { string selectedJob = (string)listBoxCurrentJobs.SelectedItem; string result = ControlFunctions.RemoveJobFromDoctor(doctor.Id, selectedJob); if (result != null) { MessageBox.Show(result); } else { RefreshForm(); } } else { MessageBox.Show("Выберите работу"); } }