private void CargarList()
        {
            lstCategorias.Items.Clear();
            lstMontos.Items.Clear();

            foreach (MontoCategoria elemento in PresupuestoTemporal.getPresupuestosCategorias())
            {
                lstCategorias.Items.Add(elemento.Cat);
                lstMontos.Items.Add(elemento.Monto);
            }
        }
Beispiel #2
0
        public void setPresupuestoCategoriasTest()
        {
            int    Año = 2020;
            string Mes = "Octubre";
            List <MontoCategoria> ListaCategoriasMonto   = new List <MontoCategoria>();
            MontoCategoria        montoCategoriaTemporal = new MontoCategoria(new Categoria(), 0.00M);

            ListaCategoriasMonto.Add(montoCategoriaTemporal);
            Presupuesto UnPresupuesto = new Presupuesto(Año, Mes, new List <MontoCategoria>());

            UnPresupuesto.setPresupuestosCategorias(ListaCategoriasMonto);
            Assert.AreEqual(ListaCategoriasMonto, UnPresupuesto.getPresupuestosCategorias());
        }
 private void CargarListas()
 {
     lstCategorias.Items.Clear();
     lstMontos.Items.Clear();
     PresupuestoAModificar = Repo.GetPresupuestos().Get(PresupuestoAModificar.Id);
     if (cboxPresupuestos.Text != "")
     {
         foreach (MontoCategoria elemento in PresupuestoAModificar.getPresupuestosCategorias())
         {
             lstCategorias.Items.Add(elemento.Cat);
             lstMontos.Items.Add(elemento.Monto);
         }
     }
     else
     {
         MessageBox.Show("Seleccione un presupuesto");
     }
 }
        private void btn_Consultar_Click(object sender, EventArgs e)
        {
            if (comboBox1.Text != "")
            {
                ManagerPresupuesto ManagerP = new ManagerPresupuesto(Repo);
                ManagerGasto       ManagerG = new ManagerGasto(Repo);
                data_Presupuestos.Rows.Clear();
                data_Presupuestos.Columns.Clear();
                data_Presupuestos.Columns.Add("Catgeoria", "Categoria");
                data_Presupuestos.Columns.Add("Planificado", "Planificado");
                data_Presupuestos.Columns.Add("Real", "Real");
                data_Presupuestos.Columns.Add("Diferencia", "Diferencia");
                Presupuesto Encontrado       = ManagerP.BuscarPresupuestosPorFecha(comboBox1.Text);
                decimal     TotalPlanificado = VALOR_POR_DEFECTO;
                decimal     TotalReal        = VALOR_POR_DEFECTO;
                decimal     TotalDiferencia  = VALOR_POR_DEFECTO;
                foreach (var item in Encontrado.getPresupuestosCategorias())
                {
                    List <Gasto> ListaDeGastosParaEsaFecha = ManagerG.ObtenerGastosPorFechaCategoria(item.Cat, comboBox1.Text);
                    string       SumaDeGastos = ManagerG.SumaDeGastosParaFecha(ListaDeGastosParaEsaFecha);
                    decimal      resultado    = RestaRealPlanificado(item.Monto, decimal.Parse(SumaDeGastos));
                    data_Presupuestos.Rows.Add(item.Cat.Nombre, item.Monto, SumaDeGastos, Formato(resultado));

                    TotalPlanificado += Math.Round(item.Monto, MAX_DECIMALES_MONTO);
                    TotalReal        += Math.Round(decimal.Parse(SumaDeGastos), MAX_DECIMALES_MONTO);
                    TotalDiferencia  += Math.Round(resultado);
                }
                data_Presupuestos.RowHeadersVisible = false;
                data_Presupuestos.Rows.Add("Total", TotalPlanificado, TotalReal, Formato(TotalDiferencia));
                ColorNegativo();
            }
            else
            {
                MessageBox.Show("Seleccione un presupuesto");
            }
        }