protected virtual void ValidateEntity(FormClosingEventArgs e) { IValidate iv = Value as IValidate; if (iv != null) { DatErrorList eList = iv.ValidateErrors(); if (eList != null && eList.Count > 0) { string ErrorsMessage = ""; foreach (DatErrorList.DatError derr in eList) { ErrorsMessage += derr.Description + "\n"; } MessageBox.Show(ErrorsMessage, "Обнаружены ошибки, сохранение невозможно", MessageBoxButtons.OK, MessageBoxIcon.Error); e.Cancel = true; return; } DatErrorList wList = iv.ValidateWarnings(); if (wList != null && wList.Count > 0) { string ErrorsMessage = ""; foreach (DatErrorList.DatError derr in wList) { ErrorsMessage += derr.Description + "\n"; } ErrorsMessage += "\n\nВы по прежнему хотите сохранить запись?\n"; DialogResult r = MessageBox.Show(ErrorsMessage, "Обнаружены замечания", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2); switch (r) { case DialogResult.Abort: case DialogResult.Cancel: case DialogResult.None: case DialogResult.No: e.Cancel = true; return; case DialogResult.OK: case DialogResult.Retry: case DialogResult.Yes: case DialogResult.Ignore: break; default: break; } } } }