Fix Account loading bug
This commit is contained in:
parent
4c3f2cc209
commit
c237b9f057
|
@ -207,13 +207,15 @@ User* Database::LoadUser(wxString name)
|
||||||
if (!user->_accounts.empty())
|
if (!user->_accounts.empty())
|
||||||
{
|
{
|
||||||
it = user->_accounts.begin();
|
it = user->_accounts.begin();
|
||||||
req = _("SELECT DISTINCT year FROM account_amount WHERE account IN('") + it->id;
|
req = _("SELECT DISTINCT year FROM operation WHERE account IN('") + it->id;
|
||||||
it++;
|
it++;
|
||||||
for (;it != user->_accounts.end(); it++)
|
for (;it != user->_accounts.end(); it++)
|
||||||
{
|
{
|
||||||
req += _("', '") + it->id ;
|
req += _("', '") + it->id ;
|
||||||
}
|
}
|
||||||
req += _("') ORDER BY year ASC");
|
req += _("')");
|
||||||
|
req += _(" OR user='") + user->_id + _("'");
|
||||||
|
req += _(" ORDER BY year ASC");
|
||||||
|
|
||||||
EXECUTE_SQL_QUERY_WITH_CODE(req, set, NULL, {delete user;}, {delete user;});
|
EXECUTE_SQL_QUERY_WITH_CODE(req, set, NULL, {delete user;}, {delete user;});
|
||||||
|
|
||||||
|
@ -265,13 +267,14 @@ void Database::LoadYear(User* user, int year)
|
||||||
if (!user->_accounts.size()) return;
|
if (!user->_accounts.size()) return;
|
||||||
|
|
||||||
it = user->_accounts.begin();
|
it = user->_accounts.begin();
|
||||||
req = _("SELECT * FROM operation WHERE account IN('") + it->id;
|
req = _("SELECT * FROM operation WHERE (account IN('") + it->id;
|
||||||
it++;
|
it++;
|
||||||
for (;it != user->_accounts.end(); it++)
|
for (;it != user->_accounts.end(); it++)
|
||||||
{
|
{
|
||||||
req += _("', '") + it->id ;
|
req += _("', '") + it->id ;
|
||||||
}
|
}
|
||||||
req += _("')");
|
req += _("')");
|
||||||
|
req += _(" OR user='") + user->_id + _("')");
|
||||||
req += _(" AND year='") + wxString::Format(_("%d"), year) + _("'");
|
req += _(" AND year='") + wxString::Format(_("%d"), year) + _("'");
|
||||||
req += _(" ORDER BY fix_cost DESC, year,month,day ASC");
|
req += _(" ORDER BY fix_cost DESC, year,month,day ASC");
|
||||||
|
|
||||||
|
@ -421,13 +424,14 @@ void Database::DeleteOperations(User* user, int month, int year)
|
||||||
EXECUTE_SQL_UPDATE(req, );
|
EXECUTE_SQL_UPDATE(req, );
|
||||||
|
|
||||||
it = user->_accounts.begin();
|
it = user->_accounts.begin();
|
||||||
req = _("DELETE FROM operation WHERE account IN('") + it->id;
|
req = _("DELETE FROM operation WHERE (account IN('") + it->id;
|
||||||
it++;
|
it++;
|
||||||
for (;it != user->_accounts.end(); it++)
|
for (;it != user->_accounts.end(); it++)
|
||||||
{
|
{
|
||||||
req += _("', '") + it->id ;
|
req += _("', '") + it->id ;
|
||||||
}
|
}
|
||||||
req += _("')");
|
req += _("')");
|
||||||
|
req += _(" OR user='") + user->_id + _("')");
|
||||||
req += _(" AND year='") + wxString::Format(_("%d"), year) + _("'");
|
req += _(" AND year='") + wxString::Format(_("%d"), year) + _("'");
|
||||||
if (month != -1)
|
if (month != -1)
|
||||||
req += _(" AND month='") + wxString::Format(_("%d"), month) + _("'");
|
req += _(" AND month='") + wxString::Format(_("%d"), month) + _("'");
|
||||||
|
@ -611,13 +615,15 @@ std::map<int, std::vector<int> > Database::GetAllOperations(User* user)
|
||||||
if (!user->_accounts.empty())
|
if (!user->_accounts.empty())
|
||||||
{
|
{
|
||||||
it = user->_accounts.begin();
|
it = user->_accounts.begin();
|
||||||
req = _("SELECT DISTINCT year FROM account_amount WHERE account IN('") + it->id;
|
req = _("SELECT DISTINCT year FROM operation WHERE account IN('") + it->id;
|
||||||
it++;
|
it++;
|
||||||
for (;it != user->_accounts.end(); it++)
|
for (;it != user->_accounts.end(); it++)
|
||||||
{
|
{
|
||||||
req += _("', '") + it->id ;
|
req += _("', '") + it->id ;
|
||||||
}
|
}
|
||||||
req += _("') ORDER BY year ASC");
|
req += _("')");
|
||||||
|
req += _(" OR user='") + user->_id + _("'");
|
||||||
|
req += _(" ORDER BY year ASC");
|
||||||
|
|
||||||
EXECUTE_SQL_QUERY(req, set, res);
|
EXECUTE_SQL_QUERY(req, set, res);
|
||||||
|
|
||||||
|
@ -626,13 +632,14 @@ std::map<int, std::vector<int> > Database::GetAllOperations(User* user)
|
||||||
year = set.GetInt(_("year"));
|
year = set.GetInt(_("year"));
|
||||||
|
|
||||||
it = user->_accounts.begin();
|
it = user->_accounts.begin();
|
||||||
req = _("SELECT DISTINCT month FROM account_amount WHERE account IN('") + it->id;
|
req = _("SELECT DISTINCT month FROM operation WHERE (account IN('") + it->id;
|
||||||
it++;
|
it++;
|
||||||
for (;it != user->_accounts.end(); it++)
|
for (;it != user->_accounts.end(); it++)
|
||||||
{
|
{
|
||||||
req += _("', '") + it->id ;
|
req += _("', '") + it->id ;
|
||||||
}
|
}
|
||||||
req += _("')");
|
req += _("')");
|
||||||
|
req += _(" OR user='") + user->_id + _("')");
|
||||||
req += _(" AND year='") + set.GetAsString(_("year")) + _("'");
|
req += _(" AND year='") + set.GetAsString(_("year")) + _("'");
|
||||||
req += _(" ORDER BY month ASC");
|
req += _(" ORDER BY month ASC");
|
||||||
|
|
||||||
|
@ -810,6 +817,9 @@ void Database::NewUser(wxString name)
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Shared accounts not currently supported
|
||||||
|
*/
|
||||||
void Database::KillMe(User* user)
|
void Database::KillMe(User* user)
|
||||||
{
|
{
|
||||||
wxString req;
|
wxString req;
|
||||||
|
@ -839,6 +849,7 @@ void Database::KillMe(User* user)
|
||||||
req += _("', '") + it->id ;
|
req += _("', '") + it->id ;
|
||||||
}
|
}
|
||||||
req += _("')");
|
req += _("')");
|
||||||
|
req += _(" OR user='") + user->_id + _("')");
|
||||||
|
|
||||||
EXECUTE_SQL_UPDATE(req, );
|
EXECUTE_SQL_UPDATE(req, );
|
||||||
}
|
}
|
||||||
|
|
|
@ -952,7 +952,7 @@ void AccountPanel::OnMenuDelete(wxCommandEvent& event)
|
||||||
|
|
||||||
if (ops.size() == 1 && ops[year].size() == 1)
|
if (ops.size() == 1 && ops[year].size() == 1)
|
||||||
{
|
{
|
||||||
wxMessageBox(_("It must be at least one month"), _("Error"), wxICON_ERROR | wxOK);
|
wxMessageBox(_("It must be at least one month !"), _("Error"), wxICON_ERROR | wxOK);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -248,7 +248,8 @@ void PreferencesPanel::OnAccountModified(wxGridEvent& event)
|
||||||
{
|
{
|
||||||
if (user->_accounts.size() == 1)
|
if (user->_accounts.size() == 1)
|
||||||
{
|
{
|
||||||
wxMessageBox(_("It must be at least one account"), _("Error"), wxICON_ERROR | wxOK);
|
wxMessageBox(_("It must be at least one account !"), _("Error"), wxICON_ERROR | wxOK);
|
||||||
|
_accountsGrid->SetCellValue(row, col, _("0"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
wxMessageDialog dialog(_wxUI, _("Are you sure want to delete ")+new_account.name, _("KissCount"), wxYES_NO);
|
wxMessageDialog dialog(_wxUI, _("Are you sure want to delete ")+new_account.name, _("KissCount"), wxYES_NO);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user