Exemple #1
0
 private void frmConsultaMovimientos_Load(object sender, EventArgs e)
 {
     cbCuentas.DataSource    = CuentasRepository.ObtenerCuentas().OrderBy(r => r.Descripcion).ToList();
     cbCuentas.DisplayMember = "Descripcion";
     cbCuentas.ValueMember   = "Id";
     dtDesde.Value           = DateTime.Today;
     dtHasta.Value           = DateTime.Today.AddMonths(1);
     ConsultarDatos();
 }
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         db       = null;
         cuentaDB = null;
         subcatdb = null;
         catdb    = null;
     }
     base.Dispose(disposing);
 }
Exemple #3
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());
         }
     }
 }
Exemple #4
0
 public frmEdición()
 {
     InitializeComponent();
     this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
     this.MaximizeBox     = false;
     this.MinimizeBox     = false;
     this.ShowInTaskbar   = false;
     this.SizeGripStyle   = System.Windows.Forms.SizeGripStyle.Hide;
     this.StartPosition   = System.Windows.Forms.FormStartPosition.CenterScreen;
     //dtFecha.MaxDate = Configuration.CurrentDate;
     cbCuentas.Select();
     cbCuentas.DataSource    = CuentasRepository.ObtenerCuentas();
     cbCuentas.DisplayMember = "Descripcion";
     cbCuentas.ValueMember   = "Id";
     cbRubros.DataSource     = RubrosRepository.ObtenerRubros();
     cbRubros.DisplayMember  = "Descripcion";
     cbRubros.ValueMember    = "Id";
     CargarTransacciones();
 }
Exemple #5
0
        private void btnEliminar_Click(object sender, EventArgs e)
        {
            int rowindex = dgvDatos.CurrentCell.RowIndex;
            var id       = (int)dgvDatos.Rows[rowindex].Cells[0].Value;
            var cta      = CuentasRepository.ObtenerCuentaPorId(id);

            if (MessageBox.Show(String.Format("¿Está seguro de que desea eliminar {0}?", cta.Descripcion),
                                "Eliminar Cuenta", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
            {
                try
                {
                    CuentasRepository.Eliminar(cta.Id);
                    ConsultarDatos();
                }
                catch (Exception ex)
                {
                    CustomMessageBox.ShowError(ex.Message);
                }
            }
        }
Exemple #6
0
 private void ConsultarDatos()
 {
     //dgvDatos.DataSource = (from c in CuentasRepository.ObtenerCuentas()
     //                       select new
     //                       {
     //                           c.Id,
     //                           c.Descripcion,
     //                           c.SaldoInicial,
     //                           DescripciónEstado = (c.Estado == 1 ? "Activa" : "Baja"),
     //                           c.Estado
     //                       }).ToSortableBindingList();
     dgvDatos.SetDataSource(from c in CuentasRepository.ObtenerCuentas()
                            select new
     {
         c.Id,
         c.Descripcion,
         c.SaldoInicial,
         DescripciónEstado = (c.Estado == 1 ? "Activa" : "Baja"),
         c.Estado
     });
 }
Exemple #7
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);
                }
            }
        }