private void Button_Click(object sender, RoutedEventArgs e) { SqlConnection connection = Connection.addConnection(); if (connection != null) { SqlCommand command = new SqlCommand(String.Format("SELECT contra FROM usuarios WHERE nombreUsuario = '{0}'", txUsuario.Text), connection); SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { if (txPassword.Text == reader.GetString(0)) { reader.Close(); connection.Close(); MessageBox.Show("Inicio de sesión completo!"); Window alta = new Alta(); alta.Show(); this.Close(); } else { MessageBox.Show("Credenciales invalidas"); } } } else { Window alta = new Alta(); alta.Show(); this.Close(); } }
public int borrarAlumno() { int res; SqlConnection con = Connection.addConnection(); SqlCommand cmd = new SqlCommand(String.Format("DELETE FROM alumno WHERE cu = {0}", this.cu), con); res = cmd.ExecuteNonQuery(); con.Close(); return(res); }
public int modificarAlumno() { SqlConnection con; con = Connection.addConnection(); SqlCommand cmd = new SqlCommand(String.Format("UPDATE alumno SET correo = '{0}' WHERE claveUnica = '{1}';", this.correo, this.cu), con); int res = cmd.ExecuteNonQuery(); con.Close(); return(res); }
public List <Alumno> buscarAlumno() { List <Alumno> list = new List <Alumno>(); SqlConnection con = Connection.addConnection(); SqlCommand cmd = new SqlCommand(String.Format("SELECT * FROM alumno WHERE nombre like '%{0}%';", this.nombre), con); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { list.Add(new Alumno(Int16.Parse(reader["cu"].ToString()), reader["correo"].ToString())); } return(list); }
public int altaAlumno() { int res; SqlConnection con = Connection.addConnection(); SqlCommand cmd = new SqlCommand(String.Format("INSERT INTO alumno VALUES ({0}, '{1}', '{2}', '{3}', {4}, {5})", this.cu, this.nombre, this.sexo, this.correo, this.semestre, this.programa), con); res = cmd.ExecuteNonQuery(); con.Close(); return(res); }