protected void btnSave_Click(object sender, EventArgs e)
        {
            //quote price, put quoteid back to pets
            if (Page.IsValid)
            {
                if (mCustomer != null)
                {
                    //validation:
                    string pet1 = ddlPet1.SelectedValue;
                    string pet2 = string.Empty;
                    string pet3 = string.Empty;
                    bool bSamePet = false;
                    if (dvPet2.Visible && dvPet3.Visible)
                    {
                        pet2 = ddlPet2.SelectedValue;
                        pet3 = ddlPet3.SelectedValue;
                        if (pet1.Equals(pet2) || pet1.Equals(pet3) || pet2.Equals(pet3))
                            bSamePet = true;
                    }
                    else if (dvPet2.Visible)
                    {
                        pet2 = ddlPet2.SelectedValue;
                        if (pet1.Equals(pet2))
                            bSamePet = true;
                    }//dvpet3 cannot be visible if dvpet2 is not
                    if (bSamePet)
                    {
                        System.Text.StringBuilder sb = new System.Text.StringBuilder();
                        sb.Append(@"<script type='text/javascript'>");
                        sb.Append("$('#same_pet').modal('show');");
                        sb.Append(@"</script>");
                        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "ShowSamePetModal", sb.ToString(), false);
                        return;
                    }
                    List<Pet> lstPets = (List<Pet>)Session["EditPlanPet"];
                    //need to reset the pets that are being edited.
                    if (lstPets != null)
                    {
                        foreach (Pet p in lstPets)
                        {
                            p.QuoteId = 0;
                            p.RecurringMonthPaymentTotal = 0;
                            p.RecurringMonthTax = 0;
                            p.PlanId = 0;
                            p.PlanName = string.Empty;
                            p.PlanType = "0";
                            p.FirstMonthPaymentTotal = 0;
                            p.FirstMonthTax = 0;
                            p.FirstMonthPremiumOnly = 0;
                            p.RecurringMonthPremiumOnly = 0;
                            p.AnnualPaymentTotal = 0;
                            //p.LeadId = "";//what commercial site doing currently- recreate lead when plan is removed//this is not correct, if the customer bought the policy, the old leadid not getting updated, they still get the spam email
                            ////kp: 2015-05-04 retrieve quote: logged exception bug fix--if multi-pets in a family plan, when they edit it and switch one pet to individual plan
                            ////and then later to edit the plan for remaining pets this will cause exception during bindingeditcontorl.
                            p.Enrolled = false;//if multi-pets in a family plan, when they edit to individual plan, need to force reselection of the remaining pet
                            p.QPlanId = 0;//if multi-pets in a family plan, when they edit to individual plan, they need to have its own qplanid
                            ////end 2015-05-04
                        }
                        Session.Remove("EditPlanPet");
                    }
                    mCustomer.WebserviceErrorMsg = "";
                    List<Pet> lstEnrollPets = new List<Pet>();
                    Pet p1 = (Pet)(from p in mCustomer.MyPets
                                   where p.PetName.Equals(ddlPet1.SelectedValue)
                                   select p).FirstOrDefault();
                    if (p1 != null)
                    {
                        SavePetAttributes(ref p1);
                        int planId = 0;
                        Int16 typeid = (short)(mCustomer.LifeTimeActive ? 2 : 1);
                        try
                        {
                            using (PetfirstData pfData = new PetfirstData())
                            {
                                //planId = pfData.GetPlanId(p1.LimitAmount, Int16.Parse(rblPlanType.SelectedValue));
                                planId = pfData.GetPlanId(p1.LimitAmount, typeid);
                                mCustomer.Underwriter = pfData.GetUnderwriterID(mCustomer.EnrollmentCode);
                                p1.PlanId = planId;
                                p1.QuoteId = 0;//reset
                                //p1.LeadId = "";
                                lstEnrollPets.Add(p1);

                                if (ddlPet2.Visible)
                                {
                                    Pet p2 = (Pet)(from p in mCustomer.MyPets
                                                   where p.PetName.Equals(ddlPet2.SelectedValue)
                                                   select p).FirstOrDefault();
                                    if (p2 != null)
                                    {
                                        SavePetAttributes(ref p2);
                                        p2.PlanId = planId;
                                        p2.QuoteId = 0;
                                        //p2.LeadId = "";
                                        lstEnrollPets.Add(p2);
                                    }
                                }
                                if (ddlPet3.Visible)
                                {
                                    if (ddlPet3.SelectedValue.Equals("0"))
                                    {
                                        Pet p3 = (Pet)(from p in mCustomer.MyPets
                                                       where p.PetName.Equals(ddlPet3.SelectedValue)
                                                       select p).FirstOrDefault();
                                        if (p3 != null)
                                        {
                                            SavePetAttributes(ref p3);
                                            p3.PlanId = planId;
                                            p3.QuoteId = 0;
                                            //p3.LeadId = "";
                                            lstEnrollPets.Add(p3);
                                        }
                                    }
                                }
                                int count = lstEnrollPets.Count;
                                foreach (Pet p in lstEnrollPets)
                                {
                                    p.IsFamilyPlan = count > 1;
                                }
                                PetfirstBL pfBl = new PetfirstBL();
                                try
                                {
                                    pfBl.GetMonthlyQuote(ref mCustomer, lstEnrollPets);
                                    if (mCustomer.WebserviceErrorMsg.Equals(""))
                                    {
                                        pfBl.GetAnnualQuote(ref mCustomer, lstEnrollPets);
                                        BindPetsRepeater();
                                        DetermineReviewQuoteStatus();
                                        ////kp: 2015-05-21 delete standard plan site wide
                                        //ToggleButtonActive(false);//default to lifetime
                                        PopulatePlanPanel();
                                        ////end 2015-05-21
                                        //need to rebind the right panel
                                        DetermineFamilyOrIndividualPlan();
                                        //ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "ScrollToPlanSum", "window.location = '#plansum';", false);//does not work
                                        //lead
                                        try
                                        {
                                            pfBl.StoreLeadCapture(ref mCustomer, lstEnrollPets);
                                        }
                                        catch { }
                                        try
                                        {
                                            pfData.SaveEnrolledPlan(lstEnrollPets, mCustomer.PayFrequency);
                                            pfData.LinkPlanForPet(lstEnrollPets);
                                        }
                                        catch (Exception ex)
                                        {
                                            displayError("Saving Enrolled Plan ", ex.ToString(), null);
                                        }

                                    }
                                    else
                                    {
                                        displayError("getting quote ", mCustomer.WebserviceErrorMsg, lblError);

                                    }
                                }
                                catch (Exception ex)
                                {
                                    displayError("getting quote ", ex.ToString(), lblError);
                                }
                            }
                        }
                        catch (Exception ex1)
                        {
                            displayError("getting quote ", ex1.ToString(), lblError);
                        }
                    }
                    else
                    {
                        lblError.Text = "No pets is selected.";
                    }
                }
            }
        }