protected void riskProfileSubmit(object sender, EventArgs e) { string caseId = ""; if (ViewState["caseId"] != null) { caseId = ViewState["caseId"].ToString(); } caseNumber.Value = caseId; RiskProfileAnalysis riskProfile = new RiskProfileAnalysis(); RiskProfileDAO dao = new RiskProfileDAO(); RiskProfileAnalysis riskProfileAnalysis = dao.getRiskProfileForCase(caseId); string status = "new"; if (riskProfileAnalysis != null) { status = "update"; copyRiskProfileBaseClass(riskProfile); } else { riskProfile.caseId = caseId; copyRiskProfileBaseClass(riskProfile); } if (status == "new") { dao.saveNewRiskProfile(riskProfile); } else { riskProfile.caseId = caseId; dao.updateRiskProfileDetails(riskProfile, "riskApetite"); } string actv = ""; if (ViewState["activity"] != null) { actv = ViewState["activity"].ToString(); } string cstatus = activityStatusCheck.getRiskProfileStatus(riskProfile); activityStatusDao.saveOrUpdateActivityStatus(caseId, actv, cstatus); PortFolioModellingDAO poftFolioDAO = new PortFolioModellingDAO(); poftFolioDAO.DeletePoftFolioBuilderForCapitalPreservation(caseId); markStatusOnTab(caseId); string caseStatus = activityStatusCheck.getZPlanStatus(caseId); string url = Server.MapPath("~/_layouts/Zurich/Printpages/"); pdfData = activityStatusCheck.sendDataToSalesPortal(caseId, caseStatus, url, sendPdf); populateRiskProfile(riskProfile,caseId); riskProfileSaveSuccess.Visible = true; }
protected void LoadPortFolioDetails() { lblRiskProfile.Text = strProfileName; PortFolioModellingDAO portFolioDAO = new PortFolioModellingDAO(); DataTable dtPortFolioMaster = portFolioDAO.getPortFolioMaster(caseID); if ((dtPortFolioMaster == null || dtPortFolioMaster.Rows.Count == 0) && strProfileName == "Capital Preservation") { EnableDisableControls(false); btnBackFundPlotter.Enabled = true; btnNextFundPlotter.Enabled = true; btnBackPortFolioModel.Enabled = true; btnNextPortFolioModel.Enabled = true; btnPrintRiskPlotter.Enabled = true; btnPrint.Enabled = true; optnAgreeRiskProfile.Enabled = true; imgRangeOfReturns.ImageUrl = string.Empty; return; } if (dtPortFolioMaster != null && dtPortFolioMaster.Rows.Count > 0) { lblRiskProfile.Text = dtPortFolioMaster.Rows[0]["riskProfileName"].ToString(); bool agreeWithRiskProfile = (bool)dtPortFolioMaster.Rows[0]["agreeWithRiskProfile"]; if (agreeWithRiskProfile) { optnAgreeRiskProfileYes.Selected = true; } else { optnAgreeRiskProfileNo.Selected = true; } optnAgreeRiskProfile_SelectedIndexChanged(null, null); if (optnAgreeRiskProfileYes.Selected == true && lblRiskProfile.Text == "Capital Preservation") { return; } ddlRiskProfileList.SelectedValue = dtPortFolioMaster.Rows[0]["preferredRiskPRofile"].ToString(); if (optnAgreeRiskProfileNo.Selected == true && ddlRiskProfileList.SelectedIndex == 1) { ddlRiskProfileList_SelectedIndexChanged(null, null); } if (optnAgreeRiskProfileYes.Selected == true || (optnAgreeRiskProfileNo.Selected == true && ddlRiskProfileList.SelectedIndex != 1)) { bool farp = (bool)dtPortFolioMaster.Rows[0]["followAssetAllocationOnRiskProfileYesNo"]; if (farp) { optnAssetAllocRiskProfile1.Selected = true; } else { optnAssetAllocRiskProfile2.Selected = true; } followAllocationBasedOnRiskProfile_SelectedIndexChanged(null, null); if (!farp) { //True = Fund Risk Plottor, False = Fund Selection bool arp = (bool)dtPortFolioMaster.Rows[0]["assetAllocationOnRiskProfileYesNo"]; if (arp) { optnAllocRiskProfile1.Selected = true; } else { optnAllocRiskProfile2.Selected = true; } onAllocationBasedOnRiskProfile_SelectedIndexChanged(null, null); } if (farp) { bool ncf = (bool)dtPortFolioMaster.Rows[0]["includeNonCoreFundsYesNo"]; if (ncf) { optnNonCoreFunds1.Selected = true; } else { optnNonCoreFunds2.Selected = true; } nonCoreFunds_SelectedIndexChanged(null, null); } string pselect = dtPortFolioMaster.Rows[0]["premiumSelect"].ToString().Trim(); if (pselect == "0") { optnPremiumSelect1.Selected = true; } else { optnPremiumSelect2.Selected = true; } } premium.Text = dtPortFolioMaster.Rows[0]["premiumAmount"].ToString(); ddlPaymentMode.SelectedValue = dtPortFolioMaster.Rows[0]["paymentMode"].ToString(); premiumSelect_SelectedIndexChanged(null, null); txtTotalPremium.Text = dtPortFolioMaster.Rows[0]["premiumPercent"].ToString(); txtAllocationAmtTotal.Text = dtPortFolioMaster.Rows[0]["premiumTotalAmount"].ToString(); } ShowRateOfReturnsImage(); }
public DataTable getFundRiskPlotter(String id, bool isInitialLoad) { string[] words = id.Split('-'); int assetId = int.Parse(words[0]); int riskProfileId = 0; String profileName = words[1]; switch (profileName) { case "Capital Preservation": riskProfileId = 0; break; case "Cautious": riskProfileId = 1; break; case "Moderately Cautious": riskProfileId = 2; break; case "Balanced": riskProfileId = 3; break; case "Moderately Adventurous": riskProfileId = 4; break; case "Adventurous": riskProfileId = 5; break; default: break; } PortFolioModellingDAO portFolioModellingDAO = new PortFolioModellingDAO(); DataTable dtAssets = portFolioModellingDAO.getFunds(riskProfileId, assetId, caseID, isInitialLoad); return dtAssets; }
public DataTable getFundSelection(bool isInitialLoad) { PortFolioModellingDAO portFolioModellingDAO = new PortFolioModellingDAO(); DataTable assets = portFolioModellingDAO.getFundSelection(caseID, isInitialLoad); return assets; }
private bool savePortFolioModel() { try { if ((optnAgreeRiskProfileYes.Selected == true && lblRiskProfile.Text != "Capital Preservation") || (optnAgreeRiskProfileNo.Selected == true && ddlRiskProfileList.SelectedIndex > 1)) { if (!validateAllRequiredFields()) { return false; } } int riskProfileId = -1; switch (strProfileName) { case "Capital Preservation": riskProfileId = 0; break; case "Cautious": riskProfileId = 1; break; case "Moderately Cautious": riskProfileId = 2; break; case "Balanced": riskProfileId = 3; break; case "Moderately Adventurous": riskProfileId = 4; break; case "Adventurous": riskProfileId = 5; break; default: break; } bool agreeRiskProfile = true; if (optnAgreeRiskProfileYes.Selected == true) { agreeRiskProfile = true; } if (optnAgreeRiskProfileNo.Selected == true) { agreeRiskProfile = false; } string newRiskProfile = "-1"; newRiskProfile = ddlRiskProfileList.SelectedValue.ToString(); bool followAssetAllocationOnRiskProfileYesNo = false; if (optnAssetAllocRiskProfile1.Selected == true) { followAssetAllocationOnRiskProfileYesNo = true; } if (optnAssetAllocRiskProfile2.Selected == true) { followAssetAllocationOnRiskProfileYesNo = false; } //True = Fund Risk Plottor, False = Fund Selection bool assetAllocationOnRiskProfileYesNo = false; if (optnAllocRiskProfile1.Selected == true) { assetAllocationOnRiskProfileYesNo = true; } if (optnAllocRiskProfile2.Selected == true) { assetAllocationOnRiskProfileYesNo = false; } bool includeNonCoreFundsYesNo = false; if (optnNonCoreFunds1.Selected == true) { includeNonCoreFundsYesNo = true; } if (optnNonCoreFunds2.Selected == true) { includeNonCoreFundsYesNo = false; } int premiumSelect = -1; if (optnPremiumSelect1.Selected == true) { premiumSelect = 0; } if (optnPremiumSelect2.Selected == true) { premiumSelect = 1; } double premiumAmount = 0; double premiumPercent = 0; double totalPremiumAmount = 0; if (premium.Text != null && premium.Text != "") { premiumAmount = Convert.ToDouble(premium.Text); } string paymentMode = "-1"; paymentMode = ddlPaymentMode.SelectedValue.ToString(); List<int> lstAssetId = new List<int>(); List<int> lstFundId = new List<int>(); List<int> lstAllocationPercent = new List<int>(); List<int> lstAmount = new List<int>(); DataTable dtPortFolioBuilderDetail = new DataTable(); dtPortFolioBuilderDetail.Columns.Add("AssetId", typeof(string)); dtPortFolioBuilderDetail.Columns.Add("FundId", typeof(string)); dtPortFolioBuilderDetail.Columns.Add("AllocationPercent", typeof(string)); dtPortFolioBuilderDetail.Columns.Add("Amount", typeof(string)); List<GridViewRow> gvRows = new List<GridViewRow>(); if (optnAssetAllocRiskProfile1.Selected == true && (optnNonCoreFunds1.Selected == true || optnNonCoreFunds2.Selected == true)) { if (!validateFundAllocation()) { return false; } foreach (GridViewRow gvRow in grdNonCoreFunds.Rows) { gvRows.Add(gvRow); } } if (optnAssetAllocRiskProfile2.Selected == true && optnAllocRiskProfile1.Selected == true) { if (!validateFundPlotter()) { return false; } foreach (GridViewRow gvRow in grdFundRiskPlotter.Rows) { gvRows.Add(gvRow); } foreach (GridViewRow gvRow in grdSecondaryFunds.Rows) { gvRows.Add(gvRow); } } if (optnAssetAllocRiskProfile2.Selected == true && optnAllocRiskProfile2.Selected == true) { if (!ValidateFundSelection()) { return false; } foreach (GridViewRow gvRow in grdFundsSelection.Rows) { gvRows.Add(gvRow); } } if (gvRows != null) { foreach (GridViewRow gvr in gvRows) { Label lblAssedId = (Label)gvr.FindControl("lblAssetId"); Label lblFundId = (Label)gvr.FindControl("lblFundId"); TextBox tbAllocationPercent = (TextBox)gvr.FindControl("txtAllocation"); TextBox tbAmount = (TextBox)gvr.FindControl("txtAmount"); string iAssetId = lblAssedId.Text; string iFundId = lblFundId.Text; string strAllocationPercent = tbAllocationPercent.Text; string strAmount = tbAmount.Text; double totalPercent = 0; double totalpremiumAmt = 0; if ((strAllocationPercent != null && strAllocationPercent != "" && Convert.ToDouble(strAllocationPercent) > 0) || (strAmount != null && strAmount != "" && Convert.ToDouble(strAmount) > 0)) { if (strAllocationPercent == null || strAllocationPercent == "") { strAllocationPercent = "0"; } if ( Convert.ToDouble(strAllocationPercent) == 0) { continue; } //{ totalPercent = Convert.ToDouble(strAllocationPercent); //} if (strAmount == null || strAmount == "") { strAmount = "0"; } //else //{ totalpremiumAmt = Convert.ToDouble(strAmount); //} dtPortFolioBuilderDetail.Rows.Add(iAssetId, iFundId, strAllocationPercent, strAmount); } premiumPercent = premiumPercent + totalPercent; totalPremiumAmount = totalPremiumAmount + totalpremiumAmt; //if (txtTotalPremium.Text != null && txtTotalPremium.Text != "") //{ //premiumPercent = Convert.ToDouble(txtTotalPremium.Text); //} } PortFolioModellingDAO portFolioDAO = new PortFolioModellingDAO(); bool bResult = portFolioDAO.SavePortFolioBuilderInfo(caseID, riskProfileId, agreeRiskProfile, newRiskProfile, followAssetAllocationOnRiskProfileYesNo, assetAllocationOnRiskProfileYesNo, includeNonCoreFundsYesNo, premiumSelect, premiumAmount, paymentMode, premiumPercent, totalPremiumAmount, dtPortFolioBuilderDetail); if (bResult) { string actv = ""; if (ViewState["activity"] != null) { actv = ViewState["activity"].ToString(); } string status = activityStatusCheck.getPortfolioBuilderStatus(premiumPercent); activityStatusDao.saveOrUpdateActivityStatus(caseID, actv, status); cst.Value = markStatusOnTab(caseID); ScriptManager.RegisterStartupScript(this, typeof(string), "TabStatus", "tabstatus('"+cst.Value+"');", true); string caseStatus = activityStatusCheck.getZPlanStatus(caseID); string url = Server.MapPath("~/_layouts/Zurich/Printpages/"); pdfData = activityStatusCheck.sendDataToSalesPortal(caseID, caseStatus, url, sendPdf); LoadPortFolioDetails(); if ((txtTotalPremium.Text != string.Empty && (Convert.ToInt32(txtTotalPremium.Text) < 100)) && !(optnAgreeRiskProfileNo.Selected == true && ddlRiskProfileList.SelectedIndex == 1)) { lblSubmitMessageLessThan100.Visible = true; lblSubmitMessage.Visible = false; } else { lblSubmitMessageLessThan100.Visible = false; lblSubmitMessage.Visible = true; } return true; } } } catch (Exception ex) { exceptionlog exLog = new exceptionlog(); exLog.message = ex.Message + " class: PortFolioModelling Method: SavePortFolioModel"; 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 activityStatus = new ActivityStatusDAO(); activityStatus.logException(exLog); } return false; }