Exemple #1
0
        private void ReportHeader(PdfPTable table, Image gif, ItemDetailReport pageEvent, int colspan)
        {
            PdfPCell cell = new PdfPCell();

            //  row 1
            cell        = new PdfPCell(gif);
            cell.Border = Rectangle.NO_BORDER;
            cell.HorizontalAlignment = Element.ALIGN_LEFT;
            cell.VerticalAlignment   = Element.ALIGN_TOP;
            cell.Colspan             = colspan;
            table.AddCell(cell);
            string dateMade = _pawnInfo[_pawnInfoRowNum]["DATE_MADE"] is System.DBNull ? string.Empty : Convert.ToDateTime(_pawnInfo[_pawnInfoRowNum]["DATE_MADE"]).ToShortDateString();

            //row 2
            WriteCell(table, string.Empty, ReportFont, colspan, Element.ALIGN_LEFT, Element.ALIGN_TOP, Rectangle.NO_BORDER);

            WriteCell(table, DateTime.Now.ToString(), ReportFontSmall, colspan, Element.ALIGN_LEFT, Element.ALIGN_TOP, Rectangle.NO_BORDER);
            WriteCell(table, "Item Detail", ReportFontHeading, colspan, Element.ALIGN_CENTER, Element.ALIGN_TOP, Rectangle.NO_BORDER);

            WriteCell(table, string.Empty, ReportFont, colspan, Element.ALIGN_LEFT, Element.ALIGN_TOP, Rectangle.NO_BORDER);
            WriteCell(table, string.Empty, ReportFont, colspan, Element.ALIGN_LEFT, Element.ALIGN_TOP, Rectangle.NO_BORDER);
            WriteCell(table, string.Empty, ReportFont, colspan, Element.ALIGN_LEFT, Element.ALIGN_TOP, Rectangle.NO_BORDER);

            WritePhrase(table, CombinePhrases("Name:", _pawnInfo[_pawnInfoRowNum]["CUST_NAME"].ToString()), ReportFontBold, 1, Element.ALIGN_LEFT, Element.ALIGN_TOP, Rectangle.NO_BORDER);
            WritePhrase(table, CombinePhrases("Cust #:", _pawnInfo[_pawnInfoRowNum]["CUSTOMERNUMBER"].ToString()), ReportFontBold, 1, Element.ALIGN_LEFT, Element.ALIGN_TOP, Rectangle.NO_BORDER);
            WritePhrase(table, CombinePhrases("DOB:", ReportObject.InquiryItemDetails_DOB), ReportFontBold, 1, Element.ALIGN_LEFT, Element.ALIGN_TOP, Rectangle.NO_BORDER);
            WritePhrase(table, CombinePhrases("Customer Since:", ReportObject.InquiryItemDetails_Since), ReportFontBold, 1, Element.ALIGN_LEFT, Element.ALIGN_TOP, Rectangle.NO_BORDER);
            WriteCell(table, string.Empty, ReportFont, colspan, Element.ALIGN_LEFT, Element.ALIGN_TOP, Rectangle.BOTTOM_BORDER);

            WritePhrase(table, CombinePhrases("Ticket #:", _pawnInfo[_pawnInfoRowNum]["TICKET_NUMBER"].ToString()), ReportFontBold, 1, Element.ALIGN_LEFT, Element.ALIGN_TOP, Rectangle.NO_BORDER);
            WritePhrase(table, CombinePhrases("Date Made:", dateMade), ReportFontBold, 1, Element.ALIGN_LEFT, Element.ALIGN_TOP, Rectangle.NO_BORDER);
            WritePhrase(table, CombinePhrases("Loan Amount:", Convert.ToDecimal(_pawnInfo[_pawnInfoRowNum]["PRIN_AMOUNT"]).ToString("C")), ReportFontBold, 1, Element.ALIGN_LEFT, Element.ALIGN_TOP, Rectangle.NO_BORDER);
            WritePhrase(table, CombinePhrases("Status:", _pawnInfo[_pawnInfoRowNum]["STATUS_CD"].ToString()), ReportFontBold, 1, Element.ALIGN_LEFT, Element.ALIGN_TOP, Rectangle.NO_BORDER);
            WriteCell(table, string.Empty, ReportFont, colspan, Element.ALIGN_LEFT, Element.ALIGN_TOP, Rectangle.BOTTOM_BORDER);
        }
Exemple #2
0
        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
                _pageCount  = 1;
                _pawnInfo   = ReportObject.InquiryItemDetails_theData;
                _pawnMdse   = ReportObject.InquiryItemDetails_thisData;
                _pawnRowNum = ReportObject.InquiryItemDetails_RowNumber;
                ItemDetailReport 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(-38, document.PageSize.Width + 50);

                //set up tables, etc...
                int       detailTablecolspan = 8;
                PdfPTable table = new PdfPTable(detailTablecolspan);
                table.WidthPercentage = 85;// document.PageSize.Width;
                PdfPCell cell = new PdfPCell();
                Image    gif  = Image.GetInstance(Resources.logo, BaseColor.WHITE);
                gif.ScalePercent(25);
                runReport = new RunReport();
                document.Open();
                document.SetPageSize(PageSize.HALFLETTER.Rotate());
                document.SetMargins(-100, -100, 10, 45);
                document.AddTitle(ReportObject.ReportTitle + ": " + DateTime.Now.ToString("MM/dd/yyyy"));

                //here add detail

                WriteDetail(table, detailTablecolspan);
                columns.AddElement(table);
                document.Add(columns);


                document.Close();
                //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;
            }
            catch (Exception e)
            {
                ReportObject.ReportError      = e.Message;
                ReportObject.ReportErrorLevel = (int)LogLevel.ERROR;
            }
            return(isSuccessful);
        }