public override ValidationResult Validate(object value, System.Globalization.CultureInfo cultureInfo) { BindingGroup bg = value as BindingGroup; if (bg == null) { return ValidationResult.ValidResult; } if (bg.Items.Count > 0) { Peoples tempValue = (value as BindingGroup).Items[0] as Peoples; try { BaseRepository<Peoples> peoples = new BaseRepository<Peoples>(); var temp = (from peopl in peoples.items where tempValue.inn == peopl.inn select peopl).Count<Peoples>(); if (temp == 1) { peoples.SaveChages(); return ValidationResult.ValidResult; } return new ValidationResult(false, "Найдено совпадение ИНН"); } catch (Exception ex) { return new ValidationResult(false, ex.Message); } } return ValidationResult.ValidResult; }
public override ValidationResult Validate(object value, System.Globalization.CultureInfo cultureInfo) { BindingGroup bg = value as BindingGroup; if (bg == null) { return ValidationResult.ValidResult; } if (bg.Items.Count > 0) { period_in_ATO tempValue = (value as BindingGroup).Items[0] as period_in_ATO; try { BaseRepository<period_in_ATO> periods = new BaseRepository<period_in_ATO>(); var temp = (from period in periods.items where Comparator(period, tempValue) select period).Count<period_in_ATO>(); if (temp == 1) { periods.SaveChages(); return ValidationResult.ValidResult; } return new ValidationResult(false, "Найдено совпадение периодов!!! Проверьте даты..."); } catch (Exception ex) { return new ValidationResult(false, ex.Message); } } return ValidationResult.ValidResult; }
public override ValidationResult Validate(object value, System.Globalization.CultureInfo cultureInfo) { BindingGroup bg = value as BindingGroup; if (bg == null) { return ValidationResult.ValidResult; } if (bg.Items.Count > 0) { UBD_sertificate tempValue = (value as BindingGroup).Items[0] as UBD_sertificate; try { BaseRepository<UBD_sertificate> sertificats = new BaseRepository<UBD_sertificate>(); var temp = (from sertif in sertificats.items where sertif.id_people==tempValue.id_people && sertif.certificate_number==tempValue.certificate_number select sertif).Count<UBD_sertificate>(); if (temp == 1) { sertificats.SaveChages(); return ValidationResult.ValidResult; } return new ValidationResult(false, "Запись о даном удостоверении уже существует!!!"); } catch (Exception ex) { return new ValidationResult(false, ex.Message); } } return ValidationResult.ValidResult; }