Ejemplo n.º 1
0
        public ActionResult Product(ReportFilter filter)
        {
            var model = ProductReport.Get(Employee.BussinessID, filter);

            if (Request.IsAjaxRequest())
            {
                return(Json(new
                {
                    html = RenderPartialViewToString(Views.ProductPartial, model)
                }, JsonRequestBehavior.DenyGet));
            }
            return(View(Views.Product, model));
        }
Ejemplo n.º 2
0
        public ActionResult Product()
        {
            var model = new ProductReport();

            if (Request.IsAjaxRequest())
            {
                return(Json(new
                {
                    html = RenderPartialViewToString(Views.ProductPartial, model)
                }, JsonRequestBehavior.AllowGet));
            }
            return(View(Views.Product, model));
        }
Ejemplo n.º 3
0
        public static ProductReport Get(int bussinessID, ReportFilter filter = null)
        {
            var result = new ProductReport();

            result.Filter = Report.RenderFilter(filter);
            try
            {
                using (var con = Repo.DB.SKtimeManagement)
                {
                    result.Products = con.Query <ProductSaleReport>(Report.ProductSaleQuery(bussinessID, result.Filter)).ToList();
                    result.Warehouses.AddRange(result.Products.GroupBy(i => i.WarehouseID).Select(i => new WarehouseInfo()
                    {
                        ID   = i.Key,
                        Name = i.FirstOrDefault().WarehouseName
                    }));
                }
            }
            catch (Exception e) { }
            return(result);
        }
Ejemplo n.º 4
0
        public ActionResult ProductDownload(ReportFilter filter)
        {
            var result = false;

            try
            {
                var report   = ProductReport.Get(Employee.BussinessID, filter);
                var fileName = String.Format("Revenue_{0}.xls", DateTime.Now.ToString("ddMMyyyyHHmmss"));
                var file     = String.Format("{0}/Content/Download/{1}", SiteConfiguration.ApplicationPath, fileName);
                Functions.CheckDirectory(String.Format("{0}/Content/Download/", SiteConfiguration.ApplicationPath));
                SaveProduct(file, report);
                Session[SessionKey.Download] = fileName;
                result = true;
            }
            catch { }
            return(Json(new
            {
                result = result
            }, JsonRequestBehavior.DenyGet));
        }
Ejemplo n.º 5
0
        private void SaveProduct(string fileName, ProductReport report)
        {
            var workbook = new HSSFWorkbook();

            if (report.Filter.WarehouseID.HasValue)
            {
                SaveProductWarehouse(workbook, report.Products, report.Warehouses.FirstOrDefault(w => w.ID == report.Filter.WarehouseID.Value));
            }
            else
            {
                SaveProductWarehouse(workbook, report.Products);
                foreach (var warehouse in report.Warehouses)
                {
                    SaveProductWarehouse(workbook, report.Products.Where(i => i.WarehouseID == warehouse.ID), warehouse);
                }
            }
            using (var fs = new FileStream(fileName, FileMode.OpenOrCreate, FileAccess.Write))
            {
                workbook.Write(fs);
            }
        }