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("'");
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)

View File

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

View File

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

View File

@ -439,7 +439,7 @@ void PreferencesPanel::OnAccountModified(wxGridEvent& event)
{
_accountsGrid->DeleteRows(row, 1);
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)
@ -697,7 +697,7 @@ void PreferencesPanel::OnCategoryModified(wxGridEvent& event)
{
_categoriesGrid->DeleteRows(row, 1);
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();
_wxUI->NeedReload();
}