Bugs on precedent commit

This commit is contained in:
Grégory Soutadé 2011-02-09 20:50:21 +01:00
parent 2b07cb0b30
commit aec66e7212
4 changed files with 20 additions and 12 deletions

View File

@ -998,6 +998,14 @@ void Database::DeleteCategory(User* user, Category& category, const wxString& re
req += wxT(" AND user='") + user->_id + wxT("'"); req += wxT(" AND user='") + user->_id + wxT("'");
EXECUTE_SQL_UPDATE(req, ); EXECUTE_SQL_UPDATE(req, );
if (replacement == user->_categories[0].id)
{
req = wxT("UPDATE operation SET fix_cost='1'");
req += wxT(" WHERE category='") + replacement + wxT("'");
EXECUTE_SQL_UPDATE(req, );
}
} }
bool Database::LoadCategory(const wxString& id, const wxString& name, Category& category) bool Database::LoadCategory(const wxString& id, const wxString& name, Category& category)

View File

@ -35,7 +35,7 @@ User::~User()
} }
} }
Category User::GetCategory(wxString& catId) Category User::GetCategory(const wxString& catId)
{ {
Category cat; Category cat;
std::vector<Category>::iterator it; std::vector<Category>::iterator it;
@ -57,7 +57,7 @@ Category User::GetCategory(wxString& catId)
return cat; return cat;
} }
wxString User::GetCategoryName(wxString& catId) wxString User::GetCategoryName(const wxString& catId)
{ {
Category cat; Category cat;
std::vector<Category>::iterator it; std::vector<Category>::iterator it;
@ -72,7 +72,7 @@ wxString User::GetCategoryName(wxString& catId)
return _("Unknown") ; return _("Unknown") ;
} }
wxString User::GetCategoryId(wxString& catName) wxString User::GetCategoryId(const wxString& catName)
{ {
std::vector<Category>::iterator it; std::vector<Category>::iterator it;
Category cat; Category cat;
@ -87,7 +87,7 @@ wxString User::GetCategoryId(wxString& catName)
return wxT("0") ; return wxT("0") ;
} }
const wxFont User::GetCategoryFont(wxString& catId) const wxFont User::GetCategoryFont(const wxString& catId)
{ {
wxFont f; wxFont f;
Category cat; Category cat;
@ -120,7 +120,7 @@ wxString User::GetAccountName(const wxString& accountId)
return _("Unknown") ; return _("Unknown") ;
} }
wxString User::GetAccountId(wxString& accountName) wxString User::GetAccountId(const wxString& accountName)
{ {
std::vector<Account>::iterator it; std::vector<Account>::iterator it;
for (it=_accounts.begin(); it !=_accounts.end(); it++) for (it=_accounts.begin(); it !=_accounts.end(); it++)

View File

@ -47,14 +47,14 @@ public:
std::vector<wxFont> _categoriesFonts; std::vector<wxFont> _categoriesFonts;
std::map<wxString, wxString> _preferences; std::map<wxString, wxString> _preferences;
Category GetCategory(wxString& catId); Category GetCategory(const wxString& catId);
wxString GetCategoryName(wxString& catId); wxString GetCategoryName(const wxString& catId);
wxString GetCategoryId(wxString& catName); wxString GetCategoryId(const wxString& catName);
const wxFont GetCategoryFont(wxString& catId); const wxFont GetCategoryFont(const wxString& catId);
Account GetAccount(const wxString& accountId); Account GetAccount(const wxString& accountId);
wxString GetAccountName(const wxString& accountId); wxString GetAccountName(const wxString& accountId);
wxString GetAccountId(wxString& accountName); wxString GetAccountId(const wxString& accountName);
int GetCategoriesNumber(); int GetCategoriesNumber();
int GetAccountsNumber(); int GetAccountsNumber();

View File

@ -439,7 +439,7 @@ void PreferencesPanel::OnAccountModified(wxGridEvent& event)
{ {
_accountsGrid->DeleteRows(row, 1); _accountsGrid->DeleteRows(row, 1);
i = dialog.GetSelection(); i = dialog.GetSelection();
_kiss->DeleteAccount(new_account, (!i) ? wxT("0") : user->_accounts[i].id); _kiss->DeleteAccount(new_account, (!i) ? wxT("0") : user->GetAccountId(accounts[i]));
} }
if (user->_accounts.size() == 1) if (user->_accounts.size() == 1)
@ -697,7 +697,7 @@ void PreferencesPanel::OnCategoryModified(wxGridEvent& event)
{ {
_categoriesGrid->DeleteRows(row, 1); _categoriesGrid->DeleteRows(row, 1);
i = dialog.GetSelection(); i = dialog.GetSelection();
_kiss->DeleteCategory(user->_categories[row], (!i) ? wxT("0") : user->_accounts[i].id); _kiss->DeleteCategory(user->_categories[row], (!i) ? wxT("0") : user->GetCategoryId(categories[i]));
Fit(); Fit();
_wxUI->NeedReload(); _wxUI->NeedReload();
} }