private void Acceso_btn_Click(object sender, EventArgs e) { //Acceder a la base de datos int c = 0; //contador de coincidencias. MySqlCommand comando = new MySqlCommand(string.Format("select nom_usuario from usuarios where nom_usuario='" + Nom_usutxt.Text + "' and contraseña='" + Cont_usutxt.Text + "';"), Conexion.conectar()); MySqlDataReader lec = comando.ExecuteReader(); while (lec.Read()) { c++; } if (c == 0) { MessageBox.Show("ASEGURESE DE INTRODUCIR LOS DATOS CORRECTAMENTE", "¡DATOS INCORRECTOS!", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { DateTime f = DateTime.Now; string fechaingreso = f.ToString("yyyy-MM-dd HH:mm:ss"); MessageBox.Show("BIENVENIDO", "ACCESANDO A LA BASE DE DATOS", MessageBoxButtons.OK, MessageBoxIcon.Information); MySqlCommand inser = new MySqlCommand(string.Format("insert into bitacora (usuario,entrada,salida) values('{0}','{1}','{2}');", Nom_usutxt.Text, fechaingreso, "nada"), Conexion.conectar()); inser.ExecuteNonQuery(); Primaria.Menu frm = new Primaria.Menu(); frm.Show(); this.Hide(); } }
private void pictureBox2_Click(object sender, EventArgs e) { Primaria.Menu frm = new Primaria.Menu(); frm.Show(); Close(); }