public bool CreateReport(ReportObject.PFIMailer pfiMailer)
        {
            bool isSuccessful = false;
            var  document     = new iTextSharp.text.Document(PageSize.LETTER);

            try
            {
                PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(ReportObject.ReportTempFileFullName, FileMode.Create));
                PFIMailerDocumentPageEvents events = new PFIMailerDocumentPageEvents();
                writer.PageEvent = events;

                //MultiColumnText columns = new MultiColumnText(document.PageSize.Top - 100, document.PageSize.Height - (50));
                //columns.AddSimpleColumn(-150, document.PageSize.Width + 76);

                //set up tables, etc...
                PdfPTable table = new PdfPTable(8);
                table.WidthPercentage = 100;// document.PageSize.Width;

                runReport = new RunReport();
                //document.SetPageSize(PageSize.LETTER);
                document.SetMargins(50, 50, 30, 45);
                document.Open();

                ReportHeader(table, 8);
                //here add detail
                WriteDetail(table, pfiMailer);

                document.Add(table);
                document.Close();
                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 WriteDetail(PdfPTable detailsTable, ReportObject.PFIMailer pfiMailer)
        {
            detailsTable.AddCell(WriteBlankCellWithMinimumHeight(8, 50));
            WriteCell(detailsTable, "Dear Valued Cash America Customer,", new Font(ReportFont.BaseFont, 9), 7, Element.ALIGN_LEFT, Rectangle.NO_BORDER, false);
            detailsTable.AddCell(WriteBlankCellWithMinimumHeight(8, 20));

            WriteCell(detailsTable, "Please be advised that you have until " + pfiMailer.pfiEligibleDate.ToShortDateString() + " to redeem the property you pledged under Pawn ", new Font(ReportFont.BaseFont, 9), 7, Element.ALIGN_LEFT, Rectangle.NO_BORDER, false);
            detailsTable.AddCell(WriteBlankCellWithMinimumHeight(8, 5));

            WriteCell(detailsTable, "Ticket No. " + pfiMailer.ticketNumber + ", otherwise it will be sold.  We hope this reminder is helpful to you.", new Font(ReportFont.BaseFont, 9), 7, Element.ALIGN_LEFT, Rectangle.NO_BORDER, false);
            detailsTable.AddCell(WriteBlankCellWithMinimumHeight(8, 20));

            WriteCell(detailsTable, "Thank you for doing business with Cash America Pawn.", new Font(ReportFont.BaseFont, 9), 7, Element.ALIGN_LEFT, Rectangle.NO_BORDER, false);
            detailsTable.AddCell(WriteBlankCellWithMinimumHeight(8, 10));

            detailsTable.AddCell(WriteBlankCellWithMinimumHeight(8, 5));
            detailsTable.AddCell(WriteBlankCellWithMinimumHeight(8, 130));

            WriteCell(detailsTable, "YOU MAY EXTEND THIS LOAN", new Font(ReportFont.BaseFont, 9), 8, Element.ALIGN_LEFT, Rectangle.NO_BORDER, false);
            detailsTable.AddCell(WriteBlankCellWithMinimumHeight(8, 20));

            WriteCell(detailsTable, "EFFECTIVE AFTER JANUARY 1, 1998, A $" + pfiMailer.pfiMailerFee + " NOTIFICATION FEE WILL BE COLLECTED WHEN REDEEMING THIS LOAN.", new Font(ReportFont.BaseFont, 9), 7, Element.ALIGN_LEFT, Rectangle.NO_BORDER, false);
            detailsTable.AddCell(WriteBlankCellWithMinimumHeight(8, 100));

            detailsTable.AddCell(WriteBlankCellWithMinimumHeight(8, 50));

            detailsTable.AddCell(WriteBlankCellWithMinimumHeight(8, 5));
            detailsTable.AddCell(WriteBlankCellWithMinimumHeight(8, 5));

            detailsTable.AddCell(WriteBlankCellWithMinimumHeight(8, 5));
            detailsTable.AddCell(WriteBlankCellWithMinimumHeight(8, 5));

            detailsTable.AddCell(WriteBlankCellWithMinimumHeight(8, 5));
            detailsTable.AddCell(WriteBlankCellWithMinimumHeight(8, 5));

            detailsTable.AddCell(WriteBlankCellWithMinimumHeight(8, 5));
            detailsTable.AddCell(WriteBlankCellWithMinimumHeight(8, 25));

            detailsTable.AddCell(WriteBlankCell(8));
            WriteCell(detailsTable, "F", new Font(ReportFont.BaseFont, 9), 1, Element.ALIGN_LEFT, Rectangle.NO_BORDER, false);
            WriteCell(detailsTable, pfiMailer.storeName, new Font(ReportFont.BaseFont, 9), 3, Element.ALIGN_LEFT, Rectangle.NO_BORDER, false);
            detailsTable.AddCell(WriteBlankCell(1));
            detailsTable.AddCell(WriteBlankCell(2));
            detailsTable.AddCell(WriteBlankCell(8));

            detailsTable.AddCell(WriteBlankCell(8));
            WriteCell(detailsTable, "R", new Font(ReportFont.BaseFont, 9), 1, Element.ALIGN_LEFT, Rectangle.NO_BORDER, false);
            WriteCell(detailsTable, pfiMailer.storeAddress, new Font(ReportFont.BaseFont, 9), 3, Element.ALIGN_LEFT, Rectangle.NO_BORDER, false);
            detailsTable.AddCell(WriteBlankCell(1));
            detailsTable.AddCell(WriteBlankCell(2));
            detailsTable.AddCell(WriteBlankCell(8));

            detailsTable.AddCell(WriteBlankCell(8));
            WriteCell(detailsTable, "O", new Font(ReportFont.BaseFont, 9), 1, Element.ALIGN_LEFT, Rectangle.NO_BORDER, false);
            WriteCell(detailsTable, pfiMailer.storeCity + ", " + pfiMailer.storeState + " " + pfiMailer.storeZipCode, new Font(ReportFont.BaseFont, 9), 3, Element.ALIGN_LEFT, Rectangle.NO_BORDER, false);
            detailsTable.AddCell(WriteBlankCell(1));
            detailsTable.AddCell(WriteBlankCell(2));
            detailsTable.AddCell(WriteBlankCell(8));

            detailsTable.AddCell(WriteBlankCell(8));
            WriteCell(detailsTable, "M", new Font(ReportFont.BaseFont, 9), 1, Element.ALIGN_LEFT, Rectangle.NO_BORDER, false);
            WriteCell(detailsTable, pfiMailer.storePhone, new Font(ReportFont.BaseFont, 9), 3, Element.ALIGN_LEFT, Rectangle.NO_BORDER, false);
            detailsTable.AddCell(WriteBlankCell(1));
            detailsTable.AddCell(WriteBlankCell(2));
            detailsTable.AddCell(WriteBlankCell(8));

            detailsTable.AddCell(WriteBlankCell(8));
            detailsTable.AddCell(WriteBlankCell(1));
            detailsTable.AddCell(WriteBlankCell(3));
            WriteCell(detailsTable, "T", new Font(ReportFont.BaseFont, 9), 1, Element.ALIGN_LEFT, Rectangle.NO_BORDER, false);
            WriteCell(detailsTable, pfiMailer.customerName, new Font(ReportFont.BaseFont, 9), 3, Element.ALIGN_LEFT, Rectangle.NO_BORDER, false);
            detailsTable.AddCell(WriteBlankCell(1));
            detailsTable.AddCell(WriteBlankCell(8));

            detailsTable.AddCell(WriteBlankCell(8));
            detailsTable.AddCell(WriteBlankCell(1));
            detailsTable.AddCell(WriteBlankCell(3));
            WriteCell(detailsTable, "O", new Font(ReportFont.BaseFont, 9), 1, Element.ALIGN_LEFT, Rectangle.NO_BORDER, false);
            WriteCell(detailsTable, pfiMailer.customerAddress, new Font(ReportFont.BaseFont, 9), 3, Element.ALIGN_LEFT, Rectangle.NO_BORDER, false);
            detailsTable.AddCell(WriteBlankCell(1));
            detailsTable.AddCell(WriteBlankCell(8));

            detailsTable.AddCell(WriteBlankCell(8));
            detailsTable.AddCell(WriteBlankCell(1));
            detailsTable.AddCell(WriteBlankCell(3));
            detailsTable.AddCell(WriteBlankCell(1));
            WriteCell(detailsTable, pfiMailer.customerCity + ", " + pfiMailer.customerState + " " + pfiMailer.customerZipCode, new Font(ReportFont.BaseFont, 9), 3, Element.ALIGN_LEFT, Rectangle.NO_BORDER, false);
            detailsTable.AddCell(WriteBlankCell(1));
            detailsTable.AddCell(WriteBlankCell(8));
        }
Beispiel #3
0
        /// <summary>
        /// Retrieves PFI Mailer data based on selected PFI Mailer option and parameters
        /// </summary>
        /// <param name="dataAccessor"></param>
        /// <param name="pfiMailerOption"></param>
        /// <param name="pfiMailerObjects"></param>
        /// <param name="errorCode"></param>
        /// <param name="errorText"></param>
        /// <param name="pfiMailerAdjustmentDays"></param>
        /// <param name="startTicketNumber"></param>
        /// <param name="endTicketNumber"></param>
        /// <param name="pfiDate"></param>
        /// <returns></returns>
        public static bool ExecuteGetPFIMailerData(
            OracleDataAccessor dataAccessor,
            PFIMailerOption pfiMailerOption,
            out List <ReportObject.PFIMailer> pfiMailerObjects,
            out string errorCode,
            out string errorText,
            int pfiMailerAdjustmentDays = 0,
            int startTicketNumber       = 0,
            int endTicketNumber         = 0,
            DateTime pfiDate            = new DateTime()
            )
        {
            // initialize error output variables
            pfiMailerObjects = new List <ReportObject.PFIMailer>();
            errorCode        = String.Empty;
            errorText        = String.Empty;

            // Ensure the data accessor is valid
            if (dataAccessor == null || !dataAccessor.Initialized)
            {
                BasicExceptionHandler.Instance.AddException("ExecuteGetPFIMailerData Failed",
                                                            new ApplicationException("ExecuteGetPFIMailerData Failed: Data accessor instance is invalid"));
                return(false);
            }

            // Set up input variables
            var inParams = new List <OracleProcParam>
            {
                new OracleProcParam("p_pfi_date", pfiDate.ToShortDateString()),
                new OracleProcParam("p_store_number", GlobalDataAccessor.Instance.DesktopSession.CurrentSiteId.StoreNumber),
                new OracleProcParam("p_pfi_mailer_adjustment_days", pfiMailerAdjustmentDays),
                new OracleProcParam("p_startTicketNumber", startTicketNumber),
                new OracleProcParam("p_endTicketNumber", endTicketNumber),
                new OracleProcParam("p_pfiMailerOption", (int)pfiMailerOption)
            };


            // Set up output
            DataSet outputDataSet;
            var     retVal     = false;
            var     refCursArr = new List <PairType <string, string> >
            {
                new PairType <string, string>("pfi_mailer_info", "o_pfi_mailer_info")
            };

            try
            {
                retVal = dataAccessor.issueSqlStoredProcCommand(
                    "ccsowner", "pawn_mdse_procs",
                    "get_pfi_mailer_data", inParams,
                    refCursArr, "o_return_code",
                    "o_return_text",
                    out outputDataSet);

                errorCode = dataAccessor.ErrorCode;
                errorText = dataAccessor.ErrorDescription;
            }
            catch (OracleException oEx)
            {
                BasicExceptionHandler.Instance.AddException("ExecuteGetPFIMailerData Failed", oEx);
                errorCode = " --- ExecuteGetPFIMailerData";
                errorText = " --- OracleException thrown: " + oEx.Message;
                return(false);
            }

            if (retVal == false)
            {
                BasicExceptionHandler.Instance.AddException("ExecuteGetPFIMailerData Failed: return value is false", new ApplicationException());
                errorCode = dataAccessor.ErrorCode + " -- ExecuteGetPFIMailerData";
                errorText = dataAccessor.ErrorDescription + " -- Return value is false";
                return(false);
            }

            if (outputDataSet == null || !outputDataSet.IsInitialized ||
                (outputDataSet.Tables.Count <= 0))
            {
                return(false);
            }

            pfiMailerObjects = new List <ReportObject.PFIMailer>();

            ReportObject.PFIMailer pfiMailerObject;

            foreach (DataRow pfiMailerDataRow in outputDataSet.Tables[0].Rows)
            {
                var pfiMailerFee = new BusinessRulesProcedures(GlobalDataAccessor.Instance.DesktopSession).GetPFIMailerFee(GlobalDataAccessor.Instance.CurrentSiteId);

                pfiMailerObject = new ReportObject.PFIMailer();

                pfiMailerObject.ticketNumber    = Utilities.GetIntegerValue(pfiMailerDataRow["ticket_number"]);
                pfiMailerObject.customerNumber  = Utilities.GetIntegerValue(pfiMailerDataRow["customer_number"]);
                pfiMailerObject.originalPFINote = Utilities.GetDateTimeValue(pfiMailerDataRow["PFI_NOTE"]);
                pfiMailerObject.printNotice     = pfiMailerDataRow["PRINT_NOTICE"].ToString();
                pfiMailerObject.customerName    = pfiMailerDataRow["customer_name"].ToString();
                pfiMailerObject.customerId      = pfiMailerDataRow["customer_id"].ToString();
                pfiMailerObject.customerAddress = pfiMailerDataRow["customer_address"].ToString();
                pfiMailerObject.customerCity    = pfiMailerDataRow["customer_city"].ToString();
                pfiMailerObject.customerState   = pfiMailerDataRow["customer_state"].ToString();
                pfiMailerObject.customerZipCode = pfiMailerDataRow["customer_zipCode"].ToString();
                pfiMailerObject.pfiEligibleDate = Utilities.GetDateTimeValue(pfiMailerDataRow["pfi_eligible_date"]);
                pfiMailerObject.storeName       = pfiMailerDataRow["store_name"].ToString();
                pfiMailerObject.storeNumber     = Utilities.GetIntegerValue(pfiMailerDataRow["store_number"]);
                pfiMailerObject.storeAddress    = pfiMailerDataRow["store_address"].ToString();
                pfiMailerObject.storeCity       = pfiMailerDataRow["store_city"].ToString();
                pfiMailerObject.storeState      = pfiMailerDataRow["store_state"].ToString();
                pfiMailerObject.storeZipCode    = pfiMailerDataRow["store_zipCode"].ToString();
                pfiMailerObject.storePhone      = pfiMailerDataRow["store_phone"].ToString();
                pfiMailerObject.pfiMailerFee    = pfiMailerFee;

                pfiMailerObjects.Add(pfiMailerObject);
            }

            // method completed successfully
            return(true);
        }