private void Form_Closing(Object sender, CancelEventArgs e) { if (this.DialogResult == DialogResult.OK) { string title = (string)_titleComboBox.SelectedItem; if (title == null) { title = _titleComboBox.Text; } string eduRank = (string)_eduRankComboBox.SelectedItem; if (eduRank == null) { eduRank = _eduRankComboBox.Text; } if (_isNew) { if (Teacher.getIsTeacherDataOK(null, _nameTextBox.Text.Trim(), _lastnameTextBox.Text.Trim(), title.Trim(), eduRank.Trim())) { e.Cancel = false; } else { e.Cancel = true; string message1 = RES_MANAGER.GetString("Form_Closing.msb.teacher_not_created.message"); string caption1 = RES_MANAGER.GetString("Form_Closing.msb.teacher_not_created.caption"); MessageBoxButtons buttons1 = MessageBoxButtons.OK; MessageBox.Show(this, message1, caption1, buttons1, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); } } else { if (Teacher.getIsTeacherDataOK(_teacher, _nameTextBox.Text.Trim(), _lastnameTextBox.Text.Trim(), title.Trim(), eduRank.Trim())) { e.Cancel = false; } else { e.Cancel = true; string message2 = RES_MANAGER.GetString("Form_Closing.msb.teacher_data_not_changed.message"); string caption2 = RES_MANAGER.GetString("Form_Closing.msb.teacher_data_not_changed.caption"); MessageBoxButtons buttons2 = MessageBoxButtons.OK; MessageBox.Show(this, message2, caption2, buttons2, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); } } } }