private void button1_Click(object sender, EventArgs e)
        {
            ManagerPresupuesto manager = new ManagerPresupuesto(Repo);

            if (nmr_Año.Text != "" && cboMes.SelectedIndex != -1)
            {
                Presupuesto PresupuestoGuardar = new Presupuesto();
                try
                {
                    PresupuestoGuardar.Año = int.Parse(nmr_Año.Text);
                    PresupuestoGuardar.Mes = (String)cboMes.SelectedItem;
                    PresupuestoGuardar.setPresupuestosCategorias(PresupuestoTemporal.getPresupuestosCategorias());
                    manager.ValidacionAgregarPresupuesto(PresupuestoGuardar);
                    nmr_Año.Text         = "";
                    cboMes.SelectedIndex = -1;
                    PresupuestoTemporal  = new Presupuesto();
                    manager.CargarCategoriasPresupuesto(PresupuestoTemporal);
                    CargarList();
                }
                catch (ExceptionAñoPresupuesto año)
                {
                    MessageBox.Show("El año tiene que ser entre 2018 - 2030");
                }
                catch (ExceptionPresupuestoRepetido repetido)
                {
                    MessageBox.Show("Presupuesto para año y mes ya ingresado");
                }
            }
            else
            {
                MessageBox.Show("Los campos Año y Mes son obligatorios");
            }
        }
Ejemplo n.º 2
0
        public void CargarListaDondeHuboPresupuestosTest()
        {
            Repositorio        Repositorio      = new Repositorio();
            ManagerPresupuesto Manager          = new ManagerPresupuesto(Repositorio);
            Presupuesto        presupuestoNuevo = new Presupuesto();

            presupuestoNuevo.Año = 2020;
            presupuestoNuevo.Mes = "March";
            Repositorio.AgregarPresupuesto(presupuestoNuevo);
            Manager.CargarCategoriasPresupuesto(presupuestoNuevo);
            List <string> Lista = Manager.CargarListaDondeHuboPresupuestos();

            Assert.AreEqual(1, Lista.Count);
        }
Ejemplo n.º 3
0
        public void ValidacionAgregarPresupuestoTest()
        {
            Repositorio        Repositorio  = new Repositorio();
            ManagerPresupuesto Manager      = new ManagerPresupuesto(Repositorio);
            Categoria          UnaCategoria = new Categoria("Entretenimiento");

            Repositorio.AgregarCategoria(UnaCategoria);
            Presupuesto unPresupuesto = new Presupuesto();

            unPresupuesto.Año = 2018;
            unPresupuesto.Mes = "Julio";
            Manager.ValidacionAgregarPresupuesto(unPresupuesto);
            Manager.CargarCategoriasPresupuesto(unPresupuesto);
            Assert.AreEqual(Repositorio.GetPresupuestos().GetAll()[0].Año, 2018);
        }
Ejemplo n.º 4
0
        public void CargarCategoriasAPresupuestoTest()
        {
            Repositorio        Repositorio = new Repositorio();
            ManagerPresupuesto Manager     = new ManagerPresupuesto(Repositorio);
            Categoria          Categoria1  = new Categoria("Entretenimiento");
            Categoria          Categoria2  = new Categoria("Cine");

            Repositorio.AgregarCategoria(Categoria1);
            Repositorio.AgregarCategoria(Categoria2);
            Presupuesto unPresupuesto = new Presupuesto();

            unPresupuesto.Año = 2020;
            unPresupuesto.Mes = "Ebola";
            Manager.ValidacionAgregarPresupuesto(unPresupuesto);
            Manager.CargarCategoriasPresupuesto(unPresupuesto);
            Assert.AreEqual(unPresupuesto.PresupuestosCategorias[1].Cat.Id, Categoria2.Id);
        }
 private void RegistroPresupuestoUI_Load(object sender, EventArgs e)
 {
     try
     {
         ManagerPresupuesto manager = new ManagerPresupuesto(Repo);
         manager.CargarCategoriasPresupuesto(PresupuestoTemporal);
         CargarList();
     }
     catch (System.Data.Entity.Core.EntityException)
     {
         this.Enabled = false;
         MessageBox.Show("Error: La base de datos no se encuentra disponible");
     }
     catch (System.Data.SqlClient.SqlException)
     {
         this.Enabled = false;
         MessageBox.Show("Error: La base de datos no se encuentra disponible");
     }
 }
Ejemplo n.º 6
0
        public void AgregarUnMontoTest()
        {
            Repositorio        Repositorio = new Repositorio();
            ManagerPresupuesto Manager     = new ManagerPresupuesto(Repositorio);
            Categoria          Categoria1  = new Categoria("Entretenimiento");
            Categoria          Categoria2  = new Categoria("Cine");

            Repositorio.AgregarCategoria(Categoria1);
            Repositorio.AgregarCategoria(Categoria2);
            Presupuesto unPresupuesto = new Presupuesto();

            unPresupuesto.Año = 2020;
            unPresupuesto.Mes = "Febrero";
            Manager.ValidacionAgregarPresupuesto(unPresupuesto);
            Manager.CargarCategoriasPresupuesto(unPresupuesto);
            decimal unMonto = 1200.00M;

            Manager.ValidacionAgregarUnMonto(unPresupuesto, Categoria1, unMonto);
            Assert.AreEqual(unPresupuesto.PresupuestosCategorias[0].Monto, unMonto);
        }