private void FillTotalContent(TransactionGrouped groupedGroupedObj, FilterTransactionReport filter) { foreach (TransactionReportGroupedDTO trans in groupedGroupedObj.GroupedObj) { Row rowHead = _table.AddRow(); FillRow(rowHead, 0, GetMainInfo(trans, filter), false, ParagraphAlignment.Left, VerticalAlignment.Center); //Total amount FillRow(rowHead, 1, trans.TotalAmount.ToMoneyString(), false, ParagraphAlignment.Right, VerticalAlignment.Center); if (filter.ReportType == TransFilterType.Bill) { //Paid amount FillRow(rowHead, 2, trans.PaidTotalAmount.ToMoneyString(), false, ParagraphAlignment.Right, VerticalAlignment.Center); //due amount FillRow(rowHead, 3, trans.DueTotalAmount.ToMoneyString(), false, ParagraphAlignment.Right, VerticalAlignment.Center); // unasignedAmount if (filter.ShowUnasinged) { FillRow(rowHead, 4, trans.UnasignedAmount.ToMoneyString(), false, ParagraphAlignment.Right, VerticalAlignment.Center); } } } Row gransRow = _table.AddRow(); FillGrandTotal(gransRow, groupedGroupedObj, filter); }
/// <summary> /// Initializate collections in case if we need name of one of them /// </summary> /// <param name="transFunc">Use delegate for translation method wich work with localResource file</param> /// <param name="paymentMethods"></param> /// <param name="solicitors"></param> /// <param name="mailings"></param> /// <param name="departments"></param> /// <param name="categoryTree"></param> public byte[] CreateDocument(FilterTransactionReport filter, TransactionGrouped grouped, int countTrans) { // Create a new MigraDoc document _document = new Document { Info = { Title = filter.Name } }; DefineStyles(); if (filter.view == TransFilterView.Details) { var colsCount = CreatePage(filter, countTrans); if (string.Equals(filter.subtotalBy, "None", StringComparison.InvariantCultureIgnoreCase)) { FillContent(colsCount, grouped.GroupedObj, filter); } else { FillGroupedContent(colsCount, grouped.GroupedObj, filter); } } if (filter.view == TransFilterView.Total) { if (string.Equals(filter.totalOnlyBy, "totalOnly", StringComparison.InvariantCultureIgnoreCase)) { CreatePage(filter, countTrans); if (string.Equals(filter.subtotalBy, "None", StringComparison.InvariantCultureIgnoreCase)) { FillTotalContent(grouped, filter); } if (!string.Equals(filter.subtotalBy, "None", StringComparison.InvariantCultureIgnoreCase)) { FillSubGroupedTotalContent(grouped, filter); } } else { if (filter.ReportType == TransFilterType.Payment) { FillMatrixRows((MatrixDTO)grouped, filter, countTrans); } } } // FillContent(colsCount); PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(true); pdfRenderer.Document = _document; pdfRenderer.RenderDocument(); using (MemoryStream ms = new MemoryStream()) { pdfRenderer.Save(ms, false); byte[] buffer = new byte[ms.Length]; ms.Seek(0, SeekOrigin.Begin); ms.Flush(); ms.Read(buffer, 0, (int)ms.Length); ms.Close(); return(buffer); } }
static void FillGrandTotal(Row row, TransactionGrouped grouped, FilterTransactionReport filter) { FillRow(row, 0, "Grand Total", true, ParagraphAlignment.Left, VerticalAlignment.Center); FillRow(row, 1, grouped.GrandAmount == null ? 0M.ToMoneyString() : ((decimal)grouped.GrandAmount).ToMoneyString(), true, ParagraphAlignment.Right, VerticalAlignment.Center); if (filter.ReportType == TransFilterType.Bill) { FillRow(row, 2, grouped.GrandPaid == null ? 0M.ToMoneyString() : ((decimal)grouped.GrandPaid).ToMoneyString(), true, ParagraphAlignment.Right, VerticalAlignment.Center); FillRow(row, 3, grouped.GrandDue == null ? 0M.ToMoneyString() : ((decimal)grouped.GrandDue).ToMoneyString(), true, ParagraphAlignment.Right, VerticalAlignment.Center); FillRow(row, 4, grouped.GrandUnasignedAmount == null ? 0M.ToMoneyString() : ((decimal)grouped.GrandUnasignedAmount).ToMoneyString(), true, ParagraphAlignment.Right, VerticalAlignment.Center); } }
private void FillSubGroupedTotalContent(TransactionGrouped groupedGroupedObj, FilterTransactionReport filter) { var colSpanCount = filter.ReportType == TransFilterType.Bill ? (filter.ShowUnasinged ? 5 : 4) : 2; foreach (TransactionReportGroupedDTO sg in groupedGroupedObj.GroupedObj) { Row rowHead = _table.AddRow(); FillRow(rowHead, 0, GetMainInfo(sg, filter), true, ParagraphAlignment.Left, VerticalAlignment.Center); rowHead.Cells[0].MergeRight = colSpanCount - 1; foreach (TransactionReportGroupedDTO grouped in sg.SubGrouped) { Row rowGp = _table.AddRow(); FillRow(rowGp, 0, GetMainInfo(grouped, filter), false, ParagraphAlignment.Left, VerticalAlignment.Center, marginLeft: 10); //Total amount FillRow(rowGp, 1, grouped.TotalAmount.ToMoneyString(), false, ParagraphAlignment.Right, VerticalAlignment.Center); if (filter.ReportType == TransFilterType.Bill) { //Paid amount FillRow(rowGp, 2, grouped.PaidTotalAmount.ToMoneyString(), false, ParagraphAlignment.Right, VerticalAlignment.Center); //due amount FillRow(rowGp, 3, grouped.DueTotalAmount.ToMoneyString(), false, ParagraphAlignment.Right, VerticalAlignment.Center); // unasignedAmount if (filter.ShowUnasinged) { FillRow(rowGp, 4, string.IsNullOrEmpty(grouped.UnasignedAmount.ToMoneyString()) ? 0M.ToMoneyString() : grouped.UnasignedAmount.ToMoneyString(), false, ParagraphAlignment.Right, VerticalAlignment.Center); } } } Row subTotal = _table.AddRow(); FillRow(subTotal, 0, sg.TotalName, true, ParagraphAlignment.Left, VerticalAlignment.Center); FillRow(subTotal, 1, sg.TotalAmount.ToMoneyString(), true, ParagraphAlignment.Right, VerticalAlignment.Center); if (filter.ReportType == TransFilterType.Bill) { FillRow(subTotal, 2, sg.PaidTotalAmount.ToMoneyString(), true, ParagraphAlignment.Right, VerticalAlignment.Center); FillRow(subTotal, 3, sg.DueTotalAmount.ToMoneyString(), true, ParagraphAlignment.Right, VerticalAlignment.Center); if (filter.ShowUnasinged) { FillRow(subTotal, 4, sg.UnasignedAmount.ToMoneyString(), true, ParagraphAlignment.Right, VerticalAlignment.Center); } } AddEmptyRow(); } Row grand = _table.AddRow(); FillGrandTotal(grand, groupedGroupedObj, filter); }
public static Document CreateDocument(FilterTransactionReport filter, TransactionGrouped grouped, int countTrans) { // Create a new MigraDoc document _document = new Document { Info = { Title = filter.Name } }; DefineStyles(); if (filter.view == TransFilterView.Details) { var colsCount = CreatePage(filter, countTrans); if (string.Equals(filter.subtotalBy, "None", StringComparison.InvariantCultureIgnoreCase)) { FillContent(colsCount, grouped.GroupedObj, filter); } else { FillGroupedContent(colsCount, grouped.GroupedObj, filter); } } if (filter.view == TransFilterView.Total) { if (string.Equals(filter.totalOnlyBy, "totalOnly", StringComparison.InvariantCultureIgnoreCase)) { if (string.Equals(filter.subtotalBy, "None", StringComparison.InvariantCultureIgnoreCase)) { FillTotalContent(grouped, filter); } if (!string.Equals(filter.subtotalBy, "None", StringComparison.InvariantCultureIgnoreCase)) { FillSubGroupedTotalContent(grouped, filter); } } else { if (filter.ReportType == TransFilterType.Payment) { FillMatrixRows((MatrixDTO)grouped, filter, countTrans); } } } // FillContent(colsCount); return(_document); }