Replace Account class by account structure
This commit is contained in:
@@ -169,10 +169,10 @@ User* Database::LoadUser(wxString name)
|
||||
wxSQLite3ResultSet set;
|
||||
wxString req;
|
||||
User* user;
|
||||
struct Account account;
|
||||
struct account account;
|
||||
struct category category;
|
||||
|
||||
std::vector<Account>::iterator it;
|
||||
std::vector<struct account>::iterator it;
|
||||
|
||||
req = wxT("SELECT * FROM user WHERE name='") + name + wxT("'");
|
||||
|
||||
@@ -259,7 +259,7 @@ void Database::LoadYear(User* user, int year)
|
||||
{
|
||||
wxSQLite3ResultSet set;
|
||||
wxString req;
|
||||
std::vector<Account>::iterator it;
|
||||
std::vector<struct account>::iterator it;
|
||||
|
||||
if (user->_operations[year] == NULL)
|
||||
user->_operations[year] = new std::map<unsigned int, std::vector<operation> >();
|
||||
@@ -407,7 +407,7 @@ void Database::DeleteOperation(struct operation op)
|
||||
void Database::DeleteOperations(User* user, int month, int year)
|
||||
{
|
||||
wxString req;
|
||||
std::vector<Account>::iterator it;
|
||||
std::vector<struct account>::iterator it;
|
||||
|
||||
it = user->_accounts.begin();
|
||||
req = wxT("DELETE FROM account_amount WHERE account IN('") + it->id;
|
||||
@@ -470,7 +470,7 @@ void Database::SetAccountAmount(int month, int year, wxString accountId, double
|
||||
}
|
||||
}
|
||||
|
||||
wxString Database::AddAccount(User* user, struct Account ac)
|
||||
wxString Database::AddAccount(User* user, struct account ac)
|
||||
{
|
||||
wxString req, res;
|
||||
wxSQLite3ResultSet set;
|
||||
@@ -506,7 +506,7 @@ wxString Database::AddAccount(User* user, struct Account ac)
|
||||
return res;
|
||||
}
|
||||
|
||||
void Database::UpdateAccount(struct Account ac)
|
||||
void Database::UpdateAccount(struct account ac)
|
||||
{
|
||||
wxString req;
|
||||
req = wxT("UPDATE account SET ") ;
|
||||
@@ -525,7 +525,7 @@ void Database::UpdateAccount(struct Account ac)
|
||||
EXECUTE_SQL_UPDATE(req, );
|
||||
}
|
||||
|
||||
void Database::DeleteAccount(struct Account ac)
|
||||
void Database::DeleteAccount(struct account ac)
|
||||
{
|
||||
wxString req;
|
||||
req = wxT("DELETE FROM account WHERE id='") + ac.id + wxT("'");
|
||||
@@ -608,7 +608,7 @@ std::map<int, std::vector<int> > Database::GetAllOperations(User* user)
|
||||
{
|
||||
wxString req;
|
||||
wxSQLite3ResultSet set, set2;
|
||||
std::vector<Account>::iterator it;
|
||||
std::vector<struct account>::iterator it;
|
||||
std::map<int, std::vector<int> > res;
|
||||
int year;
|
||||
|
||||
@@ -659,7 +659,7 @@ std::map<int, std::vector<int> > Database::GetAllOperations(User* user)
|
||||
|
||||
void Database::GenerateMonth(User* user, int monthFrom, int yearFrom, int monthTo, int yearTo)
|
||||
{
|
||||
std::vector<Account>::iterator it;
|
||||
std::vector<struct account>::iterator it;
|
||||
wxString req;
|
||||
wxSQLite3ResultSet set;
|
||||
double amount;
|
||||
@@ -823,7 +823,7 @@ void Database::NewUser(wxString name)
|
||||
void Database::KillMe(User* user)
|
||||
{
|
||||
wxString req;
|
||||
std::vector<Account>::iterator it;
|
||||
std::vector<struct account>::iterator it;
|
||||
|
||||
req = wxT("DELETE FROM preference WHERE user='") + user->_id + wxT("'");
|
||||
EXECUTE_SQL_UPDATE(req, );
|
||||
|
||||
@@ -31,9 +31,9 @@ class Database
|
||||
double GetAccountAmount(wxString id, int month, int year);
|
||||
void SetAccountAmount(int month, int year, wxString accountId, double amount);
|
||||
|
||||
wxString AddAccount(User* user, struct Account ac);
|
||||
void UpdateAccount(struct Account ac);
|
||||
void DeleteAccount(struct Account ac);
|
||||
wxString AddAccount(User* user, struct account ac);
|
||||
void UpdateAccount(struct account ac);
|
||||
void DeleteAccount(struct account ac);
|
||||
|
||||
wxString AddCategory(User* user, struct category category);
|
||||
void UpdateCategory(struct category category);
|
||||
|
||||
@@ -54,7 +54,7 @@ wxString User::GetCategoryId(wxString catName)
|
||||
|
||||
wxString User::GetAccountName(wxString accountId)
|
||||
{
|
||||
std::vector<Account>::iterator it;
|
||||
std::vector<struct account>::iterator it;
|
||||
for (it=_accounts.begin(); it !=_accounts.end(); it++)
|
||||
if (it->id == accountId)
|
||||
return it->name;
|
||||
@@ -64,7 +64,7 @@ wxString User::GetAccountName(wxString accountId)
|
||||
|
||||
wxString User::GetAccountId(wxString accountName)
|
||||
{
|
||||
std::vector<Account>::iterator it;
|
||||
std::vector<struct account>::iterator it;
|
||||
for (it=_accounts.begin(); it !=_accounts.end(); it++)
|
||||
if (it->name == accountName)
|
||||
return it->id;
|
||||
|
||||
@@ -19,7 +19,7 @@ struct operation {
|
||||
bool checked;
|
||||
} ;
|
||||
|
||||
struct Account {
|
||||
struct account {
|
||||
wxString id;
|
||||
wxString name;
|
||||
wxString number;
|
||||
@@ -44,7 +44,7 @@ public:
|
||||
wxString _id;
|
||||
wxString _name;
|
||||
wxString _password;
|
||||
std::vector<Account> _accounts;
|
||||
std::vector<struct account> _accounts;
|
||||
std::map<unsigned int, std::map<unsigned int, std::vector<operation> >* > _operations;
|
||||
std::vector<struct category> _categories;
|
||||
std::map<wxString, wxString> _preferences;
|
||||
|
||||
Reference in New Issue
Block a user