Exemplo n.º 1
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (this.listBox1.Items.Count != 0)
     {
         int         iD   = JawelList[JawelList.Count - 1].a_index + 1;
         JawelStruct temp = new JawelStruct();
         temp.a_index = iD;
         JawelList.Add(temp);
         this.listBox1.Items.Clear();
         int num = JawelList.Count <JawelStruct>();
         for (int i = 0; i < num; i++)
         {
             int iD2 = JawelList[i].a_index;
             this.listBox1.Items.Add(iD2);
         }
         if (this.checkBox1.Checked)
         {
             //Mysql Insert
             MySqlConnection mySqlConnection = new MySqlConnection("datasource=" + Host + ";port=3306;username="******";password="******";database=" + Database);
             mySqlConnection.Open();
             MySqlCommand mySqlCommand3 = new MySqlCommand(string.Concat(new object[]
             {
                 "INSERT INTO t_jewel_data (a_index)VALUES('",
                 iD,
                 //"','1",
                 "');"
             }), mySqlConnection);
             mySqlCommand3.ExecuteNonQuery();
             mySqlConnection.Close();
         }
     }
 }
Exemplo n.º 2
0
        private void LoadListBox()
        {
            MySqlConnection mysqlCon = new MySqlConnection("datasource=" + Host + ";port=3306;username="******";password="******";database=" + Database);

            mysqlCon.Open();
            MySqlCommand Command = new MySqlCommand("SELECT * FROM t_jewel_data ORDER BY a_index ASC;", mysqlCon);

            Command.ExecuteNonQuery();
            MySqlDataReader Reader = Command.ExecuteReader();

            while (Reader.Read())
            {
                JawelStruct temp = new JawelStruct();
                temp.a_index = (int)Reader["a_index"];
                temp.a_normal_compose_neednas     = (long)Reader["a_normal_compose_neednas"];
                temp.a_chaos_compose_neednas      = (long)Reader["a_chaos_compose_neednas"];
                temp.a_normal_compose_prob        = (int)Reader["a_normal_compose_prob"];
                temp.a_chaos_compose_prob         = (int)Reader["a_chaos_compose_prob"];
                temp.a_compose_normalToChaos_prob = (int)Reader["a_compose_normalToChaos_prob"];
                temp.a_normal_plus2_prob          = (int)Reader["a_normal_plus2_prob"];
                temp.a_normal_plus3_prob          = (int)Reader["a_normal_plus3_prob"];
                temp.a_chaos_plus2_prob           = (int)Reader["a_chaos_plus2_prob"];
                temp.a_chaos_plus3_prob           = (int)Reader["a_chaos_plus3_prob"];
                temp.a_normal_minus1_prob         = (int)Reader["a_normal_minus1_prob"];
                temp.a_normal_minus2_prob         = (int)Reader["a_normal_minus2_prob"];
                temp.a_normal_minus3_prob         = (int)Reader["a_normal_minus3_prob"];
                temp.a_chaos_minus1_prob          = (int)Reader["a_chaos_minus1_prob"];
                temp.a_chaos_minus2_prob          = (int)Reader["a_chaos_minus2_prob"];
                temp.a_chaos_minus3_prob          = (int)Reader["a_chaos_minus3_prob"];
                JawelList.Add(temp);
            }
            listBox1.Items.Clear();
            int sk = JawelList.Count();

            for (int i = 0; i < sk; i++)
            {
                int ID = JawelList[i].a_index;
                listBox1.Items.Add(ID);
            }
            mysqlCon.Close();
        }