コード例 #1
0
 private void listBoxSubmultiplicators_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listBoxSubmultiplicators.SelectedIndex != -1)
     {
         SubMultiplicator s = (SubMultiplicator)listBoxSubmultiplicators.SelectedItem;
         textBoxSub.Text = s.multiplicationValue.ToString();
     }
 }
コード例 #2
0
 public ScoreModuleInfo(int mainMult, string name, LinkedList <string> names, LinkedList <int> values, bool state)
 {
     Active            = state;
     Name              = name;
     MainMultiplicator = mainMult;
     SubMultiplicators = new LinkedList <SubMultiplicator>();
     for (int i = 0; i < Math.Max(names.Count, values.Count); i++)
     {
         SubMultiplicator s = new SubMultiplicator();
         s.name = names.ElementAt(i);
         s.multiplicationValue = values.ElementAt(i);
         SubMultiplicators.AddLast(s);
     }
 }
コード例 #3
0
 private void buttonSetSub_Click(object sender, EventArgs e)
 {
     if (listBoxSubmultiplicators.SelectedIndex != -1)
     {
         SubMultiplicator s = (SubMultiplicator)listBoxSubmultiplicators.SelectedItem;
         try
         {
             int val = Convert.ToInt32(textBoxSub.Text);
             s.multiplicationValue = val;
         }
         catch (Exception)
         {
             MessageBox.Show("Incorrect data");
         }
     }
 }
コード例 #4
0
        public RecommendationsSystem getRecomsSystem()
        {
            LinkedList <ScoreModuleInfo> modules = new LinkedList <ScoreModuleInfo>();

            string     cmdText = "select descriptor, active, multiplicator from RecommendationsModules";
            SqlCommand cmd     = new SqlCommand(cmdText, cnn);

            using (SqlDataReader oReader = cmd.ExecuteReader())
            {
                while (oReader.Read())
                {
                    string desc       = oReader.GetString(0);
                    string activeChar = oReader.GetString(1).ToLower();
                    int    mult       = oReader.GetInt32(2);
                    bool   active     = true;
                    if (activeChar == "n")
                    {
                        active = false;
                    }
                    ScoreModuleInfo module = new ScoreModuleInfo(mult, desc, new LinkedList <string>(), new LinkedList <int>(), active);
                    modules.AddLast(module);
                }
            }

            foreach (ScoreModuleInfo s in modules)
            {
                cmdText = "select descriptor, multpicator from subRecommendators where moduleDescriptor = @mod_name";
                SqlCommand cmd2 = new SqlCommand(cmdText, cnn);
                cmd2.Parameters.AddWithValue("@mod_name", s.Name);
                using (SqlDataReader oReader = cmd2.ExecuteReader())
                {
                    while (oReader.Read())
                    {
                        string           name = oReader.GetString(0);
                        int              val  = oReader.GetInt32(1);
                        SubMultiplicator ss   = new SubMultiplicator();
                        ss.name = name;
                        ss.multiplicationValue = val;
                        s.SubMultiplicators.AddLast(ss);
                    }
                }
            }
            return(new RecommendationsSystem(modules));
        }