Month generation in progress

This commit is contained in:
2010-06-23 14:25:00 +02:00
parent 391aef379b
commit ac5c26bc4f
9 changed files with 122 additions and 4 deletions

View File

@@ -555,3 +555,53 @@ void Database::DeleteCategory(User* user, struct category category)
EXECUTE_SQL_UPDATE(req, );
}
std::map<int, std::vector<int> > Database::GetAllOperations(User* user)
{
wxString req;
wxSQLite3ResultSet set, set2;
std::vector<Account>::iterator it;
std::map<int, std::vector<int> > res;
int year;
if (!user->_accounts.empty())
{
it = user->_accounts.begin();
req = _("SELECT DISTINCT year FROM account_amount WHERE account IN('") + it->id;
it++;
for (;it != user->_accounts.end(); it++)
{
req += _("', '") + it->id ;
}
req += _("') ORDER BY year ASC");
EXECUTE_SQL_QUERY(req, set, res);
while (set.NextRow())
{
year = set.GetInt(_("year"));
it = user->_accounts.begin();
req = _("SELECT DISTINCT month FROM account_amount WHERE account IN('") + it->id;
it++;
for (;it != user->_accounts.end(); it++)
{
req += _("', '") + it->id ;
}
req += _("')");
req += _(" AND year='") + set.GetAsString(_("year")) + _("'");
req += _(" ORDER BY month ASC");
EXECUTE_SQL_QUERY(req, set2, res);
while (set2.NextRow())
{
res[year].push_back(set2.GetInt(_("month")));
}
set2.Finalize();
}
set.Finalize();
}
return res;
}

View File

@@ -38,6 +38,8 @@ class Database
void UpdateCategory(User* user, wxString oldName, wxString name, wxString color);
void DeleteCategory(User* user, struct category category);
std::map<int, std::vector<int> > GetAllOperations(User* user);
private:
wxSQLite3Database _db;