Beispiel #1
0
        private IQueryable <ReportCombinationDto> GetInventoryReportQueryable(ReportInventorySearchModel searchModel)
        {
            IQueryable <ReportCombinationDto> list = null;

            if (searchModel.IsNull())
            {
                list = _reportCombinationService.GetAll().OrderByDescending(r => r.DateCreated);
            }
            else
            {
                var predicate      = PredicateBuilder.True <ReportCombinationDto>();
                var hasOtherFilter = false;

                if (!searchModel.BranchID.IsNull())
                {
                    hasOtherFilter = true;
                    predicate      = predicate.And(p => p.BranchId == searchModel.BranchID);
                }

                if (!searchModel.ProductID.IsNull())
                {
                    hasOtherFilter = true;
                    predicate      = predicate.And(p => p.ProductID == searchModel.ProductID);
                }

                list = _reportCombinationService.GetAll().AsExpandable().Where(predicate).OrderBy(r => r.DateCreated);
            }

            return(list);
        }
Beispiel #2
0
        public virtual ActionResult ExtractReportInventoryReportToExcel(ReportInventorySearchModel searchModel)
        {
            List <ReportCombinationDto> listOfReport = new List <ReportCombinationDto>();

            listOfReport = GetInventoryReportQueryable(searchModel).ToList();

            if (listOfReport.Count > 0)
            {
                return(ReportPerInventoryReportExtract(searchModel, listOfReport));
            }
            else
            {
                return(View(IOBALANCEMVC.ReportManagement.InventorySales.Views.InventoryReport));
            }

            //return View();
        }
Beispiel #3
0
        private System.Web.Mvc.FileResult ReportPerInventoryReportExtract(ReportInventorySearchModel searchModel, List <ReportCombinationDto> listOfReport)
        {
            int rowId = 0;
            int colId = 0;

            var fileNameGenerated = string.Format("{0}{1}", Constants.InventoryReport, ".xlsx");
            var contentType       = "application/vnd.ms-excel";

            //var templateFile = new FileInfo(path);
            //var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(path);

            var package   = new ExcelPackage();
            var workSheet = package.Workbook.Worksheets.Add(Constants.InventoryReport);

            workSheet.Cells["A1"].Value = "Product Name";
            workSheet.Cells["B1"].Value = "(+)";
            workSheet.Cells["C1"].Value = "(-)";
            workSheet.Cells["D1"].Value = "Product QTY";
            workSheet.Cells["E1"].Value = "Remarks";
            workSheet.Cells["F1"].Value = "Branch Name";

            rowId = 2;
            for (int i = 0; i < listOfReport.Count; i++)
            {
                workSheet.Cells["A" + rowId.ToString()].Value = listOfReport[i].ProductFullDisplayWithExtension;
                workSheet.Cells["B" + rowId.ToString()].Value = listOfReport[i].PurchaseOrderQty;
                workSheet.Cells["C" + rowId.ToString()].Value = listOfReport[i].SalesOrderQty;
                workSheet.Cells["D" + rowId.ToString()].Value = listOfReport[i].ProductQty;
                workSheet.Cells["E" + rowId.ToString()].Value = listOfReport[i].Remarks;
                workSheet.Cells["F" + rowId.ToString()].Value = listOfReport[i].BranchName;
                rowId++;
            }


            var memoryStream = new MemoryStream();

            //package.Save();
            package.SaveAs(memoryStream);
            memoryStream.Position = 0;

            return(File(memoryStream, contentType, fileNameGenerated));
        }
Beispiel #4
0
        public virtual ActionResult GetInventoryReport([DataSourceRequest] DataSourceRequest request, ReportInventorySearchModel searchModel)
        {
            IQueryable <ReportCombinationDto> list = null;

            list = GetInventoryReportQueryable(searchModel);
            return(Json(list.ToDataSourceResult(request), JsonRequestBehavior.AllowGet));
        }