Пример #1
0
 public void RemoverIngresDetalle(Ingres ingres, IngresDetalle ingresDetalle)
 {
     if (ingres != null && ingresDetalle != null)
     {
         ingres.IngresDetalle.Remove(ingresDetalle);
     }
 }
Пример #2
0
 public void AgregarIngresDetalle(Ingres ingres)
 {
     if (ingres != null)
     {
         var nuevoDetalle = new IngresDetalle();
         ingres.IngresDetalle.Add(nuevoDetalle);
     }
 }
Пример #3
0
        public Resultado GuardarIngres(Ingres ingres)
        {
            var resultado = Validar(ingres);

            if (resultado.Exitoso == false)
            {
                return(resultado);
            }

            CalcularExistenciaIngres(ingres);
            _contexto.SaveChanges();

            resultado.Exitoso = true;
            return(resultado);
        }
Пример #4
0
 public void CalcularExistenciaIngres(Ingres ingres)
 {
     foreach (var detalle in ingres.IngresDetalle)
     {
         var producto = _contexto.Productos.Find(detalle.ProductoId);
         if (producto != null)
         {
             if (ingres.Activo == true)
             {
                 producto.Existencia = producto.Existencia + detalle.Cantidad;
             }
             else
             {
                 producto.Existencia = producto.Existencia - detalle.Cantidad;
             }
         }
     }
 }
Пример #5
0
 public void CalcularFactura(Ingres ingres)
 {
     if (ingres != null)
     {
         double subtotal = 0;
         foreach (var detalle in ingres.IngresDetalle)
         {
             var producto = _contexto.Productos.Find(detalle.ProductoId);
             if (producto != null)
             {
                 detalle.Precio = producto.Precio;
                 detalle.Total  = detalle.Cantidad * producto.Precio;
                 subtotal      += detalle.Total;
             }
         }
         ingres.Total = subtotal;
     }
 }
Пример #6
0
        private Resultado Validar(Ingres ingres)
        {
            var resultado = new Resultado();

            resultado.Exitoso = true;

            if (ingres == null)
            {
                resultado.Mensaje = "Agregue una transaccion para poderla salvar";
                resultado.Exitoso = false;

                return(resultado);
            }

            if (ingres.Id != 0 && ingres.Activo == true)
            {
                resultado.Mensaje = "La transaccion ya fue emitida y no se pueden realizar cambios en ella";
                resultado.Exitoso = false;
            }

            if (ingres.Activo == false)
            {
                resultado.Mensaje = "La transaccion esta anulada no se pueden realizar cambios en ella";
                resultado.Exitoso = false;
            }

            if (ingres.IngresDetalle.Count == 0)
            {
                resultado.Mensaje = "Agregue productos a la factura";
                resultado.Exitoso = false;
            }
            foreach (var detalle in ingres.IngresDetalle)
            {
                if (detalle.ProductoId == 0)
                {
                    resultado.Mensaje = "Seleccione productos validos";
                    resultado.Exitoso = false;
                }
            }

            return(resultado);
        }
Пример #7
0
        public void AgregarIngres()
        {
            var nuevaIngres = new Ingres();

            ListaIngress.Add(nuevaIngres);//REVISAR PORQ NO CONTEXTO
        }