public bool CreateReport()
        {
            bool isSuccessful = false;

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

                //set up tables, etc...
                PdfPTable table       = new PdfPTable(11);
                PdfPTable footerTable = new PdfPTable(11);
                PdfPCell  cell        = new PdfPCell();
                Image     gif         = Image.GetInstance(Common.Properties.Resources.logo, BaseColor.WHITE);
                footerTable.HorizontalAlignment = Rectangle.ALIGN_BOTTOM;
                _reportFont           = FontFactory.GetFont("Arial", 8, iTextSharp.text.Font.NORMAL);
                _reportFontLargeBold  = FontFactory.GetFont("Arial", 8, iTextSharp.text.Font.BOLD);
                _reportFontUnderlined = FontFactory.GetFont("Arail", 8, iTextSharp.text.Font.UNDERLINE);

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

                document.SetPageSize(PageSize.HALFLETTER.Rotate());
                document.SetMargins(-40, -40, 5, 23);
                document.AddTitle(string.Empty);

                ReportHeader(table, writer);
                ReportDetail(table);
                ReportSummary(footerTable);

                table.HeaderRows = 11;
                document.Open();
                document.Add(table);
                document.Add(footerTable);
                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);
        }
Exemple #2
0
        private void buttonSubmit_Click(object sender, EventArgs e)
        {
            bool         returnValue = false;
            DialogResult dgr         = DialogResult.Retry;

            //Release police hold
            if (!PoliceSeize && !ReleaseToClaimant)
            {
                do
                {
                    if (!customTextBoxAgency.isValid || !customTextBoxBadgeNumber.isValid ||
                        !customTextBoxOfficerFirstName.isValid || !customTextBoxOfficerLastName.isValid ||
                        !customTextBoxPhoneAreaCode.isValid || !customTextBoxPhoneNumber.isValid ||
                        richTextBoxReason.Text.Trim().Length <= 0)
                    {
                        MessageBox.Show("Please enter all the required fields and submit");
                        return;
                    }
                    returnValue = HoldsProcedures.RemovePoliceHolds(policeHolds, this.richTextBoxReason.Text,
                                                                    customTextBoxOfficerFirstName.Text,
                                                                    customTextBoxOfficerLastName.Text,
                                                                    customTextBoxBadgeNumber.Text,
                                                                    customTextBoxAgency.Text,
                                                                    customTextBoxCaseNumber.Text,
                                                                    customTextBoxPhoneAreaCode.Text,
                                                                    customTextBoxPhoneNumber.Text,
                                                                    customTextBoxPhoneExt.Text);
                    if (returnValue)
                    {
                        MessageBox.Show("selected transactions released from police hold successfully");
                        break;
                    }
                    else
                    {
                        dgr = MessageBox.Show(Commons.GetMessageString("ProcessingError"), "Error", MessageBoxButtons.RetryCancel);
                    }
                }while (dgr == DialogResult.Retry);
            }
            //Process police seize
            if (PoliceSeize)
            {
                if (!customTextBoxAgency.isValid || !customTextBoxBadgeNumber.isValid ||
                    !customTextBoxOfficerFirstName.isValid || !customTextBoxOfficerLastName.isValid ||
                    !customTextBoxPhoneAreaCode.isValid || !customTextBoxPhoneNumber.isValid ||
                    richTextBoxReason.Text.Trim().Length <= 0 || !customTextBoxCaseNumber.isValid)
                {
                    MessageBox.Show("Please enter all the required fields and submit");
                    return;
                }
                CustomerVO currentCustomer = GlobalDataAccessor.Instance.DesktopSession.ActiveCustomer;
                foreach (HoldData policeHold in policeHolds)
                {
                    policeHold.HoldComment = richTextBoxReason.Text;
                }
                PoliceInfo policeInfo = new PoliceInfo
                {
                    Agency           = customTextBoxAgency.Text,
                    BadgeNumber      = customTextBoxBadgeNumber.Text,
                    CaseNumber       = customTextBoxCaseNumber.Text,
                    OfficerFirstName = customTextBoxOfficerFirstName.Text,
                    OfficerLastName  = customTextBoxOfficerLastName.Text,
                    PhoneAreaCode    = customTextBoxPhoneAreaCode.Text,
                    PhoneExtension   = customTextBoxPhoneExt.Text,
                    PhoneNumber      = customTextBoxPhoneNumber.Text,
                    RequestType      = ""
                };

                do
                {
                    int seizeNumber = 0;

                    returnValue = HoldsProcedures.AddPoliceSeize(
                        policeHolds, policeHolds[0].HoldComment,
                        policeInfo, currentCustomer, out seizeNumber);
                    if (returnValue && seizeNumber > 0)
                    {
                        policeInfo.SeizeNumber = seizeNumber;
                        ReceiptDetailsVO rDVO = new ReceiptDetailsVO();
                        if (!HoldsProcedures.insertPoliceReceipt(policeHolds, ref rDVO))
                        {
                            FileLogger.Instance.logMessage(LogLevel.ERROR, null, "Receipt details could not be entered for police seize " + seizeNumber);
                        }

                        MessageBox.Show("Selected items police seized successfully");
                        //Print police seize document
                        foreach (HoldData policehold in policeHolds)
                        {
                            policehold.PoliceInformation = policeInfo;
                        }
                        //Call print Police seize form if print is enabled
                        if (SecurityAccessor.Instance.EncryptConfig.ClientConfig.ClientConfiguration.PrintEnabled)
                        {
                            //PoliceSeizeform seizeFrm = new PoliceSeizeform();
                            //seizeFrm.PoliceSeizeLoans = policeHolds;
                            //seizeFrm.ShowDialog();

                            //Calling policeseizereport(Itextsharp) instead of bitmap(policeseizeform) calling
                            var policeseizereport = new Reports.PoliceSeizeReport();
                            var reportObject      = new ReportObject();
                            reportObject.ReportTempFileFullName      = SecurityAccessor.Instance.EncryptConfig.ClientConfig.GlobalConfiguration.BaseLogPath + "\\Police Seize" + DateTime.Now.ToString("MMddyyyyhhmmssFFFFFFF") + ".pdf";
                            policeseizereport.reportObject           = reportObject;
                            policeseizereport.ReportTempFileFullName = reportObject.ReportTempFileFullName;
                            policeseizereport.STORE_NAME             = GlobalDataAccessor.Instance.CurrentSiteId.StoreName;
                            policeseizereport.STORE_ADDRESS          = GlobalDataAccessor.Instance.CurrentSiteId.StoreAddress1;
                            policeseizereport.STORE_CITY             = GlobalDataAccessor.Instance.CurrentSiteId.StoreCityName;
                            policeseizereport.STORE_STATE            = GlobalDataAccessor.Instance.CurrentSiteId.State;
                            policeseizereport.STORE_ZIP       = GlobalDataAccessor.Instance.CurrentSiteId.StoreZipCode;
                            policeseizereport.CurrentCust     = GlobalDataAccessor.Instance.DesktopSession.ActiveCustomer;
                            policeseizereport.EmpNo           = GlobalDataAccessor.Instance.DesktopSession.UserName.ToLowerInvariant();
                            policeseizereport.TransactionDate = ShopDateTime.Instance.ShopDate.FormatDate();
                            policeseizereport.HoldData        = policeHolds[0];
                            policeseizereport.CustHomeAddr    = GlobalDataAccessor.Instance.DesktopSession.ActiveCustomer.CustomerAddress[0];
                            policeseizereport.CreateReport();
                            string strReturnMessage;
                            if (GlobalDataAccessor.Instance.DesktopSession.PDALaserPrinter.IsValid)
                            {
                                if (FileLogger.Instance.IsLogInfo)
                                {
                                    FileLogger.Instance.logMessage(LogLevel.INFO, this, "Printing PoliceSeize report on PDA Laser printer: {0}",
                                                                   GlobalDataAccessor.Instance.DesktopSession.PDALaserPrinter);
                                }
                                strReturnMessage = PrintingUtilities.printDocument(
                                    reportObject.ReportTempFileFullName,
                                    GlobalDataAccessor.Instance.DesktopSession.PDALaserPrinter.IPAddress,
                                    GlobalDataAccessor.Instance.DesktopSession.PDALaserPrinter.Port,
                                    2);
                            }
                            else if (GlobalDataAccessor.Instance.DesktopSession.LaserPrinter.IsValid)
                            {
                                if (FileLogger.Instance.IsLogWarn)
                                {
                                    FileLogger.Instance.logMessage(LogLevel.WARN, this,
                                                                   "Could not find valid PDA laser printer to print the PoliceSeize report." + Environment.NewLine +
                                                                   " Printing on default pawn laser printer: {0}",
                                                                   GlobalDataAccessor.Instance.DesktopSession.LaserPrinter);
                                }
                                strReturnMessage = PrintingUtilities.printDocument(
                                    reportObject.ReportTempFileFullName,
                                    GlobalDataAccessor.Instance.DesktopSession.LaserPrinter.IPAddress,
                                    GlobalDataAccessor.Instance.DesktopSession.LaserPrinter.Port,
                                    2);
                            }
                            else
                            {
                                if (FileLogger.Instance.IsLogError)
                                {
                                    FileLogger.Instance.logMessage(LogLevel.ERROR, this,
                                                                   "Could not find a valid laser printer to print the PoliceSeize report");
                                }
                                strReturnMessage = "FAIL - NO PRINTER FOUND";
                            }
                            if (strReturnMessage.IndexOf("SUCCESS", StringComparison.OrdinalIgnoreCase) == -1)
                            {
                                if (FileLogger.Instance.IsLogError)
                                {
                                    FileLogger.Instance.logMessage(LogLevel.ERROR, this,
                                                                   "Cannot print the PoliceSeize report: " + strReturnMessage);
                                }
                            }
                        }

                        break;
                    }

                    dgr = MessageBox.Show(Commons.GetMessageString("ProcessingError"), "Error", MessageBoxButtons.RetryCancel);
                }while (dgr == DialogResult.Retry);
            }
            //Process Release to claimant
            if (ReleaseToClaimant)
            {
                //Store the police info in session
                if (GlobalDataAccessor.Instance.DesktopSession.PoliceInformation == null)
                {
                    if (!customTextBoxAgency.isValid || !customTextBoxBadgeNumber.isValid ||
                        !customTextBoxOfficerFirstName.isValid || !customTextBoxOfficerLastName.isValid ||
                        !customTextBoxPhoneAreaCode.isValid || !customTextBoxPhoneNumber.isValid ||
                        richTextBoxReason.Text.Trim().Length <= 0)
                    {
                        MessageBox.Show("Please enter all the required fields and submit");
                        return;
                    }
                    foreach (HoldData policeHold in policeHolds)
                    {
                        policeHold.HoldComment = richTextBoxReason.Text;
                    }
                    PoliceInfo policeInfo = new PoliceInfo
                    {
                        Agency           = customTextBoxAgency.Text,
                        BadgeNumber      = customTextBoxBadgeNumber.Text,
                        CaseNumber       = customTextBoxCaseNumber.Text,
                        OfficerFirstName = customTextBoxOfficerFirstName.Text,
                        OfficerLastName  = customTextBoxOfficerLastName.Text,
                        PhoneAreaCode    = customTextBoxPhoneAreaCode.Text,
                        PhoneExtension   = customTextBoxPhoneExt.Text,
                        PhoneNumber      = customTextBoxPhoneNumber.Text
                    };
                    GlobalDataAccessor.Instance.DesktopSession.PoliceInformation = policeInfo;
                    GlobalDataAccessor.Instance.DesktopSession.ReleaseToClaimant = true;
                    NavControlBox.IsCustom     = true;
                    NavControlBox.CustomDetail = "FindClaimant";
                    this.NavControlBox.Action  = NavBox.NavAction.BACKANDSUBMIT;
                }
                else
                {
                    bool       gunInvolved     = false;
                    CustomerVO currentCustomer = GlobalDataAccessor.Instance.DesktopSession.ActiveCustomer;
                    //Check if any of the loans being released has a gun

                    foreach (HoldData pl in policeHolds)
                    {
                        var gunItems = from pItem in pl.Items
                                       where pItem.GunNumber > 0
                                       select pItem;
                        if (gunItems.Any())
                        {
                            gunInvolved = true;
                            break;
                        }
                    }
                    //if gun involved check for cwp
                    bool backgroundCheck = false;
                    if (gunInvolved)
                    {
                        /*DateTime currentDate = ShopDateTime.Instance.ShopDate;
                         * string strStoreState = GlobalDataAccessor.Instance.CurrentSiteId.State;
                         * if (currentCustomer.HasValidConcealedWeaponsPermitInState(strStoreState, currentDate))
                         * {
                         *  if (CustomerProcedures.IsBackgroundCheckRequired())
                         *  {
                         *      FirearmsBackgroundCheck backgroundcheckFrm = new FirearmsBackgroundCheck();
                         *      backgroundcheckFrm.ShowDialog(this);
                         *  }
                         *  else //If the background check is not needed
                         *      CashlinxDesktopSession.Instance.BackgroundCheckCompleted = true;
                         * }
                         * //else if they do not have CWP or not a CWP in the store state or expired
                         * //then show the background check form
                         * else
                         * {
                         *  FirearmsBackgroundCheck backgroundcheckFrm = new FirearmsBackgroundCheck();
                         *  backgroundcheckFrm.ShowDialog(this);
                         * }*/
                        FirearmsBackgroundCheck backgroundcheckFrm = new FirearmsBackgroundCheck();
                        backgroundcheckFrm.ShowDialog(this);
                        if (GlobalDataAccessor.Instance.DesktopSession.BackgroundCheckCompleted)
                        {
                            backgroundCheck = true;
                        }
                    }
                    else
                    {
                        backgroundCheck = true;
                    }

                    if (backgroundCheck)
                    {
                        do
                        {
                            returnValue = HoldsProcedures.AddReleaseToClaimant(policeHolds, policeHolds[0].HoldComment,
                                                                               GlobalDataAccessor.Instance.DesktopSession.PoliceInformation, currentCustomer);
                            if (returnValue)
                            {
                                MessageBox.Show("selected transactions released to claimant successfully");
                                //Print RTC form
                                foreach (var policeHold in policeHolds)
                                {
                                    policeHold.PoliceInformation = GlobalDataAccessor.Instance.DesktopSession.PoliceInformation;
                                    policeHold.RestitutionPaid   = radioButtonYes.Checked;

                                    if (panelRestitution.Visible == true && radioButtonYes.Checked == true)
                                    {
                                        // there was restitution paid
                                        if (customTextBoxResAmount.Text.Trim() == "")
                                        {
                                            // Probably should have caught this before
                                            policeHold.RestitutionAmount = 0;
                                            MessageBox.Show("Please enter the restitution amount!", "Restitution amount missing");
                                            customTextBoxResAmount.Focus();
                                            return;
                                        }
                                    }
                                    else
                                    {
                                        // No restitution paid
                                        policeHold.RestitutionPaid   = false;
                                        policeHold.RestitutionAmount = 0;
                                    }
                                }
                                //Call print RTC if print is enabled
                                if (SecurityAccessor.Instance.EncryptConfig.ClientConfig.ClientConfiguration.PrintEnabled)
                                {
                                    var rtcprintFrm = new RTCform();
                                    rtcprintFrm.RTCLoans = policeHolds;

                                    rtcprintFrm.ShowDialog();
                                }
                                break;
                            }
                            dgr = MessageBox.Show(Commons.GetMessageString("ProcessingError"), "Error", MessageBoxButtons.RetryCancel);
                        }while (dgr == DialogResult.Retry);
                    }
                    else
                    {
                        MessageBox.Show("Background check not completed. selected transactions not released to claimant");
                        RemoveTempStatusOnLoans();
                    }

                    GlobalDataAccessor.Instance.DesktopSession.PoliceInformation = null;
                    GlobalDataAccessor.Instance.DesktopSession.ReleaseToClaimant = false;
                }
            }
            this.NavControlBox.Action = NavBox.NavAction.BACKANDSUBMIT;
        }
Exemple #3
0
        public bool CreateReport()
        {
            bool isSuccessful = false;

            iTextSharp.text.Document document = new iTextSharp.text.Document(PageSize.HALFLETTER);
            try
            {
                //ReportTempFileFullName = @"C:\pdfs\PoliceHoldSample.pdf";
                //set up RunReport event overrides & create doc
                PoliceSeizeReport events = new PoliceSeizeReport();
                PdfWriter         writer = PdfWriter.GetInstance(document, new FileStream(ReportTempFileFullName, FileMode.Create));
                writer.PageEvent = events;

                //set up tables, etc...
                PdfPTable headerTableNoBorders   = new PdfPTable(11);
                PdfPTable headerTableWithBorders = new PdfPTable(11);
                PdfPTable detailsTable           = new PdfPTable(11);
                PdfPTable footerTableWithBorders = new PdfPTable(11);
                PdfPTable footerTableNoBorders   = new PdfPTable(11);
                PdfPCell  cell = new PdfPCell();
                Image     gif  = Image.GetInstance(Resources.logo, BaseColor.WHITE);
                _reportFont           = FontFactory.GetFont("Arial", 6, iTextSharp.text.Font.NORMAL);
                _reportFontLargeBold  = FontFactory.GetFont("Arial", 8, iTextSharp.text.Font.BOLD);
                _reportFontUnderlined = FontFactory.GetFont("Arial", 8, iTextSharp.text.Font.UNDERLINE);

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

                document.SetPageSize(PageSize.HALFLETTER.Rotate());
                document.SetMargins(-40, -40, 5, 23);
                document.AddTitle(string.Empty);

                ReportHeaderNoBorder(headerTableNoBorders);
                ReportHeaderWithBorder(headerTableWithBorders);
                ReportDetails(detailsTable);
                ReportFooterNoBorders(footerTableNoBorders);
                ReportFooterWithBorders(footerTableWithBorders);

                //headerTableNoBorders.HeaderRows = 15;

                document.Open();
                document.Add(headerTableNoBorders);
                document.Add(headerTableWithBorders);
                document.Add(detailsTable);
                document.Add(footerTableWithBorders);
                document.Add(footerTableNoBorders);
                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);
        }