Beispiel #1
0
        public ActionResult CrearOrdenProduccion(string numero)
        {
            var model = new OrdenProduccionModel();

            try
            {
                OrdenVenta ordenVenta;
                using (var service = new ProduccionServiceClient())
                {
                    ordenVenta = service.ObtenerOrdenVentaPorNumero(numero);
                }

                if (ordenVenta == null)
                {
                    throw new Exception("El número (" + numero + ") de Orden de Venta no existe.");
                }

                model.IdOrdenVenta        = ordenVenta.Id;
                model.CantidadOrdenVenta  = ordenVenta.Cantidad;
                model.IdProducto          = ordenVenta.Producto.Id;
                model.DescripcionProducto = ordenVenta.Producto.Descripcion;
                model.FechaEntrega        = ordenVenta.FechaEntrega;
                model.NumeroOrdenVenta    = ordenVenta.Numero;
                model.StockMinimoProducto = ordenVenta.Producto.StockMinimo;
                model.StockProducto       = ordenVenta.Producto.Stock;
                model.CantidadProducto    = model.CantidadOrdenVenta + model.StockMinimoProducto - model.StockProducto;

                List <Material> materiales = null;
                using (var service = new ProduccionServiceClient())
                {
                    materiales = service.ListarMaterialesPorProducto(ordenVenta.Producto.Id);
                }

                foreach (var material in materiales)
                {
                    var materialRequerido = new OrdenProduccionMaterialModel
                    {
                        DescripcionMaterial = material.Descripcion,
                        IdMaterial          = material.Id,
                        Stock       = material.Stock,
                        StockMinimo = material.StockMinimo,
                        Requerido   = material.Cantidad, //Cantidad necesaria para un Producto
                        Reservado   = material.Reservado
                    };

                    model.Materiales.Add(materialRequerido);
                }
            }
            catch (Exception ex)
            {
                LogError(ex);
            }
            return(View("OrdenProduccion", model));
        }
        public ActionResult CrearOrdenProduccion(string numero)
        {
            var model = new OrdenProduccionModel();
            try
            {
                OrdenVenta ordenVenta;
                using (var service = new ProduccionServiceClient())
                {
                    ordenVenta = service.ObtenerOrdenVentaPorNumero(numero);
                }

                if (ordenVenta == null)
                {
                    throw new Exception("El número (" + numero + ") de Orden de Venta no existe.");
                }

                model.IdOrdenVenta = ordenVenta.Id;
                model.CantidadOrdenVenta = ordenVenta.Cantidad;
                model.IdProducto = ordenVenta.Producto.Id;
                model.DescripcionProducto = ordenVenta.Producto.Descripcion;
                model.FechaEntrega = ordenVenta.FechaEntrega;
                model.NumeroOrdenVenta = ordenVenta.Numero;
                model.StockMinimoProducto = ordenVenta.Producto.StockMinimo;
                model.StockProducto = ordenVenta.Producto.Stock;
                model.CantidadProducto = model.CantidadOrdenVenta + model.StockMinimoProducto - model.StockProducto;

                List<Material> materiales = null;
                using (var service = new ProduccionServiceClient())
                {
                    materiales = service.ListarMaterialesPorProducto(ordenVenta.Producto.Id);
                }

                foreach (var material in materiales)
                {
                    var materialRequerido = new OrdenProduccionMaterialModel
                    {
                        DescripcionMaterial = material.Descripcion,
                        IdMaterial = material.Id,
                        Stock = material.Stock,
                        StockMinimo = material.StockMinimo,
                        Requerido = material.Cantidad, //Cantidad necesaria para un Producto
                        Reservado = material.Reservado
                    };

                    model.Materiales.Add(materialRequerido);
                }
            }
            catch (Exception ex)
            {
                LogError(ex);
            }
            return View("OrdenProduccion", model);
        }