private void CheckExpiredQuote(QuoteHeader quoteHeader, ref Step nextPageIndex)
        {
            var policyEffectiveDate = DateTime.Parse(this.BusinessLogic().Coverage.PolicyEffDate);
            var expirationDate = (DateTime)this.BusinessLogic().Quote.ExpirationDt;

            var today = DateTime.Today;
            var ts1 = expirationDate - today;
            var ts2 = policyEffectiveDate - today;

            if ((ts1.Days <= 0) || (ts2.Days <= 0))
            {
                var sessionAdapter = new Homesite.IQuote.Data.SessionDataProviderTableAdapters.Session();

                try
                {
                    sessionAdapter.UpdateExpiredQuote(quoteHeader.SessionId);
                }
                catch (Exception ex)
                {
                    throw new SystemException("Error updating expired quote.", ex);
                }

                if (this.BusinessLogic().AdditionalCoverage.Ho0015Flag != null &&
                    this.BusinessLogic().AdditionalCoverage.Ho0015Flag == 1)
                {
                    var hshohhFlagProvider =
                        new Homesite.IQuote.Data.ISODataProviderTableAdapters.TUScoreRateTableAdapter();

                    // RI Mitigation -- added the issue date parameter
                    int? grandFatherFlagHooo15 = 0;
                    int? avlForSelectHooo15 = 0;
                    hshohhFlagProvider.GetHSHOHHFlags(quoteHeader.State, "HO0015", Convert.ToDateTime(quoteHeader.OriginalQuoteDate), ref grandFatherFlagHooo15, ref avlForSelectHooo15);
                    //There is no need to check grandfather flag as it is expired quote
                    if (avlForSelectHooo15 == 1)
                    {
                        this.BusinessLogic().AdditionalCoverage.Ho0015Flag = 1;
                        this.BusinessLogic().AdditionalCoverage.HH0015Flag = 0;
                    }
                    else
                    {
                        this.BusinessLogic().AdditionalCoverage.Ho0015Flag = 0;
                        this.BusinessLogic().AdditionalCoverage.HH0015Flag = 1;
                    }
                }

                if (quoteHeader.State.Equals("CA"))
                    SetCAEndoresementsOnRetrieve(quoteHeader);

                nextPageIndex = Step.InitialQuestions2;
                quoteHeader.ExpiredQuote = true;

                if (qHeader.FormCode == 1)
                {
                    this.BusinessLogic().Header.FormNumber = 4;
                    this.BusinessLogic().Quote.FormNumber = "4";
                    this.BusinessLogic().Header.Save();
                    this.BusinessLogic().Quote.Save();
                }
            }
        }
        private void SetCAEndoresementsOnRetrieve(QuoteHeader qHeader)
        {
            Homesite.IQuote.Data.ISODataProviderTableAdapters.TUScoreRateTableAdapter hshohhFlagProvider = new Homesite.IQuote.Data.ISODataProviderTableAdapters.TUScoreRateTableAdapter();

            // RI Mitigation
            //System.Nullable<byte> grandFatherFlag = 0, avlForSelect = 0;
            System.Nullable<int> grandFatherFlag = 0, avlForSelect = 0;
            hshohhFlagProvider.GetHSHOHHFlags(qHeader.State, "HH0015", Convert.ToDateTime(qHeader.OriginalQuoteDate), ref grandFatherFlag, ref avlForSelect);
            if (avlForSelect == 1)
            {
                this.BusinessLogic().AdditionalCoverage.HH0015Flag = 1;
                this.BusinessLogic().AdditionalCoverage.Ho0015Flag = 0;
                // set flag to 2 in CA table.

                Homesite.IQuote.Data.ISODataProviderTableAdapters.TUScoreRateTableAdapter CAHH0015QueryAdapter = new Homesite.IQuote.Data.ISODataProviderTableAdapters.TUScoreRateTableAdapter();
                CAHH0015QueryAdapter.SetCAPackageQuoteFlag(qHeader.QuoteNumber, null);
            }
        }
        public bool ShowForm2Popup()
        {
            //MI Market Value
            decimal RCMVRatio;
            System.Nullable<Int32> marketvalueEnable = 0;
            System.Nullable<decimal> RCMVRatiolimit = 0;
            //calculate RC to MV

            Homesite.IQuote.Data.ISODataProviderTableAdapters.TUScoreRateTableAdapter Marketvalueflow = new Homesite.IQuote.Data.ISODataProviderTableAdapters.TUScoreRateTableAdapter();
            Marketvalueflow.hssp_hs_MarketValue_workflow_enabled(this.BusinessLogic().Header.RatingVersion, this.BusinessLogic().Header.FormNumber, ref marketvalueEnable, ref RCMVRatiolimit);

            if (marketvalueEnable == 1)
            {
                if (this.BusinessLogic().Coverage.EstimatedReplCostAmt != 0 && this.BusinessLogic().Coverage.EstimatedReplCostAmt != null &&
                    this.BusinessLogic().Structure.ValueOfHome != null && this.BusinessLogic().Structure.ValueOfHome != 0)
                {
                    RCMVRatio = Convert.ToDecimal(this.BusinessLogic().Coverage.EstimatedReplCostAmt) / Convert.ToDecimal(this.BusinessLogic().Structure.ValueOfHome);

                    if (RCMVRatio >= RCMVRatiolimit)
                    {
                        return true;
                    }
                }
            }

            return false;
        }