public bool CreateReport() { bool isSuccessful = false; iTextSharp.text.Document document = new iTextSharp.text.Document(PageSize.LETTER); try { //set up RunReport event overrides & create doc LayawayHistoryAndSchedule events = new LayawayHistoryAndSchedule(); PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(reportObject.ReportTempFileFullName, FileMode.Create)); writer.PageEvent = events; //set up tables, etc... PdfPTable table = new PdfPTable(8); Image gif = Image.GetInstance(Common.Properties.Resources.logo, BaseColor.WHITE); _reportFont = FontFactory.GetFont("Arial", 7, iTextSharp.text.Font.NORMAL); _reportFontLargeBold = FontFactory.GetFont("Arial", 8, iTextSharp.text.Font.BOLD); _reportFontSmallBold = FontFactory.GetFont("Arial", 6, iTextSharp.text.Font.BOLD); gif.ScalePercent(25); runReport = new LayawayRunReports(); document.SetPageSize(PageSize.LETTER); document.SetMargins(-50, -50, 10, 45); document.AddTitle(reportObject.ReportTitle + ": " + DateTime.Now.ToString("MM/dd/yyyy")); ReportHeader(table, gif); AddLines(1, table); ReportTitleAndOtherInfo(table); AddLines(1, table); ColumnHeaders(table); DrawLine(table, _reportFontLargeBold); //ReportDetail(table); //ReportSummary(table); WriteSchedule(table); table.HeaderRows = 11; document.Open(); document.Add(table); 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); }