KissCount/controller/KissCount.cpp

65 lines
1.0 KiB
C++
Raw Normal View History

#include "KissCount.h"
2010-05-16 10:35:34 +02:00
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;
2010-05-16 10:35:34 +02:00
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)
{
2010-05-16 10:35:34 +02:00
if (_user) delete _user;
_user = _db->LoadUser(user) ;
_wxUI->LoadUser();
}
2010-05-17 18:03:21 +02:00
void KissCount::LoadYear(int year, bool force)
2010-05-16 10:35:34 +02:00
{
if (!force && _user->_operations[year] != NULL) return;
if (_user->_operations[year] != NULL)
{
delete _user->_operations[year];
}
_db->LoadYear(_user, year);
}
2010-05-16 10:35:34 +02:00
User* KissCount::GetUser()
{
return _user;
}