-
Notifications
You must be signed in to change notification settings - Fork 0
/
cbranch.cpp
214 lines (172 loc) · 4.31 KB
/
cbranch.cpp
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
/****************************************************************************************
*
* File:
*
* This file is part of the MEGASeries Project.
* Copyright (C) 2015 Joerg Pauly, MEGAMover.de
* File created 27.02.2015 by joerg
* All Rights reserved
*
* Dieses Programm ist Freie Software: Sie können es unter den Bedingungen
* der GNU Lesser General Public License, wie von der Free Software Foundation,
* Version 3 der Lizenz oder (nach Ihrer Option) jeder späteren
* veröffentlichten Version, weiterverbreiten und/oder modifizieren.
*
* Dieses Programm wird in der Hoffnung, dass es nützlich sein wird, aber
* OHNE JEDE GEWÄHRLEISTUNG, bereitgestellt; sogar ohne die implizite
* Gewährleistung der MARKTFÄHIGKEIT oder EIGNUNG FÜR EINEN BESTIMMTEN ZWECK.
* Siehe die GNU Lesser General Public License für weitere Details.
*
* Sie sollten eine Kopie der GNU Lesser General Public License zusammen mit diesem
* Programm erhalten haben. Wenn nicht, siehe <http://www.gnu.org/licenses/>.
*
*****************************************************************************************/
#include "cbranch.h"
CBranch::CBranch()
{
m_ID = 0;
m_Name1 = "";
m_Name2 = "";
m_Name3 = "";
m_Adress1 = "";
m_Adress2 = "";
m_Adress3 = "";
m_Adress4 = "";
m_Adress5 = "";
m_Hours = "";
m_Valid = true;
}
CBranch::CBranch(int pID)
{
m_Valid = false;
QSqlQuery lqry;
lqry.prepare("SELECT * FROM tblBranches WHERE ID = :ID;");
lqry.bindValue(":ID", QVariant(pID));
lqry.exec();
lqry.first();
if(!lqry.isValid())
{
return;
}
else
{
m_Valid = true;
}
m_ID = pID;
m_Name1 = lqry.value(lqry.record().indexOf("Name1")).toString();
m_Name2 = lqry.value(lqry.record().indexOf("Name2")).toString();
m_Name3 = lqry.value(lqry.record().indexOf("Name3")).toString();
m_Adress1 = lqry.value(lqry.record().indexOf("Adress1")).toString();
m_Adress2 = lqry.value(lqry.record().indexOf("Adress2")).toString();
m_Adress3 = lqry.value(lqry.record().indexOf("Adress3")).toString();
m_Adress4 = lqry.value(lqry.record().indexOf("Adress4")).toString();
m_Adress5 = lqry.value(lqry.record().indexOf("Adress5")).toString();
m_Hours = lqry.value(lqry.record().indexOf("Hours")).toString();
}
CBranch::~CBranch()
{
}
bool CBranch::saveToDB()
{
QSqlQuery lqry;
lqry.prepare("UPDATE tblBranches SET Name1 = :N1, Name2 = :N2, Name3 = :N3, Adress1 = :A1, Adress2 = :A2, Adress3 = :A3, Adress4 = :A4, Adress5 = :A5, Hours = :HX WHERE ID = :ID;");
lqry.bindValue(":N1", m_Name1);
lqry.bindValue(":N2", m_Name2);
lqry.bindValue(":N3", m_Name3);
lqry.bindValue(":A1", m_Adress1);
lqry.bindValue(":A2", m_Adress2);
lqry.bindValue(":A3", m_Adress3);
lqry.bindValue(":A4", m_Adress4);
lqry.bindValue(":A5", m_Adress5);
lqry.bindValue(":HX", m_Hours);
lqry.bindValue(":ID", m_ID);
return lqry.exec();
}
int CBranch::ID() const
{
return m_ID;
}
void CBranch::setID(int ID)
{
m_ID = ID;
}
QString CBranch::Name1() const
{
return m_Name1;
}
void CBranch::setName1(const QString &Name1)
{
m_Name1 = Name1;
}
QString CBranch::Name2() const
{
return m_Name2;
}
void CBranch::setName2(const QString &Name2)
{
m_Name2 = Name2;
}
QString CBranch::Name3() const
{
return m_Name3;
}
void CBranch::setName3(const QString &Name3)
{
m_Name3 = Name3;
}
QString CBranch::Adress1() const
{
return m_Adress1;
}
void CBranch::setAdress1(const QString &Adress1)
{
m_Adress1 = Adress1;
}
QString CBranch::Adress2() const
{
return m_Adress2;
}
void CBranch::setAdress2(const QString &Adress2)
{
m_Adress2 = Adress2;
}
QString CBranch::Adress3() const
{
return m_Adress3;
}
void CBranch::setAdress3(const QString &Adress3)
{
m_Adress3 = Adress3;
}
QString CBranch::Adress4() const
{
return m_Adress4;
}
void CBranch::setAdress4(const QString &Adress4)
{
m_Adress4 = Adress4;
}
QString CBranch::Adress5() const
{
return m_Adress5;
}
void CBranch::setAdress5(const QString &Adress5)
{
m_Adress5 = Adress5;
}
QString CBranch::Hours() const
{
return m_Hours;
}
void CBranch::setHours(const QString &Hours)
{
m_Hours = Hours;
}
int CBranch::Valid() const
{
return m_Valid;
}
void CBranch::setValid(int Valid)
{
m_Valid = Valid;
}