Ejemplo n.º 1
0
        public override ValidationResult Validate(object value, CultureInfo cultureInfo)
        {
            Disease disease = (value as BindingGroup).Items[0] as Disease;

            if (disease.Name == null || disease.Name.Length == 0)
            {
                return(new ValidationResult(false, "The name value can't be empty"));
            }
            if (disease.Name != null && disease.Name.Length > 50)
            {
                return(new ValidationResult(false, "Disease name is too long. Length should be smaller than 50 characters"));
            }
            if (disease.Description != null && disease.Description.Length > 50)
            {
                return(new ValidationResult(false, "Diease description is too long. Length should be smaller than 50 characters"));
            }

            if (disease.OccurencesNumber < 0)
            {
                return(new ValidationResult(false, "Value of occurence number shall be greater or equal 0"));
            }

            DiseaseDatabaseEntities tempContext = new DiseaseDatabaseEntities();

            if (tempContext.Diseases.Count(s => (s.Name == disease.Name) && (s.Id != disease.Id)) > 0)
            {
                return(new ValidationResult(false, "Disease names have to be unique"));
            }

            return(ValidationResult.ValidResult);
        }
Ejemplo n.º 2
0
        public override ValidationResult Validate(object value, CultureInfo cultureInfo)
        {
            SymptomCathegory cathegory = (value as BindingGroup).Items[0] as SymptomCathegory;

            if (cathegory.Name == null || cathegory.Name.Length == 0)
            {
                return(new ValidationResult(false, "The name value can't be empty"));
            }
            if (cathegory.Name != null && cathegory.Name.Length > 50)
            {
                return(new ValidationResult(false, "Cathegory name is too long. Length should be smaller than 50 characters"));
            }
            if (cathegory.ParentCathegory != null && cathegory.ParentCathegory.ToString() == cathegory.Id.ToString())
            {
                return(new ValidationResult(false, "Cathegory can not be 'parent cathegory' for its self"));
            }

            DiseaseDatabaseEntities tempContext = new DiseaseDatabaseEntities();

            if (tempContext.SymptomCathegories.Count(s => (s.Name == cathegory.Name) && (s.Id != cathegory.Id)) > 0)
            {
                return(new ValidationResult(false, "Cathegory names have to be unique"));
            }

            return(ValidationResult.ValidResult);
        }
Ejemplo n.º 3
0
        public override ValidationResult Validate(object value, CultureInfo cultureInfo)
        {
            Symptom symptom = (value as BindingGroup).Items[0] as Symptom;

            if (symptom.Name == null || symptom.Name.Length == 0)
            {
                return(new ValidationResult(false, "The name value can't be empty"));
            }
            if (symptom.Name != null && symptom.Name.Length > 50)
            {
                return(new ValidationResult(false, "Symptom name is too long. Length should be smaller than 50 characters"));
            }
            if (symptom.QuickDescription != null && symptom.QuickDescription.Length > 50)
            {
                return(new ValidationResult(false, "Symptom description is too long. Length should be smaller than 50 characters"));
            }

            if (symptom.GeneralizationDegree < 0 || symptom.GeneralizationDegree > 100)
            {
                return(new ValidationResult(false, "Value of generalization should be in range (0, 100)"));
            }

            DiseaseDatabaseEntities tempContext = new DiseaseDatabaseEntities();

            if (tempContext.Symptoms.Count(s => (s.Name == symptom.Name) && (s.Id != symptom.Id)) > 0)
            {
                return(new ValidationResult(false, "Symptom names have to be unique"));
            }

            return(ValidationResult.ValidResult);
        }
Ejemplo n.º 4
0
 public MainWindow()
 {
     InitializeComponent();
     dbContextSymptomCathegory  = new DiseaseDatabaseEntities();
     dbContextSymptom           = new DiseaseDatabaseEntities();
     dbContextDisease           = new DiseaseDatabaseEntities();
     dbContextDiseaseCorelation = new DiseaseDatabaseEntities();
     dbContextConcreteSymptomDiseaseConnection = new DiseaseDatabaseEntities();
 }
Ejemplo n.º 5
0
        private void CaseComboBox_OnDropDownOpened(object sender, EventArgs e)
        {
            if (!diseaseFlag)
            {
                dbContextDisease.SaveChanges();

                dbContextDiseaseCorelation = new DiseaseDatabaseEntities();
                dbContextDiseaseCorelation.Diseases.Load();
                _diseasesListRemote.Source = dbContextDiseaseCorelation.Diseases.Local;
            }
        }
Ejemplo n.º 6
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);
        }
Ejemplo n.º 7
0
        private void DiseaseRowUpdate(object sender, DataGridRowEditEndingEventArgs e)
        {
            if (DiseaseDataGrid.SelectedItem != null)
            {
                DiseaseDataGrid.RowEditEnding -= DiseaseRowUpdate;
                DiseaseDataGrid.CommitEdit();
                DiseaseDataGrid.RowEditEnding += DiseaseRowUpdate;
            }
            else
            {
                return;
            }

            var result = new DiseaseValidation().Validate(e.Row.BindingGroup, CultureInfo.CurrentCulture);

            if (!result.IsValid)
            {
                DiseasesSearchBox.IsEnabled = false;
                return;
            }

            DiseasesSearchBox.IsEnabled = true;

            dbContextDisease.SaveChanges();

            dbContextDiseaseCorelation = new DiseaseDatabaseEntities();
            dbContextDiseaseCorelation.Diseases.Load();
            dbContextDiseaseCorelation.DiseaseCorelations.Load();
            _diseasesListRemote.Source          = dbContextDiseaseCorelation.Diseases.Local;
            _diseaseCorelationViewSource.Source = dbContextDiseaseCorelation.DiseaseCorelations.Local;
            DiseaseCorelationDataGrid.Items.Refresh();

            dbContextConcreteSymptomDiseaseConnection = new DiseaseDatabaseEntities();
            dbContextConcreteSymptomDiseaseConnection.Diseases.Load();
            dbContextConcreteSymptomDiseaseConnection.ConcreteSymptomDiseaseConnections.Load();
            _concreteDiseasesListRemote.Source = dbContextConcreteSymptomDiseaseConnection.Diseases.Local;
            _concreteSymptomDiseaseConnectionViewSource.Source =
                dbContextConcreteSymptomDiseaseConnection.ConcreteSymptomDiseaseConnections.Local;
            ConcreteSymptomDiseaseConnectionDataGrid.Items.Refresh();

            DiseaseDataGrid.Items.Refresh();
            diseaseFlag = false;
        }
Ejemplo n.º 8
0
        private void SymptomCathegoryRowUpdate(object sender,
                                               DataGridRowEditEndingEventArgs dataGridRowEditEndingEventArgs)
        {
            if (SymptomCathegoriesDataGrid.SelectedItem != null)
            {
                SymptomCathegoriesDataGrid.RowEditEnding -= SymptomCathegoryRowUpdate;
                SymptomCathegoriesDataGrid.CommitEdit();
                SymptomCathegoriesDataGrid.RowEditEnding += SymptomCathegoryRowUpdate;
            }
            else
            {
                return;
            }

            var result = new SymptomCathegoryValidation().Validate(dataGridRowEditEndingEventArgs.Row.BindingGroup,
                                                                   CultureInfo.CurrentCulture);

            if (!result.IsValid)
            {
                SymptomCathegoriesSearchBox.IsEnabled = false;
                return;
            }

            SymptomCathegoriesSearchBox.IsEnabled = true;

            dbContextSymptomCathegory.SaveChanges();

            dbContextSymptom = new DiseaseDatabaseEntities();
            dbContextSymptom.SymptomCathegories.Load();
            dbContextSymptom.Symptoms.Load();
            _symptomCathegoriesListRemote.Source = dbContextSymptom.SymptomCathegories.Local;
            _symptomViewSource.Source            = dbContextSymptom.Symptoms.Local;
            SymptomDataGrid.Items.Refresh();

            SymptomCathegoriesDataGrid.Items.Refresh();


            symptomCathegoryFlag = false;
        }
Ejemplo n.º 9
0
        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);
        }
Ejemplo n.º 10
0
        private void Selector_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if ((!(e.Source is TabControl)) || e.RemovedItems.Count == 0 || e.AddedItems.Count == 0)
            {
//                SymptomDataGrid.
                return;
            }

            if (SymptomsTab.IsSelected)
            {
                if (!symptomCathegoryFlag)
                {
                    dbContextSymptomCathegory.SaveChanges();

                    dbContextSymptom = new DiseaseDatabaseEntities();
                    dbContextSymptom.SymptomCathegories.Load();
                    dbContextSymptom.Symptoms.Load();
                    _symptomCathegoriesListRemote.Source = dbContextSymptom.SymptomCathegories.Local;
                    _symptomViewSource.Source            = dbContextSymptom.Symptoms.Local;
                    SymptomDataGrid.Items.Refresh();
                }
            }
            else if (DiseaseCorelationsTab.IsSelected)
            {
                if (!diseaseFlag)
                {
                    dbContextDisease.SaveChanges();

                    dbContextDiseaseCorelation = new DiseaseDatabaseEntities();
                    dbContextDiseaseCorelation.Diseases.Load();
                    dbContextDiseaseCorelation.DiseaseCorelations.Load();
                    _diseasesListRemote.Source          = dbContextDiseaseCorelation.Diseases.Local;
                    _diseaseCorelationViewSource.Source = dbContextDiseaseCorelation.DiseaseCorelations.Local;
                    DiseaseCorelationDataGrid.Items.Refresh();
                }
            }
            else if (ConcreteSymptomDiseaseConnectionTab.IsSelected)
            {
                if (!symptomFlag)
                {
                    dbContextSymptom.SaveChanges();

                    dbContextConcreteSymptomDiseaseConnection = new DiseaseDatabaseEntities();
                    dbContextConcreteSymptomDiseaseConnection.Symptoms.Load();
                    dbContextConcreteSymptomDiseaseConnection.ConcreteSymptomDiseaseConnections.Load();
                    _concreteSymptomsListRemote.Source = dbContextConcreteSymptomDiseaseConnection.Symptoms.Local;
                    _concreteSymptomDiseaseConnectionViewSource.Source =
                        dbContextConcreteSymptomDiseaseConnection.ConcreteSymptomDiseaseConnections.Local;
                    ConcreteSymptomDiseaseConnectionDataGrid.Items.Refresh();
                }

                if (!diseaseFlag)
                {
                    dbContextDisease.SaveChanges();

                    dbContextConcreteSymptomDiseaseConnection = new DiseaseDatabaseEntities();
                    dbContextConcreteSymptomDiseaseConnection.Diseases.Load();
                    dbContextConcreteSymptomDiseaseConnection.ConcreteSymptomDiseaseConnections.Load();
                    _concreteDiseasesListRemote.Source = dbContextConcreteSymptomDiseaseConnection.Diseases.Local;
                    _concreteSymptomDiseaseConnectionViewSource.Source =
                        dbContextConcreteSymptomDiseaseConnection.ConcreteSymptomDiseaseConnections.Local;
                    ConcreteSymptomDiseaseConnectionDataGrid.Items.Refresh();
                }
            }
        }