private void buttonSave_Click(object sender, EventArgs e) { if (comboBoxCabinet.SelectedIndex >= 0 && comboBoxCorpus.SelectedIndex >= 0 && comboBoxDoctor.SelectedIndex >= 0) { TimeForVisit tfv = ControlFunctions.CreateTimeForVisit(comboBoxDoctor.Text, comboBoxCorpus.Text, comboBoxCabinet.Text, datePicker.Text, timePicker.Text); string result = ControlFunctions.AddTimeForVisit(tfv); if (result != null) { MessageBox.Show(result); } else { this.Close(); } } else { MessageBox.Show("Заполните поля"); } }