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);
            }
        }
        protected void btnContinue_Click(object sender, EventArgs e)
        {
            bool bDiscountsChanged = false;
            bool bQuoteError = false;

            try
            {
                string url = "customizeplan.aspx";
                mCustomer.MembershipInfo.Email = txtEmail.Text;

                //Need to check each one to see if they are same as coming in
                //Important!! If they change something, it has to change for all pets!

                if (mCustomer.DiscountInternetPurchase != chkInternetDiscount.Checked)
                {
                    bDiscountsChanged = true;
                    mCustomer.DiscountInternetPurchase = chkInternetDiscount.Checked;
                }

                if (mCustomer.DiscountEBEnrollmentCode != chkEmployeeGroup.Checked)
                {
                    bDiscountsChanged = true;
                    mCustomer.DiscountEBEnrollmentCode = chkEmployeeGroup.Checked;
                }

                if (mCustomer.DiscountVetSelected != chkVetEmp.Checked)
                {
                    bDiscountsChanged = true;
                    mCustomer.DiscountVetSelected = chkVetEmp.Checked;
                }

                if (mCustomer.DiscountMilitarySelected != chkMilitary.Checked)
                {
                    bDiscountsChanged = true;
                    mCustomer.DiscountMilitarySelected = chkMilitary.Checked;
                }

                if (chkEmployeeGroup.Checked && mCustomer.EnrollmentCode == "99-99-00-9998")
                {
                    //set this up for the generic enrollment code.
                    mCustomer.EnrollmentCode = "99-99-18-6232";
                    mCustomer.EBEnrollmentCodeCompany = txtEmployer.Text.ToString();
                }

                if (chkMilitary.Checked)
                {
                    mCustomer.MilitaryBranchID = (short) ddlBranch.SelectedIndex;
                    mCustomer.MilitaryStatusID = (short) rblServiceType.SelectedIndex;
                }

                if (!bCurrentCustomer)
                {
                    mthisPet.DeductibleAmount = 250;
                    mthisPet.LimitAmount = 5000;
                    mthisPet.Reimbursement = .8m;
                    mthisPet.RiderName = "";
                    mthisPet.Routine = "";
                }

                int planId = 0;
                Int16 typeid = (short)(mCustomer.LifeTimeActive ? 2 : 1);

                PetfirstData pfData = new PetfirstData();
                {
                    planId = pfData.GetPlanId(mthisPet.LimitAmount, typeid);
                    mCustomer.Underwriter = pfData.GetUnderwriterID(mCustomer.EnrollmentCode);

                    //Save our data//
                    //mCustomer.MyPets.Add(mthisPet);
                    pfData.SaveCustomer(mCustomer);
                }

                PetfirstBL pfBl = new PetfirstBL();
                List<Pet> lstEnrollPet = new List<Pet>();
                lstEnrollPet.Add(mthisPet);

                //Now if something has changed we have to go back and
                if (bDiscountsChanged && mCustomer.MyPets.Count > 0)
                {
                    DoRequote();
                }

                try
                {
                    mthisPet.PlanId = planId;
                    mthisPet.QuoteId = 0;

                    if (!pfBl.GetFastQuote(ref mCustomer, ref mthisPet, true))
                    {

                        pfBl.GetMonthlyQuote(ref mCustomer, lstEnrollPet);

                        if (mCustomer.WebserviceErrorMsg.Equals(""))
                        {
                            pfBl.GetAnnualQuote(ref mCustomer, lstEnrollPet);
                        }
                        else
                        {
                            displayError("getting quote ", mCustomer.WebserviceErrorMsg, true);
                            bQuoteError = true;
                        }
                    }

                }
                catch(Exception ex)
                {
                    displayError("getting quote ", ex.ToString(), true);
                    bQuoteError = true;
                }

                //mCustomer.MyPets.Add(mthisPet);
                pfData.SaveCustomer(mCustomer);

                if (!bQuoteError)
                {
                    Response.Redirect(url, false);
                    Context.ApplicationInstance.CompleteRequest();
                }

                try
                {
                    pfBl.StoreLeadCapture(ref mCustomer, lstEnrollPet);
                }
                catch { }
            }
            catch  { }
        }
        private void RecalculatePlan()
        {
            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();
            try
            {
                if (!pfBl.GetFastQuote(ref mCustomer, ref mthisPet, false))
                {
                    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("Recalc ", mCustomer.WebserviceErrorMsg, true);
                    }
                }
            }
            catch (Exception ex)
            {
                displayError("Requote ", ex.ToString(), true);
            }

            UpdateLabels();
        }
        private void DoRequote()
        {
            var planGroup = from p in mCustomer.MyPets
                            where p.Enrolled == true
                            group p by p.QuoteId into g
                            select g;
            PetfirstBL pfBL = new PetfirstBL();
            bool error = false;
            foreach (var pg in planGroup)
            {

                List<Pet> lstPets = (from p in mCustomer.MyPets
                                     where p.QuoteId == pg.Key
                                     select p).ToList();

                if (!pfBL.GetFastQuote(ref mCustomer, ref mthisPet, true))
                {
                    try
                    {
                        pfBL.GetMonthlyQuote(ref mCustomer, lstPets);

                        if (mCustomer.WebserviceErrorMsg.Equals(""))
                        {
                            //save to database
                            try
                            {
                                using (PetfirstData pfData = new PetfirstData())
                                {
                                    pfData.SaveCustomer(mCustomer);
                                    pfData.SaveEnrolledPlan(lstPets, mCustomer.PayFrequency);
                                }
                            }
                            catch (Exception ex)
                            {
                                displayError("Requote ", ex.ToString(), true);
                                error = true;
                            }
                            //get AnuallyQuote
                            try
                            {
                                pfBL.GetAnnualQuote(ref mCustomer, lstPets);
                            }
                            catch (Exception ex)
                            {
                                displayError("Requote ", ex.ToString(), true);
                                error = true;
                            }
                        }
                        else
                        {
                            displayError("Requote ", mCustomer.WebserviceErrorMsg, true);
                            error = true;
                        }
                    }
                    catch (Exception ex)
                    {
                        displayError("Requote ", ex.ToString(), true);
                        error = true;
                    }
                }
                if (error)
                    break;
            }
        }