Passes re

This commit is contained in:
Grégory Soutadé 2010-07-05 18:35:12 +02:00
parent dfe81f2b03
commit 4544a5c3ad
6 changed files with 80 additions and 80 deletions

View File

@ -36,12 +36,12 @@ std::list<wxString> KissCount::GetUsers()
return _db->GetUsers();
}
bool KissCount::IsValidUser(wxString user, wxString password)
bool KissCount::IsValidUser(const wxString& user, const wxString& password)
{
return _db->IsValidUser(user, password) ;
}
void KissCount::LoadUser(wxString user)
void KissCount::LoadUser(const wxString& user)
{
if (_user) delete _user;
_user = _db->LoadUser(user) ;
@ -66,22 +66,22 @@ User* KissCount::GetUser()
return _user;
}
double KissCount::GetAccountAmount(wxString id, int month, int year)
double KissCount::GetAccountAmount(const wxString& id, int month, int year)
{
return _db->GetAccountAmount(id, month, year);
}
void KissCount::UpdateOperation(Operation op)
void KissCount::UpdateOperation(Operation& op)
{
_db->UpdateOperation(op);
}
wxString KissCount::AddOperation(Operation op)
wxString KissCount::AddOperation(Operation& op)
{
return _db->AddOperation(_user, op);
}
void KissCount::DeleteOperation(Operation op)
void KissCount::DeleteOperation(Operation& op)
{
_db->DeleteOperation(op);
}
@ -99,12 +99,12 @@ void KissCount::DeleteOperations(int month, int year)
}
}
void KissCount::SetAccountAmount(int month, int year, wxString accountId, double amount)
void KissCount::SetAccountAmount(int month, int year, const wxString& accountId, double amount)
{
_db->SetAccountAmount(month, year, accountId, amount);
}
wxString KissCount::AddAccount(Account ac)
wxString KissCount::AddAccount(Account& ac)
{
ac.id = _db->AddAccount(_user, ac);
_user->_accounts.push_back(ac);
@ -112,7 +112,7 @@ wxString KissCount::AddAccount(Account ac)
return ac.id;
}
void KissCount::UpdateAccount(Account ac)
void KissCount::UpdateAccount(Account& ac)
{
std::vector<Account>::iterator it;
int i;
@ -123,7 +123,7 @@ void KissCount::UpdateAccount(Account ac)
_user->_accounts[i] = ac;
}
void KissCount::DeleteAccount(Account ac)
void KissCount::DeleteAccount(Account& ac)
{
std::vector<Account>::iterator it;
int i;
@ -137,7 +137,7 @@ void KissCount::DeleteAccount(Account ac)
}
}
wxString KissCount::AddCategory(Category category)
wxString KissCount::AddCategory(Category& category)
{
wxString id;
id = _db->AddCategory(_user, category);
@ -148,7 +148,7 @@ wxString KissCount::AddCategory(Category category)
return id;
}
void KissCount::UpdateCategory(Category category)
void KissCount::UpdateCategory(Category& category)
{
_db->UpdateCategory(category);
@ -160,7 +160,7 @@ void KissCount::UpdateCategory(Category category)
}
}
void KissCount::DeleteCategory(Category category)
void KissCount::DeleteCategory(Category& category)
{
_db->DeleteCategory(_user, category);
@ -206,23 +206,23 @@ void KissCount::GenerateMonth(int monthFrom, int yearFrom, int monthTo, int year
_wxUI->GenerateMonth(monthTo, yearTo);
}
void KissCount::ChangePassword(wxString password)
void KissCount::ChangePassword(const wxString& password)
{
_db->ChangePassword(_user, password);
}
bool KissCount::UserExists(wxString name)
bool KissCount::UserExists(const wxString& name)
{
return _db->UserExists(name);
}
void KissCount::ChangeName(wxString name)
void KissCount::ChangeName(const wxString& name)
{
_db->ChangeName(_user, name);
_user->_name = name;
}
void KissCount::NewUser(wxString name)
void KissCount::NewUser(const wxString& name)
{
wxDateTime curDate;
Account ac = {wxT(""), wxT("Account 1"), wxT(""), false, true};

View File

@ -16,30 +16,30 @@ class KissCount
~KissCount();
std::list<wxString> GetUsers();
bool IsValidUser(wxString user, wxString password);
void LoadUser(wxString user);
bool IsValidUser(const wxString& user, const wxString& password);
void LoadUser(const wxString& user);
User* GetUser();
void ChangePassword(wxString password);
bool UserExists(wxString name);
void ChangeName(wxString name);
void NewUser(wxString name);
void ChangePassword(const wxString& password);
bool UserExists(const wxString& name);
void ChangeName(const wxString& name);
void NewUser(const wxString& name);
void LoadYear(int year, bool force=false);
wxString AddOperation(Operation op);
void UpdateOperation(Operation op);
void DeleteOperation(Operation op);
wxString AddOperation(Operation& op);
void UpdateOperation(Operation& op);
void DeleteOperation(Operation& op);
void DeleteOperations(int month, int year);
double GetAccountAmount(wxString id, int month, int year);
void SetAccountAmount(int month, int year, wxString accountId, double value);
wxString AddAccount(Account ac);
void UpdateAccount(Account ac);
void DeleteAccount(Account ac);
double GetAccountAmount(const wxString& id, int month, int year);
void SetAccountAmount(int month, int year, const wxString& accountId, double value);
wxString AddAccount(Account& ac);
void UpdateAccount(Account& ac);
void DeleteAccount(Account& ac);
wxString AddCategory(Category category);
void UpdateCategory(Category category);
void DeleteCategory(Category category);
wxString AddCategory(Category& category);
void UpdateCategory(Category& category);
void DeleteCategory(Category& category);
std::map<int, std::vector<int> > GetAllOperations();

View File

@ -113,7 +113,7 @@ void Database::CreateDatabase()
}
wxString Database::HashPassword(wxString password)
wxString Database::HashPassword(const wxString& password)
{
blk_SHA_CTX sha_ctx;
unsigned char sha[20];
@ -148,7 +148,7 @@ std::list<wxString> Database::GetUsers()
return res;
}
bool Database::IsValidUser(wxString user, wxString password)
bool Database::IsValidUser(const wxString& user, const wxString& password)
{
bool res;
wxString req;
@ -164,7 +164,7 @@ bool Database::IsValidUser(wxString user, wxString password)
return res;
}
User* Database::LoadUser(wxString name)
User* Database::LoadUser(const wxString& name)
{
wxSQLite3ResultSet set;
wxString req;
@ -299,7 +299,7 @@ void Database::LoadYear(User* user, int year)
set.Finalize();
}
double Database::GetAccountAmount(wxString id, int month, int year)
double Database::GetAccountAmount(const wxString& id, int month, int year)
{
wxSQLite3ResultSet set;
wxString req;
@ -325,7 +325,7 @@ double Database::GetAccountAmount(wxString id, int month, int year)
return res;
}
void Database::UpdateOperation(Operation op)
void Database::UpdateOperation(Operation& op)
{
wxString req;
req = wxT("UPDATE operation SET ") ;
@ -345,7 +345,7 @@ void Database::UpdateOperation(Operation op)
EXECUTE_SQL_UPDATE(req, );
}
wxString Database::AddOperation(User* user, Operation op)
wxString Database::AddOperation(User* user, Operation& op)
{
wxString req, res;
wxSQLite3ResultSet set;
@ -394,7 +394,7 @@ wxString Database::AddOperation(User* user, Operation op)
return res;
}
void Database::DeleteOperation(Operation op)
void Database::DeleteOperation(Operation& op)
{
wxString req;
req = wxT("DELETE FROM operation WHERE id='") + op.id + wxT("'");
@ -438,7 +438,7 @@ void Database::DeleteOperations(User* user, int month, int year)
}
void Database::SetAccountAmount(int month, int year, wxString accountId, double amount)
void Database::SetAccountAmount(int month, int year, const wxString& accountId, double amount)
{
wxString req;
req = wxT("UPDATE account_amount SET ") ;
@ -468,7 +468,7 @@ void Database::SetAccountAmount(int month, int year, wxString accountId, double
}
}
wxString Database::AddAccount(User* user, Account ac)
wxString Database::AddAccount(User* user, Account& ac)
{
wxString req, res;
wxSQLite3ResultSet set;
@ -504,7 +504,7 @@ wxString Database::AddAccount(User* user, Account ac)
return res;
}
void Database::UpdateAccount(Account ac)
void Database::UpdateAccount(Account& ac)
{
wxString req;
req = wxT("UPDATE account SET ") ;
@ -523,7 +523,7 @@ void Database::UpdateAccount(Account ac)
EXECUTE_SQL_UPDATE(req, );
}
void Database::DeleteAccount(Account ac)
void Database::DeleteAccount(Account& ac)
{
wxString req;
req = wxT("DELETE FROM account WHERE id='") + ac.id + wxT("'");
@ -531,7 +531,7 @@ void Database::DeleteAccount(Account ac)
EXECUTE_SQL_UPDATE(req, );
}
wxString Database::AddCategory(User* user, Category category)
wxString Database::AddCategory(User* user, Category& category)
{
wxString req, res;
wxSQLite3ResultSet set;
@ -567,7 +567,7 @@ wxString Database::AddCategory(User* user, Category category)
return res;
}
void Database::UpdateCategory(Category category)
void Database::UpdateCategory(Category& category)
{
wxString req;
wxString color;
@ -587,7 +587,7 @@ void Database::UpdateCategory(Category category)
EXECUTE_SQL_UPDATE(req, );
}
void Database::DeleteCategory(User* user, Category category)
void Database::DeleteCategory(User* user, Category& category)
{
wxString req;
@ -733,7 +733,7 @@ void Database::GenerateMonth(User* user, int monthFrom, int yearFrom, int monthT
}
}
void Database::ChangePassword(User* user, wxString password)
void Database::ChangePassword(User* user, const wxString& password)
{
wxString req;
@ -744,7 +744,7 @@ void Database::ChangePassword(User* user, wxString password)
EXECUTE_SQL_UPDATE(req, );
}
bool Database::UserExists(wxString name)
bool Database::UserExists(const wxString& name)
{
wxSQLite3ResultSet set;
wxString req;
@ -764,7 +764,7 @@ bool Database::UserExists(wxString name)
return res;
}
void Database::ChangeName(User* user, wxString name)
void Database::ChangeName(User* user, const wxString& name)
{
wxString req;
@ -775,7 +775,7 @@ void Database::ChangeName(User* user, wxString name)
EXECUTE_SQL_UPDATE(req, );
}
void Database::NewUser(wxString name)
void Database::NewUser(const wxString& name)
{
wxString req, id;
wxSQLite3ResultSet set;

View File

@ -19,40 +19,40 @@ class Database
Database();
std::list<wxString> GetUsers();
bool IsValidUser(wxString user, wxString password);
bool IsValidUser(const wxString& user, const wxString& password);
User* LoadUser(wxString name);
User* LoadUser(const wxString& name);
void LoadYear(User* user, int year);
void UpdateOperation(Operation op);
wxString AddOperation(User* user, Operation op);
void DeleteOperation(Operation op);
void UpdateOperation(Operation& op);
wxString AddOperation(User* user, Operation& op);
void DeleteOperation(Operation& op);
void DeleteOperations(User* user, int month, int year);
double GetAccountAmount(wxString id, int month, int year);
void SetAccountAmount(int month, int year, wxString accountId, double amount);
double GetAccountAmount(const wxString& id, int month, int year);
void SetAccountAmount(int month, int year, const wxString& accountId, double amount);
wxString AddAccount(User* user, Account ac);
void UpdateAccount(Account ac);
void DeleteAccount(Account ac);
wxString AddAccount(User* user, Account& ac);
void UpdateAccount(Account& ac);
void DeleteAccount(Account& ac);
wxString AddCategory(User* user, Category category);
void UpdateCategory(Category category);
void DeleteCategory(User* user, Category category);
wxString AddCategory(User* user, Category& category);
void UpdateCategory(Category& category);
void DeleteCategory(User* user, Category& category);
std::map<int, std::vector<int> > GetAllOperations(User* user);
void GenerateMonth(User* user, int monthFrom, int yearFrom, int monthTo, int yearTo);
void ChangePassword(User* user, wxString password);
bool UserExists(wxString name);
void ChangeName(User* user, wxString name);
void NewUser(wxString name);
void ChangePassword(User* user, const wxString& password);
bool UserExists(const wxString& name);
void ChangeName(User* user, const wxString& name);
void NewUser(const wxString& name);
void KillMe(User* user);
private:
wxSQLite3Database _db;
void CreateDatabase();
wxString HashPassword(wxString password);
wxString HashPassword(const wxString& password);
};
#endif

View File

@ -13,7 +13,7 @@ User::~User()
}
}
Category User::GetCategory(wxString catId)
Category User::GetCategory(wxString& catId)
{
Category cat;
std::vector<Category>::iterator it;
@ -31,7 +31,7 @@ Category User::GetCategory(wxString catId)
return cat;
}
wxString User::GetCategoryName(wxString catId)
wxString User::GetCategoryName(wxString& catId)
{
std::vector<Category>::iterator it;
for (it=_categories.begin(); it !=_categories.end(); it++)
@ -41,7 +41,7 @@ wxString User::GetCategoryName(wxString catId)
return _("Unknown") ;
}
wxString User::GetCategoryId(wxString catName)
wxString User::GetCategoryId(wxString& catName)
{
std::vector<Category>::iterator it;
for (it=_categories.begin(); it !=_categories.end(); it++)
@ -51,7 +51,7 @@ wxString User::GetCategoryId(wxString catName)
return wxT("0") ;
}
wxString User::GetAccountName(wxString accountId)
wxString User::GetAccountName(wxString& accountId)
{
std::vector<Account>::iterator it;
for (it=_accounts.begin(); it !=_accounts.end(); it++)
@ -61,7 +61,7 @@ wxString User::GetAccountName(wxString accountId)
return _("Unknown") ;
}
wxString User::GetAccountId(wxString accountName)
wxString User::GetAccountId(wxString& accountName)
{
std::vector<Account>::iterator it;
for (it=_accounts.begin(); it !=_accounts.end(); it++)

View File

@ -23,11 +23,11 @@ class User
std::vector<Category> _categories;
std::map<wxString, wxString> _preferences;
Category GetCategory(wxString catId);
wxString GetCategoryName(wxString catId);
wxString GetCategoryId(wxString catName);
wxString GetAccountName(wxString accountId);
wxString GetAccountId(wxString accountName);
Category GetCategory(wxString& catId);
wxString GetCategoryName(wxString& catId);
wxString GetCategoryId(wxString& catName);
wxString GetAccountName(wxString& accountId);
wxString GetAccountId(wxString& accountName);
int GetCategoriesNumber();
int GetAccountsNumber();
int GetOperationsNumber(int month, int year);