Ejemplo n.º 1
0
    protected void PopulateGrid(int accountId, DateTime start, DateTime end)
    {
        if (accountId == 0)
        {
            this.GridTransactions.DataSource = new FinancialAccountRows();
            return;
        }

        FinancialAccount account = FinancialAccount.FromIdentity(accountId);

        DateTime balanceStart = new DateTime(DateTime.Today.Year, 1, 1);

        if (account.AccountType == FinancialAccountType.Asset || account.AccountType == FinancialAccountType.Debt)
        {
            balanceStart = new DateTime(2006, 1, 1); // The dawn of mankind, for our purposes
        }

        currentAccountBalance = account.GetDelta(balanceStart, start.AddSeconds(-1));

        // We use "AddDays (1)" onto the end date, as the underlying select works like this:
        // "get rows where datetime >= start or datetime < end"
        // This assures us that the dates given in the interface make an inclusive range.

        this.GridTransactions.DataSource = FinancialAccount.FromIdentity(accountId).GetRows(start, end.AddDays(1));
    }