Example #1
0
        public void mysqlligar(String l3, String l4)
        {
            MySqlConnection connection = new MySqlConnection("datasource=localhost;port=3306;username=root;password=;database=pessoasc#");

            connection.Open();

            if (connection.State == ConnectionState.Open)
            {
                button2.BackColor = Color.Green;

                //string myInsertQuery = "INSERT INTO pessoa (id_pessoa,nome,idade) Values(101, %s,%d)";
                MySqlCommand Command       = new MySqlCommand();
                IEnumerator  EmpEnumerator = myAL.GetEnumerator(); //Getting the Enumerator
                EmpEnumerator.Reset();                             //Position at the Beginning
                int j = 0;
                while (EmpEnumerator.MoveNext())                   //Till not finished do print
                {
                    if (j == numericUpDown1.Value)
                    {
                        Console.WriteLine((Pessoa)EmpEnumerator.Current);
                        Pessoa p = (Pessoa)EmpEnumerator.Current;
                        Command.Parameters.Add("@nome", MySqlDbType.Text).Value   = p.getnome();
                        Command.Parameters.Add("@idade", MySqlDbType.Int32).Value = Convert.ToInt32(p.getage());
                        Command.Parameters.Add("@id", MySqlDbType.Int32).Value    = Convert.ToInt32(p.getid());
                        Command.CommandText = "INSERT INTO pessoa(id_pessoa, nome, idade) Values(@id,@nome,@idade)";
                    }
                    j++;
                }
                // Command.Parameters.Add("@nome", MySqlDbType.Text).Value = textBox1.Text;
                //Command.Parameters.Add("@idade", MySqlDbType.Int32).Value = Convert.ToInt32(textBox2.Text);
                //Command.Parameters.Add("@id", MySqlDbType.Int32).Value=

                // Command.CommandText = "INSERT INTO pessoa(id_pessoa, nome, idade) Values(102,@nome,@idade)";
                Command.Connection = connection;

                //  connection.Open();Convert.ToInt32(textBox2.Text)
                Command.ExecuteNonQuery();
                Command.Connection.Close();
            }
            else
            {
                button2.BackColor = Color.Red;
            }
        }
Example #2
0
        private void numericUpDown1_ValueChanged(object sender, EventArgs e)
        {
            label2.Text = "";
            //numericUpDown1.;
            IEnumerator EmpEnumerator = myAL.GetEnumerator(); //Getting the Enumerator

            EmpEnumerator.Reset();                            //Position at the Beginning
            int j = 0;

            while (EmpEnumerator.MoveNext()) //Till not finished do print
            {
                if (j == numericUpDown1.Value)
                {
                    Console.WriteLine((Pessoa)EmpEnumerator.Current);
                    Pessoa p = (Pessoa)EmpEnumerator.Current;

                    label2.Text = label2.Text + "\n\nNome:" + p.getnome() + "\nAge:" + p.getage() + "\nId:" + p.getid();
                }
                j++;
            }
            //label5

            EmpEnumerator.Reset();
            int count = myAL.Count;

            label5.Text = "";
            j           = 0;                 //Position at the Beginning
            while (EmpEnumerator.MoveNext()) //Till not finished do print
            {
                if (j <= numericUpDown1.Value + 2 && j >= numericUpDown1.Value)
                {
                    Console.WriteLine((Pessoa)EmpEnumerator.Current);
                    Pessoa p = (Pessoa)EmpEnumerator.Current;

                    label5.Text = label5.Text + "\n\nNome:" + p.getnome() + "\nAge:" + p.getage();
                }
                j++;
            }
        }