private void personDetailsControl_PersonExistanceCheckNeeded(object sender, PersonExistanceCheckNededEventArgs e)
        {
            if (!IsNewPerson) return;

            Person person = Program.CurrentDataContext.GetPersonByName(e.Person.FirstName, e.Person.Surname);

            if (person == null) return;

            e.FindedPerson = person;
            e.Exists = true;

            if (Conformation.PersonAdding(person.FirstName, person.LastName, this))
            {
                DialogResult = DialogResult.OK;
                Close();
            }
        }
        private void PersonDetailsControl_Validating(object sender, System.ComponentModel.CancelEventArgs e)
        {
            bool firstNameError = String.IsNullOrEmpty(firstNameEdit.EditValue as string);
            bool lastNameError = String.IsNullOrEmpty(lastNameEdit.EditValue as string);
            bool surnameNameError = String.IsNullOrEmpty(surNameEdit.EditValue as string);

            ErrorProvider.SetError(lastNameEdit, lastNameError ? "Необходима ввести отчество" : null, true);
            ErrorProvider.SetError(firstNameEdit, firstNameError ? "Необходима ввести имя" : null, true);
            ErrorProvider.SetError(surNameEdit, surnameNameError ? "Необходима ввести фамилию" : null, true);

            e.Cancel = firstNameError | lastNameError | surnameNameError;

            if (e.Cancel) return;

            var existanceCheck =new PersonExistanceCheckNededEventArgs(
                new Person
                    {
                        FirstName = firstNameEdit.EditValue as string,
                        Surname = surNameEdit.EditValue as string
                    });

            OnPersonExistanceCheckNeeded(existanceCheck);

            ErrorProvider.SetError(firstNameEdit, existanceCheck.Exists ? "Человек с таким именем уже существует." : null, true);
            ErrorProvider.SetError(surNameEdit, existanceCheck.Exists ? "Человек с такой фамилией уже существует." : null, true);

            e.Cancel = existanceCheck.Exists;
        }
 private void OnPersonExistanceCheckNeeded(PersonExistanceCheckNededEventArgs e)
 {
     EventHandler<PersonExistanceCheckNededEventArgs> needed = PersonExistanceCheckNeeded;
     if (needed != null) needed(this, e);
 }