private void WriteRetailSaleTransactionDetailSection(PdfPTable detailsTable, Int32 columnCount, ReportObject.RetailSaleListing retailSaleListing, List <ReportObject.RetailSaleTender> retailSaleTenderList) { if (retailSaleListing.ticketNumber > 0) { WriteCell(detailsTable, String.Empty, ReportFontMedium, 1, Element.ALIGN_CENTER, Rectangle.NO_BORDER, false); WriteCell(detailsTable, "MSR #:", ReportFontBold, 2, Element.ALIGN_RIGHT, Rectangle.NO_BORDER, false); WriteCell(detailsTable, retailSaleListing.ticketNumber.ToString(), ReportFontMedium, 1, Element.ALIGN_LEFT, Rectangle.NO_BORDER, false); WriteCell(detailsTable, "Date and Time:", ReportFontBold, 2, Element.ALIGN_RIGHT, Rectangle.NO_BORDER, false); WriteCell(detailsTable, retailSaleListing.date.ToShortDateString() + " " + retailSaleListing.date.ToShortTimeString(), ReportFontMedium, 1, Element.ALIGN_LEFT, Rectangle.NO_BORDER, false); WriteCell(detailsTable, "Total Sale Amount w/Tax:", ReportFontBold, 2, Element.ALIGN_RIGHT, Rectangle.NO_BORDER, false); WriteCell(detailsTable, "$" + (retailSaleListing.saleAmount + retailSaleListing.tax).ToString("0.00"), ReportFontMedium, 2, Element.ALIGN_LEFT, Rectangle.NO_BORDER, false); WriteCell(detailsTable, String.Empty, ReportFontMedium, 1, Element.ALIGN_CENTER, Rectangle.NO_BORDER, false); WriteCell(detailsTable, String.Empty, ReportFontMedium, 1, Element.ALIGN_CENTER, Rectangle.NO_BORDER, false); WriteCell(detailsTable, "Layaway #:", ReportFontBold, 2, Element.ALIGN_RIGHT, Rectangle.NO_BORDER, false); WriteCell(detailsTable, retailSaleListing.layawayTicketNumber.ToString(), ReportFontMedium, 1, Element.ALIGN_LEFT, Rectangle.NO_BORDER, false); WriteCell(detailsTable, "Terminal ID:", ReportFontBold, 2, Element.ALIGN_RIGHT, Rectangle.NO_BORDER, false); WriteCell(detailsTable, retailSaleListing.terminalId, ReportFontMedium, 1, Element.ALIGN_LEFT, Rectangle.NO_BORDER, false); WriteCell(detailsTable, "Sales Tax Amount:", ReportFontBold, 2, Element.ALIGN_RIGHT, Rectangle.NO_BORDER, false); WriteCell(detailsTable, "$" + retailSaleListing.tax.ToString("0.00"), ReportFontMedium, 2, Element.ALIGN_LEFT, Rectangle.NO_BORDER, false); WriteCell(detailsTable, String.Empty, ReportFontMedium, 1, Element.ALIGN_CENTER, Rectangle.NO_BORDER, false); WriteCell(detailsTable, String.Empty, ReportFontMedium, 1, Element.ALIGN_CENTER, Rectangle.NO_BORDER, false); WriteCell(detailsTable, "Original #:", ReportFontBold, 2, Element.ALIGN_RIGHT, Rectangle.NO_BORDER, false); WriteCell(detailsTable, retailSaleListing.originalTicketNumber.ToString(), ReportFontMedium, 1, Element.ALIGN_LEFT, Rectangle.NO_BORDER, false); WriteCell(detailsTable, "Tender Types:", ReportFontBold, 2, Element.ALIGN_RIGHT, Rectangle.NO_BORDER, false); if (retailSaleTenderList != null) { WriteCell(detailsTable, retailSaleTenderList[0].tenderType + " " + retailSaleTenderList[0].refAmount.ToString(), ReportFontMedium, 1, Element.ALIGN_LEFT, Rectangle.NO_BORDER, false); } else { WriteCell(detailsTable, String.Empty, ReportFontMedium, 1, Element.ALIGN_LEFT, Rectangle.NO_BORDER, false); } WriteCell(detailsTable, "Shop Number:", ReportFontBold, 2, Element.ALIGN_RIGHT, Rectangle.NO_BORDER, false); WriteCell(detailsTable, retailSaleListing.shopNumber.ToString(), ReportFontMedium, 2, Element.ALIGN_LEFT, Rectangle.NO_BORDER, false); WriteCell(detailsTable, String.Empty, ReportFontMedium, 1, Element.ALIGN_CENTER, Rectangle.NO_BORDER, false); WriteCell(detailsTable, String.Empty, ReportFontMedium, 1, Element.ALIGN_CENTER, Rectangle.NO_BORDER, false); WriteCell(detailsTable, "User ID:", ReportFontBold, 2, Element.ALIGN_RIGHT, Rectangle.NO_BORDER, false); WriteCell(detailsTable, retailSaleListing.userId, ReportFontMedium, 1, Element.ALIGN_LEFT, Rectangle.NO_BORDER, false); WriteCell(detailsTable, String.Empty, ReportFontMedium, 2, Element.ALIGN_RIGHT, Rectangle.NO_BORDER, false); if (retailSaleTenderList != null && retailSaleTenderList.Count > 1) { WriteCell(detailsTable, retailSaleTenderList[1].tenderType + " " + retailSaleTenderList[1].refAmount.ToString(), ReportFontMedium, 1, Element.ALIGN_LEFT, Rectangle.NO_BORDER, false); } else { WriteCell(detailsTable, String.Empty, ReportFontMedium, 1, Element.ALIGN_LEFT, Rectangle.NO_BORDER, false); } WriteCell(detailsTable, "Status:", ReportFontBold, 2, Element.ALIGN_RIGHT, Rectangle.NO_BORDER, false); WriteCell(detailsTable, retailSaleListing.status, ReportFontMedium, 2, Element.ALIGN_LEFT, Rectangle.NO_BORDER, false); WriteCell(detailsTable, String.Empty, ReportFontMedium, 1, Element.ALIGN_CENTER, Rectangle.NO_BORDER, false); WriteCell(detailsTable, String.Empty, ReportFontMedium, 1, Element.ALIGN_CENTER, Rectangle.NO_BORDER, false); WriteCell(detailsTable, "Cash Drawer", ReportFontBold, 2, Element.ALIGN_RIGHT, Rectangle.NO_BORDER, false); WriteCell(detailsTable, retailSaleListing.cashDrawer.ToString(), ReportFontMedium, 1, Element.ALIGN_LEFT, Rectangle.NO_BORDER, false); WriteCell(detailsTable, String.Empty, ReportFontMedium, 2, Element.ALIGN_CENTER, Rectangle.NO_BORDER, false); if (retailSaleTenderList != null && retailSaleTenderList.Count > 2) { WriteCell(detailsTable, retailSaleTenderList[2].tenderType + " " + retailSaleTenderList[2].refAmount.ToString(), ReportFontMedium, 1, Element.ALIGN_LEFT, Rectangle.NO_BORDER, false); } else { WriteCell(detailsTable, String.Empty, ReportFontMedium, 1, Element.ALIGN_LEFT, Rectangle.NO_BORDER, false); } WriteCell(detailsTable, String.Empty, ReportFontMedium, 2, Element.ALIGN_CENTER, Rectangle.NO_BORDER, false); WriteCell(detailsTable, String.Empty, ReportFontMedium, 2, Element.ALIGN_CENTER, Rectangle.NO_BORDER, false); WriteCell(detailsTable, String.Empty, ReportFontMedium, 1, Element.ALIGN_CENTER, Rectangle.NO_BORDER, false); if (retailSaleTenderList != null) { for (int i = 3; i < retailSaleTenderList.Count; i++) { WriteCell(detailsTable, String.Empty, ReportFontMedium, 1, Element.ALIGN_CENTER, Rectangle.NO_BORDER, false); WriteCell(detailsTable, String.Empty, ReportFontMedium, 2, Element.ALIGN_CENTER, Rectangle.NO_BORDER, false); WriteCell(detailsTable, String.Empty, ReportFontMedium, 1, Element.ALIGN_CENTER, Rectangle.NO_BORDER, false); WriteCell(detailsTable, String.Empty, ReportFontMedium, 2, Element.ALIGN_CENTER, Rectangle.NO_BORDER, false); WriteCell(detailsTable, retailSaleTenderList[i].tenderType + " " + retailSaleTenderList[i].refAmount.ToString(), ReportFontMedium, 1, Element.ALIGN_LEFT, Rectangle.NO_BORDER, false); WriteCell(detailsTable, String.Empty, ReportFontMedium, 2, Element.ALIGN_CENTER, Rectangle.NO_BORDER, false); WriteCell(detailsTable, String.Empty, ReportFontMedium, 2, Element.ALIGN_CENTER, Rectangle.NO_BORDER, false); WriteCell(detailsTable, String.Empty, ReportFontMedium, 1, Element.ALIGN_CENTER, Rectangle.NO_BORDER, false); } } WriteCell(detailsTable, String.Empty, ReportFontMedium, 1, Element.ALIGN_CENTER, Rectangle.NO_BORDER, false); WriteCell(detailsTable, String.Empty, ReportFontMedium, 2, Element.ALIGN_CENTER, Rectangle.NO_BORDER, false); WriteCell(detailsTable, String.Empty, ReportFontMedium, 1, Element.ALIGN_CENTER, Rectangle.NO_BORDER, false); WriteCell(detailsTable, String.Empty, ReportFontMedium, 2, Element.ALIGN_CENTER, Rectangle.NO_BORDER, false); WriteCell(detailsTable, String.Empty, ReportFontMedium, 1, Element.ALIGN_LEFT, Rectangle.NO_BORDER, false); WriteCell(detailsTable, String.Empty, ReportFontMedium, 2, Element.ALIGN_CENTER, Rectangle.NO_BORDER, false); WriteCell(detailsTable, String.Empty, ReportFontMedium, 2, Element.ALIGN_CENTER, Rectangle.NO_BORDER, false); WriteCell(detailsTable, String.Empty, ReportFontMedium, 1, Element.ALIGN_CENTER, Rectangle.NO_BORDER, false); WriteCell(detailsTable, String.Empty, ReportFontMedium, 1, Element.ALIGN_CENTER, Rectangle.NO_BORDER, false); WriteCell(detailsTable, String.Empty, ReportFontMedium, 2, Element.ALIGN_CENTER, Rectangle.NO_BORDER, false); WriteCell(detailsTable, String.Empty, ReportFontMedium, 1, Element.ALIGN_CENTER, Rectangle.NO_BORDER, false); WriteCell(detailsTable, String.Empty, ReportFontMedium, 2, Element.ALIGN_CENTER, Rectangle.NO_BORDER, false); WriteCell(detailsTable, String.Empty, ReportFontMedium, 1, Element.ALIGN_LEFT, Rectangle.NO_BORDER, false); WriteCell(detailsTable, String.Empty, ReportFontMedium, 2, Element.ALIGN_CENTER, Rectangle.NO_BORDER, false); WriteCell(detailsTable, String.Empty, ReportFontMedium, 2, Element.ALIGN_CENTER, Rectangle.NO_BORDER, false); WriteCell(detailsTable, String.Empty, ReportFontMedium, 1, Element.ALIGN_CENTER, Rectangle.NO_BORDER, false); } }
public bool CreateReport(ReportObject.RetailSaleListing RetailSaleListingData, ReportObject.RetailSaleCustomer RetailSaleCustomerData, List <ReportObject.RetailSaleMerchandise> RetailSaleMerchandiseList, List <ReportObject.RetailSaleTender> RetailSaleTenderList, List <ReportObject.RetailSaleHistory> RetailSaleHistoryList) { bool isSuccessful = false; iTextSharp.text.Document document = new iTextSharp.text.Document(PageSize.LETTER.Rotate()); try { //set up RunReport event overrides & create doc _pageCount = 1; RetailSaleInquiryDetailReport events = this; PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(ReportObject.ReportTempFileFullName, FileMode.Create)); writer.PageEvent = events; MultiColumnText columns = new MultiColumnText(document.PageSize.Top - 100, document.PageSize.Height - (50)); float pageLeft = document.PageSize.Left; float pageright = document.PageSize.Right; columns.AddSimpleColumn(-75, document.PageSize.Width + 76); //set up tables, etc... PdfPCell cell = new PdfPCell(); Image gif = Image.GetInstance(Resources.logo, BaseColor.WHITE); gif.ScalePercent(25); runReport = new RunReport(); document.Open(); document.SetPageSize(PageSize.LETTER.Rotate()); document.SetMargins(-100, -100, 10, 45); document.AddTitle(ReportObject.ReportTitle + ": " + DateTime.Now.ToString("MM/dd/yyyy")); PdfPTable customerTable = new PdfPTable(12); customerTable.WidthPercentage = 100;// document.PageSize.Width; WriteRetailSaleCustomerSectionHeader(customerTable, RetailSaleCustomerData); WriteRetailSaleCustomerSection(customerTable, 12, RetailSaleCustomerData); columns.AddElement(customerTable); PdfPTable transactionDetailTable = new PdfPTable(12); transactionDetailTable.WidthPercentage = 100;// document.PageSize.Width; WriteRetailSaleTransactionDetailSectionHeader(transactionDetailTable, RetailSaleListingData); WriteRetailSaleTransactionDetailSection(transactionDetailTable, 12, RetailSaleListingData, RetailSaleTenderList); columns.AddElement(transactionDetailTable); PdfPTable merchandiseTable = new PdfPTable(12); merchandiseTable.WidthPercentage = 100;// document.PageSize.Width; WriteRetailSaleMerchandiseSectionHeader(merchandiseTable, RetailSaleMerchandiseList); WriteRetailSaleMerchandiseSection(merchandiseTable, 12, RetailSaleMerchandiseList); columns.AddElement(merchandiseTable); PdfPTable retailSaleHistoryTable = new PdfPTable(12); retailSaleHistoryTable.WidthPercentage = 100;// document.PageSize.Width; WriteRetailSaleHistorySectionHeader(retailSaleHistoryTable, RetailSaleHistoryList); WriteRetailSaleHistorySectionColumnHeaders(retailSaleHistoryTable, RetailSaleHistoryList); WriteRetailSaleHistorySection(retailSaleHistoryTable, 12, RetailSaleHistoryList); columns.AddElement(retailSaleHistoryTable); //here add detail document.Add(columns); document.Close(); OpenFile(ReportObject.ReportTempFileFullName); //CreateReport(_icn, _description, theData); isSuccessful = true; } catch (DocumentException de) { ReportObject.ReportError = de.Message; ReportObject.ReportErrorLevel = (int)LogLevel.ERROR; } catch (IOException ioe) { ReportObject.ReportError = ioe.Message; ReportObject.ReportErrorLevel = (int)LogLevel.ERROR; } return(isSuccessful); }
private void WriteRetailSaleTransactionDetailSectionHeader(PdfPTable columnsTable, ReportObject.RetailSaleListing retailSaleListing) { if (retailSaleListing.ticketNumber > 0) { WriteCell(columnsTable, String.Empty, ReportFontBold, 12, Element.ALIGN_RIGHT, Rectangle.TOP_BORDER); WriteCell(columnsTable, String.Empty, ReportFontBold, 1, Element.ALIGN_RIGHT, Rectangle.NO_BORDER); WriteCell(columnsTable, "Transaction Detail", ReportFontHeading, 11, Element.ALIGN_LEFT, Rectangle.NO_BORDER); WriteCell(columnsTable, String.Empty, ReportFontBold, 12, Element.ALIGN_RIGHT, Rectangle.BOTTOM_BORDER); } }