private void mostrarDatos() { try { GestorPublishers gp = new GestorPublishers(); DataTable dt = gp.mostrarDatos(); dataGridPublishers.DataSource = dt; } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } }
private void BtnModificar_Click(object sender, EventArgs e) { try { Publishers publi = new Publishers(); publi.Id = textId.Text; publi.Nombre = textNombre.Text; publi.Ciudad = textCiudad.Text; publi.Estado = textEstado.Text; publi.Pais = textPais.Text; GestorPublishers gp = new GestorPublishers(); gp.actualizarDatos(publi); mostrarDatos(); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } }
private void BtnEliminar_Click(object sender, EventArgs e) { try { if (dataGridPublishers.CurrentRow == null) { MessageBox.Show("Seleccione una fila de la grilla"); return; } DataGridViewRow row = dataGridPublishers.CurrentRow; String idPubli = row.Cells[0].Value.ToString(); GestorPublishers gp = new GestorPublishers(); gp.eliminarDatos(idPubli); mostrarDatos(); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); MessageBox.Show("El campo que desea eliminar tiene una relacion con otra tabla, no es posible realizar la operacion"); } }