Example #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            string myConnection = "datasource=localhost;port=3306;username=root;password=bety145";
            MySqlConnection myConn = new MySqlConnection(myConnection);

            try
            {
                myConn.Open();
                string ComandoSelect = "INSERT  INTO videojuego.videojuegos (nombre,compañia,año,genero) VALUES ('" + textBoxNombre.Text + "','" + textBoxCompañia.Text + "','" + textBoxAño.Text + "','" + textBoxGenero.Text + "') ;";
                MySqlCommand guardarcontacto = new MySqlCommand(ComandoSelect, myConn);
                guardarcontacto.ExecuteNonQuery();

                MessageBox.Show("Videojuego Guardado");

                Videojuegos nuevovideojuego = new Videojuegos();
                nuevovideojuego.Visible = true;
                this.Visible = false;

                myConn.Close();
            }
            catch (Exception ex)
            {

                MessageBox.Show(ex.Message);
            }
        }
Example #2
0
        private void bentrar_Click_1(object sender, EventArgs e)
        {
            try
            {

                string myConnection = "datasource=localhost;port=3306;username=root;password=bety145";
                MySqlConnection myConn = new MySqlConnection(myConnection);
                MySqlCommand ComandoSelect = new MySqlCommand("select * from videojuego.Usuarios where Usuario='" + this.textBoxusuario.Text + "' and Contraseña='" + this.textBoxpass.Text + "';", myConn);
                MySqlDataReader myReader;
                myConn.Open();
                myReader = ComandoSelect.ExecuteReader();
                int contador = 0;
                while (myReader.Read())
                {
                    contador = contador + 1;

                }
                if (contador == 1)
                {

                    MessageBox.Show("Bienvenido");
                    textBoxusuario.Enabled = false;
                    textBoxpass.Enabled = false;
                    bentrar.Enabled = false;

                    Videojuegos nuevovideojuego = new Videojuegos();
                    nuevovideojuego.Visible = true;
                    this.Visible = false;
                }
                else if (contador > 1)
                {

                    MessageBox.Show(" Usuario y Contraseña duplicados acceso denegado");
                }
                else MessageBox.Show("usuario y contraseña son incorrectos");

                myConn.Close();
            }
            catch (Exception ex)
            {

                MessageBox.Show(ex.Message);
            }
        }