PreferencesPanel in work

This commit is contained in:
2010-06-21 10:53:43 +02:00
parent 36c01b0c56
commit 083054b376
15 changed files with 346 additions and 32 deletions

0
model/Account.cpp Normal file → Executable file
View File

0
model/Account.h Normal file → Executable file
View File

View File

@@ -274,7 +274,10 @@ double Database::GetAccountAmount(wxString id, int month, int year)
if (set.NextRow())
res = set.GetDouble(_("amount"));
else
res = 0.0;
{
SetAccountAmount(month, year, id, 0.0);
res = 0.0;
}
set.Finalize();
@@ -343,3 +346,50 @@ void Database::SetAccountAmount(int month, int year, wxString accountId, double
EXECUTE_SQL_UPDATE(req, );
}
void Database::InsertAccount(User* user, struct Account ac)
{
wxString req;
req = _("INSERT INTO account ('user', 'name', 'number', 'shared', 'default_account') VALUES ('") ;
req += user->_id + _("'");
req += _(", '") + ac.name + _("'");
req += _(", '") + ac.number + _("'");
if (ac.shared)
req += _(", '1'") ;
else
req += _(", '0'") ;
if (ac._default)
req += _(", '1'") ;
else
req += _(", '0'") ;
req += _(")");
EXECUTE_SQL_UPDATE(req, );
}
void Database::UpdateAccount(struct Account ac)
{
wxString req;
req = _("UPDATE account SET ") ;
req += _("name='") + ac.name + _("'");
req += _(", number='") + ac.number + _("'");
if (ac.shared)
req += _(", shared='1'");
else
req += _(", shared='0'");
if (ac._default)
req += _(", default_account='1'");
else
req += _(", default_account='0'");
req += _(" WHERE id='") + ac.id + _("'");
EXECUTE_SQL_UPDATE(req, );
}
void Database::DeleteAccount(struct Account ac)
{
wxString req;
req = _("DELETE FROM account WHERE id='") + ac.id + _("'");
EXECUTE_SQL_UPDATE(req, );
}

View File

@@ -23,13 +23,17 @@ class Database
User* LoadUser(wxString name);
void LoadYear(User* user, int year);
double GetAccountAmount(wxString id, int month, int year);
void UpdateOperation(struct operation op);
void AddOperation(User* user, struct operation op);
void DeleteOperation(struct operation op);
double GetAccountAmount(wxString id, int month, int year);
void SetAccountAmount(int month, int year, wxString accountId, double amount);
void InsertAccount(User* user, struct Account ac);
void UpdateAccount(struct Account ac);
void DeleteAccount(struct Account ac);
private:
wxSQLite3Database _db;

0
model/Preferences.cpp Executable file → Normal file
View File

View File

@@ -22,7 +22,6 @@ struct Account {
wxString id;
wxString name;
wxString number;
int amount;
bool shared;
bool _default;
};