protected void Page_Load(object sender, EventArgs e)
        {
            activity = activityStatusDao.getActivity(3);
            ViewState["activity"] = activity;

            //string text = "2020";
            string caseId = "";
            if (!IsPostBack)
            {
                string nextCaseId = Request.Form["caseid"];
                string menuCaseId = Request.QueryString["caseid"];
                string helperUsed = Request.Form["helperUsed"];

                if (nextCaseId != null && nextCaseId != "")
                {
                    caseId = nextCaseId;
                }

                if (menuCaseId != null && menuCaseId != "")
                {
                    caseId = menuCaseId;
                }

                if (Session["fnacaseid"] != null)
                {
                    caseId = Session["fnacaseid"].ToString();
                }

                ViewState["caseId"] = caseId;
                AssetAndLiabilityDAO assetAndLiabilityDAO = new AssetAndLiabilityDAO();
                if (caseId != null || caseId != "")
                {
                    assetAndLiability assetLiabilityForCase = assetAndLiabilityDAO.getAssetLiabilityForCase(caseId);
                    if (assetLiabilityForCase != null)
                    {
                        populateAssetAndLiabilityDetails(assetLiabilityForCase, caseId);
                    }
                }

            }
        }
        protected void saveAssetLiabilitiesDetails(object sender, EventArgs e)
        {
            string caseId = "";
            if (ViewState["caseId"] != null)
            {
                caseId = ViewState["caseId"].ToString();
            }

            if (Session["fnacaseid"] != null)
            {
                caseId = Session["fnacaseid"].ToString();
            }

            string actv = "";
            if (ViewState["activity"] != null)
            {
                actv = ViewState["activity"].ToString();
            }

            AssetAndLiabilityDAO assetAndLiabilityDAO = new AssetAndLiabilityDAO();
            assetAndLiability assetAndLiability = assetAndLiabilityDAO.getAssetLiabilityForCase(caseId);

            string status = "new";

            if (assetAndLiability != null)
            {
                copyAssetBaseClass(assetAndLiability);
                status = "update";
            }
            else
            {
                assetAndLiability = new assetAndLiability();
                copyAssetBaseClass(assetAndLiability);
            }

            int noofmemberOfInvestedAssets = 0;
            int noOfLiabilitiesNumber = 0;
            int noPersonalUsedAssetsNumber = 0;

            if (otherInvestedAssetsNumber.Value != "")
            {
                noofmemberOfInvestedAssets = Int16.Parse(otherInvestedAssetsNumber.Value) + 1;
            }

            if (otherPersonalUsedAssetsNumber.Value != "")
            {
                noPersonalUsedAssetsNumber = Int16.Parse(otherPersonalUsedAssetsNumber.Value) + 1;
            }

            if (otherLiabilitiesNumber.Value != "")
            {
                noOfLiabilitiesNumber = Int16.Parse(otherLiabilitiesNumber.Value) + 1;
            }

            EntitySet<personalUseAssetsOther> personalUseAssets = new EntitySet<personalUseAssetsOther>();
            EntitySet<liabilityOther> liabilityOthers = new EntitySet<liabilityOther>();
            EntitySet<investedAssetOther> investedAssetOther = new EntitySet<investedAssetOther>();

            if (noofmemberOfInvestedAssets > 0)
            {
                for (int i = 0; i < noofmemberOfInvestedAssets; i++)
                {

                    if (Request.Form["priothers-" + i] != null)
                    {
                        investedAssetOther asset = new investedAssetOther();
                        asset.cash = Request.Form["priotherscash-" + i];
                        asset.cpf = Request.Form["priotherscpf-" + i];
                        asset.date = DateTime.Today;
                        asset.assetDesc = Request.Form["priothers-" + i];
                        investedAssetOther.Add(asset);
                    }
                }
            }
            assetAndLiability.investedAssetOthers = investedAssetOther;
            if (noPersonalUsedAssetsNumber > 0)
            {
                for (int i = 0; i < noPersonalUsedAssetsNumber; i++)
                {

                    if (Request.Form["priotherspu-" + i] != null)
                    {
                        personalUseAssetsOther asset = new personalUseAssetsOther();
                        asset.cash = Request.Form["priotherspucash-" + i];
                        asset.cpf = Request.Form["priotherspucpf-" + i];
                        asset.date = DateTime.Today;
                        asset.assetDesc = Request.Form["priotherspu-" + i];
                        personalUseAssets.Add(asset);

                    }
                }
            }
            assetAndLiability.personalUseAssetsOthers = personalUseAssets;
            if (noOfLiabilitiesNumber > 0)
            {
                for (int i = 0; i < noOfLiabilitiesNumber; i++)
                {

                    if (Request.Form["priotherslb-" + i] != null)
                    {
                        liabilityOther liability = new liabilityOther();
                        liability.liabilityDesc = Request.Form["priotherslb-" + i];
                        liability.cash = Request.Form["priotherslbamount-" + i];
                        liability.date = DateTime.Today;
                        liabilityOthers.Add(liability);

                    }
                }
            }

            assetAndLiability.liabilityOthers = liabilityOthers;
            AssetAndLiabilityDAO dao = new AssetAndLiabilityDAO();
            if (status.Equals("new"))
            {
                assetAndLiability.caseId = caseId;
                dao.insertNewAssetLiabilityDetails(assetAndLiability);
            }
            else
                dao.updateAssetLiabilityDetails(assetAndLiability);

            this.assetList.DataSource = investedAssetOther;
            this.assetList.DataBind();
            this.liabilitiesOtherRepeater.DataSource = liabilityOthers;
            this.liabilitiesOtherRepeater.DataBind();
            this.otherPersonalAssetsRepeater.DataSource = personalUseAssets;
            this.otherPersonalAssetsRepeater.DataBind();

            string sts = activityStatusCheck.getAssetLiabilityStatus(assetAndLiability);
            activityStatusDao.saveOrUpdateActivityStatus(caseId, actv, sts);

            markStatusOnTab(caseId);

            string caseStatus = activityStatusCheck.getZPlanStatus(caseId);

            string url = Server.MapPath("~/_layouts/Zurich/Printpages/");
            pdfData = activityStatusCheck.sendDataToSalesPortal(caseId, caseStatus, url, sendPdf);

            /*if (st == 1)
            {
                lblStatusSubmitted.Visible = false;
            }
            else
            {
                lblStatusSubmissionFailed.Visible = true;
            }*/

            if (liabilityOthers.Count > 0)
                this.otherInvestedAssetsNumber.Value = (liabilityOthers.Count - 1) + "";
            if (personalUseAssets.Count > 0)
                this.otherPersonalUsedAssetsNumber.Value = (personalUseAssets.Count - 1) + "";
            if (investedAssetOther.Count > 0)
                this.otherInvestedAssetsNumber.Value = (investedAssetOther.Count - 1) + "";
            activityId.Value = caseId;

            lblPdSummarySaveSuccess.Visible = true;

            List<string> errors = printErrorMessages(assetAndLiability);
            this.ErrorRepeater.DataSource = errors;
            this.ErrorRepeater.DataBind();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            activity = activityStatusDao.getActivity(3);
            ViewState["activity"] = activity;

            lblPdSummarySaveSuccess.Visible = false;
            lblPdSummarySaveFailed.Visible = false;

            netWorth.Attributes.Add("readonly", "readonly");

            assetAndLiability assetLiabilityForCase = null;

            if (!IsPostBack)
            {
                string nextCaseId = Request.Form["caseid"];
                string menuCaseId = Request.QueryString["caseid"];
                string helperUsed = Request.Form["helperUsed"];

                if (nextCaseId != null && nextCaseId != "")
                {
                    csid = nextCaseId;
                }

                if (menuCaseId != null && menuCaseId != "")
                {
                    csid = menuCaseId;
                }

                if (Session["fnacaseid"] != null)
                {
                    csid = Session["fnacaseid"].ToString();
                }

                ViewState["caseId"] = csid;
                AssetAndLiabilityDAO assetAndLiabilityDAO = new AssetAndLiabilityDAO();
                if (csid != null || csid != "")
                {
                    assetLiabilityForCase = assetAndLiabilityDAO.getAssetLiabilityForCase(csid);
                }

                populateAssetAndLiabilityDetails(assetLiabilityForCase, csid);

            }

            markStatusOnTab(csid);
        }
        private void populateFamilyNeedIfNoNeed(string caseId)
        {
            IncomeExpenseDAO incomeExpenseDao = new IncomeExpenseDAO();
            incomeExpense incomeExpense = incomeExpenseDao.getIncomeExpenseForCase(caseId);

            AssetAndLiabilityDAO assetLiabilityDao = new AssetAndLiabilityDAO();
            assetAndLiability assetAndLiability = assetLiabilityDao.getAssetLiabilityForCase(caseId);

            string yearsToSupport = getYearsToSupport(caseId);

            txtYrsOfSupport.Text = yearsToSupport;

            float percentage = 70;

            familyIncPrNeeded2.Selected = true;
            mortgagePrNeeded2.Selected = true;

            if (incomeExpense != null)
            {
                if (incomeExpense.netMonthlyIncomeAfterCpf != null && incomeExpense.netMonthlyIncomeAfterCpf != "")
                {
                    txtReplacementIncome.Text = Math.Round((float.Parse(incomeExpense.netMonthlyIncomeAfterCpf) * 12 * percentage * .01)) + "";
                }
                else
                    txtReplacementIncome.Text = "0";
            }
            else
                txtReplacementIncome.Text = "0";

            if (incomeExpense != null)
            {
                if (incomeExpense.emergencyFundsNeeded != null && incomeExpense.emergencyFundsNeeded != "")
                    txtEmergencyFundsNeeded.Text = incomeExpense.emergencyFundsNeeded;
                else
                    txtEmergencyFundsNeeded.Text = "0";
            }
            else
                txtEmergencyFundsNeeded.Text = "0";

                AssumptionDAO assumptionDao = new AssumptionDAO();
                txtInflationAdjustedReturns.Text = assumptionDao.getAssumptionById(4).percentage + "";

            if (assetAndLiability != null)
            {
                float liability = 0;

                if (assetAndLiability.vehicleLoan != null && assetAndLiability.vehicleLoan != "")
                {
                    liability += float.Parse(assetAndLiability.vehicleLoan);
                }

                if (assetAndLiability.cashLoan != null && assetAndLiability.cashLoan != "")
                {
                    liability += float.Parse(assetAndLiability.cashLoan);
                }

                if (assetAndLiability.creditCard != null && assetAndLiability.creditCard != "")
                {
                    liability += float.Parse(assetAndLiability.creditCard);
                }

                if (assetAndLiability.liabilityOthers != null)
                {
                    int count = assetAndLiability.liabilityOthers.Count;

                    EntitySet<liabilityOther> others = assetAndLiability.liabilityOthers;
                    for (int i = 0; i < count; i++)
                    {
                        if (others[i].cash != null && others[i].cash != "")
                            liability += float.Parse(others[i].cash);
                    }
                }

                txtOtherLiabilities.Text = liability + "";
            }
            else
                txtOtherLiabilities.Text = "0";

            float existLifeInsurance = 0;
            if (incomeExpense != null)
            {
                if (incomeExpense.DeathTermInsuranceSA != null && incomeExpense.DeathTermInsuranceSA != "")
                {
                    existLifeInsurance += float.Parse(incomeExpense.DeathTermInsuranceSA);
                }
                if (incomeExpense.DeathWholeLifeInsuranceSA != null && incomeExpense.DeathWholeLifeInsuranceSA != "")
                {
                    existLifeInsurance += float.Parse(incomeExpense.DeathWholeLifeInsuranceSA);
                }
                if (incomeExpense.lifeInsuranceSA != null && incomeExpense.lifeInsuranceSA != "")
                {
                    existLifeInsurance += float.Parse(incomeExpense.lifeInsuranceSA);
                }
            }

            txtExistingLifeInsurance.Text = existLifeInsurance + "";

            if (assetAndLiability != null)
            {
                if (assetAndLiability.homeMortgage != null && assetAndLiability.homeMortgage != "")
                {
                    txtMortgageProtectionOutstanding.Text = assetAndLiability.homeMortgage;
                }
                else
                    txtMortgageProtectionOutstanding.Text = "0";
            }
            else
                txtMortgageProtectionOutstanding.Text = "0";

            if (incomeExpense != null)
            {
                if (incomeExpense.mortgageSA != null && incomeExpense.mortgageSA != "")
                {
                    txtMortgageProtectionInsurances.Text = incomeExpense.mortgageSA;
                }
                else
                    txtMortgageProtectionInsurances.Text = "0";
            }
            else
                txtMortgageProtectionInsurances.Text = "0";
        }
        private void populateFamilyNeed(familyNeed fNeed)
        {
            //txtReplacementIncome.Text = (fNeed.replacementIncomeRequired == null || fNeed.replacementIncomeRequired == "") ? "0" : fNeed.replacementIncomeRequired;

            familyIncPrNeeded.SelectedValue = fNeed.familyIncPrNeeded.ToString();
            mortgagePrNeeded.SelectedValue = fNeed.mortgageNeeded.ToString();

            if(fNeed.yearsOfSupportRequired == null || fNeed.yearsOfSupportRequired == "")
            {
                string yearsToSupport = getYearsToSupport(fNeed.caseId);
                txtYrsOfSupport.Text = yearsToSupport;
            }
            else
                txtYrsOfSupport.Text=fNeed.yearsOfSupportRequired;

            txtInflationAdjustedReturns.Text = (fNeed.inflationAdjustedReturns == null || fNeed.inflationAdjustedReturns == "") ? "0" : fNeed.inflationAdjustedReturns;
            txtLumpSumRequired.Text = (fNeed.lumpSumRequired == null || fNeed.lumpSumRequired == "") ? "0" : fNeed.lumpSumRequired;
            txtOtherLiabilities.Text = (fNeed.otherLiabilities == null || fNeed.otherLiabilities == "") ? "0" : fNeed.otherLiabilities;
            txtEmergencyFundsNeeded.Text = (fNeed.emergencyFundsNeeded == null || fNeed.emergencyFundsNeeded == "") ? "0" : fNeed.emergencyFundsNeeded;
            txtFinalExpenses.Text = (fNeed.finalExpenses == null || fNeed.finalExpenses == "") ? "0" : fNeed.finalExpenses;
            txtOtherFundingNeeds.Text = (fNeed.otherFundingNeeds == null || fNeed.otherFundingNeeds == "") ? "0" : fNeed.otherFundingNeeds;
            //txtotherComments.Text = (fNeed.otherComments == null || fNeed.otherComments == "") ? "0" : fNeed.otherComments;
            txtTotalRequired.Text = (fNeed.totalRequired == null || fNeed.totalRequired == "") ? "0" : fNeed.totalRequired;
            txtExistingLifeInsurance.Text = (fNeed.existingLifeInsurance == null || fNeed.existingLifeInsurance == "") ? "0" : fNeed.existingLifeInsurance;
            //txtExistingAssetsFamilyneeds.Text = (fNeed.existingAssetsFamilyneeds == null || fNeed.existingAssetsFamilyneeds == "") ? "0" : fNeed.existingAssetsFamilyneeds;
            txtTotalShortfallSurplus.Text = (fNeed.totalShortfallSurplus == null || fNeed.totalShortfallSurplus == "") ? "0" : fNeed.totalShortfallSurplus;
            hiddenTotalShortfallSurplus.Value = (fNeed.totalShortfallSurplus == null || fNeed.totalShortfallSurplus == "") ? "0" : fNeed.totalShortfallSurplus;

            txtMortgageProtectionOutstanding.Text = (fNeed.mortgageProtectionOutstanding == null || fNeed.mortgageProtectionOutstanding == "") ? "0" : fNeed.mortgageProtectionOutstanding;
               // txtMortgageProtectionInsurances.Text = (fNeed.mortgageProtectionInsurances == null || fNeed.mortgageProtectionInsurances == "") ? "0" : fNeed.mortgageProtectionInsurances;
            txtMortgageProtectionTotal.Text = (fNeed.mortgageProtectionTotal == null || fNeed.mortgageProtectionTotal == "") ? "0" : fNeed.mortgageProtectionTotal;

            float percentage= 70;

            IncomeExpenseDAO incomeExpenseDao = new IncomeExpenseDAO();
            incomeExpense incomeExpense= incomeExpenseDao.getIncomeExpenseForCase(fNeed.caseId);

            AssetAndLiabilityDAO assetLiabilityDao= new AssetAndLiabilityDAO();
            assetAndLiability assetAndLiability=assetLiabilityDao.getAssetLiabilityForCase(fNeed.caseId);

            if (fNeed.replacementIncomeRequired == null || fNeed.replacementIncomeRequired == "")
            {
                if(incomeExpense!=null)
                {
                    if (incomeExpense.netMonthlyIncomeAfterCpf != null && incomeExpense.netMonthlyIncomeAfterCpf != "")
                    {
                        txtReplacementIncome.Text=Math.Round((float.Parse(incomeExpense.netMonthlyIncomeAfterCpf)*12*percentage*.01))+"";
                    }
                }
                else
                    txtReplacementIncome.Text="0";
            }
            else
                txtReplacementIncome.Text=fNeed.replacementIncomeRequired;

            if (fNeed.emergencyFundsNeeded == null || fNeed.emergencyFundsNeeded == "")
            {
                if(incomeExpense!=null)
                {
                    if (incomeExpense.emergencyFundsNeeded != null &&  incomeExpense.emergencyFundsNeeded == "")
                        txtEmergencyFundsNeeded.Text=incomeExpense.emergencyFundsNeeded;
                }
                else
                    txtEmergencyFundsNeeded.Text="0";
            }
            else
                txtEmergencyFundsNeeded.Text=fNeed.emergencyFundsNeeded;

            if(fNeed.otherLiabilities==null || fNeed.otherLiabilities=="")
            {

                if(assetAndLiability!=null)
                {
                    float liability=0;

                    if (assetAndLiability.vehicleLoan != null && assetAndLiability.vehicleLoan != "")
                    {
                        liability+=float.Parse(assetAndLiability.vehicleLoan);
                    }

                    if (assetAndLiability.cashLoan != null && assetAndLiability.cashLoan != "")
                    {
                        liability+=float.Parse(assetAndLiability.cashLoan);
                    }

                    if (assetAndLiability.creditCard != null && assetAndLiability.creditCard != "")
                    {
                        liability+=float.Parse(assetAndLiability.creditCard);
                    }

                    if(assetAndLiability.liabilityOthers!=null)
                    {
                        int count=assetAndLiability.liabilityOthers.Count;

                        EntitySet<liabilityOther> others = assetAndLiability.liabilityOthers;
                        for (int i = 0; i < count; i++)
                        {
                            if (others[i].cash != null && others[i].cash != "")
                                liability+= float.Parse(others[i].cash);
                        }
                    }

                    txtOtherLiabilities.Text=liability+"";
                }
                else
                    txtOtherLiabilities.Text="0";
            }

            float existLifeInsurance=0;

            if(fNeed.existingLifeInsurance ==null || fNeed.existingLifeInsurance=="")
            {
                if (incomeExpense != null)
                {
                    if (incomeExpense.DeathTermInsuranceSA != null && incomeExpense.DeathTermInsuranceSA != "")
                    {
                        existLifeInsurance += float.Parse(incomeExpense.DeathTermInsuranceSA);
                    }
                    if (incomeExpense.DeathWholeLifeInsuranceSA != null && incomeExpense.DeathWholeLifeInsuranceSA != "")
                    {
                        existLifeInsurance += float.Parse(incomeExpense.DeathWholeLifeInsuranceSA);
                    }
                    if (incomeExpense.lifeInsuranceSA != null && incomeExpense.lifeInsuranceSA != "")
                    {
                        existLifeInsurance += float.Parse(incomeExpense.lifeInsuranceSA);
                    }
                }

                 txtExistingLifeInsurance.Text=existLifeInsurance+"";
            }
            else
                txtExistingLifeInsurance.Text=fNeed.existingLifeInsurance;

            if(fNeed.mortgageProtectionOutstanding ==null || fNeed.mortgageProtectionOutstanding=="")
            {
                if(assetAndLiability!=null)
                {
                    if (assetAndLiability.homeMortgage != null && assetAndLiability.homeMortgage != "")
                    {
                        txtMortgageProtectionOutstanding.Text=assetAndLiability.homeMortgage;
                    }
                    else
                        txtMortgageProtectionOutstanding.Text="0";
                }
            }
            else
                txtMortgageProtectionOutstanding.Text=fNeed.mortgageProtectionOutstanding;

            if(fNeed.mortgageProtectionInsurances ==null || fNeed.mortgageProtectionInsurances=="")
            {
                if(incomeExpense!=null)
                {
                    if (incomeExpense.mortgageSA != null && incomeExpense.mortgageSA != "")
                    {
                        txtMortgageProtectionInsurances.Text=incomeExpense.mortgageSA;
                    }
                    else
                        txtMortgageProtectionInsurances.Text="0";
                }
                else
                   txtMortgageProtectionInsurances.Text="0";
            }
                else
                    txtMortgageProtectionInsurances.Text=fNeed.mortgageProtectionInsurances;

            if (fNeed.inflationAdjustedReturns == null || fNeed.inflationAdjustedReturns == "")
            {
                AssumptionDAO assumptionDao = new AssumptionDAO();
                txtInflationAdjustedReturns.Text = assumptionDao.getAssumptionById(4).percentage+"";
            }
            else
                txtInflationAdjustedReturns.Text = fNeed.inflationAdjustedReturns;

            if (fNeed.familyNeedsAssets!=null)
                noofmembers.Value = fNeed.familyNeedsAssets.Count+"";
            else
                noofmembers.Value = "0";

            familyNeedsAssetList.DataSource = fNeed.familyNeedsAssets;
            familyNeedsAssetList.DataBind();

            if (fNeed.familyNeedsAssets != null)
            {
                ViewState["assetsSize"] = fNeed.familyNeedsAssets.Count;

                double sum = 0;
                txtExistingAssetsFamilyneeds.Text = sum.ToString();
            }
        }
        private void populateMyNeedIfNoNeed(string caseId)
        {
            IncomeExpenseDAO IncomeExpenseDAO = new IncomeExpenseDAO();
            incomeExpense incomeExpense = IncomeExpenseDAO.getIncomeExpenseForCase(caseId);

            AssetAndLiabilityDAO assetLiabilityDao = new AssetAndLiabilityDAO();
            assetAndLiability assetAndLiability = assetLiabilityDao.getAssetLiabilityForCase(caseId);

            float criticalIllnessPercentage = 100;
            float disabilityIncomePercentage = 75;

            criticalIllnessPr2.Selected = true;
            disabilityPr2.Selected = true;
            hospitalmedCoverNeeded2.Selected = true;
            accidentalHealthCoverNeeded2.Selected = true;

            if (incomeExpense != null)
            {
                if (incomeExpense.netMonthlyIncomeAfterCpf != null && incomeExpense.netMonthlyIncomeAfterCpf != "")
                {
                    replacementIncomeRequired.Text = Math.Round((float.Parse(incomeExpense.netMonthlyIncomeAfterCpf) * 12 * criticalIllnessPercentage * .01)) + "";
                }
            }
            else
                replacementIncomeRequired.Text = "0";

            if (incomeExpense != null)
            {
                if (incomeExpense.netMonthlyIncomeAfterCpf != null && incomeExpense.netMonthlyIncomeAfterCpf != "")
                {
                    disabilityProtectionReplacementIncomeRequired.Text = (float.Parse(incomeExpense.netMonthlyIncomeAfterCpf) * 12 * disabilityIncomePercentage * .01) + "";
                }
            }
            else
                disabilityProtectionReplacementIncomeRequired.Text = "0";

            if (incomeExpense != null)
            {
                if (incomeExpense.criticalIllnessSA != null && incomeExpense.criticalIllnessSA != "")
                {
                    txtCriticalIllnessInsurance.Text = incomeExpense.criticalIllnessSA;
                }
                else
                    txtCriticalIllnessInsurance.Text = "0";
            }
            else
                txtCriticalIllnessInsurance.Text = "0";

            if (incomeExpense != null)
            {
                if (incomeExpense.tpdcSA != null && incomeExpense.tpdcSA != "")
                {
                    disabilityInsurance.Text = incomeExpense.tpdcSA;
                }
                else
                    disabilityInsurance.Text = "0";
            }
            else
                disabilityInsurance.Text = "0";

            AssumptionDAO assumptionDao = new AssumptionDAO();
            inflationAdjustedReturns.Text = assumptionDao.getAssumptionById(4).percentage + "";
            inflatedAdjustedReturns.Text = assumptionDao.getAssumptionById(4).percentage + "";
            yearsOfSupportRequired.Text = getYearsToSupportCriticalIllness(caseId);
            disabilityYearsOfSupport.Text = getYearsToSupportDisabilityProtection(caseId);
        }
        private void populateMyNeed(myNeed mNeed)
        {
            IncomeExpenseDAO IncomeExpenseDAO = new IncomeExpenseDAO();
            incomeExpense incomeExpense= IncomeExpenseDAO.getIncomeExpenseForCase(mNeed.caseId);

            AssetAndLiabilityDAO assetLiabilityDao = new AssetAndLiabilityDAO();
            assetAndLiability assetAndLiability = assetLiabilityDao.getAssetLiabilityForCase(mNeed.caseId);

            float criticalIllnessPercentage = 100;
            float disabilityIncomePercentage = 75;

            if (mNeed.criticalIllnessPrNeeded != null)
            {
                criticalIllnessPr.SelectedValue = mNeed.criticalIllnessPrNeeded.ToString();
            }
            else
            {
                criticalIllnessPr2.Selected = true;
            }

            if (mNeed.disabilityPrNeeded != null)
            {
                disabilityPr.SelectedValue = mNeed.disabilityPrNeeded.ToString();
            }
            else
            {
                disabilityPr2.Selected = true;
            }

            if (mNeed.hospitalmedCoverNeeded != null)
            {
                hospitalmedCoverNeeded.SelectedValue = mNeed.hospitalmedCoverNeeded.ToString();
            }
            else
            {
                hospitalmedCoverNeeded2.Selected = true;
            }

            if (mNeed.accidentalhealthCoverNeeded != null)
            {
                accidentalHealthCoverNeeded.SelectedValue = mNeed.accidentalhealthCoverNeeded.ToString();
            }
            else
            {
                accidentalHealthCoverNeeded2.Selected = true;
            }

            if (mNeed.replacementIncomeRequired == null || mNeed.replacementIncomeRequired == "")
            {
                if (incomeExpense != null)
                {
                    if (incomeExpense.netMonthlyIncomeAfterCpf != null && incomeExpense.netMonthlyIncomeAfterCpf != "")
                    {
                        replacementIncomeRequired.Text = Math.Round((float.Parse(incomeExpense.netMonthlyIncomeAfterCpf) * 12 * criticalIllnessPercentage * .01)) + "";
                    }
                }
                else
                    replacementIncomeRequired.Text = "0";
            }
            else
                replacementIncomeRequired.Text = mNeed.replacementIncomeRequired;

            if (mNeed.disabilityProtectionReplacementIncomeRequired == null || mNeed.disabilityProtectionReplacementIncomeRequired == "")
            {
                if (incomeExpense != null)
                {
                    if (incomeExpense.netMonthlyIncomeAfterCpf != null && incomeExpense.netMonthlyIncomeAfterCpf != "")
                    {
                        disabilityProtectionReplacementIncomeRequired.Text = (float.Parse(incomeExpense.netMonthlyIncomeAfterCpf) * 12 * disabilityIncomePercentage * .01) + "";
                    }
                }
                else
                    disabilityProtectionReplacementIncomeRequired.Text = "0";
            }
            else
                disabilityProtectionReplacementIncomeRequired.Text = mNeed.disabilityProtectionReplacementIncomeRequired;

            if (mNeed.criticalIllnessInsurance == null || mNeed.criticalIllnessInsurance == "")
            {
                if (incomeExpense != null)
                {
                    if (incomeExpense.criticalIllnessSA != null && incomeExpense.criticalIllnessSA != "")
                    {
                        txtCriticalIllnessInsurance.Text = incomeExpense.criticalIllnessSA;
                    }
                    else
                        txtCriticalIllnessInsurance.Text = "0";
                }
                else
                    txtCriticalIllnessInsurance.Text = "0";
             }
            else
                txtCriticalIllnessInsurance.Text = mNeed.criticalIllnessInsurance;

            if (mNeed.disabilityInsurance == null || mNeed.disabilityInsurance == "")
            {
                if (incomeExpense != null)
                {
                    if (incomeExpense.tpdcSA != null && incomeExpense.tpdcSA != "")
                    {
                        disabilityInsurance.Text = incomeExpense.tpdcSA;
                    }
                    else
                        disabilityInsurance.Text = "0";
                }
                else
                    disabilityInsurance.Text = "0";
            }
            else
                disabilityInsurance.Text = mNeed.disabilityInsurance;

            string yearsToSupportCriticalIllness = getYearsToSupportCriticalIllness(mNeed.caseId);
            string yearsToSupportDisabilityProtection = getYearsToSupportDisabilityProtection(mNeed.caseId);

            if (mNeed.yearsOfSupportRequired == null || mNeed.yearsOfSupportRequired == "")
            {
                yearsOfSupportRequired.Text = yearsToSupportCriticalIllness;
            }
            else
                yearsOfSupportRequired.Text = mNeed.yearsOfSupportRequired;

            if (mNeed.disabilityYearsOfSupport == null || mNeed.disabilityYearsOfSupport == "")
            {
                disabilityYearsOfSupport.Text = yearsToSupportDisabilityProtection;
            }
            else
                disabilityYearsOfSupport.Text = mNeed.disabilityYearsOfSupport;

            //inflatedAdjustedReturns.Text = (mNeed.inflatedAdjustedReturns == null || mNeed.inflatedAdjustedReturns == "") ? "0" : mNeed.inflatedAdjustedReturns;
            replacementAmountRequired.Text = (mNeed.replacementAmountRequired == null || mNeed.replacementAmountRequired == "") ? "0" : mNeed.replacementAmountRequired;
            disabilityReplacementAmountRequired.Text = (mNeed.disabilityReplacementAmountRequired == null || mNeed.disabilityReplacementAmountRequired == "") ? "0" : mNeed.disabilityReplacementAmountRequired;
            //disabilityInsurance.Text = (mNeed.disabilityInsurance == null || mNeed.disabilityInsurance == "") ? "0" : mNeed.disabilityInsurance;
            //inflationAdjustedReturns.Text = (mNeed.inflationAdjustedReturns == null || mNeed.inflationAdjustedReturns == "") ? "0" : mNeed.inflationAdjustedReturns;

            if (mNeed.inflationAdjustedReturns == null || mNeed.inflationAdjustedReturns == "")
            {
                AssumptionDAO assumptionDao = new AssumptionDAO();
                inflationAdjustedReturns.Text = assumptionDao.getAssumptionById(4).percentage + "";
            }
            else
                inflationAdjustedReturns.Text = mNeed.inflationAdjustedReturns;

            if (mNeed.inflatedAdjustedReturns == null || mNeed.inflatedAdjustedReturns == "")
            {
                AssumptionDAO assumptionDao = new AssumptionDAO();
                inflatedAdjustedReturns.Text = assumptionDao.getAssumptionById(4).percentage + "";
            }
            else
                inflatedAdjustedReturns.Text = mNeed.inflatedAdjustedReturns;

            txtlumpSumRequiredForTreatment.Text = (mNeed.lumpSumRequiredForTreatment == null || mNeed.lumpSumRequiredForTreatment == "") ? "0" : mNeed.lumpSumRequiredForTreatment;
            //txtCriticalIllnessInsurance.Text = (mNeed.criticalIllnessInsurance == null || mNeed.criticalIllnessInsurance == "") ? "0" : mNeed.criticalIllnessInsurance;
            txtExistingAssetsMyNeedsCritical.Text = (mNeed.existingAssetsMyneeds == null || mNeed.existingAssetsMyneeds == "") ? "0" : mNeed.existingAssetsMyneeds;
            txtExistingAssetsMyneedsDisability.Text = (mNeed.existingAssetsMyneedsDisability == null || mNeed.existingAssetsMyneedsDisability == "") ? "0" : mNeed.existingAssetsMyneedsDisability;
            ddlHospitalTypeList.SelectedValue = (mNeed.typeOfHospitalCoverage == null || mNeed.typeOfHospitalCoverage == "") ? "" : mNeed.typeOfHospitalCoverage;

            if (mNeed.anyExistingPlans != null)
            {
                ddlExistingPlanList.SelectedValue = mNeed.anyExistingPlans == true ? "1" : "0";
            }
            else
            {
                ddlExistingPlanList.SelectedValue = "";
            }
            ViewState["anyExPl"] = ddlExistingPlanList.SelectedValue;

            if (mNeed.typeOfRoomCoverage != null)
            {
                ddlRoomTypeList.SelectedValue = mNeed.typeOfRoomCoverage.ToString();
            }
            else
            {
                ddlRoomTypeList.SelectedValue = "";
            }

            if (mNeed.coverageOldageYesNo != null)
            {
                ddlCoverageOldageYesNo.SelectedValue = mNeed.coverageOldageYesNo == true ? "1" : "0";
            }
            else
                ddlCoverageOldageYesNo.SelectedValue = "";

            if (mNeed.coverageOutpatientMedExp != null)
            {
                coverageOutpatientMedExp.SelectedValue = mNeed.coverageOutpatientMedExp == true ? "1" : "0";
            }
            else
            {
                coverageOutpatientMedExp.SelectedValue = "";
            }

            if (mNeed.coverageLossOfIncome != null)
            {
                coverageLossOfIncome.SelectedValue = mNeed.coverageLossOfIncome == true ? "1" : "0";
            }
            else
            {
                coverageLossOfIncome.SelectedValue = "";
            }

            if (mNeed.coverageOldageDisabilities != null)
            {
                coverageOldageDisabilities.SelectedValue = mNeed.coverageOldageDisabilities == true ? "1" : "0";
            }
            else
            {
                coverageOldageDisabilities.SelectedValue = "";
            }

            if (mNeed.coverageDentalExp != null)
            {
                coverageDentalExp.SelectedValue = mNeed.coverageDentalExp == true ? "1" : "0";
            }
            else
            {
                coverageDentalExp.SelectedValue = "";
            }

            //ddlEpOldageYesNo.SelectedValue = mNeed.epOldageYesNo == true ? "1" : "0";

            if (mNeed.epOldageYesNo != null)
            {
                ddlEpOldageYesNo.SelectedValue = mNeed.epOldageYesNo == true ? "1" : "0";
            }
            else
            {
                ddlEpOldageYesNo.SelectedValue = "";
            }
            ViewState["oldageExPl"] = ddlEpOldageYesNo.SelectedValue;

            //ddlCoveragePersonalYesNo.SelectedValue = mNeed.coveragePersonalYesNo == true ? "1" : "0";

            if (mNeed.coveragePersonalYesNo != null)
            {
                ddlCoveragePersonalYesNo.SelectedValue = mNeed.coveragePersonalYesNo == true ? "1" : "0";
            }
            else
                ddlCoveragePersonalYesNo.SelectedValue = "";

            //ddlEpPersonalYesNo.SelectedValue = mNeed.epPersonalYesNo == true ? "1" : "0";

            if (mNeed.epPersonalYesNo != null)
            {
                ddlEpPersonalYesNo.SelectedValue = mNeed.epPersonalYesNo == true ? "1" : "0";
            }
            else
            {
                ddlEpPersonalYesNo.SelectedValue = "";
            }
            ViewState["personalExPl"] = ddlEpPersonalYesNo.SelectedValue;

            if (mNeed.epOutpatientMedExp != null)
            {
                epOutpatientMedExp.SelectedValue = mNeed.epOutpatientMedExp == true ? "1" : "0";
            }
            else
            {
                epOutpatientMedExp.SelectedValue = "";
            }
            ViewState["epOutpatientMedExp"] = epOutpatientMedExp.SelectedValue;

            if (mNeed.epLossOfIncome != null)
            {
                epLossOfIncome.SelectedValue = mNeed.epLossOfIncome == true ? "1" : "0";
            }
            else
            {
                epLossOfIncome.SelectedValue = "";
            }
            ViewState["epLossOfIncome"] = epLossOfIncome.SelectedValue;

            if (mNeed.epOldageDisabilities != null)
            {
                epOldageDisabilities.SelectedValue = mNeed.epOldageDisabilities == true ? "1" : "0";
            }
            else
            {
                epOldageDisabilities.SelectedValue = "";
            }
            ViewState["epOldageDisabilities"] = epOldageDisabilities.SelectedValue;

            if (mNeed.epDentalExp != null)
            {
                epDentalExp.SelectedValue = mNeed.epDentalExp == true ? "1" : "0";
            }
            else
            {
                epDentalExp.SelectedValue = "";
            }
            ViewState["epDentalExp"] = epDentalExp.SelectedValue;

            if (mNeed.existingPlansDetail != null)
            {
                DetailsOfExistingPlans.Text = mNeed.existingPlansDetail.ToString();
            }
            else
                DetailsOfExistingPlans.Text = "";

            myNeedsCriticalAssetList.DataSource = mNeed.myNeedsCriticalAssets;
            myNeedsCriticalAssetList.DataBind();

            if (mNeed.myNeedsCriticalAssets != null)
            {
                ViewState["noofcriticalassets"] = mNeed.myNeedsCriticalAssets.Count;

                double sum = 0;
                txtTotalShortfallSurplusMyNeeds.Text = sum.ToString();
            }

            myNeedsDisabilityAssetList.DataSource = mNeed.myNeedsDisabilityAssets;
            myNeedsDisabilityAssetList.DataBind();

            if (mNeed.myNeedsDisabilityAssets != null)
            {
                ViewState["noofdisablityassets"] = mNeed.myNeedsDisabilityAssets.Count;
            }
        }