BigBlueBox
An Inventory Management System for a NYLT Course or other Boy Scout Programs
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Pages
dbconnect.h
Go to the documentation of this file.
1 #ifndef DBCONNECT_H
2 #define DBCONNECT_H
3 
4 //*********************************************************************************
5 // For database connection & error checking
6 #include <QSqlDatabase>
7 #include <QSqlQuery>
8 #include <QDebug>
9 #include <QSqlError>
10 #include <QSqlRecord>
11 
12 // For strings
13 #include <QString>
14 #include <QStringList>
15 
16 // For returnings vectors of objects
17 #include <QVector>
18 #include <algorithm>
19 
20 // Business Objects
21 #include "item.h"
22 #include "_filereader.h"
23 #include "gear.h"
24 //*********************************************************************************
25 
26 namespace bbb {
27 //*********************************************************************************
33 // I know there is a lot of stuff in this class, I'm sorry. I did not want to
34 // mess with inherting singletons and building interfaces.
35 //*********************************************************************************
36 class DbConnect
37 {
38 private:
39  //**********************************************************
41  QSqlDatabase bbb_db;
42  //**********************************************************
43 
44  //**********************************************************
47  //**********************************************************
48 
49  //**********************************************************
54  DbConnect();
55  //**********************************************************
56 
57 public:
58  //**********************************************************
60  const QString dateFormat = "yyyy/MM/dd hh:mm::ss";
61  //**********************************************************
62 
63  //**********************************************************
67  ~DbConnect();
68  //**********************************************************
69 
70  //**********************************************************
75  static DbConnect* getInstance();
76  //**********************************************************
77 
78  //**********************************************************
84  QVector<Item> getFullInvAsVector();
85  //**********************************************************
86 
87  //**********************************************************
94  void updateItem(QString orgName, Row newRowInfo);
95  //**********************************************************
96 
97  //**********************************************************
102  void addNewItem(Item newItem);
103  //**********************************************************
104 
105  //**********************************************************
111  void deleteItem(QString name);
112  //**********************************************************
113 
114  //**********************************************************
121  bool itemAlreadyExists(QString name);
122  //**********************************************************
123 
124  //**********************************************************
131  QVector<GearNote> getGearNotes(int catId, int idvId);
132  //**********************************************************
133 
134  //**********************************************************
140  Gear getGearInfo(int catId, int idvId);
141  //**********************************************************
142 
143  //**********************************************************
149  QStringList getGearHealthStatusList();
150  //**********************************************************
151 
152  //**********************************************************
158  bool isCheckedOut(int catId, int idvId);
159  //**********************************************************
160 
161  //**********************************************************
167  QStringList getTroopNames();
168  //**********************************************************
169 
170  //**********************************************************
176  QStringList getPatrolNamesByTroop(int troopNum);
177  //**********************************************************
178 
179  //**********************************************************
184  QStringList getDefaultNotes();
185  //**********************************************************
186 
187  //**********************************************************
193  void addNote(int catId, int idvId, QString note, QString author);
194  //**********************************************************
195 
196  //**********************************************************
197  bool gearItemExists(int catId, int idvId);
198  //**********************************************************
199 
200 
201  //**********************************************************
202  void checkOutGear(int catId, int idvId, QString pid);
203  //**********************************************************
204 
205  //**********************************************************
206  void checkInGear(int catId, int idvId);
207  //**********************************************************
208 
209  //**********************************************************
213  void sysLog(QString log);
214  //**********************************************************
215 
216 
217  //**********************************************************
222  void updateGearItemHealth(int catId, int idvId, int health);
223  //**********************************************************
224 
225  QString isCheckedOutBy(int catId, int idvId);
226 
227 }; // end class
228 //*********************************************************************************
229 } // end namespace
230 #endif // DBCONNECT_H
void addNote(int catId, int idvId, QString note, QString author)
Adds new Gear Note to DB.
Definition: dbconnect.cpp:466
bool isCheckedOut(int catId, int idvId)
Checks if Gear is checked out.
Definition: dbconnect.cpp:403
QString isCheckedOutBy(int catId, int idvId)
Definition: dbconnect.cpp:618
bool gearItemExists(int catId, int idvId)
Definition: dbconnect.cpp:492
const QString dateFormat
Server DateTime format for all Date.toString()'s.
Definition: dbconnect.h:60
QVector< GearNote > getGearNotes(int catId, int idvId)
Gets notes for a gear item.
Definition: dbconnect.cpp:203
QStringList getDefaultNotes()
Gets Default Notes.
Definition: dbconnect.cpp:438
void deleteItem(QString name)
Deletes a item from the database.
Definition: dbconnect.cpp:159
static DbConnect * instance
Singleton Pointer.
Definition: dbconnect.h:46
bool itemAlreadyExists(QString name)
Checks to see if an item exists.
Definition: dbconnect.cpp:173
Business Object Layer : Inventory Item.
Definition: item.h:18
DbConnect()
Default no-args constructor.
Definition: dbconnect.cpp:8
QVector< Item > getFullInvAsVector()
Gets full inventory.
Definition: dbconnect.cpp:50
void updateItem(QString orgName, Row newRowInfo)
Updates the contents of one item.
Definition: dbconnect.cpp:100
void sysLog(QString log)
System Log.
Definition: dbconnect.cpp:574
void checkOutGear(int catId, int idvId, QString pid)
Definition: dbconnect.cpp:526
QSqlDatabase bbb_db
Database object.
Definition: dbconnect.h:41
QStringList getTroopNames()
Gets Troop names.
Definition: dbconnect.cpp:300
Gear getGearInfo(int catId, int idvId)
Gets all info for a gear item.
Definition: dbconnect.cpp:258
DataBase Comm. Layer : Singleton.
Definition: dbconnect.h:36
static DbConnect * getInstance()
Singleton pointer return function.
Definition: dbconnect.cpp:39
void updateGearItemHealth(int catId, int idvId, int health)
Updates Health Status.
Definition: dbconnect.cpp:595
void checkInGear(int catId, int idvId)
Definition: dbconnect.cpp:550
Ui Object Layer : Inventory Table Row.
Definition: item.h:78
Definition: gear.h:7
QStringList getPatrolNamesByTroop(int troopNum)
Gets Patrol names.
Definition: dbconnect.cpp:337
~DbConnect()
Default non-args de-constructor.
Definition: dbconnect.cpp:28
void addNewItem(Item newItem)
Addes a new item to the database.
Definition: dbconnect.cpp:134
QStringList getGearHealthStatusList()
Gets all Heath Statuses.
Definition: dbconnect.cpp:371