private void ReportHeader(PdfPTable headingtable, Image gif, TerminatedLayawayPickingSlip pageEvent) { PdfPCell cell = new PdfPCell(); // heading - row 1 cell = new PdfPCell(gif); cell.Border = Rectangle.NO_BORDER; cell.HorizontalAlignment = Element.ALIGN_LEFT; cell.VerticalAlignment = Element.ALIGN_TOP; cell.Colspan = 1; headingtable.AddCell(cell); WriteCell(headingtable, string.Empty, ReportFont, 6, Element.ALIGN_CENTER, Element.ALIGN_TOP, Rectangle.NO_BORDER); WriteCell(headingtable, string.Empty, ReportFont, 7, Element.ALIGN_CENTER, Element.ALIGN_TOP, Rectangle.NO_BORDER); WriteCell(headingtable, DateTime.Now.ToString("MM/dd/yyyy"), ReportFont, 6, Element.ALIGN_LEFT, Element.ALIGN_TOP, Rectangle.NO_BORDER); WriteCell(headingtable, string.Empty, ReportFont, 1, Element.ALIGN_LEFT, Rectangle.NO_BORDER); WriteCell(headingtable, pageEvent.ReportObject.ReportTitle, ReportFontHeading, 7, Element.ALIGN_CENTER, Rectangle.NO_BORDER); WriteCell(headingtable, "Employee #:" + pageEvent.ReportObject.ReportEmployee, ReportFont, 7, Element.ALIGN_LEFT, Rectangle.NO_BORDER); //draw line DrawLine(headingtable); }
public bool CreateReport() { bool isSuccessful = false; iTextSharp.text.Document document = new iTextSharp.text.Document(PageSize.HALFLETTER.Rotate()); try { //set up RunReport event overrides & create doc TerminatedLayawayPickingSlip events = this; PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(ReportObject.ReportTempFileFullName, FileMode.Create)); writer.PageEvent = events; MultiColumnText columns = new MultiColumnText(document.PageSize.Top - 90, document.PageSize.Height - (90)); float pageLeft = document.PageSize.Left; float pageright = document.PageSize.Right; columns.AddSimpleColumn(-27, document.PageSize.Width + 29); //set up tables, etc... PdfPTable table = new PdfPTable(7); table.WidthPercentage = 85;// document.PageSize.Width; PdfPCell cell = new PdfPCell(); Image gif = Image.GetInstance(Resources.logo, BaseColor.WHITE); gif.ScalePercent(25); runReport = new LayawayRunReports(); document.Open(); document.SetPageSize(PageSize.HALFLETTER.Rotate()); document.SetMargins(-100, -100, 10, 45); document.AddTitle(ReportObject.ReportTitle + ": " + DateTime.Now.ToString("MM/dd/yyyy")); //int layawayCount = ReportObject.TerminatedLayawayPickingSlipList.Count; //int counter = 1; //foreach (LayawayVO layaway in ReportObject.TerminatedLayawayPickingSlipList) //{ WriteCell(table, "Ticket #: " + ReportObject.TerminatedLayaway.TicketNumber.ToString(), ReportFontBold, 9, Rectangle.ALIGN_CENTER, Rectangle.NO_BORDER); WriteInfo(table, ReportObject.TerminatedLayaway); DrawLine(table); WritePaymentList(table, ReportObject.TerminatedLayaway); DrawLine(table); WriteDetail(table, ReportObject.TerminatedLayaway); /*while (counter < layawayCount) * { * WriteCell(table, string.Empty, ReportFont, 7, Rectangle.ALIGN_CENTER, Rectangle.NO_BORDER); * WriteCell(table, string.Empty, ReportFont, 7, Rectangle.ALIGN_CENTER, Rectangle.NO_BORDER); * WriteCell(table, string.Empty, ReportFont, 7, Rectangle.ALIGN_CENTER, Rectangle.NO_BORDER); * WriteCell(table, string.Empty, ReportFont, 7, Rectangle.ALIGN_CENTER, Rectangle.NO_BORDER); * WriteCell(table, string.Empty, ReportFont, 7, Rectangle.ALIGN_CENTER, Rectangle.NO_BORDER); * WriteCell(table, string.Empty, ReportFont, 7, Rectangle.ALIGN_CENTER, Rectangle.NO_BORDER); * WriteCell(table, string.Empty, ReportFont, 7, Rectangle.ALIGN_CENTER, Rectangle.NO_BORDER); * WriteCell(table, string.Empty, ReportFont, 7, Rectangle.ALIGN_CENTER, Rectangle.NO_BORDER); * WriteCell(table, string.Empty, ReportFont, 7, Rectangle.ALIGN_CENTER, Rectangle.NO_BORDER); * WriteCell(table, string.Empty, ReportFont, 7, Rectangle.ALIGN_CENTER, Rectangle.NO_BORDER); * break; * } * counter++; * }*/ columns.AddElement(table); document.Add(columns); document.Close(); //OpenFile(); //CreateReport(); 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); }
//create report public bool CreateReport(IPdfLauncher pdfLauncher) { bool isSuccessful = false; try { //set up fonts reportObject.CreateTemporaryFullName(); switch (reportObject.ReportNumber) { case (int)LayawayReportIDs.LayawayHistoryAndSchedule: LayawayHistoryAndSchedule layawayHistoryAndSchedule = new LayawayHistoryAndSchedule(); layawayHistoryAndSchedule.reportObject = this.reportObject; isSuccessful = layawayHistoryAndSchedule.CreateReport(); break; case (int)LayawayReportIDs.LayawayContract: LayawayContractReport layawayContractRpt = new LayawayContractReport(pdfLauncher); layawayContractRpt.ReportObject = this.reportObject; isSuccessful = layawayContractRpt.CreateReport(); break; case (int)LayawayReportIDs.LayawayForfeitPickingSlip: LayawayForefeitPickingSlip layawayForefeitPickingSlip = new LayawayForefeitPickingSlip(pdfLauncher); layawayForefeitPickingSlip.ReportObject = this.reportObject; isSuccessful = layawayForefeitPickingSlip.CreateReport(); break; case (int)LayawayReportIDs.ForfeitedLayawaysListing: ForfeitedLayawaysListingReport forfeitedLayawaysListingReport = new ForfeitedLayawaysListingReport(pdfLauncher); forfeitedLayawaysListingReport.ReportObject = this.reportObject; isSuccessful = forfeitedLayawaysListingReport.CreateReport(); break; case (int)LayawayReportIDs.TerminatedLayawaysPickingSlip: TerminatedLayawayPickingSlip terminatedLayawayPickingSlip = new TerminatedLayawayPickingSlip(pdfLauncher); terminatedLayawayPickingSlip.ReportObject = this.reportObject; isSuccessful = terminatedLayawayPickingSlip.CreateReport(); break; case (int)LayawayReportIDs.TerminatedLayawaysListing: TerminatedLayawaysListingReport terminatedLayawaysListingReport = new TerminatedLayawaysListingReport(pdfLauncher); terminatedLayawaysListingReport.ReportObject = this.reportObject; isSuccessful = terminatedLayawaysListingReport.CreateReport(); break; } } catch (DocumentException de) { reportObject.ReportError = de.Message; reportObject.ReportErrorLevel = (int)LogLevel.WARN; } catch (IOException ioe) { reportObject.ReportError = ioe.Message; reportObject.ReportErrorLevel = (int)LogLevel.WARN; } return(isSuccessful); }