private void customButtonSubmit_Click(object sender, EventArgs e) { string errorCode; string errorText; var dSession = GlobalDataAccessor.Instance.DesktopSession; MerchandiseProcedures.UpdateGunCustomerData(GlobalDataAccessor.Instance.CurrentSiteId.StoreNumber, gunNumber, dSession.GunAcquireCustomer ? "A" : "D", newCustomer.LastName, newCustomer.FirstName, !string.IsNullOrEmpty(newCustomer.MiddleInitial) ? newCustomer.MiddleInitial.Substring(0, 1) : "", string.Format("{0} {1}", customTextBoxaddr1.Text, customTextBoxAddr2.Text), customTextBoxCity.Text, state1.selectedValue, zipcode1.Text, newCustomer.getFirstIdentity().IdType, newCustomer.getFirstIdentity().IdIssuer, newCustomer.getFirstIdentity().IdValue, dSession.UserName, out errorCode, out errorText); if (errorCode != "0") { MessageBox.Show("Customer data could not be updated"); } else { MessageBox.Show("Customer data updated successfully"); DataTable gunTableData; Item gunItem; MerchandiseProcedures.GetGunData(GlobalDataAccessor.Instance.OracleDA, GlobalDataAccessor.Instance.CurrentSiteId.StoreNumber, Utilities.GetIntegerValue(gunNumber), out gunTableData, out gunItem, out errorCode, out errorText); dSession.GunData = gunTableData; dSession.GunItemData = gunItem; } NavControlBox.Action = NavBox.NavAction.BACKANDSUBMIT; }
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; } }
private void ExistingCustomer_Load(object sender, EventArgs e) { try { //set the owner form ownerFrm = this.Owner; this.NavControlBox.Owner = this; //Pull data out of cashlinx desktop session var gSess = GlobalDataAccessor.Instance; var dSession = gSess.DesktopSession; _currentCustomer = dSession.EXCurrentCustomer; _existingCustomers = dSession.EXExistingCustomers; if (!string.IsNullOrEmpty(dSession.EXErrorMessage)) { _strMessageToShow = dSession.EXErrorMessage; } else { _strMessageToShow = dSession.EXMessageToShow; } _nameCheck = dSession.EXNameCheck; _newCustomer = dSession.EXNewCustomer; //Set the message to show on top this.labelRedHeader.Text = Commons.GetMessageString("ExistingCustomerHeader"); this.labelMessage.Text = _strMessageToShow; //Binding new customer data _newCustBindingSouce = new BindingSource(); var dataTableNewCustomer = new DataTable(); dataTableNewCustomer.Columns.Add("LastName"); dataTableNewCustomer.Columns.Add("FirstName"); dataTableNewCustomer.Columns.Add("CustAddress"); dataTableNewCustomer.Columns.Add("DateOfBirth"); dataTableNewCustomer.Columns.Add("IDData"); dataTableNewCustomer.Columns.Add("IssuerName"); var newCustRow = dataTableNewCustomer.NewRow(); newCustRow["LastName"] = _newCustomer.LastName; newCustRow["FirstName"] = _newCustomer.FirstName; if (_newCustomer.getHomeAddress() != null) { newCustRow["CustAddress"] = _newCustomer.getHomeAddress().CustAddress; } else { newCustRow["CustAddress"] = string.Empty; } newCustRow["DateOfBirth"] = (_newCustomer.DateOfBirth).FormatDate(); var custId = _newCustomer.getFirstIdentity(); if (custId != null) { newCustRow["IDData"] = custId.IDData; newCustRow["IssuerName"] = custId.IdIssuerCode; } else { newCustRow["IDData"] = string.Empty; newCustRow["IssuerName"] = string.Empty; } dataTableNewCustomer.Rows.Add(newCustRow); _newCustBindingSouce.DataSource = dataTableNewCustomer; this.customDataGridViewNewCustomer.AutoGenerateColumns = false; int newColIndex = 0; var selectNewColumn = new DataGridViewCheckBoxColumn { HeaderText = "Select", ReadOnly = false, ThreeState = false, FalseValue = false }; newColIndex = this.customDataGridViewNewCustomer.Columns.Add(selectNewColumn); newColIndex = this.customDataGridViewNewCustomer.Columns.Add("LastName", "Last Name"); this.customDataGridViewNewCustomer.Columns[newColIndex].DataPropertyName = "LastName"; this.customDataGridViewNewCustomer.Columns[newColIndex].ReadOnly = true; newColIndex = this.customDataGridViewNewCustomer.Columns.Add("FirstName", "First Name"); this.customDataGridViewNewCustomer.Columns[newColIndex].DataPropertyName = "FirstName"; this.customDataGridViewNewCustomer.Columns[newColIndex].ReadOnly = true; newColIndex = this.customDataGridViewNewCustomer.Columns.Add("CustAddress", "Address"); this.customDataGridViewNewCustomer.Columns[newColIndex].DataPropertyName = "CustAddress"; this.customDataGridViewNewCustomer.Columns[newColIndex].ReadOnly = true; newColIndex = this.customDataGridViewNewCustomer.Columns.Add("birthdate", "Date of Birth"); this.customDataGridViewNewCustomer.Columns[newColIndex].DataPropertyName = "DateOfBirth"; this.customDataGridViewNewCustomer.Columns[newColIndex].ReadOnly = true; newColIndex = this.customDataGridViewNewCustomer.Columns.Add("IdTypeNumber", "ID Type & Number"); this.customDataGridViewNewCustomer.Columns[newColIndex].DataPropertyName = "IDData"; this.customDataGridViewNewCustomer.Columns[newColIndex].ReadOnly = true; newColIndex = this.customDataGridViewNewCustomer.Columns.Add("Issuer_Name", "Issuer"); this.customDataGridViewNewCustomer.Columns[newColIndex].DataPropertyName = "IssuerName"; this.customDataGridViewNewCustomer.Columns[newColIndex].ReadOnly = true; if (_nameCheck) { customDataGridViewNewCustomer.Columns["LastName"].DefaultCellStyle.ForeColor = Color.Red; customDataGridViewNewCustomer.Columns["FirstName"].DefaultCellStyle.ForeColor = Color.Red; customDataGridViewNewCustomer.Columns["birthdate"].DefaultCellStyle.ForeColor = Color.Red; } else { customDataGridViewNewCustomer.Columns["IdTypeNumber"].DefaultCellStyle.ForeColor = Color.Red; customDataGridViewNewCustomer.Columns["Issuer_Name"].DefaultCellStyle.ForeColor = Color.Red; } customDataGridViewNewCustomer.DataSource = _newCustBindingSouce; customDataGridViewNewCustomer.AutoResizeColumns(); //Binding existing customer data _existingCustomers.Columns.Add("IDData"); _existingCustomers.Columns.Add("Address"); string idData; string address; //Concatenate the ID type and number in the ID Data field //Concatenate the address fields in one foreach (DataRow dr in _existingCustomers.Rows) { idData = string.Format("{0}-{1}", dr["Ident_type_code"], dr["Issued_number"]); dr.SetField("idData", idData); string addr2 = dr["address2_text"].ToString(); if (addr2.Trim().Length > 0) { address = string.Format("{0},{1},{2},{3},{4}", dr["address1_text"], dr["address2_text"], dr["city_name"], dr["state_province_name"], dr["postal_code_text"]); } else { address = string.Format("{0},{1},{2},{3}", dr["address1_text"], dr["city_name"], dr["state_province_name"], dr["postal_code_text"]); } dr.SetField("Address", address); } _existingCustBindingSource = new BindingSource(); //Add primary key to the existing customers table var key = new DataColumn[1]; key[0] = _existingCustomers.Columns["customer_number"]; _existingCustomers.PrimaryKey = key; _existingCustBindingSource.DataSource = _existingCustomers; this.customDataGridViewExistingCustomer.AutoGenerateColumns = false; newColIndex = 0; var selectColumn = new DataGridViewCheckBoxColumn { HeaderText = "Select", ReadOnly = false, ThreeState = false, FalseValue = false }; newColIndex = this.customDataGridViewExistingCustomer.Columns.Add(selectColumn); newColIndex = this.customDataGridViewExistingCustomer.Columns.Add("family_name", "Last Name"); this.customDataGridViewExistingCustomer.Columns[newColIndex].DataPropertyName = "family_name"; this.customDataGridViewExistingCustomer.Columns[newColIndex].ReadOnly = true; newColIndex = this.customDataGridViewExistingCustomer.Columns.Add("first_name", "First Name"); this.customDataGridViewExistingCustomer.Columns[newColIndex].DataPropertyName = "first_name"; this.customDataGridViewExistingCustomer.Columns[newColIndex].ReadOnly = true; newColIndex = this.customDataGridViewExistingCustomer.Columns.Add("Address", "Address"); this.customDataGridViewExistingCustomer.Columns[newColIndex].DataPropertyName = "Address"; this.customDataGridViewExistingCustomer.Columns[newColIndex].ReadOnly = true; newColIndex = this.customDataGridViewExistingCustomer.Columns.Add("birthdate", "Date of Birth"); this.customDataGridViewExistingCustomer.Columns[newColIndex].DataPropertyName = "birthdate"; this.customDataGridViewExistingCustomer.Columns[newColIndex].ReadOnly = true; newColIndex = this.customDataGridViewExistingCustomer.Columns.Add("IdcodeNumber", "ID Type & Number"); this.customDataGridViewExistingCustomer.Columns[newColIndex].DataPropertyName = "IDData"; this.customDataGridViewExistingCustomer.Columns[newColIndex].ReadOnly = true; newColIndex = this.customDataGridViewExistingCustomer.Columns.Add("Issuer_Name", "Issuer"); this.customDataGridViewExistingCustomer.Columns[newColIndex].DataPropertyName = "Issuer_Name"; this.customDataGridViewExistingCustomer.Columns[newColIndex].ReadOnly = true; if (_nameCheck) { this.customDataGridViewExistingCustomer.Columns["family_name"].DefaultCellStyle.ForeColor = Color.Red; this.customDataGridViewExistingCustomer.Columns["first_name"].DefaultCellStyle.ForeColor = Color.Red; this.customDataGridViewExistingCustomer.Columns["birthdate"].DefaultCellStyle.ForeColor = Color.Red; } else { this.customDataGridViewExistingCustomer.Columns["IdcodeNumber"].DefaultCellStyle.ForeColor = Color.Red; this.customDataGridViewExistingCustomer.Columns["Issuer_Name"].DefaultCellStyle.ForeColor = Color.Red; } this.customButtonContinue.Enabled = false; this.customDataGridViewExistingCustomer.DataSource = _existingCustBindingSource; this.customDataGridViewNewCustomer.ClearSelection(); this.customDataGridViewExistingCustomer.ClearSelection(); this.customDataGridViewExistingCustomer.AutoResizeColumns(); this.ActiveControl = labelRedHeader; } catch (SystemException ex) { BasicExceptionHandler.Instance.AddException("Error loading the existing customer screen ", ex); clearCustomerSessionValues(); this.NavControlBox.Action = NavBox.NavAction.CANCEL; } }
private void customButtonSubmit_Click(object sender, EventArgs e) { ComboBox addrstate = (ComboBox)this.state1.Controls[0]; getPersonalIdentificationDataFromForm(); if (idEditResource) { if (string.IsNullOrEmpty(customTextBoxLastName.Text.Trim()) || string.IsNullOrEmpty(customTextBoxFirstName.Text.Trim()) || string.IsNullOrEmpty(customTextBoxAddr1.Text.Trim()) || string.IsNullOrEmpty(addrstate.GetItemText(addrstate.SelectedItem)) || string.IsNullOrEmpty(customTextBoxCity.Text.Trim()) || string.IsNullOrEmpty(zipcode1.Text) || string.IsNullOrEmpty(strIdentTypeCode) || string.IsNullOrEmpty(strIdentIssuer) || string.IsNullOrEmpty(strIdentNumber.Trim())) { incompleteData = true; } } else { if (string.IsNullOrEmpty(customTextBoxAddr1.Text.Trim()) || string.IsNullOrEmpty(addrstate.GetItemText(addrstate.SelectedItem)) || string.IsNullOrEmpty(customTextBoxCity.Text.Trim()) || string.IsNullOrEmpty(zipcode1.Text)) { incompleteData = true; } } string errorCode; string errorText; string custMiddleInitial = string.Empty; custMiddleInitial = this.idEditResource ? (!string.IsNullOrEmpty(this.customTextBoxInitial.Text)?this.customTextBoxInitial.Text.Substring(0, 1):"") : this.newCustomer.MiddleInitial; var dSession = GlobalDataAccessor.Instance.DesktopSession; MerchandiseProcedures.UpdateGunCustomerData(GlobalDataAccessor.Instance.CurrentSiteId.StoreNumber, Utilities.GetStringValue(gunBookData.Rows[0]["gun_number"]), dSession.GunAcquireCustomer ? "A" : "D", idEditResource ? customTextBoxLastName.Text : newCustomer.LastName, idEditResource ? customTextBoxFirstName.Text : newCustomer.FirstName, custMiddleInitial, string.Format("{0} {1}", customTextBoxAddr1.Text, customTextBoxAddr2.Text), customTextBoxCity.Text, addrstate.GetItemText(addrstate.SelectedItem), zipcode1.Text, idEditResource ? strIdentTypeCode : newCustomer.getFirstIdentity().IdType, idEditResource ? strIdentIssuer : newCustomer.getFirstIdentity().IdIssuer, idEditResource ? strIdentNumber : newCustomer.getFirstIdentity().IdValue, dSession.UserName, out errorCode, out errorText); if (errorCode != "0") { MessageBox.Show("Customer data could not be updated"); } else { MessageBox.Show("Customer data updated successfully"); DataTable gunTableData; Item gunItem; MerchandiseProcedures.GetGunData(GlobalDataAccessor.Instance.OracleDA, GlobalDataAccessor.Instance.CurrentSiteId.StoreNumber, Utilities.GetIntegerValue(gunBookData.Rows[0]["gun_number"]), out gunTableData, out gunItem, out errorCode, out errorText); dSession.GunData = gunTableData; dSession.GunItemData = gunItem; } NavControlBox.Action = NavBox.NavAction.BACKANDSUBMIT; }
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; } } }
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)); }
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; } } } }