Esempio n. 1
0
        public ActionResult Download(string reportname, ReportByProductBrandOption search)
        {
            ReportClass rptH = new ReportClass();
            rptH.FileName = ReportPath(reportname);
            var data = searchProduct(search).ToList();
            rptH.SetDataSource(data);
            rptH.SetParameterValue("datefrom", search.FromDate.ToReportFormat());
            rptH.SetParameterValue("dateto", search.ToDate.ToReportFormat());

            Stream stream = rptH.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
            return File(stream, "application/pdf");
        }
Esempio n. 2
0
 public ActionResult ProductByBrand(PagerRequest request, ReportByProductBrandOption search)
 {
     if (!ModelState.IsValid)
     {
         ViewBag.SearchOptions = search;
         return View();
     }
     var prods = searchProduct(search);
     var v = new Pager<ProductByBrandReportViewModel>(request, prods.Count()) { Data = prods.ToList() };
     ViewBag.SearchOptions = search;
     return View(v);
 }
Esempio n. 3
0
        private IEnumerable<ProductByBrandReportViewModel> searchProduct(ReportByProductBrandOption option)
        {
            var dbContext = _productRepo.Context;
            var linq = dbContext.Set<ProductEntity>().Where(p => (!option.FromDate.HasValue || p.CreatedDate >= option.FromDate.Value) &&
                                                     (!option.ToDate.HasValue || p.CreatedDate < option.ToDate.Value))
                 .Join(dbContext.Set<StoreEntity>(), o => o.Store_Id, i => i.Id, (o, i) => new { P = o, S = i })
                 .Join(dbContext.Set<BrandEntity>(), o => o.P.Brand_Id, i => i.Id, (o, i) => new { P = o.P, S = o.S, B = i })
                 .GroupBy(l => new { l.P.Store_Id, l.S.Name, l.P.Brand_Id, BName = l.B.Name });
            return linq.Select(l => new ProductByBrandReportViewModel()
            {
                BrandId = l.Key.Brand_Id,
                BrandName = l.Key.BName,
                StoreId = l.Key.Store_Id,
                StoreName = l.Key.Name,
                Products = l.Count()

            }).OrderByDescending(l=>l.Products);
        }