public ActionResult Edit([Bind(Include = "Id,Nombre,Saldo")] CuentaModel cuentaModel) { if (ModelState.IsValid) { _repository.Actualizar(cuentaModel); return(RedirectToAction("Index")); } return(View(cuentaModel)); }
private void btnEditar_Click(object sender, EventArgs e) { int rowindex = dgvDatos.CurrentCell.RowIndex; var id = (int)dgvDatos.Rows[rowindex].Cells[0].Value; var cta = CuentasRepository.ObtenerCuentaPorId(id); using (var f = new frmEdición(cta)) { if (f.ShowDialog() == DialogResult.OK) { try { CuentasRepository.Actualizar(cta.Id, f.Descripción, f.Estado, f.SaldoInicial); ConsultarDatos(); } catch (Exception ex) { CustomMessageBox.ShowError(ex.Message); } dgvDatos.SetRow(r => Int32.Parse(r.Cells[0].Value.ToString()) == cta.Id); } } }