59 lines
1.5 KiB
C++
59 lines
1.5 KiB
C++
#ifndef DATABASE_H
|
|
#define DATABASE_H
|
|
|
|
#include <stdio.h>
|
|
#include <fstream>
|
|
#include <list>
|
|
#include <wx/wxsqlite3.h>
|
|
#include <wx/wx.h>
|
|
#include <sha1.h>
|
|
|
|
#include "model.h"
|
|
|
|
#define BDD_FILE "kc.bdd"
|
|
#define INIT_SCRIPT "init.sql"
|
|
|
|
class Database
|
|
{
|
|
public:
|
|
Database();
|
|
|
|
std::list<wxString> GetUsers();
|
|
bool IsValidUser(wxString user, wxString password);
|
|
|
|
User* LoadUser(wxString name);
|
|
void LoadYear(User* user, int year);
|
|
|
|
void UpdateOperation(Operation op);
|
|
wxString AddOperation(User* user, Operation op);
|
|
void DeleteOperation(Operation op);
|
|
void DeleteOperations(User* user, int month, int year);
|
|
double GetAccountAmount(wxString id, int month, int year);
|
|
void SetAccountAmount(int month, int year, wxString accountId, double amount);
|
|
|
|
wxString AddAccount(User* user, Account ac);
|
|
void UpdateAccount(Account ac);
|
|
void DeleteAccount(Account ac);
|
|
|
|
wxString AddCategory(User* user, Category category);
|
|
void UpdateCategory(Category category);
|
|
void DeleteCategory(User* user, Category category);
|
|
|
|
std::map<int, std::vector<int> > GetAllOperations(User* user);
|
|
void GenerateMonth(User* user, int monthFrom, int yearFrom, int monthTo, int yearTo);
|
|
|
|
void ChangePassword(User* user, wxString password);
|
|
bool UserExists(wxString name);
|
|
void ChangeName(User* user, wxString name);
|
|
void NewUser(wxString name);
|
|
|
|
void KillMe(User* user);
|
|
private:
|
|
wxSQLite3Database _db;
|
|
|
|
void CreateDatabase();
|
|
wxString HashPassword(wxString password);
|
|
};
|
|
|
|
#endif
|