Пример #1
0
        private void btnShowRules_Click(object sender, RoutedEventArgs e)
        {
            lstRules.Items.Clear();
            List <string> listProp = new List <string>();

            using (var db = new RulesModelContainer())
            {
                var query = from rule in db.RulesSet
                            orderby rule.Id
                            select rule;

                foreach (var item in query)
                {
                    listProp.Clear();

                    var query2 = from r in db.RulesDefSet
                                 orderby r.Id
                                 where r.RulesId == item.Id
                                 select r;

                    foreach (var item2 in query2)
                    {
                        listProp.Add(ConvertToString(item2.Prop));
                    }
                    lstRules.Items.Add(RebuiltRule(listProp, ConvertToString(item.Result), 'y'));
                }
            }
        }
Пример #2
0
        private void btnBigDelete_Click(object sender, RoutedEventArgs e)
        {
            if (MessageBox.Show("Esta a punto de ELIMINAR todas las reglas de la base de datos, ¿Desea Continuar?", "Eliminar Todo", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
            {
                using (var db = new RulesModelContainer())
                {
                    var query = from myvar in db.RulesSet
                                orderby myvar.Id
                                select myvar;

                    foreach (var item in query)
                    {
                        db.RulesSet.Remove(item);
                    }

                    var query2 = from m in db.RulesDefSet
                                 orderby m.Id
                                 select m;

                    foreach (var item2 in query2)
                    {
                        db.RulesDefSet.Remove(item2);
                    }

                    db.SaveChanges();
                }
            }
        }
Пример #3
0
        private void btnCreateRule_Click(object sender, RoutedEventArgs e)
        {
            if (lstProp3.Items.Count > 0 && txtResult.Text != "")
            {
                using (var db = new RulesModelContainer())
                {
                    if (ConvertToNumber(ReturnToPropAtm(txtResult.Text), NegValue(txtResult.Text)) != 0)
                    {
                        Rules rule = new Rules();
                        rule.Result = ConvertToNumber(ReturnToPropAtm(txtResult.Text), NegValue(txtResult.Text));
                        db.RulesSet.Add(rule);
                        foreach (var item in lstProp3.Items)
                        {
                            RulesDef r = new RulesDef();
                            r.Prop = ConvertToNumber(ReturnToPropAtm(item.ToString()), NegValue(item.ToString()));
                            db.RulesDefSet.Add(r);
                        }

                        db.SaveChanges();
                    }
                    else
                    {
                        MessageBox.Show("La conclusion no es valida");
                    }
                }
            }
            else
            {
                MessageBox.Show("La regla es invalida");
            }
        }
Пример #4
0
        public void ContentLoad()
        {
            using (var db = new RulesModelContainer())
            {
                var query = from myvar in db.DictionarySet
                            orderby myvar.Id
                            select myvar;

                //PropAtm = new ObservableCollection<Dictionary>(query.ToList());
            }
        }
Пример #5
0
 private void btnSave_Click(object sender, RoutedEventArgs e)
 {
     using (var db = new RulesModelContainer())
     {
         foreach (var item in lstProp.Items)
         {
             db.DictionarySet.Add(new Dictionary()
             {
                 PropAtm = item.ToString()
             });
         }
         db.SaveChanges();
     }
 }
Пример #6
0
        private void btnShowActuals_Click(object sender, RoutedEventArgs e)
        {
            using (var db = new RulesModelContainer())
            {
                var query = from myvar in db.DictionarySet
                            orderby myvar.Id
                            select myvar;

                lstProp2.Items.Clear();

                foreach (var item in query)
                {
                    lstProp2.Items.Add(item.PropAtm);
                }
            }
        }
Пример #7
0
        private void setRules(RulesClass rule)
        {
            List <string> listProp = new List <string>();
            int           cont     = 0;

            using (var db = new RulesModelContainer())
            {
                var query = from ru in db.RulesSet
                            orderby ru.Id
                            select ru;

                foreach (var item in query)
                {
                    cont++;
                    if (cont == rule.id)
                    {
                        listProp.Clear();

                        var query2 = from r in db.RulesDefSet
                                     orderby r.Id
                                     where r.RulesId == item.Id
                                     select r;

                        foreach (var item2 in query2)
                        {
                            listProp.Add(ConvertToString(item2.Prop));
                        }

                        lstExplanation.Items.Add(RebuiltRule(listProp, ConvertToString(item.Result), 'y'));

                        if (item.Result != rule.list[0])
                        {
                            for (int i = 0; i < listProp.Count; i++)
                            {
                                if (listProp[i] == ConvertToString(rule.list[0]) || listProp[i] == ConvertToString(rule.list[0] * -1))
                                {
                                    listProp.RemoveAt(i);
                                    listProp.Add(ConvertToString(item.Result * -1));
                                }
                            }

                            lstExplanation.Items.Add(RebuiltRule(listProp, ConvertToString(rule.list[0]), 'y'));
                        }
                    }
                }
            }
        }
Пример #8
0
        private int ConvertToInt(string s)
        {
            using (var db = new RulesModelContainer())
            {
                var query = from myvar in db.DictionarySet
                            orderby myvar.Id
                            where myvar.PropAtm == s
                            select myvar;

                foreach (var item in query)
                {
                    return(item.Id);
                }

                return(0);
            }
        }
Пример #9
0
        private string ConvertToString(int p)
        {
            using (var db = new RulesModelContainer())
            {
                var query = from myvar in db.DictionarySet
                            orderby myvar.Id
                            where myvar.Id == Math.Abs(p)
                            select myvar;

                foreach (var item in query)
                {
                    return((p < 0)? "NO " + item.PropAtm : item.PropAtm);
                }

                return("");
            }
        }
Пример #10
0
        //private void Window_Loaded(object sender, RoutedEventArgs e)
        //{
        //    AutoFill();
        //}

        private void AutoFill()
        {
            cmbPropList.Items.Clear();
            cmbResult.Items.Clear();
            cmbIPropAtm.Items.Clear();

            using (var db = new RulesModelContainer())
            {
                var query = from myvar in db.DictionarySet
                            orderby myvar.Id
                            select myvar;

                foreach (var item in query)
                {
                    cmbPropList.Items.Add(item.PropAtm);
                    cmbResult.Items.Add(item.PropAtm);
                    cmbIPropAtm.Items.Add(item.PropAtm);
                }
            }
        }
Пример #11
0
        public void fillRules()
        {
            using (var db = new RulesModelContainer())
            {
                var query = from myvar in db.RulesSet
                            orderby myvar.Id
                            select myvar;

                foreach (var item in query)
                {
                    List <int> list = new List <int>();
                    list.Clear();

                    foreach (var item2 in item.RulesDef)
                    {
                        item2.Prop = item2.Prop * -1;
                        list.Add(item2.Prop);
                    }

                    list.Add(item.Result);
                    listall.Add(new RulesClass(list, ++ID));
                }
            }
        }
Пример #12
0
        private int ConvertToNumber(string s, bool n)
        {
            using (var db = new RulesModelContainer())
            {
                var query = from myvar in db.DictionarySet
                            orderby myvar.Id
                            where myvar.PropAtm == s
                            select myvar;

                foreach (var item in query)
                {
                    if (n == true)
                    {
                        return(item.Id * (-1));
                    }
                    else
                    {
                        return(item.Id);
                    }
                }

                return(0);
            }
        }