public bool CreateReport()
        {
            bool isSuccessful = false;

            iTextSharp.text.Document document = new iTextSharp.text.Document(PageSize.LEGAL);
            try
            {
                //set up RunReport event overrides & create doc
                DetailInventoryReport events = new DetailInventoryReport();
                PdfWriter             writer = PdfWriter.GetInstance(document, new FileStream(reportObject.ReportTempFileFullName, FileMode.Create));
                writer.PageEvent = events;

                //set up tables, etc...
                var      table = new PdfPTable(21);
                PdfPCell cell  = new PdfPCell();
                var      gif   = Image.GetInstance(Resources.logo, BaseColor.WHITE);

                _reportFont           = FontFactory.GetFont("Arial", 7, iTextSharp.text.Font.NORMAL);
                _reportFontLargeBold  = FontFactory.GetFont("Arial", 8, iTextSharp.text.Font.BOLD);
                _reportFontUnderlined = FontFactory.GetFont("Arial", 8, iTextSharp.text.Font.UNDERLINE);

                gif.ScalePercent(35);
                runReport = new RunReport();

                document.SetPageSize(PageSize.LEGAL.Rotate());
                document.SetMargins(-100, -100, 10, 45);
                document.AddTitle(string.Format("{0}: {1}", reportObject.ReportTitle, DateTime.Now.ToString("MM/dd/yyyy")));

                ReportHeader(table, gif);
                ColumnHeaders(table);
                ReportDetail(table);
                ReportSummary(table);

                table.HeaderRows = 11;
                document.Open();
                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);
        }
Beispiel #2
0
        //create report
        public bool CreateReport(IPdfLauncher pdfLauncher)
        {
            bool isSuccessful = false;

            try
            {
                //set up fonts
                reportObject.CreateTemporaryFullName();
                switch (reportObject.ReportNumber)
                {
                //no ticket 3/4/2010 S.Murphy Added Gun Disposition

                case (int)ReportIDs.RefurbList:    //CACC Sales report
                    RefurbList refurbList = new RefurbList(pdfLauncher);
                    reportObject.CreateTemporaryFullName("RefurbList");
                    refurbList.ReportObject = this.reportObject;
                    isSuccessful            = refurbList.CreateReport();

                    break;

                case (int)ReportIDs.RifleDispositionReport:  //Multi Rifle Disposition report
                case (int)ReportIDs.GunDispositionReport:    //Gun Disposition report
                    GunDispositionReport gunDispositionReport = new GunDispositionReport(pdfLauncher);
                    gunDispositionReport.reportObject = this.reportObject;
                    isSuccessful = gunDispositionReport.CreateReport();
                    break;

                case (int)ReportIDs.GunAuditReportATFOpenRecords:    //Gun Disposition report
                    ATFOpenRecordsReport atfOpenRecordsReport = new ATFOpenRecordsReport(pdfLauncher);
                    reportObject.CreateTemporaryFullName("ATFReport");
                    atfOpenRecordsReport.ReportObject = this.reportObject;
                    isSuccessful = atfOpenRecordsReport.CreateReport();
                    break;

                case (int)ReportIDs.LoanAuditReport:    //Loan Audit report
                    LoanAuditReport loanAuditReport = new LoanAuditReport();
                    loanAuditReport.reportObject = this.reportObject;
                    isSuccessful = loanAuditReport.CreateReport();
                    break;

                case (int)ReportIDs.FullLocationsReport:    //Loan Audit report
                    FullLocationsReport fullLocationsReport = new FullLocationsReport();
                    fullLocationsReport.reportObject = this.reportObject;
                    isSuccessful = fullLocationsReport.CreateReport();
                    break;

                case (int)ReportIDs.Snapshot:    //Snapshot report
                    SnapshotReport snapshotReport = new SnapshotReport();
                    snapshotReport.reportObject = this.reportObject;
                    isSuccessful = snapshotReport.CreateReport();
                    break;

                case (int)ReportIDs.InPawnJewelryLocationReport:    //In Pawn Jewelry Locations report
                    InPawnJewelryLocationsReport inPawnJewelryLocationsReport = new InPawnJewelryLocationsReport();
                    inPawnJewelryLocationsReport.reportObject = this.reportObject;
                    isSuccessful = inPawnJewelryLocationsReport.CreateReport();
                    break;

                case (int)ReportIDs.GunAuditReport:    //Gun Audit report
                    GunAuditReport gunAuditReport = new GunAuditReport();
                    gunAuditReport.reportObject = this.reportObject;
                    isSuccessful = gunAuditReport.CreateReport();
                    break;

                case (int)ReportIDs.DetailInventory:    //Gun Disposition report
                    DetailInventoryReport detailInventoryReport = new DetailInventoryReport();
                    detailInventoryReport.reportObject = this.reportObject;
                    isSuccessful = detailInventoryReport.CreateReport();
                    break;

                case (int)ReportIDs.CashDrawerLedgerReport:    //Ledger report
                    CashDrawerLedger ledgerFrm = new CashDrawerLedger();
                    ledgerFrm.RptObject = reportObject;
                    ledgerFrm.Print();
                    isSuccessful = true;
                    break;

                case (int)ReportIDs.CACCSales:    //CACC Sales report
                    CACCSalesReport caccReport = new CACCSalesReport(pdfLauncher);
                    caccReport.reportObject = this.reportObject;
                    isSuccessful            = caccReport.CreateReport(reportObject.CACCSalesData);

                    break;

                case (int)ReportIDs.JewelryCount:
                    if (this.reportObject.ReportDetail.Equals("Detailed"))
                    {
                        JewelryCountDetailReport jewelryCountWorksheet = new JewelryCountDetailReport(pdfLauncher);
                        reportObject.ReportTitle           = "Jewelry Count Worksheet";
                        jewelryCountWorksheet.reportObject = this.reportObject;
                        isSuccessful = jewelryCountWorksheet.CreateReport(reportObject.JewleryCountDetailData);
                    }
                    else
                    {
                        JewelryCountSummaryReport jewelryCountSummary = new JewelryCountSummaryReport(pdfLauncher);
                        reportObject.ReportTitle         = "Jewelry Count Summary";
                        jewelryCountSummary.reportObject = this.reportObject;
                        isSuccessful = jewelryCountSummary.CreateReport(reportObject.JewleryCountSummaryData);
                    }
                    break;

                case (int)ReportIDs.DailySales:
                    if (this.reportObject.ReportDetail.Equals("Detail"))
                    {
                        DailySalesReport dailySalesReport = new DailySalesReport(pdfLauncher);
                        dailySalesReport.reportObject = this.reportObject;
                        isSuccessful = dailySalesReport.CreateReport(reportObject.DailySalesData);
                    }
                    else
                    {
                        DailySalesReport_Summary summary = new DailySalesReport_Summary(pdfLauncher);
                        summary.reportObject = this.reportObject;
                        isSuccessful         = summary.CreateReport(reportObject.DailySalesSummaryData);
                    }
                    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);
        }