Replace Account class by account structure
This commit is contained in:
parent
77de073d2e
commit
1383d22818
|
@ -102,15 +102,15 @@ void KissCount::SetAccountAmount(int month, int year, wxString accountId, double
|
|||
_db->SetAccountAmount(month, year, accountId, amount);
|
||||
}
|
||||
|
||||
void KissCount::AddAccount(struct Account ac)
|
||||
void KissCount::AddAccount(struct account ac)
|
||||
{
|
||||
ac.id = _db->AddAccount(_user, ac);
|
||||
_user->_accounts.push_back(ac);
|
||||
}
|
||||
|
||||
void KissCount::UpdateAccount(struct Account ac)
|
||||
void KissCount::UpdateAccount(struct account ac)
|
||||
{
|
||||
std::vector<Account>::iterator it;
|
||||
std::vector<struct account>::iterator it;
|
||||
int i;
|
||||
|
||||
_db->UpdateAccount(ac);
|
||||
|
@ -119,9 +119,9 @@ void KissCount::UpdateAccount(struct Account ac)
|
|||
_user->_accounts[i] = ac;
|
||||
}
|
||||
|
||||
void KissCount::DeleteAccount(struct Account ac)
|
||||
void KissCount::DeleteAccount(struct account ac)
|
||||
{
|
||||
std::vector<Account>::iterator it;
|
||||
std::vector<struct account>::iterator it;
|
||||
int i;
|
||||
|
||||
_db->DeleteAccount(ac);
|
||||
|
@ -221,7 +221,7 @@ void KissCount::ChangeName(wxString name)
|
|||
void KissCount::NewUser(wxString name)
|
||||
{
|
||||
wxDateTime curDate;
|
||||
struct Account ac = {wxT(""), wxT("Account 1"), wxT(""), false, true};
|
||||
struct account ac = {wxT(""), wxT("Account 1"), wxT(""), false, true};
|
||||
|
||||
_db->NewUser(name);
|
||||
if (_user) delete _user;
|
||||
|
|
|
@ -33,9 +33,9 @@ class KissCount
|
|||
|
||||
double GetAccountAmount(wxString id, int month, int year);
|
||||
void SetAccountAmount(int month, int year, wxString accountId, double value);
|
||||
void AddAccount(struct Account ac);
|
||||
void UpdateAccount(struct Account ac);
|
||||
void DeleteAccount(struct Account ac);
|
||||
void AddAccount(struct account ac);
|
||||
void UpdateAccount(struct account ac);
|
||||
void DeleteAccount(struct account ac);
|
||||
|
||||
wxString AddCategory(struct category category);
|
||||
void UpdateCategory(struct category category);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -29,7 +29,7 @@ AccountPanel::AccountPanel(KissCount* kiss, wxUI *parent) : wxScrolledWindow(&(*
|
|||
int i ;
|
||||
DEFAULT_FONT(font);
|
||||
User* user = _kiss->GetUser();
|
||||
std::vector<Account>::iterator accountIt;
|
||||
std::vector<struct account>::iterator accountIt;
|
||||
std::vector<category>::iterator categoryIt;
|
||||
wxColour categoryColors[] = {wxColour(0x00, 0x45, 0x86),
|
||||
wxColour(0xFF, 0x3E, 0x0E),
|
||||
|
@ -230,7 +230,7 @@ void AccountPanel::ChangeUser()
|
|||
else
|
||||
_tree.AppendItem(rootNode, wxString::Format(wxT("%d"), it->first));
|
||||
}
|
||||
|
||||
Fit();
|
||||
if (curYear != -1)
|
||||
{
|
||||
_tree.SelectItem(curNode, true);
|
||||
|
@ -273,7 +273,7 @@ void AccountPanel::LoadYear(int year, bool showMonth)
|
|||
}
|
||||
|
||||
_tree.Expand(parentNode);
|
||||
|
||||
Fit();
|
||||
if (showMonth)
|
||||
{
|
||||
_tree.SelectItem(curMonthNode, true);
|
||||
|
@ -373,7 +373,7 @@ void AccountPanel::ShowMonth(int month, int year)
|
|||
|
||||
UpdateStats();
|
||||
|
||||
// Fit();
|
||||
Fit();
|
||||
// SetMinSize(GetSize());
|
||||
}
|
||||
|
||||
|
@ -474,7 +474,7 @@ void AccountPanel::InsertOperation(User* user, operation* op, int line, bool fix
|
|||
|
||||
void AccountPanel::InitAccountsGrid(User* user, int month, int year)
|
||||
{
|
||||
std::vector<Account>::iterator it;
|
||||
std::vector<struct account>::iterator it;
|
||||
int curLine = 0;
|
||||
double value;
|
||||
int i, a;
|
||||
|
@ -516,7 +516,7 @@ void AccountPanel::UpdateStats()
|
|||
std::map<wxString, double> curAccountAmount, finalAccountAmount;
|
||||
std::map<wxString, double>::iterator doubleIt;
|
||||
std::map<wxString, int>::iterator intIt;
|
||||
std::vector<Account>::iterator accountIt;
|
||||
std::vector<struct account>::iterator accountIt;
|
||||
unsigned int day;
|
||||
|
||||
day = _calendar->GetDate().GetDay()-1;
|
||||
|
|
|
@ -85,9 +85,9 @@ PreferencesPanel::PreferencesPanel(KissCount* kiss, wxUI *parent) : wxPanel(&(*p
|
|||
|
||||
void PreferencesPanel::InitAccounts(User* user)
|
||||
{
|
||||
std::vector<Account>::iterator it;
|
||||
std::vector<struct account>::iterator it;
|
||||
int curLine = 0;
|
||||
Account account ;
|
||||
struct account account ;
|
||||
DEFAULT_FONT(font);
|
||||
|
||||
_accountsGrid->CreateGrid(0, NUMBER_COLS_ACCOUNT);
|
||||
|
@ -180,7 +180,7 @@ void PreferencesPanel::OnAccountModified(wxGridEvent& event)
|
|||
{
|
||||
int op_complete = 2;
|
||||
wxString value ;
|
||||
struct Account new_account, account;
|
||||
struct account new_account, account;
|
||||
User* user = _kiss->GetUser();
|
||||
int row = event.GetRow();
|
||||
int col = event.GetCol();
|
||||
|
|
Loading…
Reference in New Issue
Block a user