String modification using wxT macro

This commit is contained in:
2010-07-03 11:19:02 +02:00
parent c237b9f057
commit 77de073d2e
16 changed files with 316 additions and 345 deletions

View File

@@ -1,7 +0,0 @@
#include "Account.h"
Account::~Account()
{
}

View File

@@ -1,21 +0,0 @@
#ifndef ACCOUNT_H
#define ACCOUNT_H
#include <list>
#include <map>
#include <wx/wx.h>
class Account
{
public:
~Account();
wxString _id;
wxString _name;
wxString _number;
int _amount;
bool _shared;
bool _default;
};
#endif

View File

@@ -46,8 +46,8 @@ static inline wxString DoubleToString(double d)
{
wxString res;
res = wxString::Format(_("%.2lf"), d);
res.Replace(_(","), _("."));
res = wxString::Format(wxT("%.2lf"), d);
res.Replace(wxT(","), wxT("."));
return res;
}
@@ -63,7 +63,7 @@ Database::Database()
CreateDatabase();
}
else
_db.Open(_(BDD_FILE));
_db.Open(wxT(BDD_FILE));
bdd_file.close();
}
@@ -74,7 +74,7 @@ void Database::CreateDatabase()
std::string line;
wxString wxline;
wxMessageBox(_("No database found, creating a new one"), _("KissCount"), wxICON_EXCLAMATION | wxOK );
wxMessageBox(_("No database found, creating a new one"), wxT("KissCount"), wxICON_EXCLAMATION | wxOK );
init_script.open(INIT_SCRIPT);
@@ -84,14 +84,14 @@ void Database::CreateDatabase()
throw "init.sql not found, aborting";
}
_db.Open(_(BDD_FILE));
_db.Open(wxT(BDD_FILE));
do
{
getline(init_script, line);
wxline = wxString(line.c_str(), wxConvUTF8);
wxline.Trim(false);
if (!wxline.Length() || wxline.StartsWith(_("--"))) continue;
if (!wxline.Length() || wxline.StartsWith(wxT("--"))) continue;
if (!_db.CheckSyntax(wxline))
{
std::cout << line << " is invalid !\n" ;
@@ -136,7 +136,7 @@ std::list<wxString> Database::GetUsers()
// Check whether value exists in table
wxSQLite3ResultSet set ;
req = _("SELECT name FROM user ORDER BY name");
req = wxT("SELECT name FROM user ORDER BY name");
EXECUTE_SQL_QUERY(req, set, res);
while (set.NextRow())
@@ -154,7 +154,7 @@ bool Database::IsValidUser(wxString user, wxString password)
wxString req;
wxSQLite3ResultSet set;
req = _("SELECT name FROM user WHERE name='") + user + _("' AND password='") + HashPassword(password) + _("'");
req = wxT("SELECT name FROM user WHERE name='") + user + wxT("' AND password='") + HashPassword(password) + wxT("'");
EXECUTE_SQL_QUERY(req, set, false);
@@ -174,7 +174,7 @@ User* Database::LoadUser(wxString name)
std::vector<Account>::iterator it;
req = _("SELECT * FROM user WHERE name='") + name + _("'");
req = wxT("SELECT * FROM user WHERE name='") + name + wxT("'");
EXECUTE_SQL_QUERY(req, set, NULL);
@@ -183,23 +183,23 @@ User* Database::LoadUser(wxString name)
user = new User();
user->_id = set.GetAsString(_("id"));
user->_name = set.GetAsString(_("name"));
user->_password = _("") ; // Security reasons set.GetAsString("password");
user->_id = set.GetAsString(wxT("id"));
user->_name = set.GetAsString(wxT("name"));
user->_password = wxT("") ; // Security reasons set.GetAsString("password");
set.Finalize();
req = _("SELECT * FROM account WHERE user='") + user->_id + _("' ORDER BY default_account DESC, name ASC");
req = wxT("SELECT * FROM account WHERE user='") + user->_id + wxT("' ORDER BY default_account DESC, name ASC");
EXECUTE_SQL_QUERY_WITH_CODE(req, set, NULL, {delete user;}, {delete user;});
while (set.NextRow())
{
account.id = set.GetAsString(_("id"));
account.name = set.GetAsString(_("name"));
account.number = set.GetAsString(_("number"));
account.shared = set.GetBool(_("shared"));
account._default = set.GetBool(_("default_account"));
account.id = set.GetAsString(wxT("id"));
account.name = set.GetAsString(wxT("name"));
account.number = set.GetAsString(wxT("number"));
account.shared = set.GetBool(wxT("shared"));
account._default = set.GetBool(wxT("default_account"));
user->_accounts.push_back(account);
}
set.Finalize();
@@ -207,36 +207,36 @@ User* Database::LoadUser(wxString name)
if (!user->_accounts.empty())
{
it = user->_accounts.begin();
req = _("SELECT DISTINCT year FROM operation WHERE account IN('") + it->id;
req = wxT("SELECT DISTINCT year FROM operation WHERE account IN('") + it->id;
it++;
for (;it != user->_accounts.end(); it++)
{
req += _("', '") + it->id ;
req += wxT("', '") + it->id ;
}
req += _("')");
req += _(" OR user='") + user->_id + _("'");
req += _(" ORDER BY year ASC");
req += wxT("')");
req += wxT(" OR user='") + user->_id + wxT("'");
req += wxT(" ORDER BY year ASC");
EXECUTE_SQL_QUERY_WITH_CODE(req, set, NULL, {delete user;}, {delete user;});
while (set.NextRow())
{
user->_operations[set.GetInt(_("year"))] = NULL;
user->_operations[set.GetInt(wxT("year"))] = NULL;
}
set.Finalize();
}
req = _("SELECT * FROM category WHERE user='") + user->_id + _("' ORDER BY name ASC");
req = wxT("SELECT * FROM category WHERE user='") + user->_id + wxT("' ORDER BY name ASC");
EXECUTE_SQL_QUERY_WITH_CODE(req, set, NULL, {delete user;}, {delete user;});
while (set.NextRow())
{
category.id = set.GetAsString(_("id"));
category.parent = set.GetAsString(_("parent"));
category.name = set.GetAsString(_("name"));
category.color = wxColour(set.GetAsString(_("color")));
category.font = set.GetAsString(_("font"));
if (category.name != _("Fixe"))
category.id = set.GetAsString(wxT("id"));
category.parent = set.GetAsString(wxT("parent"));
category.name = set.GetAsString(wxT("name"));
category.color = wxColour(set.GetAsString(wxT("color")));
category.font = set.GetAsString(wxT("font"));
if (category.name != wxT("Fixe"))
user->_categories.push_back(category);
else
user->_categories.insert(user->_categories.begin(), category);
@@ -244,11 +244,11 @@ User* Database::LoadUser(wxString name)
set.Finalize();
req = _("SELECT name, value FROM preference WHERE user='") + user->_id + _("' ORDER BY value ASC");
req = wxT("SELECT name, value FROM preference WHERE user='") + user->_id + wxT("' ORDER BY value ASC");
EXECUTE_SQL_QUERY_WITH_CODE(req, set, NULL, {delete user;}, {delete user;});
while (set.NextRow())
user->_preferences[set.GetAsString(_("name"))] = set.GetAsString(_("value"));
user->_preferences[set.GetAsString(wxT("name"))] = set.GetAsString(wxT("value"));
set.Finalize();
@@ -267,32 +267,32 @@ void Database::LoadYear(User* user, int year)
if (!user->_accounts.size()) return;
it = user->_accounts.begin();
req = _("SELECT * FROM operation WHERE (account IN('") + it->id;
req = wxT("SELECT * FROM operation WHERE (account IN('") + it->id;
it++;
for (;it != user->_accounts.end(); it++)
{
req += _("', '") + it->id ;
req += wxT("', '") + it->id ;
}
req += _("')");
req += _(" OR user='") + user->_id + _("')");
req += _(" AND year='") + wxString::Format(_("%d"), year) + _("'");
req += _(" ORDER BY fix_cost DESC, year,month,day ASC");
req += wxT("')");
req += wxT(" OR user='") + user->_id + wxT("')");
req += wxT(" AND year='") + wxString::Format(wxT("%d"), year) + wxT("'");
req += wxT(" ORDER BY fix_cost DESC, year,month,day ASC");
EXECUTE_SQL_QUERY(req, set, );
while (set.NextRow())
{
operation op;
op.id = set.GetAsString(_("id"));
op.account = set.GetAsString(_("account"));
op.day = set.GetInt(_("day"));
op.month = set.GetInt(_("month"));
op.year = set.GetInt(_("year"));
op.amount = set.GetDouble(_("amount"));
op.description = set.GetAsString(_("description"));
op.category = set.GetAsString(_("category"));
op.fix_cost = set.GetBool(_("fix_cost"));
op.checked = set.GetBool(_("checked"));
op.id = set.GetAsString(wxT("id"));
op.account = set.GetAsString(wxT("account"));
op.day = set.GetInt(wxT("day"));
op.month = set.GetInt(wxT("month"));
op.year = set.GetInt(wxT("year"));
op.amount = set.GetDouble(wxT("amount"));
op.description = set.GetAsString(wxT("description"));
op.category = set.GetAsString(wxT("category"));
op.fix_cost = set.GetBool(wxT("fix_cost"));
op.checked = set.GetBool(wxT("checked"));
(*user->_operations[op.year])[op.month].push_back(op);
}
@@ -305,15 +305,15 @@ double Database::GetAccountAmount(wxString id, int month, int year)
wxString req;
double res;
req = _("SELECT amount FROM account_amount WHERE account='") + id ;
req += _("' AND month='") + wxString::Format(_("%d"), month);
req += _("' AND year='") + wxString::Format(_("%d"), year);
req += _("'");
req = wxT("SELECT amount FROM account_amount WHERE account='") + id ;
req += wxT("' AND month='") + wxString::Format(wxT("%d"), month);
req += wxT("' AND year='") + wxString::Format(wxT("%d"), year);
req += wxT("'");
EXECUTE_SQL_QUERY(req , set, 0.0);
if (set.NextRow())
res = set.GetDouble(_("amount"));
res = set.GetDouble(wxT("amount"));
else
{
SetAccountAmount(month, year, id, 0.0);
@@ -328,19 +328,19 @@ double Database::GetAccountAmount(wxString id, int month, int year)
void Database::UpdateOperation(struct operation op)
{
wxString req;
req = _("UPDATE operation SET ") ;
req += _("account='") + op.account + _("'");
req += _(", year='") + wxString::Format(_("%d"), op.year) + _("'");
req += _(", month='") + wxString::Format(_("%d"), op.month) + _("'");
req += _(", day='") + wxString::Format(_("%d"), op.day) + _("'");
req += _(", amount='") + DoubleToString(op.amount) + _("'");
req += _(", description=\"") + op.description + _("\"");
req += _(", category='") + op.category + _("'");
req = wxT("UPDATE operation SET ") ;
req += wxT("account='") + op.account + wxT("'");
req += wxT(", year='") + wxString::Format(wxT("%d"), op.year) + wxT("'");
req += wxT(", month='") + wxString::Format(wxT("%d"), op.month) + wxT("'");
req += wxT(", day='") + wxString::Format(wxT("%d"), op.day) + wxT("'");
req += wxT(", amount='") + DoubleToString(op.amount) + wxT("'");
req += wxT(", description=\"") + op.description + wxT("\"");
req += wxT(", category='") + op.category + wxT("'");
if (op.checked)
req += _(", checked='1'");
req += wxT(", checked='1'");
else
req += _(", checked='0'");
req += _(" WHERE id='") + op.id + _("'");
req += wxT(", checked='0'");
req += wxT(" WHERE id='") + op.id + wxT("'");
//std::cout << req.mb_str() << "\n";
EXECUTE_SQL_UPDATE(req, );
@@ -352,44 +352,44 @@ wxString Database::AddOperation(User* user, struct operation op)
wxString req, res;
wxSQLite3ResultSet set;
req = _("INSERT INTO operation ('user', 'account', 'year', 'month', 'day', 'amount', 'description', 'category', 'fix_cost') VALUES ('") ;
req += user->_id + _("'");
req += _(", '") + op.account + _("'");
req += _(", '") + wxString::Format(_("%d"), op.year) + _("'");
req += _(", '") + wxString::Format(_("%d"), op.month) + _("'");
req += _(", '") + wxString::Format(_("%d"), op.day) + _("'");
req += _(", '") + DoubleToString(op.amount) + _("'");
req += _(", \"") + op.description + _("\"");
req += _(", '") + op.category + _("'");
req = wxT("INSERT INTO operation ('user', 'account', 'year', 'month', 'day', 'amount', 'description', 'category', 'fix_cost') VALUES ('") ;
req += user->_id + wxT("'");
req += wxT(", '") + op.account + wxT("'");
req += wxT(", '") + wxString::Format(wxT("%d"), op.year) + wxT("'");
req += wxT(", '") + wxString::Format(wxT("%d"), op.month) + wxT("'");
req += wxT(", '") + wxString::Format(wxT("%d"), op.day) + wxT("'");
req += wxT(", '") + DoubleToString(op.amount) + wxT("'");
req += wxT(", \"") + op.description + wxT("\"");
req += wxT(", '") + op.category + wxT("'");
if (op.fix_cost)
req += _(", '1'") ;
req += wxT(", '1'") ;
else
req += _(", '0'") ;
req += _(")");
req += wxT(", '0'") ;
req += wxT(")");
EXECUTE_SQL_UPDATE(req, _("0"));
EXECUTE_SQL_UPDATE(req, wxT("0"));
req = _("SELECT id FROM operation WHERE ");
req += _("user='") + user->_id + _("'");
req += _(" AND account='") + op.account + _("'");
req += _(" AND year='") + wxString::Format(_("%d"), op.year) + _("'");
req += _(" AND month='") + wxString::Format(_("%d"), op.month) + _("'");
req += _(" AND day='") + wxString::Format(_("%d"), op.day) + _("'");
req += _(" AND amount='") + DoubleToString(op.amount) + _("'");
req += _(" AND description=\"") + op.description + _("\"");
req += _(" AND category='") + op.category + _("'");
req = wxT("SELECT id FROM operation WHERE ");
req += wxT("user='") + user->_id + wxT("'");
req += wxT(" AND account='") + op.account + wxT("'");
req += wxT(" AND year='") + wxString::Format(wxT("%d"), op.year) + wxT("'");
req += wxT(" AND month='") + wxString::Format(wxT("%d"), op.month) + wxT("'");
req += wxT(" AND day='") + wxString::Format(wxT("%d"), op.day) + wxT("'");
req += wxT(" AND amount='") + DoubleToString(op.amount) + wxT("'");
req += wxT(" AND description=\"") + op.description + wxT("\"");
req += wxT(" AND category='") + op.category + wxT("'");
if (op.fix_cost)
req += _(" AND fix_cost='1'") ;
req += wxT(" AND fix_cost='1'") ;
else
req += _(" AND fix_cost='0'") ;
req += _("ORDER BY ID DESC") ;
req += wxT(" AND fix_cost='0'") ;
req += wxT("ORDER BY ID DESC") ;
EXECUTE_SQL_QUERY(req , set, _("0"));
EXECUTE_SQL_QUERY(req , set, wxT("0"));
if (set.NextRow())
res = set.GetAsString(_("id"));
res = set.GetAsString(wxT("id"));
else
res = _("0");
res = wxT("0");
set.Finalize();
@@ -399,7 +399,7 @@ wxString Database::AddOperation(User* user, struct operation op)
void Database::DeleteOperation(struct operation op)
{
wxString req;
req = _("DELETE FROM operation WHERE id='") + op.id + _("'");
req = wxT("DELETE FROM operation WHERE id='") + op.id + wxT("'");
EXECUTE_SQL_UPDATE(req, );
}
@@ -410,31 +410,31 @@ void Database::DeleteOperations(User* user, int month, int year)
std::vector<Account>::iterator it;
it = user->_accounts.begin();
req = _("DELETE FROM account_amount WHERE account IN('") + it->id;
req = wxT("DELETE FROM account_amount WHERE account IN('") + it->id;
it++;
for (;it != user->_accounts.end(); it++)
{
req += _("', '") + it->id ;
req += wxT("', '") + it->id ;
}
req += _("')");
req += _(" AND year='") + wxString::Format(_("%d"), year) + _("'");
req += wxT("')");
req += wxT(" AND year='") + wxString::Format(wxT("%d"), year) + wxT("'");
if (month != -1)
req += _(" AND month='") + wxString::Format(_("%d"), month) + _("'");
req += wxT(" AND month='") + wxString::Format(wxT("%d"), month) + wxT("'");
EXECUTE_SQL_UPDATE(req, );
it = user->_accounts.begin();
req = _("DELETE FROM operation WHERE (account IN('") + it->id;
req = wxT("DELETE FROM operation WHERE (account IN('") + it->id;
it++;
for (;it != user->_accounts.end(); it++)
{
req += _("', '") + it->id ;
req += wxT("', '") + it->id ;
}
req += _("')");
req += _(" OR user='") + user->_id + _("')");
req += _(" AND year='") + wxString::Format(_("%d"), year) + _("'");
req += wxT("')");
req += wxT(" OR user='") + user->_id + wxT("')");
req += wxT(" AND year='") + wxString::Format(wxT("%d"), year) + wxT("'");
if (month != -1)
req += _(" AND month='") + wxString::Format(_("%d"), month) + _("'");
req += wxT(" AND month='") + wxString::Format(wxT("%d"), month) + wxT("'");
EXECUTE_SQL_UPDATE(req, );
@@ -443,22 +443,22 @@ void Database::DeleteOperations(User* user, int month, int year)
void Database::SetAccountAmount(int month, int year, wxString accountId, double amount)
{
wxString req;
req = _("UPDATE account_amount SET ") ;
req += _("amount='") + DoubleToString(amount) + _("'");
req += _(" WHERE account='") + accountId + _("'");
req += _(" AND year='") + wxString::Format(_("%d"), year) + _("'");
req += _(" AND month='") + wxString::Format(_("%d"), month) + _("'");
req = wxT("UPDATE account_amount SET ") ;
req += wxT("amount='") + DoubleToString(amount) + wxT("'");
req += wxT(" WHERE account='") + accountId + wxT("'");
req += wxT(" AND year='") + wxString::Format(wxT("%d"), year) + wxT("'");
req += wxT(" AND month='") + wxString::Format(wxT("%d"), month) + wxT("'");
try
{
if (!_db.ExecuteUpdate(req))
{
req = _("INSERT INTO account_amount ('account', 'year', 'month', 'amount') VALUES ('") ;
req += accountId + _("'");
req += _(" ,'") + wxString::Format(_("%d"), year) + _("'");
req += _(" ,'") + wxString::Format(_("%d"), month) + _("'");
req += _(" ,'") + DoubleToString(amount) + _("'");
req += _(")");
req = wxT("INSERT INTO account_amount ('account', 'year', 'month', 'amount') VALUES ('") ;
req += accountId + wxT("'");
req += wxT(" ,'") + wxString::Format(wxT("%d"), year) + wxT("'");
req += wxT(" ,'") + wxString::Format(wxT("%d"), month) + wxT("'");
req += wxT(" ,'") + DoubleToString(amount) + wxT("'");
req += wxT(")");
EXECUTE_SQL_UPDATE(req, );
}
}
@@ -475,31 +475,31 @@ wxString Database::AddAccount(User* user, struct Account ac)
wxString req, res;
wxSQLite3ResultSet set;
req = _("INSERT INTO account ('user', 'name', 'number', 'shared', 'default_account') VALUES ('") ;
req += user->_id + _("'");
req += _(", '") + ac.name + _("'");
req += _(", '") + ac.number + _("'");
req = wxT("INSERT INTO account ('user', 'name', 'number', 'shared', 'default_account') VALUES ('") ;
req += user->_id + wxT("'");
req += wxT(", '") + ac.name + wxT("'");
req += wxT(", '") + ac.number + wxT("'");
if (ac.shared)
req += _(", '1'") ;
req += wxT(", '1'") ;
else
req += _(", '0'") ;
req += wxT(", '0'") ;
if (ac._default)
req += _(", '1'") ;
req += wxT(", '1'") ;
else
req += _(", '0'") ;
req += _(")");
req += wxT(", '0'") ;
req += wxT(")");
EXECUTE_SQL_UPDATE(req, _("0"));
EXECUTE_SQL_UPDATE(req, wxT("0"));
req = _("SELECT id FROM account WHERE name='") + ac.name + _("'") ;
req += _("AND user='") + user->_id + _("'");
req = wxT("SELECT id FROM account WHERE name='") + ac.name + wxT("'") ;
req += wxT("AND user='") + user->_id + wxT("'");
EXECUTE_SQL_QUERY(req , set, _("0"));
EXECUTE_SQL_QUERY(req , set, wxT("0"));
if (set.NextRow())
res = set.GetAsString(_("id"));
res = set.GetAsString(wxT("id"));
else
res = _("0");
res = wxT("0");
set.Finalize();
@@ -509,18 +509,18 @@ wxString Database::AddAccount(User* user, struct Account ac)
void Database::UpdateAccount(struct Account ac)
{
wxString req;
req = _("UPDATE account SET ") ;
req += _("name='") + ac.name + _("'");
req += _(", number='") + ac.number + _("'");
req = wxT("UPDATE account SET ") ;
req += wxT("name='") + ac.name + wxT("'");
req += wxT(", number='") + ac.number + wxT("'");
if (ac.shared)
req += _(", shared='1'");
req += wxT(", shared='1'");
else
req += _(", shared='0'");
req += wxT(", shared='0'");
if (ac._default)
req += _(", default_account='1'");
req += wxT(", default_account='1'");
else
req += _(", default_account='0'");
req += _(" WHERE id='") + ac.id + _("'");
req += wxT(", default_account='0'");
req += wxT(" WHERE id='") + ac.id + wxT("'");
EXECUTE_SQL_UPDATE(req, );
}
@@ -528,7 +528,7 @@ void Database::UpdateAccount(struct Account ac)
void Database::DeleteAccount(struct Account ac)
{
wxString req;
req = _("DELETE FROM account WHERE id='") + ac.id + _("'");
req = wxT("DELETE FROM account WHERE id='") + ac.id + wxT("'");
EXECUTE_SQL_UPDATE(req, );
}
@@ -539,30 +539,30 @@ wxString Database::AddCategory(User* user, struct category category)
wxSQLite3ResultSet set;
wxString color;
color = _("#") ;
color += wxString::Format(_("%02X"), category.color.Red());
color += wxString::Format(_("%02X"), category.color.Green());
color += wxString::Format(_("%02X"), category.color.Blue());
color = wxT("#") ;
color += wxString::Format(wxT("%02X"), category.color.Red());
color += wxString::Format(wxT("%02X"), category.color.Green());
color += wxString::Format(wxT("%02X"), category.color.Blue());
req = _("INSERT INTO category ('user', 'parent', 'name', 'color', font) VALUES ('") ;
req += user->_id + _("'");
req += _(", '") + category.parent + _("'");
req += _(", '") + category.name + _("'");
req += _(", '") + color + _("'");
req += _(", '") + category.font + _("'");
req += _(")");
req = wxT("INSERT INTO category ('user', 'parent', 'name', 'color', font) VALUES ('") ;
req += user->_id + wxT("'");
req += wxT(", '") + category.parent + wxT("'");
req += wxT(", '") + category.name + wxT("'");
req += wxT(", '") + color + wxT("'");
req += wxT(", '") + category.font + wxT("'");
req += wxT(")");
EXECUTE_SQL_UPDATE(req, _("0"));
EXECUTE_SQL_UPDATE(req, wxT("0"));
req = _("SELECT id FROM preference WHERE user='") + user->_id + _("'") ;
req += _(" AND name='") + category.name + _("'");
req = wxT("SELECT id FROM preference WHERE user='") + user->_id + wxT("'") ;
req += wxT(" AND name='") + category.name + wxT("'");
EXECUTE_SQL_QUERY(req , set, _("0"));
EXECUTE_SQL_QUERY(req , set, wxT("0"));
if (set.NextRow())
res = set.GetAsString(_("id"));
res = set.GetAsString(wxT("id"));
else
res = _("0");
res = wxT("0");
set.Finalize();
@@ -574,17 +574,17 @@ void Database::UpdateCategory(struct category category)
wxString req;
wxString color;
color = _("#") ;
color += wxString::Format(_("%02X"), category.color.Red());
color += wxString::Format(_("%02X"), category.color.Green());
color += wxString::Format(_("%02X"), category.color.Blue());
color = wxT("#") ;
color += wxString::Format(wxT("%02X"), category.color.Red());
color += wxString::Format(wxT("%02X"), category.color.Green());
color += wxString::Format(wxT("%02X"), category.color.Blue());
req = _("UPDATE category SET") ;
req += _(" parent='") + category.parent + _("'");
req += _(", name='") + category.name + _("'");
req += _(", color='") + color + _("'");
req += _(", font='") + category.font + _("'");
req += _(" WHERE id='") + category.id + _("'");
req = wxT("UPDATE category SET") ;
req += wxT(" parent='") + category.parent + wxT("'");
req += wxT(", name='") + category.name + wxT("'");
req += wxT(", color='") + color + wxT("'");
req += wxT(", font='") + category.font + wxT("'");
req += wxT(" WHERE id='") + category.id + wxT("'");
EXECUTE_SQL_UPDATE(req, );
}
@@ -593,13 +593,13 @@ void Database::DeleteCategory(User* user, struct category category)
{
wxString req;
req = _("DELETE FROM category WHERE id='") + category.id + _("'");
req = wxT("DELETE FROM category WHERE id='") + category.id + wxT("'");
EXECUTE_SQL_UPDATE(req, );
req = _("UPDATE category SET") ;
req += _(" parent='0'");
req += _(" WHERE parent='") + category.id + _("'");
req = wxT("UPDATE category SET") ;
req += wxT(" parent='0'");
req += wxT(" WHERE parent='") + category.id + wxT("'");
EXECUTE_SQL_UPDATE(req, );
}
@@ -615,39 +615,39 @@ std::map<int, std::vector<int> > Database::GetAllOperations(User* user)
if (!user->_accounts.empty())
{
it = user->_accounts.begin();
req = _("SELECT DISTINCT year FROM operation WHERE account IN('") + it->id;
req = wxT("SELECT DISTINCT year FROM operation WHERE account IN('") + it->id;
it++;
for (;it != user->_accounts.end(); it++)
{
req += _("', '") + it->id ;
req += wxT("', '") + it->id ;
}
req += _("')");
req += _(" OR user='") + user->_id + _("'");
req += _(" ORDER BY year ASC");
req += wxT("')");
req += wxT(" OR user='") + user->_id + wxT("'");
req += wxT(" ORDER BY year ASC");
EXECUTE_SQL_QUERY(req, set, res);
while (set.NextRow())
{
year = set.GetInt(_("year"));
year = set.GetInt(wxT("year"));
it = user->_accounts.begin();
req = _("SELECT DISTINCT month FROM operation WHERE (account IN('") + it->id;
req = wxT("SELECT DISTINCT month FROM operation WHERE (account IN('") + it->id;
it++;
for (;it != user->_accounts.end(); it++)
{
req += _("', '") + it->id ;
req += wxT("', '") + it->id ;
}
req += _("')");
req += _(" OR user='") + user->_id + _("')");
req += _(" AND year='") + set.GetAsString(_("year")) + _("'");
req += _(" ORDER BY month ASC");
req += wxT("')");
req += wxT(" OR user='") + user->_id + wxT("')");
req += wxT(" AND year='") + set.GetAsString(wxT("year")) + wxT("'");
req += wxT(" ORDER BY month ASC");
EXECUTE_SQL_QUERY(req, set2, res);
while (set2.NextRow())
{
res[year].push_back(set2.GetInt(_("month")));
res[year].push_back(set2.GetInt(wxT("month")));
}
set2.Finalize();
}
@@ -668,12 +668,12 @@ void Database::GenerateMonth(User* user, int monthFrom, int yearFrom, int monthT
{
for (it = user->_accounts.begin(); it != user->_accounts.end(); it++)
{
req = _("INSERT INTO account_amount ('account', 'year', 'month', 'amount') VALUES ('") ;
req += it->id + _("'");
req += _(" ,'") + wxString::Format(_("%d"), yearTo) + _("'");
req += _(" ,'") + wxString::Format(_("%d"), monthTo) + _("'");
req += _(" ,'0.0'");
req += _(")");
req = wxT("INSERT INTO account_amount ('account', 'year', 'month', 'amount') VALUES ('") ;
req += it->id + wxT("'");
req += wxT(" ,'") + wxString::Format(wxT("%d"), yearTo) + wxT("'");
req += wxT(" ,'") + wxString::Format(wxT("%d"), monthTo) + wxT("'");
req += wxT(" ,'0.0'");
req += wxT(")");
EXECUTE_SQL_UPDATE(req, );
}
@@ -683,32 +683,32 @@ void Database::GenerateMonth(User* user, int monthFrom, int yearFrom, int monthT
for (it = user->_accounts.begin(); it != user->_accounts.end(); it++)
{
amount = 0.0;
req = _("SELECT amount FROM operation WHERE") ;
req += _(" account='") + it->id + _("'");
req += _(" AND year='") + wxString::Format(_("%d"), yearFrom) + _("'");
req += _(" AND month='") + wxString::Format(_("%d"), monthFrom) + _("'");
req = wxT("SELECT amount FROM operation WHERE") ;
req += wxT(" account='") + it->id + wxT("'");
req += wxT(" AND year='") + wxString::Format(wxT("%d"), yearFrom) + wxT("'");
req += wxT(" AND month='") + wxString::Format(wxT("%d"), monthFrom) + wxT("'");
EXECUTE_SQL_QUERY(req, set, );
while (set.NextRow())
amount += set.GetDouble(_("amount"));
amount += set.GetDouble(wxT("amount"));
req = _("SELECT amount FROM account_amount WHERE") ;
req += _(" account='") + it->id + _("'");
req += _(" AND year='") + wxString::Format(_("%d"), yearFrom) + _("'");
req += _(" AND month='") + wxString::Format(_("%d"), monthFrom) + _("'");
req = wxT("SELECT amount FROM account_amount WHERE") ;
req += wxT(" account='") + it->id + wxT("'");
req += wxT(" AND year='") + wxString::Format(wxT("%d"), yearFrom) + wxT("'");
req += wxT(" AND month='") + wxString::Format(wxT("%d"), monthFrom) + wxT("'");
EXECUTE_SQL_QUERY(req, set, );
if (set.NextRow())
amount += set.GetDouble(_("amount"));
amount += set.GetDouble(wxT("amount"));
req = _("INSERT INTO account_amount ('account', 'year', 'month', 'amount') VALUES ('") ;
req += it->id + _("'");
req += _(" ,'") + wxString::Format(_("%d"), yearTo) + _("'");
req += _(" ,'") + wxString::Format(_("%d"), monthTo) + _("'");
req += _(" ,'") + DoubleToString(amount) + _("'");
req += _(")");
req = wxT("INSERT INTO account_amount ('account', 'year', 'month', 'amount') VALUES ('") ;
req += it->id + wxT("'");
req += wxT(" ,'") + wxString::Format(wxT("%d"), yearTo) + wxT("'");
req += wxT(" ,'") + wxString::Format(wxT("%d"), monthTo) + wxT("'");
req += wxT(" ,'") + DoubleToString(amount) + wxT("'");
req += wxT(")");
EXECUTE_SQL_UPDATE(req, );
}
@@ -718,9 +718,9 @@ void Database::ChangePassword(User* user, wxString password)
{
wxString req;
req = _("UPDATE user SET ") ;
req += _("password='") + HashPassword(password) + _("'");
req += _(" WHERE name='") + user->_name + _("'");
req = wxT("UPDATE user SET ") ;
req += wxT("password='") + HashPassword(password) + wxT("'");
req += wxT(" WHERE name='") + user->_name + wxT("'");
EXECUTE_SQL_UPDATE(req, );
}
@@ -731,7 +731,7 @@ bool Database::UserExists(wxString name)
wxString req;
bool res=false;
req = _("SELECT name FROM user WHERE name='") + name + _("'") ;
req = wxT("SELECT name FROM user WHERE name='") + name + wxT("'") ;
EXECUTE_SQL_QUERY(req , set, false);
@@ -749,9 +749,9 @@ void Database::ChangeName(User* user, wxString name)
{
wxString req;
req = _("UPDATE user SET ") ;
req += _("name='") + name + _("'");
req += _(" WHERE name='") + user->_name + _("'");
req = wxT("UPDATE user SET ") ;
req += wxT("name='") + name + wxT("'");
req += wxT(" WHERE name='") + user->_name + wxT("'");
EXECUTE_SQL_UPDATE(req, );
}
@@ -761,53 +761,53 @@ void Database::NewUser(wxString name)
wxString req, id;
wxSQLite3ResultSet set;
req = _("INSERT INTO user ('name', 'password') VALUES ('") ;
req += name + _("'");
req += _(", '") + HashPassword(_("")) + _("'");
req += _(")");
req = wxT("INSERT INTO user ('name', 'password') VALUES ('") ;
req += name + wxT("'");
req += wxT(", '") + HashPassword(wxT("")) + wxT("'");
req += wxT(")");
EXECUTE_SQL_UPDATE(req, );
req = _("SELECT id FROM user WHERE ");
req += _("name='") + name + _("'");
req = wxT("SELECT id FROM user WHERE ");
req += wxT("name='") + name + wxT("'");
EXECUTE_SQL_QUERY(req , set, );
set.NextRow();
id = set.GetAsString(_("id"));
id = set.GetAsString(wxT("id"));
set.Finalize();
req = _("SELECT * FROM default_preference");
req = wxT("SELECT * FROM default_preference");
EXECUTE_SQL_QUERY(req, set,);
while (set.NextRow())
{
req = _("INSERT INTO preference ('user', 'name', 'value') VALUES ('") ;
req += id + _("'");
req += _(", '") + set.GetAsString(_("type")) + _("'");
req += _(", '") + set.GetAsString(_("value")) + _("'");
req += _(")");
req = wxT("INSERT INTO preference ('user', 'name', 'value') VALUES ('") ;
req += id + wxT("'");
req += wxT(", '") + set.GetAsString(wxT("type")) + wxT("'");
req += wxT(", '") + set.GetAsString(wxT("value")) + wxT("'");
req += wxT(")");
EXECUTE_SQL_UPDATE(req, );
}
set.Finalize();
req = _("SELECT * FROM default_category");
req = wxT("SELECT * FROM default_category");
EXECUTE_SQL_QUERY(req, set,);
while (set.NextRow())
{
req = _("INSERT INTO category ('user', 'parent', 'name', 'color', 'font') VALUES ('") ;
req += id + _("'");
req += _(", '") + set.GetAsString(_("parent")) + _("'");
req += _(", '") + set.GetAsString(_("name")) + _("'");
req += _(", '") + set.GetAsString(_("color")) + _("'");
req += _(", '") + set.GetAsString(_("font")) + _("'");
req += _(")");
req = wxT("INSERT INTO category ('user', 'parent', 'name', 'color', 'font') VALUES ('") ;
req += id + wxT("'");
req += wxT(", '") + set.GetAsString(wxT("parent")) + wxT("'");
req += wxT(", '") + set.GetAsString(wxT("name")) + wxT("'");
req += wxT(", '") + set.GetAsString(wxT("color")) + wxT("'");
req += wxT(", '") + set.GetAsString(wxT("font")) + wxT("'");
req += wxT(")");
EXECUTE_SQL_UPDATE(req, );
}
@@ -825,41 +825,41 @@ void Database::KillMe(User* user)
wxString req;
std::vector<Account>::iterator it;
req = _("DELETE FROM preference WHERE user='") + user->_id + _("'");
req = wxT("DELETE FROM preference WHERE user='") + user->_id + wxT("'");
EXECUTE_SQL_UPDATE(req, );
if (!user->_accounts.empty())
{
it = user->_accounts.begin();
req = _("DELETE FROM account_amount WHERE account IN('") + it->id;
req = wxT("DELETE FROM account_amount WHERE account IN('") + it->id;
it++;
for (;it != user->_accounts.end(); it++)
{
req += _("', '") + it->id ;
req += wxT("', '") + it->id ;
}
req += _("')");
req += wxT("')");
EXECUTE_SQL_UPDATE(req, );
it = user->_accounts.begin();
req = _("DELETE FROM operation WHERE account IN('") + it->id;
req = wxT("DELETE FROM operation WHERE account IN('") + it->id;
it++;
for (;it != user->_accounts.end(); it++)
{
req += _("', '") + it->id ;
req += wxT("', '") + it->id ;
}
req += _("')");
req += _(" OR user='") + user->_id + _("')");
req += wxT("')");
req += wxT(" OR user='") + user->_id + wxT("')");
EXECUTE_SQL_UPDATE(req, );
}
req = _("DELETE FROM account WHERE user='") + user->_id + _("'");
req = wxT("DELETE FROM account WHERE user='") + user->_id + wxT("'");
EXECUTE_SQL_UPDATE(req, );
req = _("DELETE FROM category WHERE user='") + user->_id + _("'");
req = wxT("DELETE FROM category WHERE user='") + user->_id + wxT("'");
EXECUTE_SQL_UPDATE(req, );
req = _("DELETE FROM user WHERE id='") + user->_id + _("'");
req = wxT("DELETE FROM user WHERE id='") + user->_id + wxT("'");
EXECUTE_SQL_UPDATE(req, );
}

View File

@@ -23,10 +23,10 @@ struct category User::GetCategory(wxString catId)
if (it->id == catId)
return *it;
cat.id = _("0");
cat.parent = _("0");
cat.id = wxT("0");
cat.parent = wxT("0");
cat.name = _("Unknown");
cat.font = _("");
cat.font = wxT("");
cat.color = wxColour(0xFF, 0xFF, 0xFF);
return cat;
@@ -49,7 +49,7 @@ wxString User::GetCategoryId(wxString catName)
if (it->name == catName)
return it->id;
return _("0") ;
return wxT("0") ;
}
wxString User::GetAccountName(wxString accountId)
@@ -69,7 +69,7 @@ wxString User::GetAccountId(wxString accountName)
if (it->name == accountName)
return it->id;
return _("0") ;
return wxT("0") ;
}
int User::GetCategoriesNumber()

View File

@@ -2,7 +2,6 @@
#define MODEL_H
#include "User.h"
#include "Preferences.h"
#include "Database.h"
#endif