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