public void GetAssetAllocation() { DataSet dsGetCustomerRiskProfile = riskprofilebo.GetCustomerRiskProfile(CustomerId, advisorVo.advisorId, 1); if (dsGetCustomerRiskProfile.Tables[0].Rows.Count > 0) { riskCode = dsGetCustomerRiskProfile.Tables[0].Rows[0]["XRC_RiskClassCode"].ToString(); DataSet dsGetAssetAllocationRules = riskprofilebo.GetAssetAllocationRules(riskCode, advisorVo.advisorId); DataTable dtAsset = new DataTable(); dtAsset.Columns.Add("AssetType"); dtAsset.Columns.Add("Percentage"); dtAsset.Columns.Add("AssetTypeCode"); DataRow drAsset; double equityAdjustment = 0; double equitycalc = 0.0; double equityPercentage = 0; double debtpercentage = 0; double cashPercentage = 0; if (dsGetAssetAllocationRules != null && dsGetAssetAllocationRules.Tables[0].Rows[0]["A_AdviserId"].ToString() != advisorVo.advisorId.ToString()) { foreach (DataRow dr in dsGetAssetAllocationRules.Tables[0].Rows) { if (dr["WAC_AssetClassification"].ToString() == "Cash") { cashPercentage = double.Parse(dr["WAAR_AssetAllocationPercenatge"].ToString()); } else if (dr["WAC_AssetClassification"].ToString() == "Equity") { if (dr["WAAR_Adjustment"].ToString() != "") { equityAdjustment = double.Parse(dr["WAAR_Adjustment"].ToString()); } } } equitycalc = double.Parse(((100 - double.Parse(age.ToString())) / 100).ToString()); equityPercentage = (((100 - cashPercentage) * equitycalc + (equityAdjustment))); debtpercentage = (100 - equityPercentage - cashPercentage); drAsset = dtAsset.NewRow(); drAsset[0] = "Equity"; drAsset[1] = equityPercentage.ToString(); drAsset[2] = 1; dtAsset.Rows.Add(drAsset); drAsset = dtAsset.NewRow(); drAsset[0] = "Debt"; drAsset[1] = debtpercentage.ToString(); drAsset[2] = 2; dtAsset.Rows.Add(drAsset); drAsset = dtAsset.NewRow(); drAsset[0] = "Cash"; drAsset[1] = cashPercentage.ToString(); drAsset[2] = 3; dtAsset.Rows.Add(drAsset); } else { foreach (DataRow dr in dsGetAssetAllocationRules.Tables[0].Rows) { drAsset = dtAsset.NewRow(); drAsset[0] = dr["WAC_AssetClassification"].ToString(); if (dr["WAAR_AssetAllocationPercenatge"] != null) { drAsset[1] = dr["WAAR_AssetAllocationPercenatge"].ToString(); } else { drAsset[1] = 0; } drAsset[2] = dr["WAC_AssetClassificationCode"].ToString(); dtAsset.Rows.Add(drAsset); } } dtRecommendedAllocation = dtAsset; if ((dtAsset.Rows.Count > 0) && (dtAsset.ToString() != null)) { lblCurrChartErrorDisplay.Visible = false; /* For Chart binding */ Legend ShowRecomondedAssetAlllegend = null; ShowRecomondedAssetAlllegend = new Legend("ShowRecomondedAssetAlllegendLegends"); ShowRecomondedAssetAlllegend.Enabled = true; Series seriesAssets = new Series("RecomondedAsset"); seriesAssets.ChartType = SeriesChartType.Pie; ChartRecomonedAsset.Visible = true; ChartRecomonedAsset.Series.Clear(); ChartRecomonedAsset.Series.Add(seriesAssets); ChartRecomonedAsset.DataSource = dtAsset; ChartRecomonedAsset.Series[0].XValueMember = "AssetType"; ChartRecomonedAsset.Series[0].YValueMembers = "Percentage"; ChartRecomonedAsset.Series[0].ToolTip = "#VALX: #PERCENT"; ChartRecomonedAsset.Legends.Add(ShowRecomondedAssetAlllegend); ChartRecomonedAsset.Legends["ShowRecomondedAssetAlllegendLegends"].Title = "Assets"; ChartRecomonedAsset.Legends["ShowRecomondedAssetAlllegendLegends"].TitleAlignment = StringAlignment.Center; ChartRecomonedAsset.Legends["ShowRecomondedAssetAlllegendLegends"].TitleSeparator = LegendSeparatorStyle.None; ChartRecomonedAsset.Legends["ShowRecomondedAssetAlllegendLegends"].Alignment = StringAlignment.Center; ChartRecomonedAsset.Legends["ShowRecomondedAssetAlllegendLegends"].TitleSeparator = LegendSeparatorStyle.GradientLine; ChartRecomonedAsset.Legends["ShowRecomondedAssetAlllegendLegends"].TitleSeparatorColor = Color.Black; // Enable X axis margin LegendCellColumn colorColumn = new LegendCellColumn(); colorColumn.ColumnType = LegendCellColumnType.SeriesSymbol; colorColumn.HeaderBackColor = Color.WhiteSmoke; ChartRecomonedAsset.Legends["ShowRecomondedAssetAlllegendLegends"].CellColumns.Add(colorColumn); ChartRecomonedAsset.Legends["ShowRecomondedAssetAlllegendLegends"].BackColor = Color.FloralWhite; LegendCellColumn totalColumn = new LegendCellColumn(); totalColumn.Alignment = ContentAlignment.MiddleLeft; totalColumn.Text = "#VALX: #PERCENT"; totalColumn.Name = "AssetsColumn"; totalColumn.HeaderBackColor = Color.WhiteSmoke; ChartRecomonedAsset.Legends["ShowRecomondedAssetAlllegendLegends"].CellColumns.Add(totalColumn); ChartRecomonedAsset.Series[0]["PieLabelStyle"] = "Disabled"; ChartRecomonedAsset.ChartAreas["caActualAsset"].AxisX.IsMarginVisible = true; ChartRecomonedAsset.BackColor = Color.Transparent; ChartRecomonedAsset.ChartAreas[0].BackColor = Color.Transparent; ChartRecomonedAsset.ChartAreas[0].Area3DStyle.Enable3D = true; ChartRecomonedAsset.ChartAreas[0].Area3DStyle.Perspective = 50; tdCurrentAssetAllocation.Visible = true; ChartRecomonedAsset.DataBind(); } else { lblChartErrorDisplay.Visible = true; ChartRecomonedAsset.Visible = false; } } else { lblChartErrorDisplay.Visible = true; ChartRecomonedAsset.Visible = false; } }
/**************************** For Recommended Asset Allocation Chart *************************************/ public void LoadRecommendedAssetAllocation() { DataTable dtChartRecommendedAsset = new DataTable(); DataSet dsGetCustomerDOBById = new DataSet(); customerVo = new CustomerVo(); string RecommendedEquity = "0"; string RecommendedDebt = "0"; string RecommendedCash = "0"; string RecommendedAlternates = "0"; dsGetCustomerDOBById = riskprofilebo.GetCustomerDOBById(CustomerId); if (Session[SessionContents.CustomerVo] != null && Session[SessionContents.CustomerVo].ToString() != "") { customerVo = (CustomerVo)Session[SessionContents.CustomerVo]; } if (dsGetCustomerDOBById.Tables[0].Rows[0]["C_DOB"].ToString() != "" && dsGetCustomerDOBById.Tables[0].Rows[0]["C_DOB"].ToString() != null) { DateTime bday = DateTime.Parse(dsGetCustomerDOBById.Tables[0].Rows[0]["C_DOB"].ToString()); DateTime now = DateTime.Today; age = now.Year - bday.Year; if (now < bday.AddYears(age)) { age--; } if (dsFPCurrentAndRecomondedAssets.Tables[1].Rows.Count > 0) { DataTable dtRecommendedAssetAllocation = new DataTable(); dtRecommendedAssetAllocation = dsFPCurrentAndRecomondedAssets.Tables[1]; dtChartRecommendedAsset.Columns.Add("AssetClass"); dtChartRecommendedAsset.Columns.Add("RecommendedPercentage"); foreach (DataRow dr in dtRecommendedAssetAllocation.Rows) { drChartRecommendedAsset = dtChartRecommendedAsset.NewRow(); if (dr["AssetType"].ToString() == "Equity") { if (double.Parse(dr["Percentage"].ToString()) > 0) { drChartRecommendedAsset["AssetClass"] = dr["AssetType"].ToString(); drChartRecommendedAsset["RecommendedPercentage"] = dr["Percentage"].ToString(); RecommendedEquity = drChartRecommendedAsset["RecommendedPercentage"].ToString(); dtChartRecommendedAsset.Rows.Add(drChartRecommendedAsset); } } if (dr["AssetType"].ToString() == "Debt") { if (double.Parse(dr["Percentage"].ToString()) > 0) { drChartRecommendedAsset["AssetClass"] = dr["AssetType"].ToString(); drChartRecommendedAsset["RecommendedPercentage"] = dr["Percentage"].ToString(); RecommendedDebt = drChartRecommendedAsset["RecommendedPercentage"].ToString(); dtChartRecommendedAsset.Rows.Add(drChartRecommendedAsset); } } if (dr["AssetType"].ToString() == "Cash") { if (double.Parse(dr["Percentage"].ToString()) > 0) { drChartRecommendedAsset["AssetClass"] = dr["AssetType"].ToString(); drChartRecommendedAsset["RecommendedPercentage"] = dr["Percentage"].ToString(); RecommendedCash = drChartRecommendedAsset["RecommendedPercentage"].ToString(); dtChartRecommendedAsset.Rows.Add(drChartRecommendedAsset); } } if (dr["AssetType"].ToString() == "Alternates") { if (double.Parse(dr["Percentage"].ToString()) > 0) { drChartRecommendedAsset["AssetClass"] = dr["AssetType"].ToString(); drChartRecommendedAsset["RecommendedPercentage"] = dr["Percentage"].ToString(); RecommendedAlternates = drChartRecommendedAsset["RecommendedPercentage"].ToString(); dtChartRecommendedAsset.Rows.Add(drChartRecommendedAsset); } } } if ((RecommendedEquity != "0") || (RecommendedDebt != "0") || (RecommendedCash != "0") || (RecommendedAlternates != "0")) { lblCurrChartErrorDisplay.Visible = false; /* For Chart binding */ Legend ShowRecomondedAssetAlllegend = null; ShowRecomondedAssetAlllegend = new Legend("ShowRecomondedAssetAlllegendLegends"); ShowRecomondedAssetAlllegend.Enabled = true; ChartRecomonedAsset.Palette = ChartColorPalette.Pastel; ChartRecomonedAsset.PaletteCustomColors = new Color[] { Color.LimeGreen, Color.Yellow, Color.LightBlue, Color.Purple, Color.Goldenrod, Color.Blue, Color.BurlyWood, Color.Chocolate, Color.DeepPink, Color.Plum, Color.Violet, Color.Gainsboro, Color.Tomato, Color.Teal }; Series seriesAssets = new Series("RecomondedAsset"); seriesAssets.ChartType = SeriesChartType.Pie; ChartRecomonedAsset.Visible = true; ChartRecomonedAsset.Series.Clear(); ChartRecomonedAsset.Series.Add(seriesAssets); ChartRecomonedAsset.DataSource = dtChartRecommendedAsset; ChartRecomonedAsset.Series[0].XValueMember = "AssetClass"; ChartRecomonedAsset.Series[0].YValueMembers = "RecommendedPercentage"; ChartRecomonedAsset.Series[0].ToolTip = "#VALX: #PERCENT"; ChartRecomonedAsset.Legends.Add(ShowRecomondedAssetAlllegend); ChartRecomonedAsset.Legends["ShowRecomondedAssetAlllegendLegends"].Title = "Assets"; ChartRecomonedAsset.Legends["ShowRecomondedAssetAlllegendLegends"].TitleAlignment = StringAlignment.Center; ChartRecomonedAsset.Legends["ShowRecomondedAssetAlllegendLegends"].TitleSeparator = LegendSeparatorStyle.None; ChartRecomonedAsset.Legends["ShowRecomondedAssetAlllegendLegends"].Alignment = StringAlignment.Center; ChartRecomonedAsset.Legends["ShowRecomondedAssetAlllegendLegends"].TitleSeparator = LegendSeparatorStyle.GradientLine; ChartRecomonedAsset.Legends["ShowRecomondedAssetAlllegendLegends"].TitleSeparatorColor = Color.Black; // Enable X axis margin LegendCellColumn colorColumn = new LegendCellColumn(); colorColumn.ColumnType = LegendCellColumnType.SeriesSymbol; colorColumn.HeaderBackColor = Color.WhiteSmoke; ChartRecomonedAsset.Legends["ShowRecomondedAssetAlllegendLegends"].CellColumns.Add(colorColumn); ChartRecomonedAsset.Legends["ShowRecomondedAssetAlllegendLegends"].BackColor = Color.FloralWhite; LegendCellColumn totalColumn = new LegendCellColumn(); totalColumn.Alignment = ContentAlignment.MiddleLeft; totalColumn.Text = "#VALX: #PERCENT"; totalColumn.Name = "AssetsColumn"; totalColumn.HeaderBackColor = Color.WhiteSmoke; ChartRecomonedAsset.Legends["ShowRecomondedAssetAlllegendLegends"].CellColumns.Add(totalColumn); ChartRecomonedAsset.Series[0]["PieLabelStyle"] = "Disabled"; ChartRecomonedAsset.ChartAreas["caActualAsset"].AxisX.IsMarginVisible = true; ChartRecomonedAsset.BackColor = Color.Transparent; ChartRecomonedAsset.ChartAreas[0].BackColor = Color.Transparent; ChartRecomonedAsset.ChartAreas[0].Area3DStyle.Enable3D = true; ChartRecomonedAsset.ChartAreas[0].Area3DStyle.Perspective = 50; tdCurrentAssetAllocation.Visible = true; ChartRecomonedAsset.DataBind(); } else { lblChartErrorDisplay.Visible = true; ChartRecomonedAsset.Visible = false; } } else { //GetAssetAllocation(); lblChartErrorDisplay.Visible = true; lblChartErrorDisplay.Text = "Model Portfolio is not set for your age!"; ChartRecomonedAsset.Visible = false; } } else { lblChartErrorDisplay.Visible = true; lblChartErrorDisplay.Text = "No Age to display chart. Please Fill Date of Birth in profile!"; ChartRecomonedAsset.Visible = false; } }