private void ConcreteSymptomDiseaseConnectionViewSource_Filter(object sender, FilterEventArgs e) { ConcreteSymptomDiseaseConnection cat = e.Item as ConcreteSymptomDiseaseConnection; if (cat != null) { dbContextConcreteSymptomDiseaseConnection.Symptoms.Load(); e.Accepted = (dbContextConcreteSymptomDiseaseConnection.Diseases.Local.First(d => d.Id == cat.Disease) .Name.ToUpper().Contains(ConcreteSymptomDiseaseConnectionsSearchBox.Text.ToUpper())) || (dbContextConcreteSymptomDiseaseConnection.Symptoms.Local.First(s => s.Id == cat.Symptom) .Name.ToUpper().Contains(ConcreteSymptomDiseaseConnectionsSearchBox.Text.ToUpper())); } }
public override ValidationResult Validate(object value, CultureInfo cultureInfo) { ConcreteSymptomDiseaseConnection cSDCon = (value as BindingGroup).Items[0] as ConcreteSymptomDiseaseConnection; if (cSDCon.Disease == 0) { return(new ValidationResult(false, "You have to choose one disease option")); } if (cSDCon.Symptom == 0) { return(new ValidationResult(false, "You have to choose one symptom option")); } if (cSDCon.OccurencesNumber < 0) { return(new ValidationResult(false, "Occurence number value shall be greater or equal 0")); } if (cSDCon.YesAnswers < 0) { return(new ValidationResult(false, "Yes answers value shall be greater or equal 0")); } if (cSDCon.ProbablyYesAnswers < 0) { return(new ValidationResult(false, "Probably yes value shall be greater or equal 0")); } if (cSDCon.DontKnowAnswers < 0) { return(new ValidationResult(false, "Don't know value shall be greater or equal 0")); } if (cSDCon.ProbablyNotAnswers < 0) { return(new ValidationResult(false, "Probably not value shall be greater or equal 0")); } if (cSDCon.NotAnswers < 0) { return(new ValidationResult(false, "Not answers value shall be greater or equal 0")); } if ((cSDCon.ProbabilisticEvaluation < 0.0) || (cSDCon.ProbabilisticEvaluation > 1.0)) { return(new ValidationResult(false, "Probabilisic evaluation value shall be in range (0.0, 1.0)")); } DiseaseDatabaseEntities tempContext = new DiseaseDatabaseEntities(); if (tempContext.ConcreteSymptomDiseaseConnections .Count(s => ((s.Disease == cSDCon.Disease) && (s.Id != cSDCon.Id) && (s.Symptom == cSDCon.Symptom))) > 0) { return(new ValidationResult(false, "Disease Symptom connection have to be unique")); } return(ValidationResult.ValidResult); }