private void WriteRetailSaleCustomerSectionHeader(PdfPTable columnsTable, ReportObject.RetailSaleCustomer retailSaleCustomer)
 {
     if (retailSaleCustomer.customerName != String.Empty)
     {
         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, "Customer", ReportFontHeading, 11, Element.ALIGN_LEFT, Rectangle.NO_BORDER);
         WriteCell(columnsTable, String.Empty, ReportFontBold, 12, Element.ALIGN_RIGHT, Rectangle.BOTTOM_BORDER);
     }
 }
        private void WriteRetailSaleCustomerSection(PdfPTable detailsTable, Int32 columnCount, ReportObject.RetailSaleCustomer retailSaleCustomer)
        {
            if (retailSaleCustomer.customerName != String.Empty)
            {
                WriteCell(detailsTable, String.Empty, ReportFontMedium, 2, Element.ALIGN_CENTER, Rectangle.NO_BORDER, false);
                WriteCell(detailsTable, "Customer #:", ReportFontBold, 1, Element.ALIGN_RIGHT, Rectangle.NO_BORDER, false);
                WriteCell(detailsTable, retailSaleCustomer.customerNumber, ReportFontMedium, 1, Element.ALIGN_LEFT, Rectangle.NO_BORDER, false);
                WriteCell(detailsTable, "DOB:", ReportFontBold, 1, Element.ALIGN_RIGHT, Rectangle.NO_BORDER, false);
                WriteCell(detailsTable, retailSaleCustomer.DOB.ToShortDateString(), ReportFontMedium, 1, Element.ALIGN_LEFT, Rectangle.NO_BORDER, false);
                WriteCell(detailsTable, "Sex:", ReportFontBold, 1, Element.ALIGN_RIGHT, Rectangle.NO_BORDER, false);
                WriteCell(detailsTable, retailSaleCustomer.height, ReportFontMedium, 1, Element.ALIGN_LEFT, Rectangle.NO_BORDER, false);
                WriteCell(detailsTable, "Wt:", ReportFontBold, 1, Element.ALIGN_RIGHT, Rectangle.NO_BORDER, false);
                WriteCell(detailsTable, retailSaleCustomer.weight, 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, "Name:", ReportFontBold, 1, Element.ALIGN_RIGHT, Rectangle.NO_BORDER, false);
                WriteCell(detailsTable, retailSaleCustomer.customerName, ReportFontMedium, 1, Element.ALIGN_LEFT, Rectangle.NO_BORDER, false);
                WriteCell(detailsTable, "Phone:", ReportFontBold, 1, Element.ALIGN_RIGHT, Rectangle.NO_BORDER, false);
                WriteCell(detailsTable, retailSaleCustomer.phone, ReportFontMedium, 1, Element.ALIGN_LEFT, Rectangle.NO_BORDER, false);
                WriteCell(detailsTable, "Race:", ReportFontBold, 1, Element.ALIGN_RIGHT, Rectangle.NO_BORDER, false);
                WriteCell(detailsTable, retailSaleCustomer.race, ReportFontMedium, 1, Element.ALIGN_LEFT, Rectangle.NO_BORDER, false);
                WriteCell(detailsTable, "Ht:", ReportFontBold, 1, Element.ALIGN_RIGHT, Rectangle.NO_BORDER, false);
                WriteCell(detailsTable, retailSaleCustomer.height, 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, "Address:", ReportFontBold, 1, Element.ALIGN_RIGHT, Rectangle.NO_BORDER, false);
                WriteCell(detailsTable, retailSaleCustomer.customerAddress, ReportFontMedium, 1, Element.ALIGN_LEFT, Rectangle.NO_BORDER, false);
                WriteCell(detailsTable, "Customer ID:", ReportFontBold, 1, Element.ALIGN_RIGHT, Rectangle.NO_BORDER, false);
                WriteCell(detailsTable, retailSaleCustomer.customerId, ReportFontMedium, 1, 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, "Hair:", ReportFontBold, 1, Element.ALIGN_RIGHT, Rectangle.NO_BORDER, false);
                WriteCell(detailsTable, retailSaleCustomer.hairColorCode, 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, retailSaleCustomer.city + " " + retailSaleCustomer.state + " " + retailSaleCustomer.zipCode, ReportFontMedium, 1, 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, 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, "Eyes:", ReportFontBold, 1, Element.ALIGN_RIGHT, Rectangle.NO_BORDER, false);
                WriteCell(detailsTable, retailSaleCustomer.eyeColorCode, 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, 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, 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, 1, Element.ALIGN_RIGHT, 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, 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, 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, 1, Element.ALIGN_RIGHT, 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);
            }
        }
        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);
        }