Example #1
0
        private void setDiseaseList()
        {
            var   list   = DBAPI.LoadDiseases();
            int   x      = this.Width - 400;
            int   y      = 50;
            Label naming = new Label();

            naming.Text     = "Список болезней:";
            naming.AutoSize = true;
            naming.Location = new System.Drawing.Point(x, y);
            this.Controls.Add(naming);
            y += 30;

            foreach (DiseaseEntity d in list)
            {
                Label  name   = new Label();
                Button delete = new Button();
                delete.Location = new System.Drawing.Point(x - 30, y);
                delete.AutoSize = true;
                delete.Text     = "X";
                delete.Width    = 20;
                delete.Click   += (object sender, EventArgs e) =>
                {
                    DBAPI.DeleteDisease(d);
                    //this.Controls.Remove(delete);

                    clearDiseaseList();
                    setDiseaseList();
                };

                name.Text     = d.Disease;
                name.AutoSize = true;

                name.Click += (object sender, EventArgs e) =>
                {
                    var           matches = DBAPI.LoadMatchesByDisease(d.Id);
                    StringBuilder s       = new StringBuilder();
                    foreach (MatchesEntity m in matches)
                    {
                        s.Append(DBAPI.getSymptomByID(m.Symptoms_id).Symptom + " [" + m.Confidence_measure + " : " + m.Distrust_measure + "]\n");
                    }
                    MessageBox.Show(s.ToString());
                };
                name.Location = new System.Drawing.Point(x, y);
                y            += 30;
                diseases.Add(name);
                diseaseButtons.Add(delete);
                this.Controls.Add(name);
                this.Controls.Add(delete);
            }
        }
Example #2
0
        private bool checkVxojdenie()
        {
            var diseases = DBAPI.LoadDiseases();

            var comps = symptomsComps.GroupBy(k => k.isChecked()).ToList();

            foreach (DiseaseEntity d in diseases)
            {
                var matchesids = DBAPI.LoadMatchesByDisease(d.Id);
                var sympts     = matchesids.Select(k => k.Symptoms_id).ToList();

                int count = 0;

                foreach (SymptomsComp m in comps[0])
                {
                    foreach (MatchesEntity match in matchesids)
                    {
                        if (m.Id == match.Symptoms_id)
                        {
                            count++;
                        }
                    }
                }

                if (comps[0].Count() == count && comps[0].Count() < matchesids.Count)
                {
                    MessageBox.Show("Содержится");
                    System.Console.WriteLine("Содержится");
                    return(false);
                }
                if (comps[0].Count() == count && comps[0].Count() == matchesids.Count)
                {
                    MessageBox.Show("Существует");
                    System.Console.WriteLine("Существует");
                    return(false);
                }
                if (matchesids.Count == count && comps[0].Count() > matchesids.Count && matchesids != null)
                {
                    MessageBox.Show("Содержит");
                    System.Console.WriteLine("Содержит");
                    return(false);
                }
            }

            return(true);
        }
Example #3
0
        private void setTestList()
        {
            int    x = 50, y = 50;
            double dov = 0, nedov = 0;

            Button test = new Button();

            test.Text     = "Узнать";
            test.Location = new System.Drawing.Point(x, y);
            test.Click   += (object sender, EventArgs e) =>
            {
                dov   = 0;
                nedov = 0;
                this.symptoms.Clear();
                this.coefs.Clear();
                foreach (SymptomsComp s in symptomsComps)
                {
                    if (s.isChecked())
                    {
                        this.symptoms.Add(new SymptomEntity(s.Id, s.Checkbox.Text));
                    }
                }
                var diseases = DBAPI.LoadDiseases();
                foreach (DiseaseEntity d in diseases)
                {
                    var matches = DBAPI.LoadMatchesByDisease(d.Id);
                    foreach (MatchesEntity m in matches)
                    {
                        if (this.symptoms.Find(v => v.Id == m.Symptoms_id) != null)
                        {
                            dov   += (m.Confidence_measure * (1 - dov));
                            nedov += (m.Distrust_measure * (1 - nedov));
                        }
                    }
                    this.coefs.Add(d.Disease, (dov - nedov));
                }
                result = new Result(this.coefs);
                //result.Coefs = this.coefs;
                result.Show();
            };
            this.Controls.Add(test);
            y += 40;

            var symptoms = DBAPI.LoadSymptoms();

            foreach (SymptomEntity s in symptoms)
            {
                CheckBox cb = new CheckBox();

                cb.Location = new System.Drawing.Point(x, y);
                //label.Location = new System.Drawing.Point(x + 20, y);
                cb.Text     = s.Symptom;
                cb.AutoSize = true;
                //label.AutoSize = true;

                this.Controls.AddRange(new System.Windows.Forms.Control[] { cb });
                symptomsComps.Add(new SymptomsComp(cb, new TextBox(), new TextBox(), s.Id, new Button()));

                y += 30;
            }
        }