Avoid deleting last account

This commit is contained in:
Grégory Soutadé 2010-07-03 09:52:44 +02:00
parent e08865e01f
commit 4c3f2cc209
2 changed files with 8 additions and 1 deletions

View File

@ -262,6 +262,8 @@ void Database::LoadYear(User* user, int year)
if (user->_operations[year] == NULL)
user->_operations[year] = new std::map<unsigned int, std::vector<operation> >();
if (!user->_accounts.size()) return;
it = user->_accounts.begin();
req = _("SELECT * FROM operation WHERE account IN('") + it->id;
it++;

View File

@ -246,6 +246,11 @@ void PreferencesPanel::OnAccountModified(wxGridEvent& event)
if (col == ACCOUNT_DELETE)
{
if (user->_accounts.size() == 1)
{
wxMessageBox(_("It must be at least one account"), _("Error"), wxICON_ERROR | wxOK);
return;
}
wxMessageDialog dialog(_wxUI, _("Are you sure want to delete ")+new_account.name, _("KissCount"), wxYES_NO);
if (dialog.ShowModal() == wxID_NO)
{
@ -447,7 +452,7 @@ void PreferencesPanel::OnKillMe(wxCommandEvent& event)
{
User* user = _kiss->GetUser();
wxMessageDialog dialog(_wxUI, _("Are you sure want to delete ")+user->_name+_(" account ?"), _("KissCount"), wxYES_NO);
wxMessageDialog dialog(_wxUI, _("Are you sure want to delete ")+user->_name+_(" profil ?"), _("KissCount"), wxYES_NO);
if (dialog.ShowModal() == wxID_NO)
{
return;