void Button1Click(object sender, EventArgs e) { if (verificarAutor()) { string nombre = textBox1.Text; MySqlCommand instruccion = conexion.CreateCommand(); instruccion.CommandText = "SELECT * FROM `autor` WHERE disponible =0 and NYA ='" + nombre + "';"; MySqlDataReader resultado = instruccion.ExecuteReader(); if (!resultado.HasRows) { agregadoSimple(resultado, instruccion, nombre); } else { agregadoLogico(resultado, instruccion); } MessageBox.Show("El autor fue agregado existosamente"); try{ formlis.cargarLista(); } catch { } this.Close(); } }
void eliminarAutor(MySqlCommand instruccion, int idautor) { instruccion.CommandText = "UPDATE `autor` SET disponible = 0 WHERE `idautor` = '" + idautor + "';"; instruccion.ExecuteNonQuery(); MessageBox.Show("El autor fue eliminado exitosamente."); try{ formListado.cargarLista(); } catch { } this.Close(); }
void modificarAutor(MySqlDataReader resultado, MySqlCommand instruccion) { resultado.Read(); int idautor = Convert.ToInt32(resultado["idautor"]); resultado.Close(); instruccion.CommandText = "UPDATE `autor` SET NYA = '" + textBox2.Text + "' where idautor = '" + idautor + "';"; instruccion.ExecuteNonQuery(); MessageBox.Show("El autor fue modificado exitosamente."); try{ formListado.cargarLista(); } catch { } this.Close(); }