From 4c3f2cc20935605a4d061e1fbaa348c27a9dd82e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Soutad=C3=A9?= Date: Sat, 3 Jul 2010 09:52:44 +0200 Subject: [PATCH] Avoid deleting last account --- model/Database.cpp | 2 ++ view/PreferencesPanel.cpp | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/model/Database.cpp b/model/Database.cpp index 019d0e0..1d8d48a 100644 --- a/model/Database.cpp +++ b/model/Database.cpp @@ -262,6 +262,8 @@ void Database::LoadYear(User* user, int year) if (user->_operations[year] == NULL) user->_operations[year] = new std::map >(); + if (!user->_accounts.size()) return; + it = user->_accounts.begin(); req = _("SELECT * FROM operation WHERE account IN('") + it->id; it++; diff --git a/view/PreferencesPanel.cpp b/view/PreferencesPanel.cpp index 33078bf..f149f93 100644 --- a/view/PreferencesPanel.cpp +++ b/view/PreferencesPanel.cpp @@ -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;