KissCount/controller/KissCount.cpp
2010-06-02 22:14:11 +02:00

71 lines
1.2 KiB
C++

#include "KissCount.h"
KissCount::KissCount() : _user(NULL)
{
_wxUI = new wxUI(this, _("KissCount"), wxPoint(50, 50), wxSize(1024, 768));
_wxUI->Show(true);
_wxUI->Centre();
_wxUI->Disable();
try
{
_db = new Database();
}
catch (std::string s)
{
_wxUI->Close(true);
throw s;
}
_wxUI->ChangeUser();
_wxUI->Enable();
}
KissCount::~KissCount()
{
delete _db;
delete _wxUI;
if (_user) delete _user;
}
std::list<wxString> KissCount::GetUsers()
{
return _db->GetUsers();
}
bool KissCount::IsValidUser(wxString user, wxString password)
{
return _db->IsValidUser(user, password) ;
}
void KissCount::LoadUser(wxString user)
{
if (_user) delete _user;
_user = _db->LoadUser(user) ;
if (_user)
_wxUI->LoadUser();
}
void KissCount::LoadYear(int year, bool force)
{
if (!force && _user->_operations[year] != NULL) return;
if (_user->_operations[year] != NULL)
{
delete _user->_operations[year];
}
_db->LoadYear(_user, year);
}
User* KissCount::GetUser()
{
return _user;
}
double KissCount::GetAccountAmount(wxString id, int month, int year)
{
return _db->GetAccountAmount(id, month, year);
}