Exemple #1
0
        private void DiseaseCorelationViewSource_Filter(object sender, FilterEventArgs e)
        {
            DiseaseCorelation cat = e.Item as DiseaseCorelation;

            if (cat != null)
            {
                e.Accepted =
                    (dbContextDiseaseCorelation.Diseases.Local.First(s => s.Id == cat.DiseaseA)
                     .Name.ToUpper().Contains(DiseaseCorelationsSearchBox.Text.ToUpper())) ||
                    (dbContextDiseaseCorelation.Diseases.Local.First(s => s.Id == cat.DiseaseB)
                     .Name.ToUpper().Contains(DiseaseCorelationsSearchBox.Text.ToUpper()));
            }
        }
Exemple #2
0
        public override ValidationResult Validate(object value, CultureInfo cultureInfo)
        {
            DiseaseCorelation dCor = (value as BindingGroup).Items[0] as DiseaseCorelation;


            if (dCor.DiseaseA == 0)
            {
                return(new ValidationResult(false, "You have to choose one disease A option"));
            }

            if (dCor.DiseaseB == 0)
            {
                return(new ValidationResult(false, "You have to choose one disease B option"));
            }

            if (dCor.CommonCases < 0)
            {
                return(new ValidationResult(false, "Common case value shall be greater or equal 0"));
            }

            if ((dCor.CorelationPower < 0) || (dCor.CorelationPower > 100))
            {
                return(new ValidationResult(false, "Corelation power value shall be in range (0, 100)"));
            }

            if ((dCor.CorelationDirection < -100) || (dCor.CorelationDirection > 100))
            {
                return(new ValidationResult(false, "Corelation direction power value shall be in range (-100, 100)"));
            }

            if (dCor.DiseaseA == dCor.DiseaseB)
            {
                return(new ValidationResult(false, "Diseases A and B cannot be the same"));
            }

            DiseaseDatabaseEntities tempContext = new DiseaseDatabaseEntities();

            if (tempContext.DiseaseCorelations
                .Count(s => (((s.DiseaseA == dCor.DiseaseA) && (s.DiseaseB == dCor.DiseaseB) && (s.Id != dCor.Id)) ||
                             ((s.DiseaseA == dCor.DiseaseB) && (s.DiseaseB == dCor.DiseaseA) && (s.Id != dCor.Id)))) > 0)

            {
                return(new ValidationResult(false, "Disease corelations have to be unique"));
            }

            return(ValidationResult.ValidResult);
        }