예제 #1
0
 public frmEdición(Movimiento movimiento) : this()
 {
     cbCuentas.SelectedValue = movimiento.IdCuenta;
     dtFecha.Value           = movimiento.FechaMovimiento;
     cbRubros.SelectedValue  = TransaccionesRepository.ObtenerTransaccionPorId(movimiento.IdTransaccion).IdRubro;
     CargarTransacciones();
     cbTransacciones.SelectedValue = movimiento.IdTransaccion;
     txtImporte.Text = String.Format("{0:n}", movimiento.Importe);
 }
예제 #2
0
        private void btnEliminar_Click(object sender, EventArgs e)
        {
            int rowindex = dgvDatos.CurrentCell.RowIndex;
            var id       = (int)dgvDatos.Rows[rowindex].Cells[0].Value;
            var trx      = TransaccionesRepository.ObtenerTransaccionPorId(id);

            if (MessageBox.Show(String.Format("¿Está seguro de que desea eliminar {0}?", trx.Descripcion),
                                "Eliminar transacción", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
            {
                try
                {
                    TransaccionesRepository.Eliminar(trx.Id);
                    ConsultarDatos();
                }
                catch (Exception ex)
                {
                    CustomMessageBox.ShowError(ex.Message);
                }
            }
        }
예제 #3
0
        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);
                }
            }
        }