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();
bool IsValidUser(wxString user, wxString password);
2010-05-15 11:21:42 +02:00
User* LoadUser(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-03 11:48:53 +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-06-21 10:53:43 +02:00
double GetAccountAmount(wxString id, int month, int year);
2010-06-12 15:59:27 +02:00
void SetAccountAmount(int month, int year, wxString accountId, double amount);
2010-06-03 18:28:38 +02:00
2010-07-03 11:48:53 +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-03 11:48:53 +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-06-27 21:39:49 +02:00
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:
2010-07-04 16:33:25 +02:00
wxSQLite3Database _db;
2010-07-04 16:33:25 +02:00
void CreateDatabase();
wxString HashPassword(wxString password);
};
#endif