protected void btnContinue_Click(object sender, EventArgs e) { bool bError = false; if (mCustomer == null) { InitiatePetfirstCustomer(); } string url; try { mthisPet.PetName = txtPetName.Text; mthisPet.Birthday = DateTime.Today.AddYears(-(ddlAge.SelectedIndex - 1)); mthisPet.Birthday = mthisPet.Birthday.AddMonths(-6); mthisPet.BreedId = int.Parse(ddlBreed.SelectedValue.ToString()); mthisPet.BreedName = ddlBreed.SelectedItem.Text; mthisPet.ColorId = 146; mthisPet.ColorName = "Any"; mthisPet.SpeciesId = int.Parse(rblSpecies.SelectedValue.ToString()); mthisPet.SpeciesName = rblSpecies.SelectedItem.Text; //Handle Mixed if (ddlBreed.SelectedValue.ToString() == "10000") { mthisPet.WeightId = int.Parse(rbRadioButtonListMixed.SelectedValue); mthisPet.BreedId = 54; } if (bAddPet) { try { mthisPet.DeductibleAmount = 250; mthisPet.LimitAmount = 5000; mthisPet.Reimbursement = .8m; mthisPet.RiderName = ""; mthisPet.Routine = ""; int planId = 0; Int16 typeid = (short)(mCustomer.LifeTimeActive ? 2 : 1); using (PetfirstData pfData = new PetfirstData()) { planId = pfData.GetPlanId(mthisPet.LimitAmount, typeid); mCustomer.Underwriter = pfData.GetUnderwriterID(mCustomer.EnrollmentCode); mthisPet.PlanId = planId; mthisPet.QuoteId = 0; } PetfirstBL pfBl = new PetfirstBL(); if (!pfBl.GetFastQuote(ref mCustomer, ref mthisPet, true)) { List<Pet> lstEnrollPet = new List<Pet>(); lstEnrollPet.Add(mthisPet); pfBl.GetMonthlyQuote(ref mCustomer, lstEnrollPet); if (mCustomer.WebserviceErrorMsg.Equals("")) { pfBl.GetAnnualQuote(ref mCustomer, lstEnrollPet); } else { displayError("getting quote ", mCustomer.WebserviceErrorMsg, true); bError = true; } } } catch (Exception ex) { displayError("getting quote ", ex.ToString(), true); bError = true; } if (!bError) { url = "CustomizePlan.aspx"; Response.Redirect(url, false); Context.ApplicationInstance.CompleteRequest(); } } else if (bSamePet) { CoreServiceClient csc = new CoreServiceClient(); CoreServiceGetStateByZipResponse resp = csc.GetStateByZip(txtZip.Text); if (string.IsNullOrEmpty(resp.Error.ErrorText)) { mCustomer.MembershipInfo.StateId = resp.State.Id; mCustomer.MembershipInfo.City = resp.State.CityName; mCustomer.MembershipInfo.State = resp.State.StateName; mCustomer.MembershipInfo.Zip = txtZip.Text; mCustomer.DiscountMilitaryAvailable = mCustomer.DiscountMilitarySelected = false; mCustomer.DiscountVetAvailable = mCustomer.DiscountVetSelected = false; using (PetfirstData pfData = new PetfirstData()) { mCustomer.Underwriter = pfData.GetUnderwriterID(mCustomer.EnrollmentCode); if (mCustomer.Underwriter == 4) { CoreServiceGetDiscountByStateResponse response = csc.GetDiscountsByState(mCustomer.MembershipInfo.StateId); if (string.IsNullOrEmpty(resp.Error.ErrorText)) { foreach (Discount d in response.Discounts) { switch (d.DiscountID) { case 356: mCustomer.DiscountMilitaryAvailable = true; break; case 333: mCustomer.DiscountVetAvailable = true; break; default: break; } } } } } try { mthisPet.DeductibleAmount = 250; mthisPet.LimitAmount = 5000; mthisPet.Reimbursement = .8m; mthisPet.RiderName = ""; mthisPet.Routine = ""; int planId = 0; Int16 typeid = (short)(mCustomer.LifeTimeActive ? 2 : 1); using (PetfirstData pfData = new PetfirstData()) { planId = pfData.GetPlanId(mthisPet.LimitAmount, typeid); mCustomer.Underwriter = pfData.GetUnderwriterID(mCustomer.EnrollmentCode); mthisPet.PlanId = planId; mthisPet.QuoteId = 0; } PetfirstBL pfBl = new PetfirstBL(); if (!pfBl.GetFastQuote(ref mCustomer, ref mthisPet, true)) { List<Pet> lstEnrollPet = new List<Pet>(); lstEnrollPet.Add(mthisPet); pfBl.GetMonthlyQuote(ref mCustomer, lstEnrollPet); if (mCustomer.WebserviceErrorMsg.Equals("")) { pfBl.GetAnnualQuote(ref mCustomer, lstEnrollPet); } else { displayError("getting quote ", mCustomer.WebserviceErrorMsg, true); bError = true; } } } catch (Exception ex) { displayError("getting quote ", ex.ToString(), true); bError = true; } if (!bError) { url = "YourInformation.aspx?current_customer=true"; Response.Redirect(url, false); Context.ApplicationInstance.CompleteRequest(); } } } else { CoreServiceClient csc = new CoreServiceClient(); CoreServiceGetStateByZipResponse resp = csc.GetStateByZip(txtZip.Text); if (string.IsNullOrEmpty(resp.Error.ErrorText)) { mCustomer.MembershipInfo.StateId = resp.State.Id; mCustomer.MembershipInfo.City = resp.State.CityName; mCustomer.MembershipInfo.State = resp.State.StateName; mCustomer.MembershipInfo.Zip = txtZip.Text; using (PetfirstData pfData = new PetfirstData()) { mCustomer.Underwriter = pfData.GetUnderwriterID(mCustomer.EnrollmentCode); if (mCustomer.Underwriter == 4) { CoreServiceGetDiscountByStateResponse response = csc.GetDiscountsByState(mCustomer.MembershipInfo.StateId); if (string.IsNullOrEmpty(resp.Error.ErrorText)) { foreach (Discount d in response.Discounts) { switch (d.DiscountID) { case 356: mCustomer.DiscountMilitaryAvailable = true; break; case 333: mCustomer.DiscountVetAvailable = true; break; default: break; } } } } } url = "YourInformation.aspx"; Response.Redirect(url, false); Context.ApplicationInstance.CompleteRequest(); } else { lblError.Text = string.Concat("Sorry, we cannot find the zip you entered, please make sure the zip you entered is correct.<br />If you continue to get this message, please call ", mCustomer.CallCenter); } } } catch (Exception ex) { DisplayError("verifying your zip", ex.ToString(), true); } }
private bool LoadCustomerInfo(ref PetfirstCustomer mCustomer, string scustomerLookup) { bool bReturn = true; SqlConnection con = GetConnection(); SqlDataReader sdr = null; SqlCommand cmd = new SqlCommand("usp_pricecompare_tmpcustomer_get_by_customer_id", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("@customer_id", SqlDbType.BigInt)); cmd.Parameters["@customer_id"].Value = Int32.Parse(scustomerLookup); try { con.Open(); sdr = cmd.ExecuteReader(); while (sdr.Read()) { mCustomer.MembershipInfo.FirstName = sdr.GetString(CTFIRSTNAME); mCustomer.MembershipInfo.LastName = sdr.GetString(CTLASTNAME); mCustomer.EnrollmentCode = sdr.GetString(CTENROLLMENTCODE); using (PetfirstData pfData = new PetfirstData()) { mCustomer.CallCenter = pfData.GetPhoneNumber(mCustomer.EnrollmentCode); } mCustomer.MembershipInfo.Email = sdr.GetString(CTEMAIL); mCustomer.MembershipInfo.Zip = sdr.GetString(CTZIP); mCustomer.MembershipInfo.Phone = sdr.GetString(CTPHONE); if ((sdr.GetString(CTPAYFREQUENCY)).ToString().Contains("monthly") == true) { mCustomer.PayFrequency = 1; } else { mCustomer.PayFrequency = 2; } CoreServiceClient csc = new CoreServiceClient(); CoreServiceGetStateByZipResponse resp = csc.GetStateByZip(mCustomer.MembershipInfo.Zip); if (string.IsNullOrEmpty(resp.Error.ErrorText)) { mCustomer.MembershipInfo.StateId = resp.State.Id; mCustomer.MembershipInfo.City = resp.State.CityName; mCustomer.MembershipInfo.State = resp.State.StateName; } Pet myPet = new Pet(); myPet.Birthday = sdr.GetDateTime(CTPETBIRTHDAY); myPet.ColorId = 146; //Any Breed// myPet.ColorName = "Any"; if ((sdr.GetString(CTSPECIESNAME)).ToString().Contains("dog") == true) { myPet.SpeciesId = 1; myPet.SpeciesName = "Dog"; } else { myPet.SpeciesId = 2; myPet.SpeciesName = "Cat"; } myPet.BreedId = sdr.GetInt32(CTBREEDID); myPet.WeightId = sdr.GetByte(CTWEIGHTID); myPet.PetName = sdr.GetString(CTPETNAME); myPet.GenderFull = sdr.GetString(CTPETGENDER); myPet.GenderFull.Trim(); if (myPet.GenderFull.Contains("female")) { myPet.Gender = "F"; } else { myPet.Gender = "M"; } myPet.DeductibleAmount = sdr.GetDecimal(CTDEDUCTIBLE); myPet.Reimbursement = sdr.GetDecimal(CTREIMBURSEMENT); myPet.SpayedOrNeutered = sdr.GetBoolean(CTSPAYORNEUTER); //stored procedure will take care of figuring out if this is true or not. mCustomer.DiscountVetAvailable = true; mCustomer.DiscountMilitaryAvailable = true; mCustomer.DiscountMilitarySelected = sdr.GetBoolean(CTMILITARY); mCustomer.DiscountVetSelected = sdr.GetBoolean(CTVETPROFFESIONAL); mCustomer.MyPets.Add(myPet); try { using (PetfirstData pfData = new PetfirstData()) { pfData.SaveCustomer(mCustomer); } } catch { throw; } } con.Close(); } catch (Exception ex) { bReturn = false; LoggingError(ex.Message, ex.StackTrace); } finally { if (con != null) { con.Close(); con.Dispose(); con = null; } if (cmd != null) { cmd.Dispose(); cmd = null; } } return (bReturn); }