private void DrawFinanceRatio() { //Liquidity Ratio int currentMonth = cbMonth.SelectedIndex + 1; int currentYear = DateTime.Now.Year; decimal emergencyFund = chartRepository.GetEmergencyFund(currentMonth, currentYear); decimal expense = chartRepository.GetExpense(currentMonth, currentYear); decimal debt = chartRepository.GetDebt(currentMonth, currentYear); decimal asset = chartRepository.GetAsset(currentMonth, currentYear); decimal income = chartRepository.GetIncome(currentMonth, currentYear); decimal investment = chartRepository.GetInvestment(currentMonth, currentYear); decimal saving = chartRepository.GetSaving(currentMonth, currentYear); decimal expenseAndDebt = expense + debt; lblFundBalance.Text = "Balance ( " + settingRepository.GetValue("EmergencyFund") + " )"; if (expenseAndDebt != 0) { decimal liquidityRatio = emergencyFund / expenseAndDebt; lblLiquidityRatio.Text = liquidityRatio.ToString("N1"); lblFundCurrent.Text = emergencyFund.ToString("N0"); lblFundMustHave.Text = (expenseAndDebt * 6).ToString("N0"); decimal percent = (emergencyFund / (expenseAndDebt * 6)) * 100; lblFundPercent.Text = percent.ToString("N1") + " %"; decimal pnlLiquidWidth = 300 * (percent / 100); pnlLiquidityRatio.Width = (int)pnlLiquidWidth; if (liquidityRatio < 6) { lblLiquidityStatus.Text = "Not Good"; lblLiquidityStatus.ForeColor = Color.DarkRed; } else { lblLiquidityStatus.Text = "Good"; lblLiquidityStatus.ForeColor = Color.DarkGreen; } } else { lblFundCurrent.Text = "0"; lblFundMustHave.Text = "0"; lblFundPercent.Text = "0 %"; lblLiquidityStatus.Text = "Not Good"; lblLiquidityStatus.ForeColor = Color.DarkRed; pnlLiquidityRatio.Width = 0; } //Liquid Asset to Net Worth Ratio decimal netWorth = asset - debt; if (netWorth != 0) { decimal liquidToNetWorthRatio = emergencyFund / netWorth; lblLiquidToNWRatio.Text = liquidToNetWorthRatio.ToString("N1") + " %"; if (liquidToNetWorthRatio >= 15) { lblLiquidToNWStatus.Text = "Good"; lblLiquidToNWStatus.ForeColor = Color.DarkGreen; } else { lblLiquidToNWStatus.Text = "Not Good"; lblLiquidToNWStatus.ForeColor = Color.DarkRed; } decimal pnlLiquidToNWWidth = 300 * (liquidToNetWorthRatio / 100); pnlLiquidToNWRatio.Width = (int)pnlLiquidToNWWidth; } //Solvency Ratio if (asset != 0) { decimal solvencyRatio = netWorth / asset; lblSolvencyRatio.Text = solvencyRatio.ToString("N1") + " %"; if (solvencyRatio > 35) { lblSolvencyStatus.Text = "Good"; lblSolvencyStatus.ForeColor = Color.DarkGreen; } else { lblSolvencyStatus.Text = "Not Good"; lblSolvencyStatus.ForeColor = Color.DarkRed; } decimal pnlSolvencyWidth = 300 * (solvencyRatio / 100); pnlSolvencyRatio.Width = (int)pnlSolvencyWidth; } //Debt to Asset Ratio if (asset != 0) { decimal debtToAssetRatio = debt / asset; lblDebtToAssetRatio.Text = debtToAssetRatio.ToString("N1") + " %"; if (debtToAssetRatio < 50) { lblDebtToAssetStatus.Text = "Good"; lblDebtToAssetStatus.ForeColor = Color.DarkGreen; } else { lblDebtToAssetStatus.Text = "Not Good"; lblDebtToAssetStatus.ForeColor = Color.DarkRed; } decimal pnlDebtToAsset = 300 * (debtToAssetRatio / 100); pnlDebtToAssetRatio.Width = (int)pnlDebtToAsset; } else { } //Debt Service Ratio if (income != 0) { decimal debtServiceRatio = debt / income; lblDebtServiceRatio.Text = debtServiceRatio.ToString("N1") + " %"; if (debtServiceRatio < 35) { lblDebtServiceStatus.Text = "Good"; lblDebtServiceStatus.ForeColor = Color.DarkGreen; } else if (debtServiceRatio >= 45) { lblDebtServiceStatus.Text = "Danger"; lblDebtServiceStatus.ForeColor = Color.DarkRed; } else { lblDebtServiceStatus.Text = "Not Good"; lblDebtServiceStatus.ForeColor = Color.DarkRed; } decimal pnlDebtServiceWidth = 300 * (debtServiceRatio / 100); pnlDebtServiceRatio.Width = (int)pnlDebtServiceWidth; } //Net Investment if (netWorth != 0) { decimal netInvestmentRatio = investment / netWorth; lblInvestmentRatio.Text = netInvestmentRatio.ToString("N1") + " %"; if (netInvestmentRatio >= 50) { lblInvestmentStatus.Text = "Good"; lblInvestmentStatus.ForeColor = Color.DarkGreen; } else { lblInvestmentStatus.Text = "Not Good"; lblInvestmentStatus.ForeColor = Color.DarkRed; } decimal pnlInvestmentWidth = 300 * (netInvestmentRatio / 100); pnlInvestmentRatio.Width = (int)pnlInvestmentWidth; } //Saving Ratio if (income != 0) { decimal savingRatio = saving / income; lblSavingRatio.Text = savingRatio.ToString("N1") + " %"; if (savingRatio < 10) { lblSavingStatus.Text = "Not Good"; lblSavingStatus.ForeColor = Color.DarkRed; } else { lblSavingStatus.Text = "Good"; lblSavingStatus.ForeColor = Color.DarkGreen; } decimal pnlSavingWidth = 300 * (savingRatio / 100); pnlSavingRatio.Width = (int)pnlSavingWidth; } else { pnlSavingRatio.Width = 0; lblSavingStatus.Text = string.Empty; } pnlFinancialCheckup.Visible = true; }