KissCount/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
void UpdateOperation(struct operation op);
2010-06-21 13:02:02 +02:00
wxString AddOperation(User* user, struct operation op);
2010-06-03 18:28:38 +02:00
void DeleteOperation(struct 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
wxString AddAccount(User* user, struct account ac);
void UpdateAccount(struct account ac);
void DeleteAccount(struct account ac);
2010-06-21 10:53:43 +02:00
2010-06-22 12:29:36 +02:00
wxString AddCategory(User* user, struct category category);
void UpdateCategory(struct category category);
2010-06-22 12:29:36 +02:00
void DeleteCategory(User* user, struct 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:
wxSQLite3Database _db;
void CreateDatabase();
2010-06-27 21:39:49 +02:00
wxString HashPassword(wxString password);
};
#endif