diff --git a/model/Database.cpp b/model/Database.cpp index 1d8d48a..8d77fbf 100644 --- a/model/Database.cpp +++ b/model/Database.cpp @@ -207,13 +207,15 @@ User* Database::LoadUser(wxString name) if (!user->_accounts.empty()) { 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++; for (;it != user->_accounts.end(); it++) { 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;}); @@ -265,13 +267,14 @@ void Database::LoadYear(User* user, int year) if (!user->_accounts.size()) return; it = user->_accounts.begin(); - req = _("SELECT * FROM operation WHERE account IN('") + it->id; + req = _("SELECT * FROM operation WHERE (account IN('") + it->id; it++; for (;it != user->_accounts.end(); it++) { req += _("', '") + it->id ; } - req += _("')"); + req += _("')"); + req += _(" OR user='") + user->_id + _("')"); req += _(" AND year='") + wxString::Format(_("%d"), year) + _("'"); 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, ); it = user->_accounts.begin(); - req = _("DELETE FROM operation WHERE account IN('") + it->id; + req = _("DELETE FROM operation WHERE (account IN('") + it->id; it++; for (;it != user->_accounts.end(); it++) { req += _("', '") + it->id ; } req += _("')"); + req += _(" OR user='") + user->_id + _("')"); req += _(" AND year='") + wxString::Format(_("%d"), year) + _("'"); if (month != -1) req += _(" AND month='") + wxString::Format(_("%d"), month) + _("'"); @@ -611,13 +615,15 @@ std::map > Database::GetAllOperations(User* user) if (!user->_accounts.empty()) { 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++; for (;it != user->_accounts.end(); it++) { 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); @@ -626,13 +632,14 @@ std::map > Database::GetAllOperations(User* user) year = set.GetInt(_("year")); 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++; for (;it != user->_accounts.end(); it++) { req += _("', '") + it->id ; } req += _("')"); + req += _(" OR user='") + user->_id + _("')"); req += _(" AND year='") + set.GetAsString(_("year")) + _("'"); req += _(" ORDER BY month ASC"); @@ -810,6 +817,9 @@ void Database::NewUser(wxString name) return ; } +/* + Shared accounts not currently supported + */ void Database::KillMe(User* user) { wxString req; @@ -839,6 +849,7 @@ void Database::KillMe(User* user) req += _("', '") + it->id ; } req += _("')"); + req += _(" OR user='") + user->_id + _("')"); EXECUTE_SQL_UPDATE(req, ); } diff --git a/view/AccountPanel.cpp b/view/AccountPanel.cpp index 0f34639..1d22dd5 100644 --- a/view/AccountPanel.cpp +++ b/view/AccountPanel.cpp @@ -952,7 +952,7 @@ void AccountPanel::OnMenuDelete(wxCommandEvent& event) 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; } diff --git a/view/PreferencesPanel.cpp b/view/PreferencesPanel.cpp index f149f93..141b1d4 100644 --- a/view/PreferencesPanel.cpp +++ b/view/PreferencesPanel.cpp @@ -248,7 +248,8 @@ void PreferencesPanel::OnAccountModified(wxGridEvent& event) { 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; } wxMessageDialog dialog(_wxUI, _("Are you sure want to delete ")+new_account.name, _("KissCount"), wxYES_NO);