private void WriteAgreement(PdfPTable agreementTable, LayawayContractReport layawayContractRpt) { string agreementLine1 = "I understand that my first payment of at least " + layawayContractRpt.ReportObject.CurrentLayaway.MonthlyPayment.ToString("C") + " is due on or before " + layawayContractRpt.ReportObject.CurrentLayaway.NextPayment.ToShortDateString() + " and also agree to pay “MONTHLY "; string agreementLine2 = "PAYMENT(S)” of at least " + layawayContractRpt.ReportObject.CurrentLayaway.MonthlyPayment.ToString("C") + " on or before each of the following dates: "; string agreementLine4 = "IF I FAIL TO MAKE ANY OF THE “MONTHLY PAYMENT(S)” ON OR BEFORE THE ABOVE DATES I RELINQUISH ALL RIGHTS "; string agreementLine5 = "TO THE DESCRIBED ITEM(S) AND I WILL BE ENTITLED TO A CREDIT IN THE AMOUNT OF MONEY I HAVE PAID"; string agreementLine6 = "(OTHER THAN THE SERVICE FEE) LESS A $10.00 RESTOCKING FEE. THE CREDIT CAN BE USED ONLY BY ME FOR "; string agreementLine7 = "A CASH PURCHASE OR LAYAWAY PAYMENT IN THIS STORE FOR A PERIOD OF 6 MONTHS FROM THE DATE OF THE LAST PAYMENT "; string agreementLine8 = "MADE ON THIS LAYAWAY AND CANNOT BE USED TO PAY ON A LOAN."; string agreementLine9 = "I understand that title to the item(s) will not transfer until I have paid this layaway in full and that there will be no"; string agreementLine10 = "refunds or exchanges."; AgreementLines(agreementTable, agreementLine1, ReportFont); AgreementLines(agreementTable, agreementLine2, ReportFont); GetDates(agreementTable); AgreementLines(agreementTable, agreementLine4, ReportFont); AgreementLines(agreementTable, agreementLine5, ReportFont); AgreementLines(agreementTable, agreementLine6, ReportFont); AgreementLines(agreementTable, agreementLine7, ReportFont); AgreementLines(agreementTable, agreementLine8, ReportFont); AgreementLines(agreementTable, agreementLine9, ReportFont); AgreementLines(agreementTable, agreementLine10, ReportFont); }
public bool CreateReport() { bool isSuccessful = false; iTextSharp.text.Document document = new iTextSharp.text.Document(PageSize.LETTER); runReport = new LayawayRunReports(); try { //set up RunReport event overrides & create doc _saleSubTotal = 0.0m; LayawayContractReport events = this; PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(ReportObject.ReportTempFileFullName, FileMode.Create)); writer.PageEvent = events; MultiColumnText columns = new MultiColumnText(document.PageSize.Top - 150, document.PageSize.Height - (100)); columns.AddSimpleColumn(-63, document.PageSize.Width + 63); //set up tables, etc... PdfPTable table = new PdfPTable(7); table.WidthPercentage = 80;// document.PageSize.Width; table.TotalWidth = document.PageSize.Width; Image gif = Image.GetInstance(Resources.logo, BaseColor.WHITE); gif.ScalePercent(35); document.SetPageSize(PageSize.LETTER); document.SetMargins(-100, -100, 10, 45); document.AddTitle(ReportObject.ReportTitle + ": " + DateTime.Now.ToString("MM/dd/yyyy")); ReportDetail(table); AddLines(1, table, false, " ", false, ReportFont); ReportSummary(table); AddLines(1, table, false, " ", false, ReportFont); WriteSingleLine(table, 150); AddLines(1, table, false, " ", false, ReportFont); //WriteAgreement(table, (LayawayContractReport)writer.PageEvent); //AddLines(5, table, false, " ", false, ReportFont); //WriteFooter(table, (LayawayContractReport)writer.PageEvent); document.Open(); //CallWriteAgreement(writer, document); columns.AddElement(table); float tableHeight = table.TotalHeight; //agreement stuff MultiColumnText agreementColumns; //table.WriteSelectedRows(0, -1, 10, (document.PageSize.Height - 166), writer.DirectContent); //add objects to document document.Add(columns); float agreementTableHeight = 155f; float pageSpan = (int)tableHeight / 542; float remainingHeight = 625f - (tableHeight - ((pageSpan * 542) - 50));;//document.PageSize.Top - 150 - tableHeight - 75; float newPageTop = document.PageSize.Top - 150; if (remainingHeight > agreementTableHeight) { agreementColumns = new MultiColumnText(remainingHeight + 75, agreementTableHeight); } else { document.NewPage(); //agreementColumns = new MultiColumnText(document.PageSize.Bottom + 550, document.PageSize.Height - (166)); agreementColumns = new MultiColumnText(document.PageSize.Top - 150, agreementTableHeight); } agreementColumns.AddSimpleColumn(-63, document.PageSize.Width + 63); PdfPTable agreementTable = new PdfPTable(7); agreementTable.WidthPercentage = 80;// document.PageSize.Width; agreementTable.TotalWidth = document.PageSize.Width; WriteAgreement(agreementTable, (LayawayContractReport)writer.PageEvent); AddLines(5, table, false, " ", false, ReportFont); WriteFooter(agreementTable, (LayawayContractReport)writer.PageEvent); agreementColumns.AddElement(agreementTable); float agtableHeight = agreementTable.TotalHeight; document.Add(agreementColumns); document.Close(); //nnaeme //return true; //OpenFile(ReportObject.ReportTempFileFullName); //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); }
private void WriteFooter(PdfPTable footerTable, LayawayContractReport layawayContractRpt) { PdfPCell cell = new PdfPCell(); cell = new PdfPCell(new Paragraph(string.Empty, ReportFont)); cell.Colspan = 7; cell.HorizontalAlignment = Rectangle.ALIGN_LEFT; cell.Border = Rectangle.NO_BORDER; cell.VerticalAlignment = Element.ALIGN_BOTTOM; footerTable.AddCell(cell); cell = new PdfPCell(new Paragraph(string.Empty, ReportFont)); cell.Colspan = 7; cell.HorizontalAlignment = Rectangle.ALIGN_LEFT; cell.Border = Rectangle.NO_BORDER; cell.VerticalAlignment = Element.ALIGN_BOTTOM; footerTable.AddCell(cell); cell = new PdfPCell(new Paragraph(string.Empty, ReportFont)); cell.Colspan = 7; cell.HorizontalAlignment = Rectangle.ALIGN_LEFT; cell.Border = Rectangle.NO_BORDER; cell.VerticalAlignment = Element.ALIGN_BOTTOM; footerTable.AddCell(cell); cell = new PdfPCell(new Paragraph(string.Empty, ReportFont)); cell.Colspan = 7; cell.HorizontalAlignment = Rectangle.ALIGN_LEFT; cell.Border = Rectangle.NO_BORDER; cell.VerticalAlignment = Element.ALIGN_BOTTOM; footerTable.AddCell(cell); //line 1 cell = new PdfPCell(new Paragraph(string.Empty, ReportFont)); cell.Colspan = 1; cell.HorizontalAlignment = Rectangle.ALIGN_LEFT; cell.Border = Rectangle.NO_BORDER; cell.VerticalAlignment = Element.ALIGN_BOTTOM; footerTable.AddCell(cell); cell = new PdfPCell(new Paragraph("Customer Signature:_______________________", ReportFont)); cell.Colspan = 2; cell.HorizontalAlignment = Rectangle.ALIGN_LEFT; cell.Border = Rectangle.NO_BORDER; cell.VerticalAlignment = Element.ALIGN_BOTTOM; footerTable.AddCell(cell); cell = new PdfPCell(new Paragraph("Date:___________________", ReportFont)); cell.Colspan = 2; cell.HorizontalAlignment = Rectangle.ALIGN_LEFT; cell.Border = Rectangle.NO_BORDER; cell.VerticalAlignment = Element.ALIGN_BOTTOM; footerTable.AddCell(cell); cell = new PdfPCell(new Paragraph("Emp Signature:_____________________", ReportFont)); cell.Colspan = 2; cell.HorizontalAlignment = Rectangle.ALIGN_LEFT; cell.Border = Rectangle.NO_BORDER; cell.VerticalAlignment = Element.ALIGN_BOTTOM; footerTable.AddCell(cell); //line2 cell = new PdfPCell(new Paragraph(string.Empty, ReportFont)); cell.Colspan = 1; cell.HorizontalAlignment = Rectangle.ALIGN_LEFT; cell.Border = Rectangle.NO_BORDER; cell.VerticalAlignment = Element.ALIGN_BOTTOM; footerTable.AddCell(cell); cell = new PdfPCell(new Paragraph("Customer Name: " + layawayContractRpt.ReportObject.CustomerName, ReportFont)); cell.Colspan = 2; cell.HorizontalAlignment = Rectangle.ALIGN_LEFT; cell.Border = Rectangle.NO_BORDER; cell.VerticalAlignment = Element.ALIGN_BOTTOM; footerTable.AddCell(cell); cell = new PdfPCell(new Paragraph("Contact Number: " + layawayContractRpt.ReportObject.ContactNumber, ReportFont)); cell.Colspan = 4; cell.HorizontalAlignment = Rectangle.ALIGN_LEFT; cell.Border = Rectangle.NO_BORDER; cell.VerticalAlignment = Element.ALIGN_BOTTOM; footerTable.AddCell(cell); }
private void ReportHeader(PdfPTable headingtable, Image gif, LayawayContractReport pageEvent) { PdfPCell cell = new PdfPCell(); // heading - row 1 cell = new PdfPCell(gif); cell.Border = Rectangle.NO_BORDER; cell.HorizontalAlignment = Element.ALIGN_RIGHT; cell.VerticalAlignment = Element.ALIGN_TOP; cell.Colspan = 1; headingtable.AddCell(cell); cell = new PdfPCell(new Paragraph(string.Empty, ReportFont)); cell.Border = Rectangle.NO_BORDER; cell.HorizontalAlignment = Element.ALIGN_CENTER; cell.VerticalAlignment = Element.ALIGN_TOP; cell.Colspan = 6; headingtable.AddCell(cell); // heading - row 2 //date: cell = new PdfPCell(new Paragraph(string.Empty, ReportFont)); cell.Border = Rectangle.NO_BORDER; cell.HorizontalAlignment = Element.ALIGN_CENTER; cell.VerticalAlignment = Element.ALIGN_TOP; cell.Colspan = 4; headingtable.AddCell(cell); cell = new PdfPCell(new Paragraph("Date: ", ReportFont)); cell.Border = Rectangle.NO_BORDER; //no ticket SMurphy 3/25/2010 - Store name & Run Date overlapped cell.HorizontalAlignment = Element.ALIGN_RIGHT; cell.VerticalAlignment = Element.ALIGN_TOP; cell.Colspan = 1; headingtable.AddCell(cell); cell = new PdfPCell(new Paragraph(DateTime.Now.ToString("MM/dd/yyyy"), ReportFont)); cell.Border = Rectangle.NO_BORDER; cell.HorizontalAlignment = Element.ALIGN_LEFT; cell.VerticalAlignment = Element.ALIGN_TOP; cell.Colspan = 2; headingtable.AddCell(cell); // heading - row 3 //emp# cell = new PdfPCell(new Paragraph(string.Empty, ReportFont)); cell.Border = Rectangle.NO_BORDER; cell.PaddingLeft = 12; cell.Colspan = 4; headingtable.AddCell(cell); cell = new PdfPCell(new Paragraph("Emp #: ", ReportFont)); cell.HorizontalAlignment = Element.ALIGN_RIGHT; cell.Border = Rectangle.NO_BORDER; cell.Colspan = 1; headingtable.AddCell(cell); cell = new PdfPCell(new Paragraph(pageEvent.ReportObject.ReportEmployee, ReportFont)); cell.HorizontalAlignment = Element.ALIGN_LEFT; cell.Border = Rectangle.NO_BORDER; cell.Colspan = 2; headingtable.AddCell(cell); // heading - row 4 //empty row cell = new PdfPCell(new Paragraph(string.Empty, ReportFont)); cell.Border = Rectangle.NO_BORDER; cell.HorizontalAlignment = Element.ALIGN_LEFT; cell.PaddingLeft = 12; cell.Colspan = 7; headingtable.AddCell(cell); // heading - row 5 //To: cell = new PdfPCell(new Paragraph(string.Empty, ReportFont)); cell.HorizontalAlignment = Element.ALIGN_RIGHT; cell.Border = Rectangle.NO_BORDER; cell.Colspan = 4; headingtable.AddCell(cell); cell = new PdfPCell(new Paragraph("To: ", ReportFont)); cell.HorizontalAlignment = Element.ALIGN_RIGHT; cell.Border = Rectangle.NO_BORDER; cell.Colspan = 1; headingtable.AddCell(cell); cell = new PdfPCell(new Paragraph(pageEvent.ReportObject.ReportStore, ReportFont)); cell.HorizontalAlignment = Element.ALIGN_LEFT; cell.Border = Rectangle.NO_BORDER; cell.Colspan = 2; headingtable.AddCell(cell); // heading - row 6 //Address1 cell = new PdfPCell(new Phrase(string.Empty, ReportFont)); cell.Border = Rectangle.NO_BORDER; cell.HorizontalAlignment = Element.ALIGN_CENTER; cell.Colspan = 5; headingtable.AddCell(cell); cell = new PdfPCell(new Paragraph(pageEvent.ReportObject.ReportStoreDesc1, ReportFont)); cell.HorizontalAlignment = Element.ALIGN_LEFT; cell.Border = Rectangle.NO_BORDER; cell.Colspan = 2; headingtable.AddCell(cell); // heading - row 7 //Address 2 cell = new PdfPCell(new Phrase(string.Empty, ReportFont)); cell.Border = Rectangle.NO_BORDER; cell.HorizontalAlignment = Element.ALIGN_CENTER; cell.Colspan = 5; headingtable.AddCell(cell); cell = new PdfPCell(new Paragraph(pageEvent.ReportObject.ReportStoreDesc2, ReportFont)); cell.HorizontalAlignment = Element.ALIGN_LEFT; cell.Border = Rectangle.NO_BORDER; cell.Colspan = 2; headingtable.AddCell(cell); // heading - row 8 //empty row cell = new PdfPCell(new Phrase(string.Empty, ReportFontHeading)); cell.Border = Rectangle.NO_BORDER; cell.HorizontalAlignment = Element.ALIGN_CENTER; cell.Colspan = 7; headingtable.AddCell(cell); // heading - row 9 //empty row cell = new PdfPCell(new Phrase(string.Empty, ReportFontHeading)); cell.Border = Rectangle.NO_BORDER; cell.HorizontalAlignment = Element.ALIGN_CENTER; cell.Colspan = 7; headingtable.AddCell(cell); // heading - row 10 //Report title row cell = new PdfPCell(new Phrase(pageEvent.ReportObject.ReportTitle, ReportFontHeading)); cell.Border = Rectangle.NO_BORDER; cell.HorizontalAlignment = Element.ALIGN_CENTER; cell.Colspan = 7; headingtable.AddCell(cell); // heading - row 11 //empty row cell = new PdfPCell(new Phrase(string.Empty, ReportFont)); cell.Border = Rectangle.NO_BORDER; cell.HorizontalAlignment = Element.ALIGN_CENTER; cell.Colspan = 7; headingtable.AddCell(cell); // heading - row 12 //empty row cell = new PdfPCell(new Phrase(string.Empty, ReportFont)); cell.Border = Rectangle.NO_BORDER; cell.HorizontalAlignment = Element.ALIGN_CENTER; cell.Colspan = 7; headingtable.AddCell(cell); Phrase Spacing = new Phrase("", ReportFontMedium); Phrase Spacing2 = new Phrase("", ReportFontMedium); Phrase phraseLayawayNumberText = new Phrase("Layaway #: ", ReportFontMedium); Phrase phraseLayawayNumber = new Phrase(pageEvent.ReportObject.CurrentLayaway.TicketNumber.ToString(), ReportFontLargeBold); //Spacing.Add(phraseLayawayNumberText); phraseLayawayNumberText.Add(Spacing); phraseLayawayNumberText.Add(phraseLayawayNumber); //phraseCommentsDescription.Add(Spacing); //phraseCommentsDescription.Add(phraseComments); cell = new PdfPCell(); cell.AddElement(phraseLayawayNumberText); cell.Border = Rectangle.NO_BORDER; cell.HorizontalAlignment = Element.ALIGN_RIGHT; cell.VerticalAlignment = Rectangle.ALIGN_TOP; cell.Border = Rectangle.NO_BORDER; headingtable.AddCell(cell); // heading - row 13 //empty cell /*cell = new PdfPCell(new Phrase("Layaway #: " + pageEvent.ReportObject.CurrentLayaway.TicketNumber, ReportFontLargeSize9)); * cell.Border = Rectangle.NO_BORDER; * cell.HorizontalAlignment = Element.ALIGN_RIGHT; * cell.Colspan = 1; * headingtable.AddCell(cell);*/ //Layaway # row cell = new PdfPCell(new Phrase(string.Empty, ReportFont)); cell.Border = Rectangle.NO_BORDER; cell.HorizontalAlignment = Element.ALIGN_LEFT; cell.Colspan = 6; headingtable.AddCell(cell); // heading - row 14 //empty row /*cell = new PdfPCell(new Phrase(string.Empty, ReportFont)); * cell.Border = Rectangle.NO_BORDER; * cell.HorizontalAlignment = Element.ALIGN_LEFT; * cell.Colspan = 7; * headingtable.AddCell(cell);*/ /*cell = new PdfPCell(new Phrase(PawnUtilities.String.StringUtilities.fillString("_", 150), ReportFont)); * cell.Colspan = 7; * cell.HorizontalAlignment = Rectangle.ALIGN_LEFT; * cell.Border = Rectangle.NO_BORDER; * headingtable.AddCell(cell);*/ //runReport.ReportLines(headingtable, false, PawnUtilities.String.StringUtilities.fillString("_", 85), false, ReportFont); }
//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); }