private void load_breeds(int speciesId)
 {
     try
     {
         ListsManager lm = new ListsManager();
         List<Breed> lstBreeds = lm.GetBreedList(speciesId, mCustomer);
         if (lstBreeds != null)
         {
             ddlBreed.DataSource = lstBreeds;
             ddlBreed.DataBind();
             ddlBreed.Items.Insert(0, new ListItem("Select Breed", "0"));
         }
         else
         {
             displayError("loading breed list", "", true);
         }
     }
     catch (Exception ex)
     {
        displayError("loading breed list", ex.ToString(), true);
     }
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            HandleMenuItems();

            mCustomer = (PetfirstCustomer)Session["Customer"];
            mthisPet = (Pet)Session["Pet"];
            if (mCustomer == null)
            {
                Response.Redirect("Default.aspx", false);
                Context.ApplicationInstance.CompleteRequest();
            }
            else
            {
                if (!Page.IsPostBack)
                {
                    if (mCustomer != null)
                    {
                        ListsManager lm = new ListsManager();
                        PopulatePlanDetails(lm);
                    }

                    if (mthisPet != null)
                    {
                        if(!string.IsNullOrEmpty(Request.QueryString["canceladd"])) //see if we are cancelling add pet. If so, then load latest pet.
                        {
                            mthisPet = mCustomer.MyPets.ElementAtOrDefault(mCustomer.MyPets.Count - 1);
                            mCustomer.MyPets.RemoveAt(mCustomer.MyPets.Count - 1);
                        }

                        string jd;
                        PetName.Text = mthisPet.PetName + "'s";
                        ddlLimit.SelectedValue = mthisPet.LimitAmount.ToString("C0");
                        ddlDeductible.SelectedValue  = mthisPet.DeductibleAmount.ToString("C0");
                        ddlReimburse.SelectedValue = jd = (mthisPet.Reimbursement.ToString("P0").Replace(" ", ""));
                        ddlRoutine.SelectedValue = GetRiderNameFromValue(mthisPet.Routine);
                        lblDiscounts.Text = (mthisPet.InternetDiscountAmount +
                                             mthisPet.EBDiscountAmount +
                                             mthisPet.MilitaryDiscountAmount +
                                             mthisPet.VetDiscountAmount).ToString("C2");
                    }
                }

                if (mthisPet != null)
                {
                    UpdateLabels();
                }

                this.Master.NumberofPets = (mCustomer.MyPets.Count + 1).ToString();

            }

            #region debug
            //            if (mCustomer != null && mthisPet != null)
            //            {
            //                CustomerDebug.Text = String.Format(@"  First Name: [{0}], Last Name: [{1}], Add1: [{2}], Add2: [{3}], City: [{4}], State: [{5}], StateCode: [{6}],
            //                                                 Zip: [{7}], Phone: [{8}], Email: [{9}], CustomerID: [{10}], CallCenter: [{11}], EC: [{12}], Pay Freq: [{13}],
            //                                                 CC Num: [{14}], Sec Code: [{15}], Exp: [{16}/{17}], LifeTimeActive: [{18}] DISCOUNTS: EBEC: [{19}], Vet: [{20}],
            //                                                 Military: [{21}], MilBranchID [{22}], MilStatusID[{23}]",
            //                   mCustomer.MembershipInfo.FirstName,
            //                   mCustomer.MembershipInfo.LastName,
            //                   mCustomer.MembershipInfo.Address1,
            //                   mCustomer.MembershipInfo.Address2,
            //                   mCustomer.MembershipInfo.City,
            //                   mCustomer.MembershipInfo.State,
            //                   mCustomer.MembershipInfo.StateId,
            //                   mCustomer.MembershipInfo.Zip,
            //                   mCustomer.MembershipInfo.Phone,
            //                   mCustomer.MembershipInfo.Email,
            //                   mCustomer.CustomerId,
            //                   mCustomer.CallCenter,
            //                   mCustomer.EnrollmentCode,
            //                   mCustomer.PayFrequency,
            //                   mCustomer.CcNumber,
            //                   mCustomer.SecCode,
            //                   mCustomer.ExpirationMonth,
            //                   mCustomer.ExpirationYear,
            //                   mCustomer.LifeTimeActive,
            //                   mCustomer.EBEnrollmentCodeDiscount,
            //                   mCustomer.VetDiscount,
            //                   mCustomer.MilitaryDiscount,
            //                   mCustomer.MilitaryBranchID,
            //                   mCustomer.MilitaryStatusID
            //                   );
            //                CurrentPetDebug.Text = String.Format(@"ID: [{0}], Name: [{1}], SpeciesID: [{2}], SpeciesName: [{3}], BreedID: [{4}], BreedName: [{5}], Age: [{6}],
            //                                                 BirthDay: [{7}], WeightID: [{8}], Gender: [{9}], GenderFull: [{10}], Limit Amount: [{11}], Deductible Amount: [{12}], Reimbursement: [{13}],
            //                                                 Rider Name: [{14}], Routine: [{15}], AnnualPaymentTotal: [{16}], FirstMonthlyPaymentTotal: [{17}], FirstMonthlyPremiumOnly: [{18}],
            //                                                 FirstMonthTax: [{19}], RecurringMonthPaymentTotal: [{20}], RecurringMonthPremiumOnly: [{21}], RecurringMonthTax [{22}], PolicyNumber[{23}],
            //                                                 PolicyID: [{24}], PlanType: [{25}], PlanName: [{26}], PlanID: [{27}], SpayedNeutered: [{28}]",
            //                    mthisPet.PetId,
            //                    mthisPet.PetName,
            //                    mthisPet.SpeciesId,
            //                    mthisPet.SpeciesName,
            //                    mthisPet.BreedId,
            //                    mthisPet.BreedName,
            //                    mthisPet.Age,
            //                    mthisPet.Birthday,
            //                    mthisPet.WeightId,
            //                    mthisPet.Gender,
            //                    mthisPet.GenderFull,
            //                    mthisPet.LimitAmount,
            //                    mthisPet.DeductibleAmount,
            //                    mthisPet.Reimbursement,
            //                    mthisPet.RiderName,
            //                    mthisPet.Routine,
            //                    mthisPet.AnnualPaymentTotal,
            //                    mthisPet.FirstMonthPaymentTotal,
            //                    mthisPet.FirstMonthPremiumOnly,
            //                    mthisPet.FirstMonthTax,
            //                    mthisPet.RecurringMonthPaymentTotal,
            //                    mthisPet.RecurringMonthPremiumOnly,
            //                    mthisPet.RecurringMonthTax,
            //                    mthisPet.PolicyNumber,
            //                    mthisPet.PolicyId,
            //                    mthisPet.PlanType,
            //                    mthisPet.PlanName,
            //                    mthisPet.PlanId,
            //                    mthisPet.SpayedOrNeutered);
            //            }
            #endregion
        }
 //private void ToggleSpecies(bool isDog)
 //{
 //    if (isDog)
 //    {
 //        //btnDog.CssClass= "btn btn-lg btn-pf-primary pet_species active";
 //        //btnCat.CssClass ="btn btn-lg btn-pf-primary pet_species";
 //    }
 //    else
 //    {
 //        //btnDog.CssClass = "btn btn-lg btn-pf-primary pet_species";
 //        //btnCat.CssClass = "btn btn-lg btn-pf-primary pet_species active";
 //    }
 //}
 //kp:2015-06-29
 //private void ToggleGender(bool isMale)
 //{
 //    if (isMale)
 //    {
 //        //html input not maintaining its active status after post back
 //        //lblMale.Attributes.Add("class", "btn btn-sm btn-pf-secondary active");
 //        //lblFemale.Attributes.Add("class", "btn btn-sm btn-pf-secondary");
 //        //btnMale.Checked = true;
 //        //btnFemale.Checked = false;
 //        btnMale.CssClass = "btn btn-sm btn-pf-secondary active";
 //        btnFemale.CssClass = "btn btn-sm btn-pf-secondary";
 //    }
 //    else
 //    {
 //        //lblMale.Attributes.Add("class","btn btn-sm btn-pf-secondary");
 //        //lblFemale.Attributes.Add("class", "btn btn-sm btn-pf-secondary active");
 //        //btnMale.Checked = false;
 //        //btnFemale.Checked = true;
 //        btnMale.CssClass = "btn btn-sm btn-pf-secondary";
 //        btnFemale.CssClass = "btn btn-sm btn-pf-secondary active";
 //    }
 //}
 //private void ToggleSpayed(bool isSpayed)
 //{
 //    if (isSpayed)
 //    {
 //        btnYes.CssClass = "btn btn-sm btn-pf-secondary active";
 //        btnNo.CssClass = "btn btn-sm btn-pf-secondary";
 //        //lblYes.Attributes.Add("class","btn btn-sm btn-pf-secondary active");
 //        //lblNo.Attributes.Add("class", "btn btn-sm btn-pf-secondary");
 //        //btnYes.Checked = true;
 //        //btnNo.Checked = false;
 //    }
 //    else
 //    {
 //        btnYes.CssClass = "btn btn-sm btn-pf-secondary";
 //        btnNo.CssClass = "btn btn-sm btn-pf-secondary active";
 //        //lblYes.Attributes.Add("class", "btn btn-sm btn-pf-secondary");
 //        //lblNo.Attributes.Add("class", "btn btn-sm btn-pf-secondary active");
 //        //btnNo.Checked = true;
 //        //btnYes.Checked = false;
 //    }
 //}
 //private void loadColorList()
 //{
 //    //load color from service
 //    try
 //    {
 //        ListsManager lm = new ListsManager();
 //        PetColor []  lstColor =lm.GetColorList(mCustomer);
 //        if (lstColor !=null)//check error
 //        {
 //            ddlColor.DataSource = lstColor;
 //            ddlColor.DataBind();
 //        }
 //        else
 //        {
 //            //this is already logged by the lists managmer
 //            displayError("loading color list", "", false);
 //        }
 //    }
 //    catch (Exception ex)
 //    {
 //        displayError("loading color list", ex.ToString(), true);
 //    }
 //}
 //end 2015-06-29
 private void load_breeds(int speciesId)
 {
     //load breed from service
     try
     {
         ///test exception logging and emailing
         //throw new Exception("test email server exception");
         ListsManager lm = new ListsManager();
         List<Breed> lstBreeds = lm.GetBreedList(speciesId, mCustomer);
         if (lstBreeds != null)
         {
             ddlBreed.DataSource = lstBreeds;
             ddlBreed.DataBind();
             ddlBreed.Items.Insert(0, new ListItem("Select Breed", "0"));
         }
         else
             displayError("loading breed list", "", false);
     }
     catch (Exception ex)
     {
         displayError("loading breed list", ex.ToString(), true);
     }
 }
        private void load_militarystatus()
        {
            try
            {
                ListsManager lm = new ListsManager();
                List<MilitaryStatus> lstMS = lm.GetMilitaryStatusList(mCustomer);
                if (lstMS != null)
                {
                    foreach (MilitaryStatus ms in lstMS)
                    {
                        rblServiceType.Items.Add(new ListItem(ms.StatusName, ms.StatusTypeID.ToString()));
                    }

                    rblServiceType.DataBind();
                    rblServiceType.RepeatLayout = RepeatLayout.Table;
                    rblServiceType.SelectedIndex = 1;
                }
                else
                { }
            }
            catch { }
        }
        private void PopulatePlanDetails(ListsManager lm)
        {
            Int16 typeid = (short)(mCustomer.LifeTimeActive ? 2 : 1);
            //populate limit drop down
            List<Limit> lstLimitTemp = lm.GetLimit(mCustomer.EnrollmentCode, typeid, mCustomer.MembershipInfo.StateId, mCustomer.Underwriter);
            List<decimal> lstLimit = (from l in lstLimitTemp
                                      orderby l.Amount
                                      select l.Amount
                                      ).ToList();

            ddlLimit.DataSource = lstLimit.Select(l => l.ToString("C0"));
            ddlLimit.DataBind();
            decimal LimitDefault = (from l in lstLimitTemp
                                    where l.IsDefault
                                    select l.Amount).FirstOrDefault();
            if (LimitDefault != 0)
                ddlLimit.SelectedValue = LimitDefault.ToString("C0");

            //populate remimbursement drop down
            List<Reimbursement> lstReimTemp = lm.GetReimbursement(mCustomer.EnrollmentCode, typeid);
            List<double> lstReim = (from l in lstReimTemp
                                    orderby l.Amount
                                    select l.Amount).ToList();
            ddlReimburse.DataSource = lstReim.Select(l => l.ToString("0%"));
            ddlReimburse.DataBind();
            double ReimDefault = (from l in lstReimTemp
                                  where l.IsDefault
                                  select l.Amount).FirstOrDefault();
            if (ReimDefault != 0)
                ddlReimburse.SelectedValue = ReimDefault.ToString("0%");

            //populate deductible drop down
            List<Deductible> lstDeductTemp = lm.GetDeductible(mCustomer.EnrollmentCode, typeid);
            List<decimal> lstDeductible = (from l in lstDeductTemp
                                           orderby l.Amount
                                           select l.Amount).ToList();
            ddlDeductible.DataSource = lstDeductible.Select(l => l.ToString("C0"));
            ddlDeductible.DataBind();

            //default
            decimal DeductDefault = (from l in lstDeductTemp
                                     where l.IsDefault
                                     select l.Amount).FirstOrDefault();
            if (DeductDefault != 0)
                ddlDeductible.SelectedValue = DeductDefault.ToString("C0");

            List<Rider> lstRider = lm.GetRider(mCustomer.EnrollmentCode, typeid);
            lstRiderList = lstRider;

            if (lstRider != null)
            {
                foreach (Rider r in lstRider)
                {
                    ddlRoutine.Items.Add(new ListItem(r.RiderName.Replace("Care ", "")));
                }

                ddlRoutine.DataBind();

            }

            ddlRoutine.Items.Insert(0, new ListItem("None", "0"));
        }
 private void load_militarybranches()
 {
     try
     {
         ListsManager lm = new ListsManager();
         List<MilitaryBranch> lstMB = lm.GetMilitaryBranchList(mCustomer);
         if (lstMB != null)
         {
             foreach (MilitaryBranch mb in lstMB)
             {
                 ddlBranch.Items.Add(new ListItem(mb.BranchName, mb.BranchID.ToString()));
             }
             //ddlBreed.Items.Insert(0, new ListItem("Select Breed", "0"));
         }
         else
         { }//displayError("loading breed list", "", );
     }
     catch { }
 }
        private void PopulatePlanDetails(ListsManager lm)
        {
            Int16 typeid = (short)(mCustomer.LifeTimeActive? 2 : 1);
            //populate limit drop down
            List<Limit> lstLimitTemp = lm.GetLimit(mCustomer.EnrollmentCode, typeid, mCustomer.MembershipInfo.StateId, mCustomer.Underwriter);
            List<decimal> lstLimit = (from l in lstLimitTemp
                                      orderby l.Amount
                                      select l.Amount
                                      ).ToList();

            ddlLimit.DataSource = lstLimit.Select(l => l.ToString("C0"));
            ddlLimit.DataBind();
            decimal LimitDefault = (from l in lstLimitTemp
                                    where l.IsDefault
                                    select l.Amount).FirstOrDefault();
            if (LimitDefault != 0)
                ddlLimit.SelectedValue = LimitDefault.ToString("C0");

            //populate remimbursement drop down
            List<Reimbursement> lstReimTemp =lm.GetReimbursement(mCustomer.EnrollmentCode, typeid);
            List<double> lstReim =(from l in lstReimTemp
                                   orderby l.Amount
                                   select l.Amount).ToList();
            ddlReimburse.DataSource = lstReim.Select(l => l.ToString("0%"));
            ddlReimburse.DataBind();
            double ReimDefault =(from l in lstReimTemp
                                 where l.IsDefault
                                 select l.Amount).FirstOrDefault();
            if (ReimDefault != 0)
                ddlReimburse.SelectedValue = ReimDefault.ToString("0%");

            //populate deductible drop down
            List<Deductible> lstDeductTemp =lm.GetDeductible(mCustomer.EnrollmentCode, typeid);
            List<decimal> lstDeductible = (from l in lstDeductTemp
                                           orderby l.Amount
                                           select l.Amount).ToList();
            ddlDeductible.DataSource = lstDeductible.Select(l => l.ToString("C0"));
            ddlDeductible.DataBind();

            //default
            decimal DeductDefault = (from l in lstDeductTemp
                                    where l.IsDefault
                                    select l.Amount).FirstOrDefault();
            if (DeductDefault != 0)
                ddlDeductible.SelectedValue = DeductDefault.ToString("C0");
        }
 ////kp: 2015-05-21 delete standard plan site wide
 //protected void btnLifetime_Click(object sender, EventArgs e)
 //{
 //    if(!btnLifetime.CssClass.Contains("active"))//has switched.
 //        ToggleButtonActive(false);
 //}
 //protected void btnStandard_Click(object sender, EventArgs e)
 //{
 //    if (!btnStandard.CssClass.Contains("active"))
 //        ToggleButtonActive(true);
 //}
 //private void ToggleButtonActive(bool isStandard)
 //{
 //    if (isStandard)
 //    {
 //        mCustomer.LifeTimeActive = false;
 //        btnStandard.CssClass = "btn btn-sm btn-pf-secondary active";
 //        btnLifetime.CssClass = "btn btn-sm btn-pf-secondary";
 //    }
 //    else
 //    {
 //        btnStandard.CssClass = "btn btn-sm btn-pf-secondary";
 //        btnLifetime.CssClass = "btn btn-sm btn-pf-secondary active";
 //        mCustomer.LifeTimeActive = true;
 //    }
 //    ListsManager lm = new ListsManager();
 //    PopulatePlanDetails(lm);
 //    PopulateRiders(lm);
 //}
 protected void PopulatePlanPanel()
 {
     ListsManager lm = new ListsManager();
     PopulatePlanDetails(lm);
     PopulateRiders(lm);
 }
 private void PopulateRiders(ListsManager lm)
 {
     dvRider.Visible = false;
     pnlBreeder.Visible = false;
     pnlHereditary.Visible = false;
     pnlPrescription.Visible = false;
     pnlRoutine.Visible = false;
     Int16 typeid = (short)(mCustomer.LifeTimeActive ? 2 : 1);
     List<Rider> lstRider = lm.GetRider(mCustomer.EnrollmentCode, typeid);
     List<Rider> lstRoutine = new List<Rider>();
     List<Rider> lstHereditary = new List<Rider>();
     foreach (Rider r in lstRider)
     {
         if (r.RiderName.Contains("Routine"))
         {
             pnlRoutine.Visible = true;
             ////kp:2015-05-04 retrieve quote - phase1 leftover item: sarah wants to have popover for each routine option
             //lstRoutine.Add(r);
             string routineName = r.RiderName;
             if (r.RiderName.Contains("125") && !r.RiderName.Contains("Rider Details"))
                 routineName = string.Concat(routineName, "&nbsp;&nbsp;", "<a class='rider-details' data-toggle='modal' data-target='#routine125' >Rider Details</a>");
             else if (r.RiderName.Contains("250") && !r.RiderName.Contains("Rider Details"))
                 routineName = string.Concat(routineName, "&nbsp;&nbsp;", "<a class='rider-details' data-toggle='modal' data-target='#routine250' >Rider Details</a>");
             else if (r.RiderName.Contains("400") && !r.RiderName.Contains("Rider Details"))
                 routineName = string.Concat(routineName, "&nbsp;&nbsp;", "<a class='rider-details' data-toggle='modal' data-target='#routine400' >Rider Details</a>");
             r.RiderName = routineName;
             lstRoutine.Add(r);
             ////end 2015-05-04
         }
         else if (r.RiderName.Contains("Hereditary"))
         {
             pnlHereditary.Visible = true;
             lstHereditary.Add(r);
         }
         else if (r.RiderName.Contains("Prescription"))
         {
             pnlPrescription.Visible = true;
         }
         else if (r.RiderName.Contains("Breeder"))
         {
             pnlBreeder.Visible = true;
         }
     }
     if (pnlRoutine.Visible)
     {
         lstRoutine.Add(new Rider { RiderName = "None", RiderValue = "0" });
         rblRoutine.DataSource = lstRoutine.OrderByDescending(t => t.RiderValue);
         rblRoutine.DataBind();
         rblRoutine.SelectedValue = "0";
     }
     if (pnlHereditary.Visible)
     {
         lstHereditary.Add(new Rider { RiderName = "None", RiderValue = "0" });
         rblHereditary.DataSource = lstHereditary.OrderByDescending(t => t.RiderValue);
         rblHereditary.DataBind();
         rblHereditary.SelectedValue = "0";
     }
     if (pnlBreeder.Visible || pnlHereditary.Visible || pnlPrescription.Visible || pnlRoutine.Visible)
         dvRider.Visible = true;
 }
        private void load_states()
        {
            try
            {
                //load state from service
                ListsManager lm = new ListsManager();
                State[] lstStates = lm.GetStateList(mCustomer);

                //insert select state on the top
                if (lstStates !=null)//check error
                {
                    ddlBState.DataSource = lstStates.OrderBy(s => s.StateName);
                    ddlBState.DataBind();
                    ddlState.DataSource = lstStates.OrderBy(s => s.StateName);
                    ddlState.DataBind();
                    ddlBState.Items.Insert(0, new ListItem("Select State", "0"));
                    ddlState.Items.Insert(0, new ListItem("Select State", "0"));
                }
                else
                {
                    displayListError("", "loading state list", false);
                }

            }
            catch (Exception ex)
            {
                displayListError(ex.ToString(), "loading state list", true);
            }
        }