public static Boolean sqlUpdate(Artista artista) { string sql = "Update artista set nombre = '" + artista.Nombre + "', idGenero = '" + artista.IdGenero + "' where id = '" + artista.Id + "'"; BD bd = Conexion.BD.getInstance(); bd.sqlEjecutar(sql); return true; }
protected void btAgregar_Click(object sender, EventArgs e) { if (validar()) { int idGenero = int.Parse(cbGenero.SelectedValue); Artista artista = new Artista(int.Parse(txId.Text), txNombre.Text, idGenero); if (!DAOArtista.sqlInsert(artista)) { lbMensaje.Text = "Error. No se pudo agregar el artista, porque ya existe"; } else { lbMensaje.Text = "Artista agregado exitosamente"; } } }
public static Artista sqlLeer(Artista artista) { String sql = "Select * from artista where id = '" + artista.Id + "'"; BD bd = Conexion.BD.getInstance(); bd.sqlSelect(sql); DataTable dt = BD.getInstance().sqlSelect(sql); if (dt.Rows.Count == 0) { return null; } artista.Id = int.Parse(dt.Rows[0]["id"].ToString()); artista.Nombre = dt.Rows[0]["nombre"].ToString(); artista.IdGenero = int.Parse(dt.Rows[0]["idGenero"].ToString()); return artista; }
public static Boolean sqlInsert(Artista artista) { String sql = "Insert into artista (id, nombre, idGenero) values ('" + artista.Id + "','" + artista.Nombre + "', '" + artista.IdGenero + "')"; BD bd = Conexion.BD.getInstance(); return bd.sqlEjecutar(sql); }
public static Boolean sqlDelete(Artista artista) { String sql = "Delete from artista where id = '" + artista.Id + "'"; BD bd = Conexion.BD.getInstance(); return bd.sqlEjecutar(sql); }