コード例 #1
0
        public ActionResult Refacciones()
        {
            FilterModels.FilterRefacciones filtro = (FilterModels.FilterRefacciones)Session["Filtro"];
            var ordentrabajo = db.OrdenTrabajo.Include("Cliente").Include("Usuario").Include("Taller").Include("Vin");

            List <OrdenTrabajo> ordenesFiltradas = ordentrabajo.ToList().FindAll(x => x.Fase != 0);

            if (!String.IsNullOrEmpty(filtro.Sucursal))
            {
                ordenesFiltradas = ordenesFiltradas.FindAll(x => x.Taller.Almacen.SucursalId == filtro.Sucursal);
            }
            if (filtro.FechaIni != null)
            {
                ordenesFiltradas = ordenesFiltradas.FindAll(x => x.FechaIni.Date >= filtro.FechaIni.Value.Date);
            }
            if (filtro.FechaFin != null)
            {
                ordenesFiltradas = ordenesFiltradas.FindAll(x => x.FechaIni.Date <= filtro.FechaFin.Value.Date);
            }

            if (filtro.Seleccion.Equals("Taller") && !filtro.Taller.Equals("-999"))
            {
                ordenesFiltradas = ordenesFiltradas.FindAll(x => x.TallerId == filtro.Taller);
            }
            else if (filtro.Seleccion.Equals("Vin") && filtro.Vin != null)
            {
                ordenesFiltradas = ordenesFiltradas.FindAll(x => x.Vin.Clave.Contains(filtro.Vin));
            }

            IEnumerable <ViewModels.ViewRefacciones> odtDetalle = ordenesFiltradas.Join(db.ODTDetalle, o => o.OrdenId, d => d.OrdenId,
                                                                                        (o, d) => new { Orden = o, Detalle = d })
                                                                  .Select(d => new ViewModels.ViewRefacciones()
            {
                Taller              = d.Orden.Taller,
                Folio               = d.Orden.Folio,
                Fecha               = d.Orden.FechaIni,
                Vin                 = d.Orden.Vin.Clave,
                ClaveArticulo       = d.Detalle.Articulo.Clave,
                DescripcionArticulo = d.Detalle.Articulo.Descripcion
            });

            if (filtro.Seleccion.Equals("Parte") && filtro.Parte != null)
            {
                odtDetalle = odtDetalle.Where(x => x.ClaveArticulo.Contains(filtro.Parte));
            }

            return(View(odtDetalle));
        }
コード例 #2
0
        public ActionResult FiltroRefacciones(FilterModels.FilterRefacciones filtro)
        {
            if (ModelState.IsValid)
            {
                Session["Filtro"] = filtro;
                if (!String.IsNullOrEmpty(filtro.Sucursal))
                {
                    Session["Sucursal"] = db.Sucursal.First(x => x.SucursalId == filtro.Sucursal).Descripcion;
                }
                if (filtro.Seleccion.Equals("Taller"))
                {
                    if (!String.IsNullOrEmpty(filtro.Taller) && !filtro.Taller.Equals("-999"))
                    {
                        Session["Taller"] = db.Taller.First(x => x.TallerId == filtro.Taller).Descripcion;
                    }
                }

                return(RedirectToAction("Refacciones"));
            }

            ViewBag.Sucursales = db.Sucursal.ToList();
            return(View(filtro));
        }