public void GenerateAllProductsReportForDate(ProductsReport report) { // dont touch :) var date = report.Date.ToString("dd MMM yyyy"); this.pdfWriter.Value.GenerateReport(report, "All products Report for " + date); }
public void GenerateReport(ProductsReport report, string destinationFolder, string fileName) { var document = this.CreateDocument(fileName); this.DefineStyles(document); var table = this.TableHeader(document, fileName); this.Columns(table); var useName = true; var useDate = true; if (fileName.Contains("Realm")) { useName = true; } if (fileName.Contains("Date")) { useName = false; } if (fileName.Contains("Single")) { useName = false; useDate = false; } this.HeaderRows(table, useName, useDate); this.FillData(report, table, useName, useDate); this.RenderDocument(document, destinationFolder, fileName); }
public void GenerateLocationReportForDate(ProductsReport report) { // dont touch :) var date = report.Date.ToString("dd MMM yyyy"); this.pdfWriter.Value.GenerateReport(report, "All products Report for Realm " + report.Products.First().Location + " at " + date); }
public void GenerateProductInfoForLocations(IEnumerable<ProductsReport> reports) { var reportsAsOne = new ProductsReport { Products = reports.Select( x => new ProductsReportEntry { Location = x.Products.Min( p => p.Location), Name = x.Products.Min( p => p.Name), Price = x.Products.Min( p => p.Price), ProductId = x.Products.Min( p => p.ProductId), Vendor = x.Products.Min( p => p.Vendor), Quantity = x.Products.Sum( p => p.Quantity) }) }; this.pdfWriter.Value.GenerateReport( reportsAsOne, "Single Product " + reportsAsOne.Products.First().Name + " Report by Locations"); }
public void GenerateLocationReportForDate(ProductsReport report) { var date = report.Date.ToString("dd MMM yyyy"); this.pdfWriter.Value.GenerateReport( report, "All products Report for Realm " + report.Products.First().Location + " at " + date); }
public void GenerateProductInfoForLocations(IEnumerable <ProductsReport> reports) { var reportsAsOne = new ProductsReport { Products = reports.Select( x => new ProductsReportEntry { Location = x.Products.Min( p => p.Location), Name = x.Products.Min( p => p.Name), Price = x.Products.Min( p => p.Price), ProductId = x.Products.Min( p => p.ProductId), Vendor = x.Products.Min( p => p.Vendor), Quantity = x.Products.Sum( p => p.Quantity) }) }; this.pdfWriter.Value.GenerateReport( reportsAsOne, "Single Product " + reportsAsOne.Products.First().Name + " Report by Locations"); }
protected void сallbackPanel_Callback(object sender, DevExpress.Web.CallbackEventArgsBase e) { string[] parameters = e.Parameter.Split('|'); string fieldName = parameters[0]; bool isShiftKeyPressed = Boolean.Parse(parameters[1]); ProductsReport.SortBy(fieldName, isShiftKeyPressed); }
protected void dvProducts_Init(object sender, EventArgs e) { ASPxDocumentViewer documentViewer = sender as ASPxDocumentViewer; int categoryID = Int32.Parse(Request.QueryString["CategoryID"]); ProductsReport report = new ProductsReport(); report.Parameters["CategoryID"].Value = categoryID; documentViewer.Report = report; }
public ActionResult Export(ExportModel model) { XtraReport report = new ProductsReport(); string fileName = String.Format("Report.{0}", model.Format); using (MemoryStream ms = new MemoryStream()) { switch (model.Format) { case "pdf": report.ExportToPdf(ms); break; case "docx": report.ExportToDocx(ms); break; case "xls": report.ExportToXls(ms); break; case "xlsx": report.ExportToXlsx(ms); break; case "rtf": report.ExportToRtf(ms); break; case "mht": report.ExportToMht(ms); break; case "html": report.ExportToHtml(ms); break; case "txt": report.ExportToText(ms); break; case "csv": report.ExportToCsv(ms); break; case "png": report.ExportToImage(ms, new ImageExportOptions() { Format = System.Drawing.Imaging.ImageFormat.Png }); break; } return(ExportDocument(ms.ToArray(), model.Format, fileName, false)); } }
public ActionResult Print() { XtraReport report = new ProductsReport(); using (MemoryStream ms = new MemoryStream()) { report.ExportToPdf(ms, new PdfExportOptions() { ShowPrintDialogOnOpen = true }); return(ExportDocument(ms.ToArray(), "pdf", "Report.pdf", true)); } }
private void FillData(ProductsReport productReport, Table table, bool useName, bool useDate) { var productReportEntries = productReport.Products; foreach (var reportRow in productReportEntries) { var row = table.AddRow(); row.Height = "1cm"; row.HeadingFormat = true; row.Format.Alignment = ParagraphAlignment.Center; row.Format.Font.Bold = true; row.Shading.Color = Colors.YellowGreen; row.Cells[0].AddParagraph( useName ? reportRow.Name : useDate ? productReport.Date.ToString("dd-MMM-yyyy") : reportRow.Location); row.Cells[0].Format.Alignment = ParagraphAlignment.Center; row.Cells[0].VerticalAlignment = VerticalAlignment.Center; row.Cells[1].AddParagraph(reportRow.Vendor); row.Cells[1].Format.Alignment = ParagraphAlignment.Center; row.Cells[1].VerticalAlignment = VerticalAlignment.Center; row.Cells[2].AddParagraph(reportRow.Price.ToString()); row.Cells[2].Format.Alignment = ParagraphAlignment.Center; row.Cells[2].VerticalAlignment = VerticalAlignment.Center; row.Cells[3].AddParagraph(reportRow.Quantity.ToString()); row.Cells[3].Format.Alignment = ParagraphAlignment.Center; row.Cells[3].VerticalAlignment = VerticalAlignment.Center; row.Cells[4].AddParagraph(reportRow.Total.ToString()); row.Cells[4].Format.Alignment = ParagraphAlignment.Center; row.Cells[4].VerticalAlignment = VerticalAlignment.Center; } var totalSum = productReportEntries.Sum(x => x.Total); var totalSumRow = table.AddRow(); totalSumRow.Height = "1cm"; totalSumRow.HeadingFormat = true; totalSumRow.Format.Alignment = ParagraphAlignment.Center; totalSumRow.Format.Font.Bold = true; totalSumRow.Shading.Color = Colors.LightGray; totalSumRow.Cells[0].AddParagraph("Total: " + totalSum); totalSumRow.Cells[0].Format.Alignment = ParagraphAlignment.Right; totalSumRow.Cells[0].VerticalAlignment = VerticalAlignment.Center; totalSumRow.Cells[0].MergeRight = 4; }
private static ProductsReportDto Map(ProductsReport report) => report == null ? null : new ProductsReportDto { Id = report.Id, Products = report.Products.Select(p => new ProductRankDto { Rank = p.Rank, Product = new ProductDto { Id = p.Id, Name = p.Name, Vendor = p.Vendor, Price = p.Price, }, TotalSales = p.TotalSales, TotalEarnings = p.TotalEarnings }), CreatedAt = report.CreatedAt };
public async Task AddAsync(ProductsReport report) { await _context.ProductsReports.AddAsync(report); await _context.SaveChangesAsync(); }
public void GenerateTotalLocationReport(ProductsReport report) { this.pdfWriter.Value.GenerateReport( report, "All products Report for Realm " + report.Products.First().Location); }
public void GenerateReport(ProductsReport report, string fileName) { this.GenerateReport(report, PdfSettings.Default.ReportsFolderLocation, fileName); }
public ActionResult CallbackPanelPartial(string fieldName, bool isShiftKeyPressed) { ProductsReport.SortBy(fieldName, isShiftKeyPressed); return(PartialView("_CallbackPanelPartial")); }
public async Task AddAsync(ProductsReport report) { _reports.Add(report); await Task.CompletedTask; }
public IList <ProductsReport> GenerateProductReport(int userId, DateTime dateStart, DateTime dateEnd, out List <MonthReport> monthReport) { var dataSource = _repository.Query( order => order.UserId == userId && order.Removed != true && order.Date >= dateStart.Date && order.Date <= dateEnd.Date) .Include(order => order.Prepayment) .Include(order => order.Items) .ThenInclude(item => item.ProductInfo) .Select( field => new { oId = field.Id, Date = field.Date, Total = field.Total, Items = field.Items, Prepay = field.Prepay, DatePrepay = field.DatePrepay } ) .AsNoTracking() .ToList(); //var data = dataSource // .Select( // field => new // { // ProductId = field.ProductId, // ProductName = field.ProductInfo.Name, // Total = field.Total,// + field.Prepay, // Date = field.Date, // Prepay = field.Prepayment?.Total, // DatePrepay = field.Prepayment?.Date // }); monthReport = dataSource .GroupBy(g => new { Y = g.Date.Year, M = g.Date.Month, Month = $"{g.Date:MMM}", MonthNumber = g.Date.Month, } ) .Select(rep => new MonthReport { Year = rep.Key.Y, Month = rep.Key.Month, MonthNumber = rep.Key.MonthNumber, Total = rep.Sum(s => s.Total) //rep.Sum(s => (s.DatePrepay >= dateStart.Date && s.DatePrepay <= dateEnd.Date) ? s.Total + s.Prepay : s.Total) } ) //.OrderBy(m => m.Year) .ToList(); var prepaymentsData = _repositoryPrepayment .Query(op => //(( op.Date >= dateStart.Date && op.Date <= dateEnd.Date &&//) || op.OrderInfo.Date > dateEnd.Date) op.OrderInfo.Removed != true && op.OrderInfo.UserId == userId ) .Include(order => order.OrderInfo) .Select( field => new { Date = field.Date, Total = field.Total }) .AsNoTracking() .ToList(); var prepaymentsByMonth = prepaymentsData.GroupBy(g => new { Y = g.Date.Year, M = g.Date.Month, MonthNumber = g.Date.Month, Month = $"{g.Date:MMM}" } ) .Select(rep => new MonthReport { Year = rep.Key.Y, Month = rep.Key.Month, MonthNumber = rep.Key.MonthNumber, Total = rep.Sum(s => s.Total) } ) .ToList(); foreach (var m in prepaymentsByMonth) { var t = monthReport.Find(p => p.Year == m.Year && p.MonthNumber == m.MonthNumber); if (t == null) { monthReport.Add(m); } else { t.Total += m.Total; } } var prepayments = prepaymentsData.Sum(op => op.Total); //var prepayments = dataSource.Where(order => order.DatePrepay >= dateStart.Date && order.DatePrepay <= dateEnd.Date) // .Sum(order => order.Prepay); //prepayments += onlyPrepay; //var report = new List<ProductsReport>();// dataSource //.GroupBy(g => new { g.Items, g.ProductName }) //.Select(rep => // new ProductsReport // { // ProductName = rep.Key.ProductName, // Sum = rep.Sum(s => s.Total) // } //) //.ToList(); var dic = new Dictionary <int, ProductsReport>(); foreach (var order in dataSource) { var sum = order.Items.Sum(oi => oi.ProductInfo.Price); var count = order.Items.Count; var dif = count == 0 ? 0 : Math.Round((order.Total - sum) / count, 0); foreach (var item in order.Items) { int id = (int)item.ProductId; decimal priceWithDif = (item.ProductInfo.Price + dif); if (dic.ContainsKey(id)) { dic[id].Sum += priceWithDif; } else { dic.Add(id, new ProductsReport { ProductName = item.ProductInfo.Name, Sum = priceWithDif }); } } } var report = dic.Values.ToList(); var prepayData = new ProductsReport { ProductName = "Предоплата", Sum = Convert.ToDecimal(prepayments) }; report.Add(prepayData); return(report); //monthReport = null; //return null; }
public void GenerateAllProductsInformation(ProductsReport productInformations) { this.pdfWriter.Value.GenerateReport(productInformations, "All products Report"); }
public ActionResult DocumentViewerExport() { ProductsReport report = new ProductsReport(); return(ReportViewerExtension.ExportTo(report)); }
public ActionResult DocumentViewerPartial() { ProductsReport report = new ProductsReport(); return(PartialView("_DocumentViewerPartial", report)); }
public void GenerateAllProductsReportForDate(ProductsReport report) { var date = report.Date.ToString("dd MMM yyyy"); this.pdfWriter.Value.GenerateReport(report, "All products Report for " + date); }
public ActionResult DocumentViewerPartialExport() { ProductsReport report = new ProductsReport(); return(DocumentViewerExtension.ExportTo(report, Request)); }
public List <ProductsReport> GetReportsOfProducts(int productTypeId, int productId, int attrId, int unitId, DateTime from, DateTime to) { List <ProductsReport> result = new List <ProductsReport>(); List <ProductDetail> items = new List <ProductDetail>(); if (from > to) { DateTime d = from; from = to; to = d; } using (BaoHienDBDataContext context = new BaoHienDBDataContext(SettingManager.BuildStringConnection())) { // Products has transaction on period of time var produces = context.ProductLogs.Where(x => x.UpdatedDate <= to && x.UpdatedDate >= from && x.RecordCode != ""); if (unitId > 0) { produces = produces.Where(x => x.UnitId == unitId); } if (attrId > 0) { produces = produces.Where(x => x.AttributeId == attrId); } if (productId > 0) { produces = produces.Where(x => x.ProductId == productId); } if (productTypeId > 0) { produces = produces.Where(x => x.Product.ProductType == productTypeId); } foreach (var item in produces) { items.Add(new ProductDetail() { ID = item.Id, UnitId = item.UnitId, AttributeId = item.AttributeId, Direction = item.Direction, ProductId = item.ProductId, ProductTypeId = item.Product.ProductType, Amount = item.Amount, Jampo = item.BaseAttribute.Jampo, CreatedDate = item.UpdatedDate, BeforeNumber = item.BeforeNumber, AfterNUmber = item.AfterNumber, Status = item.Status }); } // Products out period of time var old_products = context.ProductLogs.AsEnumerable().Where(x => x.UpdatedDate < from && !items.Select(y => y.ProductId.ToString() + '_' + y.AttributeId.ToString() + '_' + y.UnitId.ToString()).Contains(x.ProductId.ToString() + '_' + x.AttributeId.ToString() + '_' + x.UnitId.ToString())) .GroupBy( x => new { x.ProductId, x.AttributeId, x.UnitId }, (x, y) => new { Key = new { x.ProductId, x.AttributeId, x.UnitId }, Value = y.OrderByDescending(z => z.Id).First() }) .Select(x => x.Value); if (unitId > 0) { old_products = old_products.Where(x => x.UnitId == unitId); } if (attrId > 0) { old_products = old_products.Where(x => x.AttributeId == attrId); } if (productId > 0) { old_products = old_products.Where(x => x.ProductId == productId); } if (productTypeId > 0) { old_products = old_products.Where(x => x.Product.ProductType == productTypeId); } foreach (var item in old_products) { items.Add(new ProductDetail() { ID = item.Id, UnitId = item.UnitId, AttributeId = item.AttributeId, Direction = item.Direction, ProductId = item.ProductId, ProductTypeId = item.Product.ProductType, Amount = 0, Jampo = item.BaseAttribute.Jampo, CreatedDate = item.UpdatedDate, BeforeNumber = item.AfterNumber, AfterNUmber = item.AfterNumber, Status = item.Status }); } // Start collecting report var dits = items.GroupBy(x => new { x.ProductTypeId, x.ProductId, x.AttributeId, x.UnitId }); List <int> type_distincts = items.GroupBy(x => x.ProductTypeId).Select(x => x.First()).Select(x => x.ProductTypeId).ToList(); List <ProductType> types = context.ProductTypes.OrderBy(x => x.TypeName).ToList(); int index = 0; foreach (ProductType type in types) { if (type_distincts.Contains(type.Id)) { List <ProductsReport> type_products = new List <ProductsReport>(); type_products.Add(new ProductsReport() { ProductName = type.TypeName }); var item_types = items.Where(x => x.ProductTypeId == type.Id); var distincts = item_types.GroupBy(x => new { x.ProductId, x.AttributeId, x.UnitId }).Select(x => x.First()); foreach (var item in distincts) { Product p = context.Products.Where(x => x.Id == item.ProductId).First(); BaseAttribute b = context.BaseAttributes.Where(x => x.Id == item.AttributeId).First(); MeasurementUnit m = context.MeasurementUnits.Where(x => x.Id == item.UnitId).First(); ProductsReport pr = new ProductsReport() { ProductCode = p.ProductCode, //p.Id + " - " + b.Id + " - " + m.Id,//p.ProductCode, ProductName = p.ProductName + " - " + b.AttributeName, Jampo = item.Jampo ? "Jampo" : "", UnitName = m.Name, Index = (++index).ToString(), ProductId = p.Id, AttrId = b.Id, UnitId = m.Id }; var a = items.Where(x => x.ProductId == item.ProductId && x.AttributeId == item.AttributeId && x.UnitId == item.UnitId).OrderBy(x => x.ID); pr.FirstNumber = a.First().BeforeNumber.ToString(); pr.LastNumber = a.Last().AfterNUmber.ToString(); pr.ImportNumber = a.Where(x => x.Direction == BHConstant.DIRECTION_IN && x.Status == BHConstant.ACTIVE_STATUS).Sum(x => x.Amount).ToString(); pr.ExportNumber = a.Where(x => x.Direction == BHConstant.DIRECTION_OUT && x.Status == BHConstant.ACTIVE_STATUS).Sum(x => x.Amount).ToString(); //if (pr.LastNumber != "0") if (!(pr.FirstNumber == "0" && pr.LastNumber == "0" && pr.ImportNumber == "0" && pr.ExportNumber == "0")) { type_products.Add(pr); } } type_products = type_products.OrderBy(x => x.ProductCode).ThenBy(x => x.Jampo).ToList(); result.AddRange(type_products); } } } return(result); }
public void GenerateReport(ProductsReport report, string fileName) { this.GenerateReport(report, PdfSettings.Default.ReportsFolder, fileName); }