protected void Page_Load(object sender, EventArgs e) { lblStatusSubmissionFailed.Visible = false; lblStatusSubmitted.Visible = false; lblZurichAdvFailed.Visible = false; lblZurichAdvSuccess.Visible = false; activity = activityStatusDao.getActivity(13); ViewState["activity"] = activity; ZPlanResponseDataContract zPlanResponse = null; string clonedFrom = ""; if (!IsPostBack) { /*string nextCaseId = Request.Form["caseid"]; string menuCaseId = Request.QueryString["caseid"]; if (nextCaseId != null && nextCaseId != "") { caseid = nextCaseId; } if (menuCaseId != null && menuCaseId != "") { caseid = menuCaseId; }*/ string activityID = string.Empty; string country = string.Empty; if (Request.Form["Country"] != null) { country = Request.Form["Country"].ToString(); } string salesChannel = string.Empty; if (Request.Form["SalesChannel"] != null) { salesChannel = Request.Form["SalesChannel"].ToString(); } if (Request.Form["ActivityID"] != null) { activityID = Request.Form["ActivityID"].ToString(); //activityID = "1500"; ZPlanDataContract zPlanContract = new ZPlanDataContract(); zPlanContract.ActivityId = activityID; zPlanContract.Activity = ActivityTypeEnum.ZPlan; zPlanContract.Action = ActionEnumContracts.View; UserInfoEntity ufo = new UserInfoEntity(); ufo.Country = country; ufo.RoleType = salesChannel; zPlanContract.UserInfo = ufo; zPlanResponse = new ZPlanResponseDataContract(); try { BusinessServiceClient client = new BusinessServiceClient(); client.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation; zPlanResponse = client.ManageZPlan(zPlanContract); if (zPlanResponse != null) { salesportalinfo salesPortalDto = new salesportalinfo(); salesPortalDto.activityid = activityID; salesPortalDto.activitytype = zPlanResponse.ActivityType; salesPortalDto.caseid = zPlanResponse.CaseId; salesPortalDto.redirecturl = zPlanResponse.RedirectUrl; salesPortalDto.roletype = zPlanResponse.RoleType; salesPortalDto.salesportalurl = zPlanResponse.SalesPortalUrl; salesPortalDto.userfirstname = zPlanResponse.UserFirstName; salesPortalDto.userid = zPlanResponse.UserId; salesPortalDto.userlastname = zPlanResponse.UserLastName; salesPortalDto.usertype = zPlanResponse.UserType; salesPortalDto.casestatus = zPlanResponse.CaseStatus; salesPortalDto.country = country; salesPortalDto.saleschannel = salesChannel; activityStatusDao.saveSalesPortalInfo(activityID, salesPortalDto); caseid = zPlanResponse.ActivityId; //check if ClonedFrom is sent from portal if (zPlanResponse.ClonedFrom != null && zPlanResponse.ClonedFrom != "") { clonedFrom = zPlanResponse.ClonedFrom; //check if case has been cloned earlier clonemappingid clonemapping = activityStatusDao.getCloneMappingForCaseid(clonedFrom, zPlanResponse.ActivityId); if (clonemapping == null) { //if the case is not cloned, add entry in the clone mapping table and clone the case clonemapping = new clonemappingid(); clonemapping.clonedfrom = clonedFrom; clonemapping.newid = zPlanResponse.ActivityId; activityStatusDao.saveClonemapping(clonemapping); activityStatusDao.cloneCase(clonedFrom, zPlanResponse.ActivityId); } } } } catch (Exception ex) { //log exception to db exceptionlog exLog = new exceptionlog(); exLog.message = ex.Message + " class: MyZurichAdviser Method: Page_Load"; exLog.source = ex.Source; string strtmp = ex.StackTrace; strtmp = strtmp.Replace('\r', ' '); strtmp = strtmp.Replace('\n', ' '); exLog.stacktrace = strtmp; exLog.targetsitename = ex.TargetSite.Name; activityStatusDao.logException(exLog); } } else { string backCaseId = Request.Form["caseid"]; string menuCaseId = Request.QueryString["caseid"]; if (backCaseId != null && backCaseId != "") { caseid = backCaseId; } else if (menuCaseId != null && menuCaseId != "") { caseid = menuCaseId; } else if (Session["fnacaseid"] != null) { caseid = Session["fnacaseid"].ToString(); } else { caseid = "2040"; } } activityId.Value = caseid; PersonalDetailsDAO dao = new PersonalDetailsDAO(); personaldetail detail = dao.getPersonalDetail(caseid); if (detail != null) { if (zPlanResponse != null) { detail.datepicker = zPlanResponse.Dob; detail.gender = zPlanResponse.Gender; //detail.maritalstatus = zPlanResponse.MaritalStatus; detail.name = zPlanResponse.UserFirstName; detail.surname = zPlanResponse.UserLastName; detail.nationality = zPlanResponse.Nationality; detail.nric = zPlanResponse.NricOrPassport; detail.occupation = zPlanResponse.Occupation; if (zPlanResponse.Smoker) { detail.issmoker = "Yes"; } else { detail.issmoker = "No"; } detail.title = zPlanResponse.Title; } dao.updatePersonalDetails(detail); } else { detail = new personaldetail(); detail.caseid = caseid; if (zPlanResponse != null) { detail.datepicker = zPlanResponse.Dob; detail.gender = zPlanResponse.Gender; //detail.maritalstatus = zPlanResponse.MaritalStatus; detail.name = zPlanResponse.UserFirstName; detail.surname = zPlanResponse.UserLastName; detail.nationality = zPlanResponse.Nationality; detail.nric = zPlanResponse.NricOrPassport; detail.occupation = zPlanResponse.Occupation; if (zPlanResponse.Smoker) { detail.issmoker = "Yes"; } else { detail.issmoker = "No"; } detail.title = zPlanResponse.Title; } dao.savePersonalDetails(detail); } if (caseid != "") { ViewState["caseid"] = caseid; List<myzurichadviser> savedMzaoptions = mzaDao.getMza(caseid); if (savedMzaoptions != null && savedMzaoptions.Count>0) { ViewState["casetype"] = "update"; } else { ViewState["casetype"] = "new"; savedMzaoptions = new List<myzurichadviser>(); myzurichadviser mzadv = new myzurichadviser(); mzadv.caseid = caseid; mzadv.selectedoptionid = 1; savedMzaoptions.Add(mzadv); mzadv = new myzurichadviser(); mzadv.caseid = caseid; mzadv.selectedoptionid = 2; savedMzaoptions.Add(mzadv); } populateMzaoptions(savedMzaoptions, caseid); } } markStatusOnTab(caseid); }
private string getYearsToSupport(string caseId) { PersonalDetailsDAO dao = new PersonalDetailsDAO(); personaldetail detail = dao.getPersonalDetail(caseId); int yearsToSupport = 0; if (detail != null) { if (detail.familyMemberDetails != null || detail.familyMemberDetails.Count > 0) { EntitySet<familyMemberDetail> member = detail.familyMemberDetails; for (int i = 0; i < detail.familyMemberDetails.Count; i++) { if (member[i].yrstosupport != null) { if (i == 0) { yearsToSupport = (int)member[i].yrstosupport; } else { int support = (int)member[i].yrstosupport; if (support >= yearsToSupport) yearsToSupport = support; } } } } } return yearsToSupport + ""; }
private void populateRetirementGoal(retirementgoal retirementGoalSelf, assumption inflationAdjustedReturnAsmptn, assumption annualInflationReturn, string caseid) { double shortfallSurplusSelf = 0; int iIntendedRetirementAge = 0; PersonalDetailsDAO dao = new PersonalDetailsDAO(); personaldetail detail = dao.getPersonalDetail(caseid); int yrDob = 0; int currentYr = DateTime.Now.Year; int agePolicyOwner = 0; int iYrstoRetirement = 0; try { DateTime dt2 = DateTime.ParseExact(detail.datepicker, "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture); yrDob = dt2.Year; if (DateTime.Now.Month < dt2.Month) { agePolicyOwner = currentYr - yrDob - 1; } else if (DateTime.Now.Month > dt2.Month) { agePolicyOwner = currentYr - yrDob; } else { if (DateTime.Now.Day < dt2.Day) { agePolicyOwner = currentYr - yrDob - 1; } else if ((DateTime.Now.Day > dt2.Day) || (DateTime.Now.Day == dt2.Day)) { agePolicyOwner = currentYr - yrDob; } } iYrstoRetirement = iIntendedRetirementAge - agePolicyOwner; } catch (Exception e) { //log exception to db exceptionlog exLog = new exceptionlog(); exLog.message = e.Message + " class: ShowRetirementGoals Method: populateRetirementGoal setting yrs to retirement"; exLog.source = e.Source; string strtmp = e.StackTrace; strtmp = strtmp.Replace('\r', ' '); strtmp = strtmp.Replace('\n', ' '); exLog.stacktrace = strtmp; exLog.targetsitename = e.TargetSite.Name; activityStatusDao.logException(exLog); } pownerdob.Value = agePolicyOwner.ToString(); if (detail != null) { pownergender.Value = detail.gender; } IncomeExpenseDAO iedao = new IncomeExpenseDAO(); incomeExpense iedetail = iedao.getIncomeExpenseForCase(caseid); retirementGoalNeeded2.Selected = true; //populate self retirement goals if (retirementGoalSelf != null) { retirementGoalNeeded.SelectedValue = retirementGoalSelf.retirementGoalNeeded.ToString(); if (retirementGoalSelf.intendedretirementage != null && retirementGoalSelf.intendedretirementage != "") { intendedRetirementAge.Text = retirementGoalSelf.intendedretirementage; } else { intendedRetirementAge.Text = "62"; } iIntendedRetirementAge = Int32.Parse(intendedRetirementAge.Text); //expectedRetirementAgelbl.Text = intendedRetirementAge.Text; if (retirementGoalSelf.incomerequired != null && retirementGoalSelf.incomerequired != "") { incomeRequiredUponRetirement.Text = retirementGoalSelf.incomerequired; } else { double dincomeReq = 0; if (iedetail!=null && iedetail.netMonthlyIncomeAfterCpf != null && iedetail.netMonthlyIncomeAfterCpf != "") { dincomeReq = 0.7 * 12 * double.Parse(iedetail.netMonthlyIncomeAfterCpf); } incomeRequiredUponRetirement.Text = Math.Round(dincomeReq, 2).ToString(); } //presentIncomeNeededlbl.Text = incomeRequiredUponRetirement.Text; if (retirementGoalSelf.yrstoretirement != null && retirementGoalSelf.yrstoretirement != "") { yearsToRetirement.Text = retirementGoalSelf.yrstoretirement; } else { yearsToRetirement.Text = iYrstoRetirement.ToString(); } //currentAgelbl.Text = (double.Parse(intendedRetirementAge.Text) - double.Parse(yearsToRetirement.Text)).ToString(); if (retirementGoalSelf.inflationrate == null || retirementGoalSelf.inflationrate == "") { if (annualInflationReturn != null) { annualInflationRate.Text = annualInflationReturn.percentage.Value.ToString(); } else { annualInflationRate.Text = "0"; } } else { annualInflationRate.Text = retirementGoalSelf.inflationrate; } //inflationRatelbl.Text = annualInflationRate.Text; if (retirementGoalSelf.futureincome != null && retirementGoalSelf.futureincome != "") { futureIncomeNeeded.Text = retirementGoalSelf.futureincome; } else { futureIncomeNeeded.Text = "0"; } //futureIncomeNeededChartlbl.Text = futureIncomeNeeded.Text; if (retirementGoalSelf.sourcesofincome != null && retirementGoalSelf.sourcesofincome != "") { sourcesOfIncome.Text = retirementGoalSelf.sourcesofincome; } else { sourcesOfIncome.Text = "0"; } if (retirementGoalSelf.totalfirstyrincome != null && retirementGoalSelf.totalfirstyrincome != "") { totalFirstYearIncomeNeeded.Text = retirementGoalSelf.totalfirstyrincome; } else { totalFirstYearIncomeNeeded.Text = "0"; } //annualAmountlbl.Text = totalFirstYearIncomeNeeded.Text; if (retirementGoalSelf.inflationreturnrate == null || retirementGoalSelf.inflationreturnrate == "") { if (inflationAdjustedReturnAsmptn != null) { inflationAdjustedReturn.Text = inflationAdjustedReturnAsmptn.percentage.Value.ToString(); } else { inflationAdjustedReturn.Text = "0"; } } else { inflationAdjustedReturn.Text = retirementGoalSelf.inflationreturnrate; } //inflationAdjustedReturnslbl.Text = inflationAdjustedReturn.Text; if (retirementGoalSelf.durationretirement != null && retirementGoalSelf.durationretirement != "") { durationOfRetirement.Text = retirementGoalSelf.durationretirement; } else { int iDurationofRetirement = 0; if (detail.gender == "Male") { iDurationofRetirement = 83 - iIntendedRetirementAge; } else if (detail.gender == "Female") { iDurationofRetirement = 88 - iIntendedRetirementAge; } durationOfRetirement.Text = iDurationofRetirement.ToString(); } //durationOfRetirementValuelbl.Text = durationOfRetirement.Text; //ageAtEndOfRetirementlbl.Text = (double.Parse(durationOfRetirement.Text) + double.Parse(intendedRetirementAge.Text)).ToString(); if (retirementGoalSelf.lumpsumrequired != null && retirementGoalSelf.lumpsumrequired != "") { lumpSumRequiredAtRetirement.Text = retirementGoalSelf.lumpsumrequired; } else { lumpSumRequiredAtRetirement.Text = "0"; } if (retirementGoalSelf.maturityvalue != null && retirementGoalSelf.maturityvalue != "") { maturityValue2.Text = retirementGoalSelf.maturityvalue; } else { maturityValue2.Text = "0"; } assetListSelf.DataSource = retirementGoalSelf.existingassetrgs; assetListSelf.DataBind(); if (retirementGoalSelf.existingassetrgs != null) { ViewState["noofassets"] = retirementGoalSelf.existingassetrgs.Count; if (retirementGoalSelf.existingassetstotal != null && retirementGoalSelf.existingassetstotal != "") existingAssets2.Text = retirementGoalSelf.existingassetstotal; else existingAssets2.Text = "0"; } shortfallSurplusSelf = double.Parse(existingAssets2.Text) + double.Parse(maturityValue2.Text) - double.Parse(lumpSumRequiredAtRetirement.Text); if (shortfallSurplusSelf < 0) { ttlSSSelf.Text = "Shortfall"; ttlSSSelf.Style.Add("color", "red"); } else if (shortfallSurplusSelf > 0) { ttlSSSelf.Text = "Surplus"; ttlSSSelf.Style.Add("color", "black"); } else { ttlSSSelf.Text = "Total (Shortfall / Surplus)"; ttlSSSelf.Style.Add("color", "black"); } totalShortfallSurplus2.Text = Math.Abs(shortfallSurplusSelf).ToString(); } activityId.Value = caseid; }
protected void populateIncomeAndExpenseDetails(incomeExpense incomeExpense, string caseId) { if (incomeExpense != null) { DeathTermInsuranceSA.Text = incomeExpense.DeathTermInsuranceSA; DeathWholeLifeInsuranceSA.Text = incomeExpense.DeathWholeLifeInsuranceSA; DeathTermInsuranceTerm.Text = incomeExpense.DeathTermInsuranceTerm; DeathWholeLifeInsuranceTerm.Text = incomeExpense.DeathWholeLifeInsuranceTerm; DeathTermInsurancePremium.Text = incomeExpense.DeathTermInsurancePremium; DeathWholeLifeInsurancePremium.Text = incomeExpense.DeathWholeLifeInsurancePremium; emergencyFundsNeeded.Text = incomeExpense.emergencyFundsNeeded; shortTermGoals.Text = incomeExpense.shortTermGoals; extraDetails.Text = incomeExpense.extraDetails; netMonthlyIncomeAfterCpf.Text = incomeExpense.netMonthlyIncomeAfterCpf; netMonthlyExpenses.Text = incomeExpense.netMonthlyExpenses; monthlySavings.Text = incomeExpense.monthlySavings; lifeInsuranceSA.Text = incomeExpense.lifeInsuranceSA; lifeInsuranceMV.Text = incomeExpense.lifeInsuranceMV; lifeInsurancePremium.Text = incomeExpense.lifeInsurancePremium; tpdcSA.Text = incomeExpense.tpdcSA; tpdcMV.Text = incomeExpense.tpdcMV; tpdcPremium.Text = incomeExpense.tpdcPremium; criticalIllnessSA.Text = incomeExpense.criticalIllnessSA; criticalIllnessMV.Text = incomeExpense.criticalIllnessMV; criticalIllnessPremium.Text = incomeExpense.criticalIllnessPremium; mortgageSA.Text = incomeExpense.mortgageSA; mortgageMV.Text = incomeExpense.mortgageMV; mortgagePremium.Text = incomeExpense.mortgagePremium; otherSourcesOfIncome.Text = incomeExpense.otherSourcesOfIncome; if (incomeExpense.insuranceArrangementSavings.Count > 0) this.savingsPlusNumber.Value = (incomeExpense.insuranceArrangementSavings.Count) + ""; this.incomeInsuranceExpenseSavingRepeater.DataSource = incomeExpense.insuranceArrangementSavings; this.incomeInsuranceExpenseSavingRepeater.DataBind(); if (incomeExpense.insuranceArrangementRetirements.Count > 0) this.retirementPlusNumber.Value = (incomeExpense.insuranceArrangementRetirements.Count) + ""; this.incomeInsuranceExpenseRetirementRepeater.DataSource = incomeExpense.insuranceArrangementRetirements; this.incomeInsuranceExpenseRetirementRepeater.DataBind(); if (incomeExpense.insuranceArrangementEducations.Count > 0) this.educationPlusNumber.Value = (incomeExpense.insuranceArrangementEducations.Count) + ""; this.incomeInsuranceExpenseEducationRepeater.DataSource = incomeExpense.insuranceArrangementEducations; this.incomeInsuranceExpenseEducationRepeater.DataBind(); } activityId.Value = caseId; PersonalDetailsDAO personalDao = new PersonalDetailsDAO(); personaldetail detail = personalDao.getPersonalDetail(caseId); if (detail != null) { if ((detail.name != null) || (detail.name != "")) PersonName.Value = detail.name; else PersonName.Value = ""; } else PersonName.Value = ""; }
protected void savePersonaldetails(object sender, EventArgs e) { string caseId= (string)ViewState["caseId"]; PersonalDetailsDAO dao = new PersonalDetailsDAO(); personaldetail detail = dao.getPersonalDetail(caseId); string actv = ""; if (ViewState["activity"] != null) { actv = ViewState["activity"].ToString(); } personaldetail returnDetail = new personaldetail(); if (detail != null) { copyPersonalDetail(detail); detail= dao.updatePersonalDetails(detail); } else { detail = new personaldetail(); detail.caseid = caseId; copyPersonalDetail(detail); try { dao.savePersonalDetails(detail); lblPersonalDetailSuccess.Visible = true; } catch (Exception ex) { lblPersonalDetailFailed.Visible = true; throw ex; } } string status = activityStatusCheck.getPersonalDetailStatus(detail); activityStatusDao.saveOrUpdateActivityStatus(caseId, actv, status); markStatusOnTab(caseId); string caseStatus = activityStatusCheck.getZPlanStatus(caseId); casestatuslbl.Visible = false; casestatuslbl.Text = "zplan status: " + caseStatus; string url = Server.MapPath("~/_layouts/Zurich/Printpages/"); //try //{ // GeneratePdf genPdf = new GeneratePdf(); // MemoryStream output = genPdf.createPdf(caseId, url); // pdfData = output.ToArray(); //} //catch (Exception ex) //{ // throw; //} pdfData = activityStatusCheck.sendDataToSalesPortal(caseId, caseStatus, url, sendPdf); /*if (st == 1) { lblStatusSubmitted.Visible = false; } else { lblStatusSubmissionFailed.Visible = true; }*/ populatePersonalDetails(detail); }
protected void Page_Load(object sender, EventArgs e) { string caseId = ""; activity = activityStatusDao.getActivity(1); ViewState["activity"] = activity; casestatuslbl.Visible = false; if (!IsPostBack) { string backCaseId = Request.Form["caseid"]; string menuCaseId = Request.QueryString["caseid"]; if (backCaseId != null && backCaseId != "") { caseId = backCaseId; } else if (menuCaseId != null && menuCaseId != "") { caseId = menuCaseId; } else if (Session["fnacaseid"] != null) { caseId = Session["fnacaseid"].ToString(); } else { caseId = "2040"; } ViewState["caseId"] = caseId; activityId.Value = caseId; PersonalDetailsDAO dao = new PersonalDetailsDAO(); personaldetail detail = dao.getPersonalDetail(caseId); if (detail == null) { detail = new personaldetail(); } populatePersonalDetails(detail); } titleList.Attributes.Add("readonly", "readonly"); name.Attributes.Add("readonly", "readonly"); surname.Attributes.Add("readonly", "readonly"); datepicker.Attributes.Add("readonly", "readonly"); genderList.Attributes.Add("readonly", "readonly"); nationalityList.Attributes.Add("readonly", "readonly"); //maritalList.Attributes.Add("readonly", "readonly"); smokerList.Attributes.Add("readonly", "readonly"); nric.Attributes.Add("readonly", "readonly"); occupation.Attributes.Add("readonly", "readonly"); markStatusOnTab(caseId); }
private string getYearsToSupportDisabilityProtection(string caseId) { PersonalDetailsDAO dao = new PersonalDetailsDAO(); personaldetail detail = dao.getPersonalDetail(caseId); AssumptionDAO assumptionDao = new AssumptionDAO(); string yearsOfSupport = "0"; if (detail != null) { string dob = detail.datepicker; if (dob != null && dob != "") { DateTime now = DateTime.Today; DateTime parsedDobDate = Convert.ToDateTime(getDateInProperFormat(dob)); int age = now.Year - parsedDobDate.Year; if (now.Month < parsedDobDate.Month) { age = age - 1; } if (now.Month == parsedDobDate.Month) { if (now.Day < parsedDobDate.Day) { age = age - 1; } } if (age < 62) yearsOfSupport = (62 - age) + ""; } } return yearsOfSupport; }