private void motherValidateAndShowError() { if (_entityValidator != null) { _entityValidator.controlCollection = panelMother.Controls; _entityValidator.DataEntity = motherBindingSource.DataSource; _entityValidator.SetErrorProvider(errorProvider1); MotherNameForm.ValidateAndShowError(); MotherAddressForm.ValidateAndShowError(); } if (!MotherAddressForm.IsValid()) { MotherAddressForm.ShowMe(); MotherAddressForm.ValidateAndShowError(); } }
private async void radWizard1_SelectedPageChanging(object sender, SelectedPageChangingEventArgs e) { errorProvider1.Clear(); if (e.SelectedPage == wizardPageFather && e.NextPage == wizardPageMother) { //Leaving father page fatherValidateAndShowError(); if (!_entityValidator.IsValid() || !FatherNameForm.IsValid()) { e.Cancel = true; } } if (e.SelectedPage == wizardPageMother && e.NextPage == wizardPageFamily) { //Leaving mother page motherValidateAndShowError(); if (!_entityValidator.IsValid() || !MotherNameForm.IsValid() || !MotherAddressForm.IsValid()) { e.Cancel = true; } else { setFamilyAddressFromMotherAddress(); } } if (e.SelectedPage == wizardPageFamily && (e.NextPage == wizardPageProgress)) { //Leaving family page familyValidateAndShowError(); if (!_entityValidator.IsValid() || !FamilyAddressFormPrimary.IsValid() || (chkFamilyIsTheyRefugees.Checked && !FamilyAddressFormSecondary.IsValid())) { e.Cancel = true; } else { radWizard1.NextButton.Enabled = false; radWizard1.BackButton.Enabled = false; var family = GetFamily(); var fam = await _familyEditViewModel.Add(family); _result = fam != null ? true : false; if (_result) { if (picFamilyFamilyCardphoto1.Photo != null) { await _familyEditViewModel.SaveImage("api/family/media/page1/" + fam.Id, picFamilyFamilyCardphoto1.Photo); } if (picFamilyFamilyCardPhoto2.Photo != null) { await _familyEditViewModel.SaveImage("api/family/media/page2/" + fam.Id, picFamilyFamilyCardPhoto2.Photo); } if (picFatherPhoto.Photo != null) { await _familyEditViewModel.SaveImage($"api/father/media/photo/{fam.FatherId}", picFatherPhoto.Photo); } if (picFatherDeathCertifi.Photo != null) { await _familyEditViewModel.SaveImage($"api/father/media/death/{fam.FatherId}", picFatherDeathCertifi.Photo); } if (picMotherIDFace.Photo != null) { await _familyEditViewModel.SaveImage($"api/mother/media/idface/{fam.MotherId}", picMotherIDFace.Photo); } if (picMotherIDBack.Photo != null) { await _familyEditViewModel.SaveImage($"api/mother/media/idback/{fam.MotherId}", picMotherIDBack.Photo); } } radWizard1.SelectNextPage(); radWizard1.NextButton.Enabled = true; radWizard1.BackButton.Enabled = true; } } if (e.SelectedPage == wizardCompletionPage1 && e.NextPage == wizardPageProgress) { e.Cancel = true; radWizard1.SelectedPageChanging -= radWizard1_SelectedPageChanging; radWizard1.SelectPreviousPage(); radWizard1.SelectPreviousPage(); radWizard1.SelectedPageChanging += radWizard1_SelectedPageChanging; } if (e.NextPage == wizardCompletionPage1) { lblResult.Text = _result ? Properties.Resources.FamilyCreatedMessage : Properties.Resources.FamilyCreatedErrorMessage; } }