private void DispositionEdit_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            LoadItemData();

            gunBookCustomer               = new CustomerVOForSupportApp();
            gunBookCustomer.FirstName     = dispositionCustFirstName;
            gunBookCustomer.LastName      = dispositionCustLastName;
            gunBookCustomer.MiddleInitial = dispositionCustMiddleName;
            AddressVO addr1 = new AddressVO();

            addr1.Address1           = dispositionCustomerAddress1;
            addr1.City               = dispositionCustomerCity;
            addr1.State_Code         = dispositionCustomerState;
            addr1.ZipCode            = dispositionCustomerZipcode;
            addr1.ContactTypeCode    = CustomerAddressTypes.HOME_ADDRESS;
            addr1.ContMethodTypeCode = "POSTALADDR";
            gunBookCustomer.addAddress(addr1);
            gunBookCustomer.CustomerNumber = dispositionCustNumber;
            IdentificationVO id = new IdentificationVO();

            id.IdType       = dispositionCustIDType;
            id.IdValue      = dispositionCustIDNumber;
            id.IdIssuerCode = dispositionCustIDAgency;
            id.IsLatest     = true;
            gunBookCustomer.addIdentity(id);
            CashlinxPawnSupportSession.Instance.ActiveCustomer     = gunBookCustomer;
            CashlinxPawnSupportSession.Instance.GunAcquireCustomer = false;
            CashlinxPawnSupportSession.Instance.CustomerEditType   = CustomerType.DISPOSITION;
            NavControlBox.IsCustom     = true;
            NavControlBox.CustomDetail = "EditCustomer";
            NavControlBox.Action       = NavBox.NavAction.BACKANDSUBMIT;
        }
Example #2
0
        private void Setup()
        {
            IdentificationVO activeCustomerIdentity = GlobalDataAccessor.Instance.DesktopSession.ActiveCustomer.getFirstIdentity();

            this.PH_FirearmIDText.Text = activeCustomerIdentity.IdIssuerCode
                                         + " "
                                         + activeCustomerIdentity.DatedIdentDesc
                                         + " " + activeCustomerIdentity.IdValue + System.Environment.NewLine
                                         + " exp " + activeCustomerIdentity.IdExpiryData.ToShortDateString();
        }
        private void Setup()
        {
            var receiptType = string.Empty;

            PH_OrigPurchaseNumberValue.Text = _purchase.PurchaseOrderNumber;
            IdentificationVO activeCustomerIdentity = GlobalDataAccessor.Instance.DesktopSession.ActiveCustomer.getFirstIdentity();

            PH_ReturnReasonValue.Text = activeCustomerIdentity.IdIssuerCode
                                        + " "
                                        + activeCustomerIdentity.DatedIdentDesc
                                        + " " + activeCustomerIdentity.IdValue + System.Environment.NewLine
                                        + " exp " + activeCustomerIdentity.IdExpiryData.ToShortDateString();

            PH_ReturnAmountText.Text     = String.Format("{0:C}", _purchase.Amount);
            PH_MadeByEmpValue.Text       = _purchase.CreatedBy;
            PH_OriginationDateValue.Text = _purchase.OrgDate.ToShortDateString();
            PH_TerminalIDValue.Text      = _purchase.OrgShopNumber;

            if (_receiptIdx > -1)
            {
                receiptType = _purchase.Receipts[_receiptIdx].Event ==
                              ReceiptEventTypes.PUR.ToString()
                                         ? "Return "
                                         : "Void Return ";
            }
            else
            {
                if (_status == "VO")
                {
                    receiptType = "Void Return ";
                }
                else
                {
                    receiptType = "Return ";
                }
            }


            this.Text = receiptType + _purchase.TicketNumber.ToString() + " - "
                        + GlobalDataAccessor.Instance.DesktopSession.ActiveCustomer.FirstName
                        + " "
                        + GlobalDataAccessor.Instance.DesktopSession.ActiveCustomer.LastName;

            foreach (Item pawnItem in _purchase.Items)
            {
                int             gvIdx = PH_ItemsDataGridView.Rows.Add();
                DataGridViewRow myRow = PH_ItemsDataGridView.Rows[gvIdx];

                myRow.Cells["PH_ItemNumberColumn"].Value  = pawnItem.Icn;
                myRow.Cells["PH_DescriptionColumn"].Value = pawnItem.TicketDescription;
                myRow.Cells["PH_StatusColumn"].Value      = pawnItem.ItemReason.ToString();
                myRow.Cells["PH_LoanAmountColumn"].Value  = String.Format("{0:C}", pawnItem.ItemAmount);
            }
        }
Example #4
0
        private void populateIdNumberAndDate()
        {
            identType        = (ComboBox)this.pwnapp_identificationtype.Controls[0];
            strIdentTypeCode = identType.SelectedValue.ToString();
            //If idissuer1 is the control added in the form that means we need to
            //pull state data for ID Issuer otherwise it is the country data
            if (tableLayoutPanel2.Controls.Contains(pwnapp_identificationstate))
            {
                identIssuer     = (ComboBox)this.pwnapp_identificationstate.Controls[0];
                strIdentIssuer  = identIssuer.GetItemText(identIssuer.SelectedItem);
                stateIDSelected = true;
            }
            else
            {
                stateIDSelected = false;
                identIssuer     = (ComboBox)this.pwnapp_identificationcountry.Controls[0];
                strIdentIssuer  = identIssuer.SelectedValue.ToString();
            }

            if (newCustomer != null)
            {
                IdentificationVO customerId = null;
                customerId = newCustomer.getIdByTypeandIssuer(strIdentTypeCode, strIdentIssuer);

                if (customerId != null)
                {
                    this.pwnapp_identificationnumber.Text = customerId.IdValue.ToString();
                    if (customerId.IdExpiryData.Date != DateTime.MaxValue.Date)
                    {
                        this.pwnapp_identificationexpirationdate.Controls[0].Text = (customerId.IdExpiryData).FormatDate();
                    }
                    else
                    {
                        this.pwnapp_identificationexpirationdate.Controls[0].Text = "";
                    }
                    this.pwnapp_identificationexpirationdate.Enabled = false;
                    this.pwnapp_identificationnumber.Enabled         = false;
                    this.SelectNextControl(this.pwnapp_identificationexpirationdate, true, true, true, true);
                }
                else
                {
                    this.pwnapp_identificationnumber.Text = "";
                    this.pwnapp_identificationexpirationdate.Controls[0].Text = "";
                    this.pwnapp_identificationexpirationdate.Enabled          = true;
                    this.pwnapp_identificationnumber.Enabled = true;
                }
            }
            else
            {
                pwnapp_identificationnumber.Enabled         = true;
                pwnapp_identificationexpirationdate.Enabled = true;
            }
        }
Example #5
0
 private void GunBookCustomer_Load(object sender, EventArgs e)
 {
     gunBookCustomerData = GlobalDataAccessor.Instance.DesktopSession.GunBookCustomerData;
     gunNumber           = GlobalDataAccessor.Instance.DesktopSession.GunNumber;
     customerEditType    = GlobalDataAccessor.Instance.DesktopSession.CustomerEditType;
     if (gunBookCustomerData != null)
     {
         currentName.Text  = string.Format("{0} {1}", gunBookCustomerData.FirstName, gunBookCustomerData.LastName);
         customerName.Text = currentName.Text;
         AddressVO custAddr = gunBookCustomerData.getAddress(0);
         if (custAddr != null)
         {
             address1.Text           = custAddr.Address1;
             address2.Text           = string.Format("{0},{1} {2}", custAddr.City, custAddr.State_Code, custAddr.ZipCode);
             customTextBoxaddr1.Text = custAddr.Address1;
             customTextBoxAddr2.Text = custAddr.Address2;
             customTextBoxCity.Text  = custAddr.City;
             ComboBox custstate = (ComboBox)state1.Controls[0];
             foreach (USState currstate in custstate.Items)
             {
                 if (currstate.ShortName == custAddr.State_Code)
                 {
                     custstate.SelectedIndex = custstate.Items.IndexOf(currstate);
                     break;
                 }
             }
             zipcode1.Text = custAddr.ZipCode;
         }
         customerNumber.Text  = gunBookCustomerData.CustomerNumber;
         labelCustNumber.Text = gunBookCustomerData.CustomerNumber;
         IdentificationVO custId = gunBookCustomerData.getFirstIdentity();
         if (custId != null)
         {
             currentID.Text = custId.IdType + " " + custId.IdIssuerCode + " " + custId.IdValue;
             id.Text        = currentID.Text;
         }
         newCustomer = Utilities.CloneObject(gunBookCustomerData);
         GlobalDataAccessor.Instance.DesktopSession.GunAcquireCustomer = this.customerEditType == CustomerType.RECEIPT;
     }
 }
Example #6
0
 /*__________________________________________________________________________________________*/
 private void LoadIDDataInObject()
 {
     //_updatedCustomer = new CustomerVOForSupportApp();
     _updatedCustomer = Support.Logic.CashlinxPawnSupportSession.Instance.ActiveCustomer;
     _updatedCustomer.removeIdentities();
     if (_custIdentities != null)
     {
         foreach (DataRow cust in _custIdentities.Rows)
         {
             IdentificationVO custid = new IdentificationVO
             {
                 IdType =
                     Utilities.GetStringValue(
                         cust.ItemArray[(int)customeridrecord.IDENTTYPECODE], ""),
                 IdValue =
                     Utilities.GetStringValue(
                         cust.ItemArray[(int)customeridrecord.ISSUEDNUMBER], ""),
                 IdIssuer =
                     Utilities.GetStringValue(
                         cust.ItemArray[(int)customeridrecord.STATE_NAME], ""),
                 IdIssuerCode =
                     Utilities.GetStringValue(
                         cust.ItemArray[(int)customeridrecord.ISSUERNAME], ""),
                 DatedIdentDesc =
                     Utilities.GetStringValue(
                         cust.ItemArray[(int)customeridrecord.DATEDIDENTTYPEDESC], ""),
                 IdExpiryData =
                     Utilities.GetDateTimeValue(
                         cust.ItemArray[(int)customeridrecord.EXPIRYDATE],
                         DateTime.MaxValue),
                 IdentId =
                     Utilities.GetStringValue(
                         cust.ItemArray[(int)customeridrecord.IDENTID], "")
             };
             _updatedCustomer.addIdentity(custid);
         }
     }
 }
Example #7
0
        private void LoadIDDataInObject()
        {
            _updatedCustomer = new CustomerVO();

            if (_custIdentities != null)
            {
                foreach (DataRow cust in _custIdentities.Rows)
                {
                    IdentificationVO custid = new IdentificationVO
                    {
                        IdType =
                            Utilities.GetStringValue(
                                cust.ItemArray[(int)customeridrecord.IDENTTYPECODE], ""),
                        IdValue =
                            Utilities.GetStringValue(
                                cust.ItemArray[(int)customeridrecord.ISSUEDNUMBER], ""),
                        IdIssuer =
                            Utilities.GetStringValue(
                                cust.ItemArray[(int)customeridrecord.STATE_NAME], ""),
                        IdIssuerCode =
                            Utilities.GetStringValue(
                                cust.ItemArray[(int)customeridrecord.ISSUERNAME], ""),
                        DatedIdentDesc =
                            Utilities.GetStringValue(
                                cust.ItemArray[(int)customeridrecord.DATEDIDENTTYPEDESC], ""),
                        IdExpiryData =
                            Utilities.GetDateTimeValue(
                                cust.ItemArray[(int)customeridrecord.EXPIRYDATE],
                                DateTime.MaxValue),
                        IdentId =
                            Utilities.GetStringValue(
                                cust.ItemArray[(int)customeridrecord.IDENTID], "")
                    };
                    _updatedCustomer.addIdentity(custid);
                }
            }
        }
Example #8
0
        public void Print(PawnLoan pawnLoan)
        {
            if (pawnLoan != null)
            {
                //Get all the data to print from the desktop session
                CustomerVO currentCust = GlobalDataAccessor.Instance.DesktopSession.ActiveCustomer;
                if (pawnLoan.CustomerNumber != currentCust.CustomerNumber)
                {
                    currentCust = CustomerProcedures.getCustomerDataByCustomerNumber(GlobalDataAccessor.Instance.DesktopSession, pawnLoan.CustomerNumber);
                }
                if (currentCust != null)
                {
                    //Set all the date for printing
                    transactionDate   = ShopDateTime.Instance.ShopDate.FormatDate();
                    tktNo             = pawnLoan.TicketNumber;
                    customerName      = currentCust.LastName + "," + currentCust.FirstName;
                    custMiddleInitial = currentCust.MiddleInitial.ToUpper();

                    loanAmount = pawnLoan.Amount;
                    AddressVO custAddress = currentCust.getHomeAddress();
                    if (custAddress != null)
                    {
                        custAddr      = custAddress.Address1 + " " + custAddress.Address2;
                        custAddrLine2 = custAddress.City + "," + custAddress.State_Code + " " + custAddress.ZipCode;
                    }
                    IdentificationVO custId = currentCust.getFirstIdentity();
                    if (custId != null)
                    {
                        idData = custId.IdType + "-" + custId.IdIssuerCode + "-" + custId.IdValue;
                    }
                    loanDate    = pawnLoan.OriginationDate.FormatDate();
                    loanDueDate = pawnLoan.DueDate.FormatDate();
                    lostTktFee  = pawnLoan.LostTicketInfo.LostTicketFee;
                    //Get the interest amount
                    decimal interestCharges = 0.0M;
                    var     finCharges      = (from feeData in pawnLoan.Fees
                                               where feeData.FeeType == FeeTypes.INTEREST
                                               select feeData).FirstOrDefault();

                    if (finCharges.Value != 0)
                    {
                        interestCharges = finCharges.Value;
                    }

                    //Get the late fees
                    //If it is negative then it is a refund else it is a late fee
                    var lateFee = (from feeData in pawnLoan.Fees
                                   where feeData.FeeType == FeeTypes.LATE
                                   select feeData).FirstOrDefault();

                    if (lateFee.Value < 0)
                    {
                        refundAmt = lateFee.Value;
                    }
                    else
                    {
                        lateCharges = lateFee.Value;
                    }
                    totalPayments = loanAmount + interestCharges + refundAmt + lateCharges + lostTktFee;
                    apr           = pawnLoan.InterestRate.ToString();

                    //Open the pdf file
                    try
                    {
                        var fileName = SecurityAccessor.Instance.EncryptConfig.ClientConfig.GlobalConfiguration.BaseTemplatePath + "\\" + "lostticket.pdf";

                        if (GlobalDataAccessor.Instance.CurrentSiteId.State.Equals(States.Ohio))
                        {
                            fileName = SecurityAccessor.Instance.EncryptConfig.ClientConfig.GlobalConfiguration.BaseTemplatePath + "\\" + "lostticketOH.pdf";
                        }

                        PDFITextSharpUtilities.PdfSharpTools pdfTools;//=new PawnUtilities.ISharp.PDFITextSharpUtilities.PdfSharpTools(fileName);
                        PDFITextSharpUtilities.OpenPDFFile(fileName, out pdfTools);

                        //Generate output file name
                        string timeStamp      = DateTime.Now.ToString("yyMMddHHmmssf");
                        string genDocsDir     = SecurityAccessor.Instance.EncryptConfig.ClientConfig.GlobalConfiguration.BaseLogPath + "\\";
                        string outputFileName = genDocsDir + "LostTicketStatement" + "-" + timeStamp + ".pdf";
                        if (pdfTools == null)
                        {
                            if (FileLogger.Instance.IsLogError)
                            {
                                FileLogger.Instance.logMessage(LogLevel.ERROR, "LostTicketStatementPrint", "Could not get PDF tools instance for lost ticket statement");
                            }
                            return;
                        }
                        pdfTools.PrepForStamping(outputFileName);
                        Dictionary <string, string> lostTicketData = new Dictionary <string, string>();
                        lostTicketData.Add("TransactionDate", transactionDate);
                        lostTicketData.Add("CustomerName", customerName);
                        lostTicketData.Add("CustomerMiddleInitial", custMiddleInitial);
                        lostTicketData.Add("CustomerAddrLine1", custAddr);
                        lostTicketData.Add("CustomerAddrLine2", custAddrLine2);
                        lostTicketData.Add("CustomerIdData", idData);
                        lostTicketData.Add("DateMade", loanDate);
                        lostTicketData.Add("DateDue", loanDueDate);
                        lostTicketData.Add("TicketNumber", tktNo.ToString());
                        lostTicketData.Add("VerifyTicketNumber", tktNo.ToString());
                        lostTicketData.Add("CustomerGender", currentCust.Gender);
                        lostTicketData.Add("CustomerRace", currentCust.Race);
                        lostTicketData.Add("CustomerDOB", currentCust.DateOfBirth.FormatDate());
                        lostTicketData.Add("CustomerHeight", currentCust.Height);
                        if (currentCust.Weight > 0)
                        {
                            lostTicketData.Add("CustomerWeight", currentCust.Weight.ToString() + " lbs");
                        }
                        lostTicketData.Add("CustomerHairColor", currentCust.HairColor);
                        lostTicketData.Add("CustomerEyeColor", currentCust.EyeColor);
                        lostTicketData.Add("LostType", Commons.GetLostTicketType(pawnLoan.LostTicketInfo.LSDTicket));
                        lostTicketData.Add("AmtFinanced", String.Format("{0:C}", pawnLoan.Amount));
                        lostTicketData.Add("AmtFinanceCharges", String.Format("{0:C}", pawnLoan.InterestAmount));
                        lostTicketData.Add("AmtLateCharges", String.Format("{0:C}", lateCharges));
                        lostTicketData.Add("AmtRefunds", String.Format("{0:C}", refundAmt));
                        lostTicketData.Add("AmtTotalPayments", String.Format("{0:C}", totalPayments));
                        lostTicketData.Add("APR", apr);
                        lostTicketData.Add("LostTicketFee", String.Format("{0:0.00}", lostTktFee));

                        if (GlobalDataAccessor.Instance.CurrentSiteId.State.Equals(States.Ohio))
                        {
                            lostTicketData.Add("CurPrinAmount", pawnLoan.CurrentPrincipalAmount.ToString("c"));
                        }

                        //Add the data to the pdf file
                        if (!(PDFITextSharpUtilities.StampSimplePDFWithFormFields(pdfTools, outputFileName, false, lostTicketData)))
                        {
                            if (FileLogger.Instance.IsLogError)
                            {
                                FileLogger.Instance.logMessage(LogLevel.ERROR, "ProcessTenderController", "Could not stamp PDF document for wipe drive");
                            }
                        }
                        //Get the printer details for the form
                        string storeNumber = GlobalDataAccessor.Instance.CurrentSiteId.StoreNumber;

                        //03/18/2010 GJL - Change for pawn sec to allow development to continue and to facilitate
                        //real machine names in the pawn sec database instead of 47-byte GUID values
                        //Printing lostticket.pdf
                        const string formName = "lostticket.pdf";
                        if (SecurityAccessor.Instance.EncryptConfig.ClientConfig.ClientConfiguration.PrintEnabled &&
                            GlobalDataAccessor.Instance.DesktopSession.LaserPrinter.IsValid)
                        {
                            if (FileLogger.Instance.IsLogInfo)
                            {
                                FileLogger.Instance.logMessage(LogLevel.INFO, this, "Printing lost ticket statement on: {0}",
                                                               GlobalDataAccessor.Instance.DesktopSession.LaserPrinter);
                            }
                            if (!(PDFITextSharpUtilities.PrintOutputPDFFile(
                                      GlobalDataAccessor.Instance.DesktopSession.LaserPrinter.IPAddress,
                                      GlobalDataAccessor.Instance.DesktopSession.LaserPrinter.Port.ToString(), 1, pdfTools)))
                            {
                                if (FileLogger.Instance.IsLogError)
                                {
                                    FileLogger.Instance.logMessage(LogLevel.ERROR, "LostTicketStatement",
                                                                   "Could not print lost ticket statement PDF file");
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        BasicExceptionHandler.Instance.AddException("Error in printing lost ticket statement", new ApplicationException(ex.Message));
                        return;
                    }
                }
            }
        }
Example #9
0
        private bool identDataChanged()
        {
            _custIds = new List <IdentificationVO>();
            DataTable custDatatable;

            for (int i = 0; i < _strIdType.Length; i++)
            {
                IdentificationVO custIdObj = _custToEdit.getIdentity(_strIdType[i], _strIdNumber[i], _strIdIssuer[i]);
                IdentificationVO identobj  = _custToEdit.getIdentity(_strIdType[i], _strIdNumber[i], _strIdIssuerCode[i], _strIdExpiryDate[i]);
                if (identobj == null)
                {
                    string strIdentTypeCode = _strIdType[i];
                    string strIdentNumber   = _strIdNumber[i];
                    string strIdentIssuer   = _strIdIssuerCode[i];
                    //do the id check if the expiry date is not the only change
                    if (custIdObj == null)
                    {
                        string errorCode;
                        string errorMsg;
                        bool   retValue = new CustomerDBProcedures(GlobalDataAccessor.Instance.DesktopSession).CheckDuplicateID(strIdentTypeCode, strIdentNumber, strIdentIssuer, out custDatatable, out errorCode, out errorMsg);
                        if (retValue)
                        {
                            if (custDatatable != null)
                            //call to duplicate id check yielded records which means there are users that match the ID
                            {
                                if (custDatatable.Rows.Count > 0)
                                {
                                    StringBuilder errorMessage = new StringBuilder();
                                    errorMessage.Append(Commons.GetMessageString("DuplicateIDMessage"));
                                    errorMessage.Append("  <");
                                    errorMessage.Append(strIdentTypeCode);
                                    errorMessage.Append(",");
                                    errorMessage.Append(strIdentIssuer);
                                    errorMessage.Append(",");
                                    errorMessage.Append(strIdentNumber);
                                    errorMessage.Append(">");
                                    MessageBox.Show(errorMessage.ToString(), "Error");
                                    throw new ApplicationException("-1");
                                }
                            }
                        }
                        else
                        {
                            //If it is fatal error from the database, it would have been handled at the oracledataaccessor layer
                            FileLogger.Instance.logMessage(LogLevel.ERROR, this, errorMsg);
                        }
                    }
                    else
                    {
                        if (i >= _custToEdit.NumberIdentities && (custIdObj.IdExpiryData).FormatDate() != _strIdExpiryDate[i])
                        {
                            //no duplicate ID check needed since the user has entered an ID which is the same
                            //as another ID that exists for the customer but only the expiry date is different
                            //This scenario is only when the user enters a brand new row with the exact same ID
                            //as another id for the same user but enters a different expiry date
                            StringBuilder errorMessage = new StringBuilder();
                            errorMessage.Append(Commons.GetMessageString("DuplicateIDSameCustomerDiffExpiryDt"));
                            errorMessage.Append(System.Environment.NewLine + " <");
                            errorMessage.Append(strIdentTypeCode);
                            errorMessage.Append(",");
                            errorMessage.Append(strIdentIssuer);
                            errorMessage.Append(",");
                            errorMessage.Append(strIdentNumber);
                            errorMessage.Append(">");
                            throw new ApplicationException(errorMessage.ToString());
                        }
                    }

                    IdentificationVO newid = new IdentificationVO();
                    newid.IdType   = _strIdType[i];
                    newid.IdValue  = _strIdNumber[i];
                    newid.IdIssuer = _strIdIssuer[i];
                    try
                    {
                        newid.IdExpiryData = DateTime.Parse(_strIdExpiryDate[i], CultureInfo.InvariantCulture);
                    }
                    catch (Exception)
                    {
                        newid.IdExpiryData = DateTime.MaxValue;
                    }
                    newid.IdentId        = _strIdentId[i];
                    newid.DatedIdentDesc = _strIdTypeDesc[i];
                    newid.IdIssuerCode   = _strIdIssuerCode[i];
                    _updatedIds.Add(newid);
                    _custIds.Add(newid);
                }
                else
                {
                    //The same ID already exists for the customer..check to see
                    //if this was entered as a new row in the datagrid
                    if (i >= _custToEdit.NumberIdentities)
                    {
                        throw new ApplicationException(Commons.GetMessageString("DuplicateIDSameCustomer"));
                    }
                    else
                    {
                        _custIds.Add(identobj);
                    }
                }
            }
            if (_updatedIds.Count == 0)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
        private void LookupTicketResults_Load(object sender, EventArgs e)
        {
            _ownerfrm           = Owner;
            NavControlBox.Owner = this;
            //Show customer data using the customer object stored in session
            CustomerVO custdata = GlobalDataAccessor.Instance.DesktopSession.ActiveCustomer;

            if (custdata != null)
            {
                customDataGridViewTicketResults.Rows.Add(1);
                customDataGridViewTicketResults.Rows[0].Cells["custlastname"].Value  = custdata.LastName;
                customDataGridViewTicketResults.Rows[0].Cells["custfirstname"].Value = custdata.FirstName;
                customDataGridViewTicketResults.Rows[0].Cells["dob"].Value           = custdata.DateOfBirth.FormatDate();
                AddressVO custAddr = custdata.getHomeAddress();
                if (custAddr != null)
                {
                    customDataGridViewTicketResults.Rows[0].Cells["address"].Value = custAddr.Address1 + " " +
                                                                                     custAddr.UnitNum + " " + custAddr.City + "," + custAddr.State_Code + " " +
                                                                                     custAddr.ZipCode;
                }
                IdentificationVO currentId = custdata.getIdentity(0);
                if (GlobalDataAccessor.Instance.DesktopSession.TicketTypeLookedUp == ProductType.LAYAWAY)
                {
                    customDataGridViewTicketResults.Rows[0].Cells["IDData"].Value = currentId.IdType + "-" +
                                                                                    currentId.IdIssuer + "-" + currentId.IdValue;

                    //Get the layaway from session to get the ticket number
                    List <LayawayVO> layaway = GlobalDataAccessor.Instance.DesktopSession.Layaways;
                    var tktNumber            = string.Empty;
                    if (layaway != null)
                    {
                        LayawayVO layawayObj = layaway.First();
                        if (layawayObj != null)
                        {
                            tktNumber = layawayObj.TicketNumber.ToString();
                        }
                    }
                    tktNumberLabel.Text = tktNumber;
                }
                else
                {
                    //Get ID data from the pawn app object
                    List <PawnAppVO> pawnApplications = GlobalDataAccessor.Instance.DesktopSession.PawnApplications;
                    long             pawnAppId;
                    try
                    {
                        pawnAppId = Convert.ToInt64(GlobalDataAccessor.Instance.DesktopSession.CurPawnAppId);
                    }
                    catch (Exception)
                    {
                        pawnAppId = 0;
                    }
                    if (pawnAppId != 0 && pawnApplications != null)
                    {
                        PawnAppVO pawnApplication = pawnApplications.First
                                                        (papp => papp.PawnAppID == pawnAppId);
                        if (pawnApplication != null)
                        {
                            customDataGridViewTicketResults.Rows[0].Cells["IDData"].Value = pawnApplication.PawnAppCustIDType + "-" +
                                                                                            pawnApplication.PawnAppCustIDIssuer + "-" + pawnApplication.PawnAppCustIDNumber;
                        }

                        //Get the pawn loan from session to get the ticket number
                        //Only 1 pawn loan for this application id
                        List <PawnLoan> pawnLoans = GlobalDataAccessor.Instance.DesktopSession.PawnLoans;
                        var             tktNumber = string.Empty;
                        if (pawnLoans != null)
                        {
                            PawnLoan pawnLoanObj = pawnLoans.First
                                                       (ploan => ploan.PawnAppId == pawnAppId.ToString());
                            if (pawnLoanObj != null)
                            {
                                tktNumber = pawnLoanObj.TicketNumber.ToString();
                            }
                        }
                        tktNumberLabel.Text = tktNumber;
                    }
                    else
                    {
                        BasicExceptionHandler.Instance.AddException("Pawn Application Data is not found in Lookup Ticket Results ", new ApplicationException());
                        NavControlBox.Action = NavBox.NavAction.CANCEL;
                    }
                }
            }
            else
            {
                BasicExceptionHandler.Instance.AddException("Customer object is missing in session ", new ApplicationException());
                //NavControlBox.Action = NavBox.NavAction.CANCEL;
            }
        }
Example #11
0
        /// <summary>
        /// Gets all the identification data entered in the datagridview
        /// </summary>
        /// <returns></returns>
        public List <IdentificationVO> getIdentificationData()
        {
            customerIdentities = new List <IdentificationVO>();
            if (dataValid && CashlinxDesktopSession.Instance != null && CashlinxDesktopSession.Instance != null)
            {
                DataTable idTypeTable        = GlobalDataAccessor.Instance.DesktopSession.IdTypeTable;
                DataTable idIssuerStateTable = GlobalDataAccessor.Instance.DesktopSession.StateTable;
                var       idTypeDesc         = string.Empty;
                var       idTypeCode         = string.Empty;
                var       idIssuer           = string.Empty;
                var       idNumber           = string.Empty;
                var       idExpiryDate       = string.Empty;
                var       identId            = string.Empty;
                var       idIssuerCode       = string.Empty;


                for (int j = 0; j < dataGridViewCustomerID.Rows.Count - 1; j++)
                {
                    DataGridViewRow dgvr = dataGridViewCustomerID.Rows[j];
                    if (dgvr.Cells[0].Value != null && dgvr.Cells[0].Value.ToString() != "Select")
                    {
                        checkExpiryDate(j);
                        idTypeDesc = (string)dgvr.Cells[0].EditedFormattedValue;
                        idTypeCode = "";

                        //Get the code for the selected ID Type
                        foreach (DataRow dr in idTypeTable.Rows)
                        {
                            if (dr["codedesc"].ToString() == idTypeDesc)
                            {
                                idTypeCode = dr["code"].ToString();
                            }
                        }

                        if (idTypeCode == string.Empty)
                        {
                            idTypeCode = idTypeDesc;
                        }

                        //If the ID type is not state based, get the country code
                        //idissuercode is the 2 letter code for the state or country
                        //idissuer is the full state name or country name
                        if (Commons.IsStateIdDescription(idTypeDesc))
                        {
                            idIssuerCode = (string)dgvr.Cells[1].EditedFormattedValue;
                            //Get the full state name for the selected state ID issuer
                            foreach (DataRow dr in idIssuerStateTable.Rows)
                            {
                                if (dr["state_code"].ToString() == idIssuerCode)
                                {
                                    idIssuer = dr["state_name"].ToString();
                                }
                            }

                            if (idIssuer == string.Empty)
                            {
                                idIssuer = idIssuerCode;
                            }
                        }
                        else
                        {
                            idIssuerCode = Commons.GetCountryData(dgvr.Cells[1].EditedFormattedValue.ToString());
                            idIssuer     = dgvr.Cells[1].EditedFormattedValue.ToString();
                        }

                        idNumber = (string)dgvr.Cells[2].EditedFormattedValue;
                        //Since checkExpiryDate is called before the edited value
                        //would have been converted and stored in the value field
                        idExpiryDate = (string)dgvr.Cells[3].Value;
                        identId      = (string)dgvr.Cells[4].Value;
                        var newid = new IdentificationVO
                        {
                            IdType         = idTypeCode,
                            IdValue        = idNumber,
                            IdIssuer       = idIssuer,
                            DatedIdentDesc = idTypeDesc,
                            IdIssuerCode   = idIssuerCode
                        };
                        try
                        {
                            newid.IdExpiryData = DateTime.Parse(idExpiryDate);
                        }
                        catch (Exception)
                        {
                            newid.IdExpiryData = DateTime.MaxValue;
                        }

                        if (identId == null)
                        {
                            newid.IdentId = "";
                        }
                        else
                        {
                            newid.IdentId = identId;
                        }
                        customerIdentities.Add(newid);
                    }
                }
                return(customerIdentities);
            }
            else
            {
                return(null);
            }
        }
Example #12
0
        private void Setup()
        {
            var receiptType = string.Empty;

            PH_EligibilityDateValue.Text = _purchase.PfiEligible.ToShortDateString();
            IdentificationVO activeCustomerIdentity = GlobalDataAccessor.Instance.DesktopSession.ActiveCustomer.getFirstIdentity();

            PH_CustomerIdentificationValue.Text = activeCustomerIdentity.IdIssuerCode
                                                  + " "
                                                  + activeCustomerIdentity.DatedIdentDesc
                                                  + " " + activeCustomerIdentity.IdValue + System.Environment.NewLine
                                                  + " exp " + activeCustomerIdentity.IdExpiryData.ToShortDateString();

            PH_BuyAmountText.Text  = String.Format("{0:C}", _purchase.Amount);
            PH_MadeByEmpValue.Text = _purchase.EntityId;

            string loanStatus = (from l in GlobalDataAccessor.Instance.DesktopSession.LoanStatus
                                 where l.Left == _purchase.LoanStatus
                                 select l.Right).First <string>();

            PH_LoanStatusValue.Text = loanStatus;
            PH_ApprovedByValue.Text = _purchase.ApprovedBy;
            if (_receiptIdx > -1 && _purchase.Receipts.Count > 0)
            {
                PH_OriginationDateValue.Text = _purchase.Receipts[_receiptIdx].Date.ToShortDateString();
                PH_TerminalIDValue.Text      = _purchase.Receipts[_receiptIdx].StoreNumber;

                receiptType = _purchase.Receipts[_receiptIdx].Event ==
                              ReceiptEventTypes.PUR.ToString()
                                         ? "Buy "
                                         : "Void Buy ";
            }
            else
            {
                if (_status == "VO")
                {
                    receiptType = "Void Buy ";
                }
                else
                {
                    receiptType = "Buy ";
                }
                PH_TerminalIDValue.Text      = _purchase.StoreNumber;
                PH_OriginationDateValue.Text = _purchase.DateMade.Date.ToShortDateString();
            }
            this.Text = string.Format("{0}{1} - {2} {3}", receiptType, _purchase.TicketNumber,
                                      GlobalDataAccessor.Instance.DesktopSession.ActiveCustomer.FirstName,
                                      GlobalDataAccessor.Instance.DesktopSession.ActiveCustomer.LastName);

            foreach (Item pawnItem in _purchase.Items)
            {
                int             gvIdx = PH_ItemsDataGridView.Rows.Add();
                DataGridViewRow myRow = PH_ItemsDataGridView.Rows[gvIdx];

                myRow.Cells["PH_ItemNumberColumn"].Value      = pawnItem.Icn;
                myRow.Cells["PH_DescriptionColumn"].Value     = pawnItem.TicketDescription;
                myRow.Cells["PH_LoanAmountColumn"].Value      = String.Format("{0:C}", pawnItem.ItemAmount);
                myRow.Cells["PH_SuggestedAmountColumn"].Value = String.Format("{0:C}", pawnItem.SelectedProKnowMatch.selectedPKData.LoanVarHighAmount);
                myRow.Cells["PH_LocationColumn"].Value        = pawnItem.Location_Aisle.ToString() + " " + pawnItem.Location_Shelf.ToString() + " " + pawnItem.Location.ToString();
            }

            isSetup = true;
        }
Example #13
0
        private void CustomerReplace_Load(object sender, EventArgs e)
        {
            gunBookData = GlobalDataAccessor.Instance.DesktopSession.GunData;
            if (gunBookData != null && gunBookData.Rows.Count > 0)
            {
                if (GlobalDataAccessor.Instance.DesktopSession.GunAcquireCustomer)
                {
                    string acquireCustNumber = Utilities.GetStringValue(gunBookData.Rows[0]["acquire_customer_number"]);
                    customerNumber.Text = acquireCustNumber;
                    string acquireCustFirstName  = Utilities.GetStringValue(gunBookData.Rows[0]["acquire_first_name"]);
                    string acquireCustLastName   = Utilities.GetStringValue(gunBookData.Rows[0]["acquire_last_name"]);
                    string acquireCustMiddleName = Utilities.GetStringValue(gunBookData.Rows[0]["acquire_middle_initial"]);
                    currentName.Text = string.Format("{0} {1} {2}", acquireCustFirstName, acquireCustMiddleName, acquireCustLastName);
                    string acquireCustomerAddress1 = Utilities.GetStringValue(gunBookData.Rows[0]["acquire_address"]);
                    address1.Text = acquireCustomerAddress1;
                    string acquireCustomerCity    = Utilities.GetStringValue(gunBookData.Rows[0]["acquire_city"]);
                    string acquireCustomerState   = Utilities.GetStringValue(gunBookData.Rows[0]["acquire_state"]);
                    string acquireCustomerZipcode = Utilities.GetStringValue(gunBookData.Rows[0]["acquire_postal_code"]);
                    address2.Text = string.Format("{0},{1} {2}", acquireCustomerCity, acquireCustomerState, acquireCustomerZipcode);
                    string acquireCustIDType   = Utilities.GetStringValue(gunBookData.Rows[0]["acquire_id_type"]);
                    string acquireCustIDNumber = Utilities.GetStringValue(gunBookData.Rows[0]["acquire_id_number"]);
                    string acquireCustIDAgency = Utilities.GetStringValue(gunBookData.Rows[0]["acquire_id_agency"]);
                    id.Text = string.Format("{0} {1} {2}", acquireCustIDType, acquireCustIDAgency, acquireCustIDNumber);
                }
                else
                {
                    string dispositionCustNumber = Utilities.GetStringValue(gunBookData.Rows[0]["disposition_customer_number"]);
                    customerNumber.Text = dispositionCustNumber;

                    string dispositionCustLastName   = Utilities.GetStringValue(gunBookData.Rows[0]["disposition_last_name"]);
                    string dispositionCustFirstName  = Utilities.GetStringValue(gunBookData.Rows[0]["disposition_first_name"]);
                    string dispositionCustMiddleName = Utilities.GetStringValue(gunBookData.Rows[0]["disposition_middle_initial"]);
                    currentName.Text = string.Format("{0} {1} {2}", dispositionCustFirstName, dispositionCustMiddleName, dispositionCustLastName);

                    string dispositionCustomerAddress1 = Utilities.GetStringValue(gunBookData.Rows[0]["disposition_address"]);
                    address1.Text = dispositionCustomerAddress1;
                    string dispositionCustomerCity    = Utilities.GetStringValue(gunBookData.Rows[0]["disposition_city"]);
                    string dispositionCustomerState   = Utilities.GetStringValue(gunBookData.Rows[0]["disposition_state"]);
                    string dispositionCustomerZipcode = Utilities.GetStringValue(gunBookData.Rows[0]["disposition_postal_code"]);
                    address2.Text = string.Format("{0},{1} {2}", dispositionCustomerCity, dispositionCustomerState, dispositionCustomerZipcode);

                    string dispositionCustIDType   = Utilities.GetStringValue(gunBookData.Rows[0]["disposition_id_type"]);
                    string dispositionCustIDAgency = Utilities.GetStringValue(gunBookData.Rows[0]["disposition_id_agency"]);
                    string dispositionCustIDNumber = Utilities.GetStringValue(gunBookData.Rows[0]["disposition_id_number"]);
                    id.Text = string.Format("{0} {1} {2}", dispositionCustIDType, dispositionCustIDAgency, dispositionCustIDNumber);
                }
            }
            if (!SecurityProfileProcedures.CanUserModifyResource("EDIT RESTRICTED GUN BOOK FIELDS", GlobalDataAccessor.Instance.DesktopSession.LoggedInUserSecurityProfile, GlobalDataAccessor.Instance.DesktopSession))
            {
                tableLayoutPanel2.Visible = false;
            }
            else
            {
                idEditResource = true;
            }

            if (GlobalDataAccessor.Instance.DesktopSession.CustomerEditType == CustomerType.RECEIPT)
            {
                label1.Text = "Edit Receipt Customer Information";
            }
            else if (GlobalDataAccessor.Instance.DesktopSession.CustomerEditType == CustomerType.DISPOSITION)
            {
                label1.Text = "Edit Disposition Customer Information";
            }
            else
            {
                this.label1.Text = GlobalDataAccessor.Instance.DesktopSession.GunAcquireCustomer ? "Replace Receipt Customer Information" : "Replace Disposition Customer Information";
            }


            if (GlobalDataAccessor.Instance.DesktopSession.ActiveCustomer != null &&
                !string.IsNullOrEmpty(GlobalDataAccessor.Instance.DesktopSession.ActiveCustomer.CustomerNumber))
            {
                newCustomer = GlobalDataAccessor.Instance.DesktopSession.ActiveCustomer;
                if (newCustomer.DateOfBirth != DateTime.MaxValue && newCustomer.Age <= 18)
                {
                    DialogResult dgr = MessageBox.Show("This customer does not meet the age criteria for firearm transactions. An audit event will be generated. Do you want to continue?", "Firearm Eligibility", MessageBoxButtons.YesNo);
                    if (dgr == DialogResult.No)
                    {
                        NavControlBox.Action = NavBox.NavAction.CANCEL;
                    }
                }

                labelCustNumber.Text        = newCustomer.CustomerNumber;
                customTextBoxFirstName.Text = newCustomer.FirstName;
                customTextBoxLastName.Text  = newCustomer.LastName;
                customTextBoxInitial.Text   = newCustomer.MiddleInitial;
                ComboBox  custstate = (ComboBox)state1.Controls[0];
                AddressVO custAddr  = newCustomer.getHomeAddress();
                if (custAddr != null)
                {
                    customTextBoxAddr1.Text = custAddr.Address1;
                    customTextBoxAddr2.Text = custAddr.Address2;



                    foreach (USState currstate in custstate.Items)
                    {
                        if (currstate.ShortName == custAddr.State_Code)
                        {
                            custstate.SelectedIndex = custstate.Items.IndexOf(currstate);
                            break;
                        }
                    }
                    customTextBoxCity.Text = custAddr.City;
                    zipcode1.Text          = custAddr.ZipCode;
                }
                IdentificationVO firstIdentity = newCustomer.getFirstIdentity();
                //Populate the id details if the first identity cursor is not empty
                if (firstIdentity != null)
                {
                    strIdentIssuerName = firstIdentity.IdIssuer;
                    strIdentNumber     = firstIdentity.IdValue;
                    ComboBox custId = (ComboBox)this.pwnapp_identificationtype.Controls[0];

                    foreach (ComboBoxData idtype in custId.Items)
                    {
                        if (idtype.Code == firstIdentity.IdType)
                        {
                            custId.SelectedIndex = custId.Items.IndexOf(idtype);
                            break;
                        }
                    }
                }
                else
                {
                    pwnapp_identificationexpirationdate.Enabled = false;
                    pwnapp_identificationnumber.Enabled         = false;
                }
            }
        }
Example #14
0
        public void execute()
        {
            //Perform lookup customer

            /*this.AddLoadForm("LookupCustomer", new LookupCustomer(), 1,
             *  new Dictionary<string, string>()
             *  {
             *      {
             *          "lookupCustomerLastName",
             *          this.input.LastName
             *      },
             *      {
             *          "lookupCustomerFirstName",
             *          this.input.FirstName
             *      }
             *  },
             *  new Dictionary<string, TupleType<Control, ControlType, ControlTriggerType>>()
             *  {
             *      {
             *          "lookupCustomerFindButton",
             *          new TupleType<Control, ControlType, ControlTriggerType>(null, ControlType.BUTTON, ControlTriggerType.CLICK)
             *
             *      }
             *  });
             * this.SetFieldsOnForm("LookupCustomer");
             * this.TriggerControlOnForm("LookupCustomer", "lookupCustomerFindButton");*/
            //Get the site id
            SiteId curSite = cds.CurrentSiteId;

            //Perform customer lookup
            DateTime  dtFullStart = DateTime.Now;
            DateTime  custLookupStart = DateTime.Now;
            DataTable customerTable, customerIds, customerContacts, customerAddress, customerEmails, customerNotes, customerStoreCredit;
            string    errorCode, errorMesg;
            var       dbProcedures = new CustomerDBProcedures(this.cds);

            //CustomerProcedures custProcedures = new CustomerProcedures();
            try
            {
                bool retVal = dbProcedures.ExecuteLookupCustomer(this.input.Mid.FirstName, this.input.Mid.LastName,
                                                                 "", "", "", "", "", "", "", "", "", "", out customerTable,
                                                                 out customerIds, out customerContacts, out customerAddress,
                                                                 out customerEmails, out customerNotes, out customerStoreCredit, out errorCode,
                                                                 out errorMesg);
                if (!retVal || customerTable == null || customerTable.Rows == null || customerTable.Rows.Count <= 0)
                {
                    input.Right.Add(new TupleType <int, string, double>(input.Left, "CUSTOMER", 0.0d));
                    input.Right.Add(new TupleType <int, string, double>(input.Left, "PAWNAPPL", 0.0d));
                    input.Right.Add(new TupleType <int, string, double>(input.Left, "PAWNTEND", 0.0d));
                    input.Right.Add(new TupleType <int, string, double>(input.Left, "TOTALNEW", 0.0d));
                    return;
                }
            }
            catch (Exception eX)
            {
                input.Right.Add(new TupleType <int, string, double>(input.Left, "CUSTOMER", 0.0d));
                input.Right.Add(new TupleType <int, string, double>(input.Left, "PAWNAPPL", 0.0d));
                input.Right.Add(new TupleType <int, string, double>(input.Left, "PAWNTEND", 0.0d));
                input.Right.Add(new TupleType <int, string, double>(input.Left, "TOTALNEW", 0.0d));
                return;
            }
            DateTime custLookupStop     = DateTime.Now;
            DateTime managePawnAppStart = DateTime.Now;
            //Choose first customer returned
            DataRow    chosenCust = customerTable.Rows[0];
            var        partyId    = (string)chosenCust["party_id"];
            CustomerVO cust       = null;

            try
            {
                cust = CustomerProcedures.getCustomerDataInObject(partyId, customerIds, customerContacts,
                                                                  customerAddress, customerEmails, customerNotes,
                                                                  customerStoreCredit, chosenCust);
            }
            catch (Exception eX)
            {
                TimeSpan custLookupTimeEx = custLookupStop - custLookupStart;
                input.Right.Add(new TupleType <int, string, double>(input.Left, "CUSTOMER", custLookupTimeEx.TotalSeconds));
                input.Right.Add(new TupleType <int, string, double>(input.Left, "PAWNAPPL", 0.0d));
                input.Right.Add(new TupleType <int, string, double>(input.Left, "PAWNTEND", 0.0d));
                input.Right.Add(new TupleType <int, string, double>(input.Left, "TOTALNEW", 0.0d));
                return;
            }
            if (cust == null)
            {
                TimeSpan custLookupTimeEx = custLookupStop - custLookupStart;
                input.Right.Add(new TupleType <int, string, double>(input.Left, "CUSTOMER", custLookupTimeEx.TotalSeconds));
                input.Right.Add(new TupleType <int, string, double>(input.Left, "PAWNAPPL", 0.0d));
                input.Right.Add(new TupleType <int, string, double>(input.Left, "PAWNTEND", 0.0d));
                input.Right.Add(new TupleType <int, string, double>(input.Left, "TOTALNEW", 0.0d));
                return;
            }

            //Create pawn application
            cds.ActiveCustomer = cust;
            string pawnAppId = "1";

            try
            {
                IdentificationVO curId          = cust.getFirstIdentity();
                bool             createdPawnApp = dbProcedures.InsertPawnApplication(
                    cust.CustomerNumber,
                    curSite.StoreNumber,
                    " ",
                    " ",
                    curId.IdType,
                    curId.IdValue,
                    curId.IdIssuer,
                    curId.IdExpiryData.Date.ToShortDateString(),
                    cds.UserName,
                    out pawnAppId,
                    out errorCode,
                    out errorMesg);

                if (!createdPawnApp || string.IsNullOrEmpty(pawnAppId))
                {
                    TimeSpan custLookupTimeEx = custLookupStop - custLookupStart;
                    input.Right.Add(new TupleType <int, string, double>(input.Left, "CUSTOMER", custLookupTimeEx.TotalSeconds));
                    input.Right.Add(new TupleType <int, string, double>(input.Left, "PAWNAPPL", 0.0d));
                    input.Right.Add(new TupleType <int, string, double>(input.Left, "PAWNTEND", 0.0d));
                    input.Right.Add(new TupleType <int, string, double>(input.Left, "TOTALNEW", 0.0d));
                    return;
                }
            }
            catch (Exception eX)
            {
                TimeSpan custLookupTimeEx = custLookupStop - custLookupStart;
                input.Right.Add(new TupleType <int, string, double>(input.Left, "CUSTOMER", custLookupTimeEx.TotalSeconds));
                input.Right.Add(new TupleType <int, string, double>(input.Left, "PAWNAPPL", 0.0d));
                input.Right.Add(new TupleType <int, string, double>(input.Left, "PAWNTEND", 0.0d));
                input.Right.Add(new TupleType <int, string, double>(input.Left, "TOTALNEW", 0.0d));
                return;
            }
            DateTime managePawnAppStop = DateTime.Now;

            //Start building pawn loan
            DateTime pawnLoanTenderStart = DateTime.Now;
            PawnLoan curLoan             = cds.ActivePawnLoan;

            curLoan.OrgShopNumber = curSite.StoreNumber;
            curLoan.PawnAppId     = pawnAppId;
            cds.CurPawnAppId      = pawnAppId;
            cds.Clothing          = " ";
            cds.TTyId             = "1";
            //Choose what will be on the loan (max 3) (one of each, or a combo of general, jewelry, and/or gun)
            var randClass         = new Random();
            int numberOfLoanItems = 1 + (int)(randClass.NextDouble() * 2.0d);
            int randGenCat        = 1 + (int)(randClass.NextDouble() * 2.0d);
            int randJewCat        = 1 + (int)(randClass.NextDouble() * 2.0d);
            int randGunCat        = 1 + (int)(randClass.NextDouble() * 2.0d);



            try
            {
                //We have one loan item
                int finalGenCat = randGenCat - 1;
                if (finalGenCat < 0 || finalGenCat > 2)
                {
                    finalGenCat = 0;
                }
                int finalJewCat = randJewCat - 1;
                if (randJewCat < 0 || randJewCat > 2)
                {
                    randJewCat = 0;
                }
                int finalGunCat = randGunCat - 1;
                if (randGunCat < 0 || randGunCat > 2)
                {
                    randGunCat = 0;
                }

                curLoan.Fees = new List <Fee>(numberOfLoanItems);
                if (numberOfLoanItems == 1)
                {
                    int catG     = genCategories[randGenCat - 1];
                    var descMerc = new DescribedMerchandise(catG);
                    curLoan.Items.Add(descMerc.SelectedPawnItem);
                    curLoan.Items[0].TicketDescription = "TestGenDesc";
                    Item firstItem = curLoan.Items[0];
                    firstItem.mStore       = 6016;
                    firstItem.CategoryCode = genCategories[randGenCat - 1];
                }
                //We have two loan items
                else if (numberOfLoanItems == 2)
                {
                    int catGenG     = genCategories[randGenCat - 1];
                    int catJewG     = jewCategories[randJewCat - 1];
                    var descGenMerc = new DescribedMerchandise(catGenG);
                    var descJewMerc = new DescribedMerchandise(catJewG);
                    curLoan.Items.Add(descGenMerc.SelectedPawnItem);
                    curLoan.Items.Add(descJewMerc.SelectedPawnItem);
                    curLoan.Items[0].TicketDescription = "TestGenDesc";
                    curLoan.Items[1].TicketDescription = "TestJewDesc";
                    Item firstItem = curLoan.Items[0];
                    firstItem.mStore       = 6016;
                    firstItem.CategoryCode = genCategories[randGenCat - 1];
                    Item secItem = curLoan.Items[1];
                    secItem.mStore       = 6016;
                    secItem.CategoryCode = jewCategories[randJewCat - 1];
                }
                //We have 3 loan items
                else
                {
                    int catGenG     = genCategories[randGenCat - 1];
                    int catJewG     = jewCategories[randJewCat - 1];
                    int catGunG     = gunCategories[randGunCat - 1];
                    var descGenMerc = new DescribedMerchandise(catGenG);
                    var descJewMerc = new DescribedMerchandise(catJewG);
                    var descGunMerc = new DescribedMerchandise(catGunG);
                    curLoan.Items.Add(descGenMerc.SelectedPawnItem);
                    curLoan.Items.Add(descJewMerc.SelectedPawnItem);
                    curLoan.Items.Add(descGunMerc.SelectedPawnItem);
                    curLoan.Items[0].TicketDescription = "TestGenDesc";
                    curLoan.Items[1].TicketDescription = "TestJewDesc";
                    curLoan.Items[2].TicketDescription = "GUNTestGunDesc";
                    Item firstItem = curLoan.Items[0];
                    firstItem.mStore       = 6016;
                    firstItem.CategoryCode = genCategories[randGenCat - 1];
                    Item secItem = curLoan.Items[1];
                    secItem.mStore       = 6016;
                    secItem.CategoryCode = jewCategories[randJewCat - 1];
                    Item thdItem = curLoan.Items[2];
                    thdItem.mStore       = 6016;
                    thdItem.CategoryCode = gunCategories[randGunCat - 1];
                }
            }
            catch (Exception eX)
            {
                TimeSpan custLookupTimeEx = custLookupStop - custLookupStart;
                TimeSpan mngAppTimeEx     = managePawnAppStop - managePawnAppStart;
                input.Right.Add(new TupleType <int, string, double>(input.Left, "CUSTOMER", custLookupTimeEx.TotalSeconds));
                input.Right.Add(new TupleType <int, string, double>(input.Left, "PAWNAPPL", mngAppTimeEx.TotalSeconds));
                input.Right.Add(new TupleType <int, string, double>(input.Left, "PAWNTEND", 0.0d));
                input.Right.Add(new TupleType <int, string, double>(input.Left, "TOTALNEW", 0.0d));
                return;
            }

            //Call underwrite
            try
            {
                //Set loan amount prior to underwriting
                decimal tryAmt;
                curLoan.Amount = 60;
                if (Decimal.TryParse("" + (60 * (1 + (uint)Math.Floor(randClass.NextDouble() * 4))), out tryAmt))
                {
                    curLoan.Amount = tryAmt;
                }
                var upwUtil = new UnderwritePawnLoanUtility(this.cds);
                upwUtil.RunUWP(curSite);
                curLoan.ObjectUnderwritePawnLoanVO = upwUtil.PawnLoanVO;
                //Call process tender execute
                this.tender.ExecuteProcessTender(
                    ProcessTenderController.ProcessTenderMode.NEWLOAN);

                //cleanup once done
                this.cds.ClearCustomerList();
                this.cds.ClearPawnLoan();
                curLoan = null;
            }
            catch (Exception eX)
            {
                //MessageBox.Show("Exception thrown during process tender: " + eX.Message + ", " + eX.StackTrace);
                TimeSpan custLookupTimeEx = custLookupStop - custLookupStart;
                TimeSpan mngAppTimeEx     = managePawnAppStop - managePawnAppStart;
                input.Right.Add(new TupleType <int, string, double>(input.Left, "CUSTOMER", custLookupTimeEx.TotalSeconds));
                input.Right.Add(new TupleType <int, string, double>(input.Left, "PAWNAPPL", mngAppTimeEx.TotalSeconds));
                input.Right.Add(new TupleType <int, string, double>(input.Left, "PAWNTEND", 0.0d));
                input.Right.Add(new TupleType <int, string, double>(input.Left, "TOTALNEW", 0.0d));
                return;
            }
            DateTime pawnLoanTenderStop = DateTime.Now;

            DateTime dtFullFinish = DateTime.Now;
            //Thread finished

            //Compute times
            TimeSpan finishTime     = dtFullFinish - dtFullStart;
            TimeSpan custLookupTime = custLookupStop - custLookupStart;
            TimeSpan mngAppTime     = managePawnAppStop - managePawnAppStart;
            TimeSpan pwnLoanTender  = pawnLoanTenderStop - pawnLoanTenderStart;

            input.Right.Add(new TupleType <int, string, double>(input.Left, "CUSTOMER", custLookupTime.TotalSeconds));
            input.Right.Add(new TupleType <int, string, double>(input.Left, "PAWNAPPL", mngAppTime.TotalSeconds));
            input.Right.Add(new TupleType <int, string, double>(input.Left, "PAWNTEND", pwnLoanTender.TotalSeconds));
            input.Right.Add(new TupleType <int, string, double>(input.Left, "TOTALNEW", finishTime.TotalSeconds));
        }
        private void addCustomerButton_Click(object sender, EventArgs e)
        {
            string trigger = GlobalDataAccessor.Instance.DesktopSession.HistorySession.Trigger;
            //CashlinxDesktopSession.Instance.FormState = CashlinxDesktopSession.CustomerFormStates.ADDCUSTOMER;
            //CustomerController.NavigateUser(ownerFrm);
            var newCustomer = new CustomerVO
            {
                NewCustomer = true
            };
            //get the Search criteria entered by the user
            var searchCriteria = GlobalDataAccessor.Instance.DesktopSession.ActiveLookupCriteria;

            //Get store state from desktop session
            var strStoreState = string.Empty;

            strStoreState = GlobalDataAccessor.Instance.CurrentSiteId.State;
            var newAddr = new AddressVO
            {
                State_Code         = strStoreState,
                ContactTypeCode    = CustomerAddressTypes.HOME_ADDRESS,
                ContMethodTypeCode = "POSTALADDR"
            };

            newCustomer.addAddress(newAddr);
            newCustomer.FirstName = searchCriteria.FirstName;
            newCustomer.LastName  = searchCriteria.LastName;
            if (!string.IsNullOrEmpty(searchCriteria.DOB) && searchCriteria.DOB != "mm/dd/yyyy")
            {
                newCustomer.DateOfBirth = Utilities.GetDateTimeValue(searchCriteria.DOB);
            }
            if (!string.IsNullOrEmpty(searchCriteria.IDIssuer))
            {
                var idData = new IdentificationVO
                {
                    IdIssuer     = searchCriteria.IDIssuer,
                    IdValue      = searchCriteria.IDNumber,
                    IdIssuerCode = searchCriteria.IdIssuerCode,
                    IdType       = searchCriteria.IdTypeCode
                };
                newCustomer.addIdentity(idData);
                if (!string.IsNullOrEmpty(searchCriteria.PhoneNumber))
                {
                    var phoneData = new ContactVO
                    {
                        ContactPhoneNumber = searchCriteria.PhoneNumber,
                        ContactAreaCode    = searchCriteria.PhoneAreaCode
                    };
                    newCustomer.addContact(phoneData);
                }

                newCustomer.SocialSecurityNumber = searchCriteria.SSN;
            }
            GlobalDataAccessor.Instance.DesktopSession.ActiveCustomer = newCustomer;
            if (trigger.Equals("newpawnloan", StringComparison.OrdinalIgnoreCase))
            {
                this.NavControlBox.IsCustom     = true;
                this.NavControlBox.CustomDetail = "ManagePawnApplication";
                this.NavControlBox.Action       = NavBox.NavAction.BACKANDSUBMIT;
            }
            else
            {
                this.NavControlBox.IsCustom     = true;
                this.NavControlBox.CustomDetail = "CreateCustomer";
                this.NavControlBox.Action       = NavBox.NavAction.BACKANDSUBMIT;
            }
        }
        private void buttonSubmit_Click(object sender, EventArgs e)
        {
            string  strIdentNumber = customTextBoxCWPNumber.Text;
            Boolean cancelSubmit   = false;

            //BZ # 753
            //if (!_retailFirearmCheck && !customTextBoxRefNumber.isValid)
            if (!_retailFirearmCheck && !customTextBoxRefNumber.isValid && string.IsNullOrEmpty(strIdentNumber))
            {
                MessageBox.Show(@"Background reference number must be entered");
                return;
            }

            if (!checkExpDate())
            {
                this.dateCWP.Focus();
                return;
            }

            //store the background ref check number in the customer object
            _currentCustomer.BackgroundCheckRefNumber = customTextBoxRefNumber.Text;
            //store the CWP data against the customer if he did not already
            //have a cwp and if they entered CWP data in the form
            ComboBox statelist          = (ComboBox)stateCWP.Controls[0];
            string   cwpIssuerState     = statelist.GetItemText(statelist.SelectedItem);
            string   cwpIssuerStateName = statelist.SelectedValue.ToString();
            string   strIdentExpiryDate = dateCWP.Controls[0].Text;

            if (strIdentExpiryDate.Equals("mm/dd/yyyy"))
            {
                strIdentExpiryDate = string.Empty;
            }
            string strIdentTypeCode = CustomerIdTypes.CW.ToString();

            IdentificationVO custCWPID  = new IdentificationVO();
            string           storeState = CashlinxDesktopSession.Instance.CurrentSiteId.State;

            if (_currentCustomer.HasValidConcealedWeaponsPermitInState(storeState, ShopDateTime.Instance.ShopDate))
            {
                custCWPID = _currentCustomer.getIdByTypeandIssuer(CustomerIdTypes.CW.ToString(), storeState);
            }

            if (!string.IsNullOrEmpty(custCWPID.IdValue.Trim()))
            {
                _idCwpExists = true;

                //idExpDate = custCWPID.IdExpiryData.Date != DateTime.MaxValue.Date ? custCWPID.IdExpiryData.FormatDate() : string.Empty;
                //idIssuer = custCWPID.IdIssuerCode;
            }

            decimal backgroundCheckFee;

            if (_retailFirearmCheck || _layawayFirearmCheck)
            {
                //Check if ident number and issuer and expiry date is entered if reference number was not entered
                if (!customTextBoxRefNumber.isValid && (strIdentNumber.Equals(string.Empty) || cwpIssuerState.Equals("Select One") || strIdentExpiryDate == string.Empty || strIdentExpiryDate == string.Empty))
                {
                    if (!IsBackgroundCheckRequired)
                    {
                        MessageBox.Show("Either Background reference number or all CWP data should be entered");
                        return;
                    }
                    else
                    {
                        MessageBox.Show("Background reference number should be entered");
                        return;
                    }
                }
                else if (_layawayFirearmCheck)
                {
                    //if (!decimal.TryParse(customTextBoxBackgroundCheckFee.Text, out backgroundCheckFee) || backgroundCheckFee < 0)
                    bool formatSuccess = Commons.FormatStringAsDecimal(customTextBoxBackgroundCheckFee.Text, out backgroundCheckFee);

                    //BZ # 503
                    if (formatSuccess)
                    {
                        if (backgroundCheckFee <= 0.0m)
                        {
                            string       msg = "Back ground Check Fee amount is less or equal to zero. Is that okay?";
                            DialogResult dgr = MessageBox.Show(msg, "Back ground Check Fee equals zero", MessageBoxButtons.YesNo);
                            if (dgr == DialogResult.No)
                            {
                                return;
                            }
                        }
                        else
                        {
                            CashlinxDesktopSession.Instance.BackgroundCheckFeeValue = backgroundCheckFee;
                        }
                    }
                    else
                    {
                        MessageBox.Show("Invalid background check fee");
                        return;
                    }
                    //BZ # 503 end
                }
                else
                {
                    CashlinxDesktopSession.Instance.BackgroundCheckFeeValue = 0M;
                }
            }
            else
            {
                if ((!customTextBoxRefNumber.isValid) && (strIdentNumber.Equals(string.Empty) || cwpIssuerState.Equals("Select One")))
                {
                    if (!IsBackgroundCheckRequired)
                    {
                        MessageBox.Show("Either Background reference number or all CWP data should be entered");
                        return;
                    }
                    else
                    {
                        MessageBox.Show("Background reference number should be entered");
                        return;
                    }
                }

                CashlinxDesktopSession.Instance.BackgroundCheckFeeValue = 0M;
            }

            if ((!customTextBoxRefNumber.isValid) && !IsBackgroundCheckRequired && _currentCustomer.HasConcealedWeaponsPermit())
            {
                //check to see if the object has been populated with data.
                if (custCWPID.IdExpiryData == DateTime.MaxValue)
                {
                    custCWPID = _currentCustomer.getAllIdentifications().Where(i => i.IdType == CustomerIdTypes.CW.ToString()).FirstOrDefault();
                }

                if (strIdentNumber.Trim() != custCWPID.IdValue.Trim() || cwpIssuerState != custCWPID.IdIssuerCode)
                {
                    DialogResult dgr = MessageBox.Show("This customer has the following CWP on file: " + custCWPID.IdIssuerCode + "-" + custCWPID.IdValue + ". If you continue, the CWP you entered will replace the one on file.", "Concealed Weapons Permit Already Exists", MessageBoxButtons.YesNo);
                    if (dgr == DialogResult.No)
                    {
                        return;
                    }
                }
            }

            //Check if the ID is a new id entered in this form or it already exists
            //for the customer
            //Add to the database only if its a new id
            if (!string.IsNullOrEmpty(strIdentNumber) && !cwpIssuerState.Equals("Select One"))
            {
                IdentificationVO custIdInfo = _currentCustomer.getIdentity(CustomerIdTypes.CW.ToString(), strIdentNumber, cwpIssuerState, strIdentExpiryDate);
                if (custIdInfo == null)
                {
                    DialogResult dgr;
                    do
                    {
                        string strUserId    = CashlinxDesktopSession.Instance.UserName;
                        string errorMsg     = string.Empty;
                        string errorCode    = string.Empty;
                        bool   updateIdData = new CustomerDBProcedures(CashlinxDesktopSession.Instance).UpdateCustPersonalIdentification(_currentCustomer.PartyId, strIdentNumber, strIdentExpiryDate, strIdentTypeCode, cwpIssuerState, strUserId, out errorCode, out errorMsg);
                        if (updateIdData)
                        {
                            IdentificationVO newCustId = new IdentificationVO
                            {
                                IdType         = strIdentTypeCode,
                                IdValue        = strIdentNumber,
                                IdIssuerCode   = cwpIssuerState,
                                IdIssuer       = cwpIssuerStateName,
                                DatedIdentDesc = StateIdTypeDescription.CW.ToString(),
                                IdExpiryData   =
                                    Utilities.GetDateTimeValue(strIdentExpiryDate, DateTime.MaxValue)
                            };
                            _currentCustomer.addIdentity(newCustId);

                            break;
                        }
                        dgr = MessageBox.Show(Commons.GetMessageString("CustIdentUpdateFailure"), "Error", MessageBoxButtons.RetryCancel);
                    } while (dgr == DialogResult.Retry);
                }
            }
            //If the user cancelled retrying to update the db when it failed
            //continue since the CWP can always be added later for the customer and do
            //not have to stop the pickup flow for it
            GlobalDataAccessor.Instance.DesktopSession.BackgroundCheckCompleted = true;
            GlobalDataAccessor.Instance.DesktopSession.ActiveCustomer           = _currentCustomer;
            Close();
        }
        private void FirearmsBackgroundCheck_Load(object sender, EventArgs e)
        {
            IsBackgroundCheckRequired = CustomerProcedures.IsBackgroundCheckRequired(CashlinxDesktopSession.Instance);
            if (!IsBackgroundCheckRequired)
            {
                customLabelCWPNumber.Visible   = true;
                customTextBoxCWPNumber.Visible = true;
                customLabelCWPExpDate.Visible  = true;
                dateCWP.Visible          = true;
                customLabelState.Visible = true;
                stateCWP.Visible         = true;
            }
            else
            {
                customLabelCWPNumber.Visible   = false;
                customTextBoxCWPNumber.Visible = false;
                customLabelCWPExpDate.Visible  = false;
                dateCWP.Visible          = false;
                customLabelState.Visible = false;
                stateCWP.Visible         = false;
            }

            if (CashlinxDesktopSession.Instance.ActiveRetail != null)
            {
                _firearmItems = (from itemData in CashlinxDesktopSession.Instance.ActiveRetail.RetailItems
                                 where itemData.IsGun
                                 select itemData).ToList();
                _retailFirearmCheck  = true;
                _layawayFirearmCheck = false;
            }
            else if (CashlinxDesktopSession.Instance.ServiceLayaways != null && CashlinxDesktopSession.Instance.ServiceLayaways.Count > 0)
            {
                List <LayawayVO> pickupLayaways = CashlinxDesktopSession.Instance.ServiceLayaways.FindAll(l => l.LoanStatus == ProductStatus.PU).ToList();
                if (pickupLayaways.Count > 0)
                {
                    _firearmItems        = pickupLayaways.SelectMany(l => l.RetailItems).Where(i => i.IsGun).ToList();
                    _retailFirearmCheck  = false;
                    _layawayFirearmCheck = true;
                }
            }
            SetupDisplayForList();
            _currentCustomer = CashlinxDesktopSession.Instance.ActiveCustomer;
            string           strStoreState = CashlinxDesktopSession.Instance.CurrentSiteId.State;
            IdentificationVO custCWPID     = new IdentificationVO();
            string           idNumber      = string.Empty;
            string           idExpDate     = string.Empty;
            string           idIssuer      = string.Empty;
            bool             dateExpired   = false;

            if (!(strStoreState.Equals(string.Empty)))
            {
                List <IdentificationVO> identifications = _currentCustomer.getAllIdentifications();
                foreach (IdentificationVO id in identifications)
                {
                    if (id.IdType != null && id.IdType.Equals(CustomerIdTypes.CW.ToString()))
                    {
                        DateTime expiryDate = Utilities.GetDateTimeValue(id.IdExpiryData, DateTime.MaxValue);
                        if (expiryDate.Date < ShopDateTime.Instance.ShopDate.Date)
                        {
                            dateExpired = true;
                            break;
                        }
                    }
                }

                if (_currentCustomer.HasValidConcealedWeaponsPermitInState(strStoreState, ShopDateTime.Instance.ShopDate) || dateExpired)
                {
                    custCWPID = _currentCustomer.getIdByTypeandIssuer(CustomerIdTypes.CW.ToString(), strStoreState);
                }
            }

            if (custCWPID != null && custCWPID.IdValue != string.Empty)
            {
                _idCwpExists = true;
                idNumber     = custCWPID.IdValue;
                idExpDate    = custCWPID.IdExpiryData.Date != DateTime.MaxValue.Date ? custCWPID.IdExpiryData.FormatDate() : string.Empty;
                idIssuer     = custCWPID.IdIssuerCode;
            }

            string CWPNum = this.customTextBoxCWPNumber.Text;

            if (_idCwpExists)
            {
                ComboBox statelist = (ComboBox)this.stateCWP.Controls[0];
                statelist.SelectedIndex = 0;

                if (dateExpired)
                {
                    this.dateExpireWarning.Visible = true;
                }
                else
                {
                    this.dateExpireWarning.Visible = false;
                }
            }
            else if (string.Empty.Equals(CWPNum))
            {
                dateCWP.Enabled  = false;
                stateCWP.Enabled = false;
            }
            else
            {
                customTextBoxCWPNumber.Enabled = true;
                dateCWP.Enabled  = true;;
                stateCWP.Enabled = true;
            }
            this.dateCWP.ErrorMessage = Commons.GetMessageString("InvalidDate");

            //BZ # 503
            if (customTextBoxBackgroundCheckFee.TextLength == 0)
            {
                customTextBoxBackgroundCheckFee.Text = "0.00";
            }
            //BZ # 503 end
        }