KissCount/src/model/Database.h

59 lines
1.5 KiB
C
Raw Normal View History

#ifndef DATABASE_H
#define DATABASE_H
2010-05-15 11:21:42 +02:00
#include <stdio.h>
#include <fstream>
#include <list>
#include <wx/wxsqlite3.h>
#include <wx/wx.h>
#include <sha1.h>
2010-05-15 11:21:42 +02:00
#include "model.h"
#define BDD_FILE "kc.bdd"
#define INIT_SCRIPT "init.sql"
class Database
{
public:
Database();
std::list<wxString> GetUsers();
2010-07-05 18:35:12 +02:00
bool IsValidUser(const wxString& user, const wxString& password);
2010-05-15 11:21:42 +02:00
2010-07-05 18:35:12 +02:00
User* LoadUser(const wxString& name);
2010-05-16 10:35:34 +02:00
void LoadYear(User* user, int year);
2010-06-03 18:28:38 +02:00
2010-07-05 18:35:12 +02:00
void UpdateOperation(Operation& op);
wxString AddOperation(User* user, Operation& op);
void DeleteOperation(Operation& op);
2010-06-24 21:02:42 +02:00
void DeleteOperations(User* user, int month, int year);
2010-07-05 18:35:12 +02:00
double GetAccountAmount(const wxString& id, int month, int year);
void SetAccountAmount(int month, int year, const wxString& accountId, double amount);
2010-06-03 18:28:38 +02:00
2010-07-05 18:35:12 +02:00
wxString AddAccount(User* user, Account& ac);
void UpdateAccount(Account& ac);
void DeleteAccount(Account& ac);
2010-06-21 10:53:43 +02:00
2010-07-05 18:35:12 +02:00
wxString AddCategory(User* user, Category& category);
void UpdateCategory(Category& category);
void DeleteCategory(User* user, Category& category);
2010-06-22 11:35:21 +02:00
2010-06-23 14:25:00 +02:00
std::map<int, std::vector<int> > GetAllOperations(User* user);
2010-06-23 19:32:42 +02:00
void GenerateMonth(User* user, int monthFrom, int yearFrom, int monthTo, int yearTo);
2010-06-23 14:25:00 +02:00
2010-07-05 18:35:12 +02:00
void ChangePassword(User* user, const wxString& password);
bool UserExists(const wxString& name);
void ChangeName(User* user, const wxString& name);
void NewUser(const wxString& name);
2010-06-27 21:39:49 +02:00
void KillMe(User* user);
private:
2010-07-04 16:33:25 +02:00
wxSQLite3Database _db;
2010-07-04 16:33:25 +02:00
void CreateDatabase();
2010-07-05 18:35:12 +02:00
wxString HashPassword(const wxString& password);
};
#endif