private void PopulateBudgetData() { Ledger.Accounts = FinancialAccounts.FromSingle(_account); int year = Int32.Parse(this.DropYears.SelectedValue); Ledger.DateStart = new DateTime(year, 1, 1); Ledger.DateEnd = new DateTime(year, 12, 31); Ledger.MaxAmount = 1.0e12m; double budget = _account.GetBudget(year); Ledger.Populate(); // Populate predictions int monthIterator = 1; Int64[] monthlyPredicts = _account.GetBudgetMonthly(year); while (monthIterator <= 12) { TextBox box = (TextBox) this.Master.FindControl("BodyContent").FindControl("TextPredictMonth" + monthIterator.ToString()); if (monthlyPredicts.Length == 12) { box.Text = (monthlyPredicts[monthIterator - 1] / 100).ToString("N0", new CultureInfo("sv-SE")); } else { box.Text = string.Empty; } monthIterator++; } // Populate actuals monthIterator = 1; while (monthIterator <= 12 && new DateTime(year, monthIterator, 1).AddMonths(1) < DateTime.Today) { DateTime start = new DateTime(year, monthIterator, 1); Int64 deltaCents = _account.GetDeltaCents(start, start.AddMonths(1)); decimal deltaDecimal = -deltaCents / 100.0m; TextBox actual = (TextBox)this.Master.FindControl("BodyContent").FindControl("TextActualsMonth" + monthIterator.ToString()); actual.Text = deltaDecimal.ToString("N0", new CultureInfo(_account.Organization.DefaultCountry.Culture)); monthIterator++; } // Clear the non-set actuals fields while (monthIterator <= 12) { TextBox actual = (TextBox)this.Master.FindControl("BodyContent").FindControl("TextActualsMonth" + monthIterator.ToString()); actual.Text = string.Empty; monthIterator++; } InitSuballocation(true); ScriptManager.RegisterStartupScript(this, Page.GetType(), "set_budget_iframe", "var currWidth = document.getElementById('DivIframeContainer').offsetWidth; document.getElementById('DivIframeContainer').innerHTML='<iframe src=\"BudgetUsageBar.aspx?AccountId=" + _account.Identity.ToString() + "&Year=" + year.ToString() + "&Width=' + currWidth + '\" width=\"100%\" scrolling=\"no\" height=\"100\" frameBorder=\"0\" />';", true); }