-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdbmanager.h
67 lines (52 loc) · 2.15 KB
/
dbmanager.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
* TCN Field Booking Application
* Copyright (C) 2018 Dzianis Lamouski
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef DBMANAGER_H
#define DBMANAGER_H
#include <QDate>
#include <QSqlDatabase>
#include <QString>
#include "bookingdata.h"
class DbManager
{
public:
DbManager(const QString& path);
bool addMember(const QString &name, const QString &surname);
bool importMembersFile(QString filename);
bool addField(const QString& name, const int time_masks[7], const int seasons) const;
bool updateFieldName(const int id, const QString& name) const;
bool updateFieldTimeMask(const int id, const int day_index, const int time_mask) const;
bool updateFieldSeasons(const int id, const int seasons) const;
bool bookingSlotIsFree(const BookingSlot& slot, int &bookingId, BookingData& data);
bool addBooking(const BookingSlot& slot, const BookingData& data);
bool updateBooking(const int bookingId, const BookingData& data);
bool cancleBooking(const int bookingId);
bool markBookingAsPaid(const int bookingId);
bool markBookingAsUnpaid(const int bookingId);
bool changeBookingField(const int bookingID, const int fieldID);
bool changeAboBookingField(const int bookingID, const int fieldID);
int addBlock(const BookingSlot& slot, const BookingData& data);
int numOfUsedBlocks(int blockID);
bool deleteBlock(const int blockId);
bool checkDB();
static DbManager* instance();
static QSqlDatabase db();
private:
static DbManager* m_instance;
QSqlDatabase m_db;
};
#endif // DBMANAGER_H