Example #1
0
 private void btnNuevo_Click(object sender, EventArgs e)
 {
     using (var f = new frmEdición())
     {
         if (f.ShowDialog() == DialogResult.OK)
         {
             try
             {
                 CuentasRepository.Insertar(f.Descripción, f.Estado, f.SaldoInicial);
                 ConsultarDatos();
             }
             catch (Exception ex)
             {
                 CustomMessageBox.ShowError(ex.Message);
             }
             dgvDatos.SetRow(r => r.Cells[1].Value.ToString().ToLower() == f.Descripción.Trim().ToLower());
         }
     }
 }
Example #2
0
        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);
                }
            }
        }