private void btnNuevo_Click(object sender, EventArgs e) { using (var f = new frmEdición((int)cbRubros.SelectedValue)) { if (f.ShowDialog() == DialogResult.OK) { try { var trx = TransaccionesRepository.Insertar(f.Descripción, f.EsDébito, f.Estado, f.IdRubro); cbRubros.SelectedValue = trx.IdRubro; ConsultarDatos(); } catch (Exception ex) { CustomMessageBox.ShowError(ex.Message); } dgvDatos.SetRow(r => r.Cells[1].Value.ToString().ToLower() == f.Descripción.Trim().ToLower()); } } }
private void btnEditar_Click(object sender, EventArgs e) { int rowindex = dgvDatos.CurrentCell.RowIndex; var id = (int)dgvDatos.Rows[rowindex].Cells[0].Value; var trx = TransaccionesRepository.ObtenerTransaccionPorId(id); using (var f = new frmEdición(trx)) { if (f.ShowDialog() == DialogResult.OK) { try { TransaccionesRepository.Actualizar(trx.Id, f.Descripción, f.EsDébito, f.Estado, f.IdRubro); cbRubros.SelectedValue = f.IdRubro; ConsultarDatos(); } catch (Exception ex) { CustomMessageBox.ShowError(ex.Message); } dgvDatos.SetRow(r => Int32.Parse(r.Cells[0].Value.ToString()) == trx.Id); } } }