Ejemplo n.º 1
0
        public ActionResult MantenerPrograma()
        {
            var model = new ProgramaModel();

            try
            {
                using (var service = new ProduccionServiceClient())
                {
                    model.PlanVigente = service.ObtenerPlanVigente();
                }

                if (model.PlanVigente != null && model.PlanVigente.Estado == Constantes.EstadoPlan.Pendiente)
                {
                    using (var service = new ProduccionServiceClient())
                    {
                        model.ProgramasAnteriores = service.ListrarProgramasPorPlan(model.PlanVigente.Id);
                    }

                    if (model.ProgramasAnteriores.Any(p => p.Estado == Constantes.EstadoPrograma.Programado))
                    {
                        var programaVigente =
                            model.ProgramasAnteriores.LastOrDefault(
                                p => p.Estado == Constantes.EstadoOrdenPoduccion.Programado);

                        if (programaVigente != null)
                        {
                            model.Id          = programaVigente.Id;
                            model.Numero      = programaVigente.Numero;
                            model.FechaInicio = programaVigente.FechaInicio;
                            model.FechaFin    = programaVigente.FechaFin;
                            model.CantidadOV  = programaVigente.CantidadOV;
                            model.Estado      = programaVigente.Estado;

                            model.ProgramasAnteriores.Remove(programaVigente);

                            IList <OrdenVenta> ordenesVentaPorPrograma;
                            using (var service = new ProduccionServiceClient())
                            {
                                ordenesVentaPorPrograma = service.ListarOrdenesVentaPorPrograma(model.Id);
                            }
                            if (ordenesVentaPorPrograma.Count > 0)
                            {
                                foreach (var ordenVenta in ordenesVentaPorPrograma)
                                {
                                    model.OrdenesVenta.Add(ordenVenta);
                                }
                            }
                        }
                    }
                    else
                    {
                        using (var service = new ProduccionServiceClient())
                        {
                            model.OrdenesVenta = service.ListarOrdenesVentaPendiente();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LogError(ex);
            }
            return(View(model));
        }
        public ActionResult MantenerPrograma()
        {
            var model = new ProgramaModel();
            try
            {
                using (var service = new ProduccionServiceClient())
                {
                    model.PlanVigente = service.ObtenerPlanVigente();
                }

                if (model.PlanVigente != null && model.PlanVigente.Estado == Constantes.EstadoPlan.Pendiente)
                {
                    using (var service = new ProduccionServiceClient())
                    {
                        model.ProgramasAnteriores = service.ListrarProgramasPorPlan(model.PlanVigente.Id);
                    }

                    if (model.ProgramasAnteriores.Any(p => p.Estado == Constantes.EstadoPrograma.Programado))
                    {
                        var programaVigente =
                            model.ProgramasAnteriores.LastOrDefault(
                                p => p.Estado == Constantes.EstadoOrdenPoduccion.Programado);

                        if (programaVigente != null)
                        {
                            model.Id = programaVigente.Id;
                            model.Numero = programaVigente.Numero;
                            model.FechaInicio = programaVigente.FechaInicio;
                            model.FechaFin = programaVigente.FechaFin;
                            model.CantidadOV = programaVigente.CantidadOV;
                            model.Estado = programaVigente.Estado;

                            model.ProgramasAnteriores.Remove(programaVigente);

                            IList<OrdenVenta> ordenesVentaPorPrograma;
                            using (var service = new ProduccionServiceClient())
                            {
                                ordenesVentaPorPrograma = service.ListarOrdenesVentaPorPrograma(model.Id);
                            }
                            if (ordenesVentaPorPrograma.Count > 0)
                            {
                                foreach (var ordenVenta in ordenesVentaPorPrograma)
                                {
                                    model.OrdenesVenta.Add(ordenVenta);
                                }
                            }
                        }
                    }
                    else
                    {
                        using (var service = new ProduccionServiceClient())
                        {
                            model.OrdenesVenta = service.ListarOrdenesVentaPendiente();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LogError(ex);
            }
            return View(model);
        }
Ejemplo n.º 3
0
        public ActionResult MantenerOrdenProduccion()
        {
            var model = new ProgramacionModel();

            try
            {
                Programa programaVigente;
                using (var service = new ProduccionServiceClient())
                {
                    programaVigente = service.ObtenerProgramaVigente();
                }

                if (programaVigente != null)
                {
                    model.ProgramaVigente = new ProgramaModel
                    {
                        Id          = programaVigente.Id,
                        Numero      = programaVigente.Numero,
                        FechaInicio = programaVigente.FechaInicio,
                        FechaFin    = programaVigente.FechaFin
                    };

                    IList <OrdenVenta> ordenesVenta;
                    using (var service = new ProduccionServiceClient())
                    {
                        ordenesVenta = service.ListarOrdenesVentaPorPrograma(model.ProgramaVigente.Id);
                    }

                    foreach (var item in ordenesVenta)
                    {
                        model.OrdenesVenta.Add(new OrdenVentaModel
                        {
                            Id           = item.Id,
                            Numero       = item.Numero,
                            Cliente      = item.Cliente,
                            FechaEntrega = item.FechaEntrega,
                            Estado       = item.Estado,
                            IdPrograma   = item.IdPrograma
                        });
                    }

                    IList <OrdenProduccion> ordenesProduccion;
                    using (var service = new ProduccionServiceClient())
                    {
                        ordenesProduccion = service.ListarOrdenesProduccionPorPrograma(model.ProgramaVigente.Id);
                    }

                    foreach (var item in ordenesProduccion)
                    {
                        model.OrdenesProduccion.Add(new OrdenProduccionModel
                        {
                            Id                  = item.Id,
                            Numero              = item.Numero,
                            NumeroOrdenVenta    = item.OrdenVenta.Numero,
                            FechaEntrega        = item.OrdenVenta.FechaEntrega,
                            DescripcionProducto = item.OrdenVenta.Producto.Descripcion,
                            Estado              = item.Estado
                        });
                    }
                }
            }
            catch (Exception ex)
            {
                LogError(ex);
            }
            return(View(model));
        }
        public ActionResult MantenerOrdenProduccion()
        {
            var model = new ProgramacionModel();
            try
            {
                Programa programaVigente;
                using (var service = new ProduccionServiceClient())
                {
                    programaVigente = service.ObtenerProgramaVigente();
                }

                if (programaVigente != null)
                {
                    model.ProgramaVigente = new ProgramaModel
                    {
                        Id = programaVigente.Id,
                        Numero = programaVigente.Numero,
                        FechaInicio = programaVigente.FechaInicio,
                        FechaFin = programaVigente.FechaFin
                    };

                    IList<OrdenVenta> ordenesVenta;
                    using (var service = new ProduccionServiceClient())
                    {
                        ordenesVenta = service.ListarOrdenesVentaPorPrograma(model.ProgramaVigente.Id);
                    }

                    foreach (var item in ordenesVenta)
                    {
                        model.OrdenesVenta.Add(new OrdenVentaModel
                        {
                            Id = item.Id,
                            Numero = item.Numero,
                            Cliente = item.Cliente,
                            FechaEntrega = item.FechaEntrega,
                            Estado = item.Estado,
                            IdPrograma = item.IdPrograma
                        });
                    }

                    IList<OrdenProduccion> ordenesProduccion;
                    using (var service = new ProduccionServiceClient())
                    {
                        ordenesProduccion = service.ListarOrdenesProduccionPorPrograma(model.ProgramaVigente.Id);
                    }

                    foreach (var item in ordenesProduccion)
                    {
                        model.OrdenesProduccion.Add(new OrdenProduccionModel
                        {
                            Id = item.Id,
                            Numero = item.Numero,
                            NumeroOrdenVenta = item.OrdenVenta.Numero,
                            FechaEntrega = item.OrdenVenta.FechaEntrega,
                            DescripcionProducto = item.OrdenVenta.Producto.Descripcion,
                            Estado = item.Estado
                        });
                    }
                }
            }
            catch (Exception ex)
            {
                LogError(ex);
            }
            return View(model);
        }