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; } }
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 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(); }