private void button1_Click(object sender, EventArgs e) { string s = TextBoxesCheck(); if (s != null) { MessageBox.Show(s, "Исправьте ошибки"); } else { ControlFunctions.EditPerson(person, textBoxName.Text, dateTimePickerBirthDate.Value, comboBoxDocType.Text, textBoxDocumentNum.Text, textBoxAdress.Text, comboBoxGender.Text, textBoxInsurance.Text, textBoxPassword.Text, comboBoxBlood.Text, textBoxEducation.Text); saved = true; this.Close(); } }
private void ChangePersonInfo_FormClosing(object sender, FormClosingEventArgs e) { if (!saved) { if (e.CloseReason == CloseReason.UserClosing) { DialogResult result = MessageBox.Show("Сохранить перед выходом?", "Внимание", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning); if (result == DialogResult.Yes) { string s = TextBoxesCheck(); if (s != null) { MessageBox.Show(s, "Исправьте ошибки"); e.Cancel = false; } else { ControlFunctions.EditPerson(person, textBoxName.Text, dateTimePickerBirthDate.Value, comboBoxDocType.Text, textBoxDocumentNum.Text, textBoxAdress.Text, comboBoxGender.Text, textBoxInsurance.Text, textBoxPassword.Text, comboBoxBlood.Text, textBoxEducation.Text); this.Owner.Refresh(); e.Cancel = false; } } else if (result == DialogResult.No) { e.Cancel = false; } else if (result == DialogResult.Cancel) { e.Cancel = true; } else { ; } } else { ; } } if (this.Owner is PatientMenu) { (this.Owner as PatientMenu).ReloadForm(); } else if (this.Owner is DoctorMenu) { (this.Owner as DoctorMenu).ReloadForm(); } else if (this.Owner is PatientDetails) { (this.Owner as PatientDetails).ReloadForm(); } else { (this.Owner as DoctorDetails).ReloadForm(); } }