218 |
{ |
{ |
219 |
vector<Equipment> buffer; |
vector<Equipment> buffer; |
220 |
|
|
221 |
|
//here are the wanted equipments found through 3 seperate queries - I could also |
222 |
|
//find them all in one query where I joined the 3 selects via a UNION |
223 |
CString SQL; |
CString SQL; |
224 |
if (available == true) { |
if (available == true) { |
225 |
SQL = "SELECT DISTINCT Udstyr.stregkode,Udstyr.Navn,Udstyr.Beskrivelse,Udstyr.Placering,Status.Beskrivelse \ |
SQL = "SELECT DISTINCT Udstyr.stregkode,Udstyr.Navn,Udstyr.Beskrivelse,Udstyr.Placering,Status.Beskrivelse \ |
242 |
INNER JOIN Status ON Udstyr.status = Status.StatusID \r\n\ |
INNER JOIN Status ON Udstyr.status = Status.StatusID \r\n\ |
243 |
INNER JOIN Resevation ON Udstyr.Stregkode = Resevation.stregkode \r\n\ |
INNER JOIN Resevation ON Udstyr.Stregkode = Resevation.stregkode \r\n\ |
244 |
INNER JOIN Person ON Resevation.PersonID = Person.PersonID\r\n\ |
INNER JOIN Person ON Resevation.PersonID = Person.PersonID\r\n\ |
245 |
WHERE Udstyr.Status = 2 "; |
WHERE ( Udstyr.Status = 2 OR Person.Initialer = '" + inits + "') "; |
246 |
if (barcode != "") |
if (barcode != "") |
247 |
SQL += " AND Udstyr.stregkode = '" + barcode + "' "; |
SQL += " AND Udstyr.stregkode = '" + barcode + "' "; |
248 |
if (name != "") |
if (name != "") |
249 |
SQL += " AND Udstyr.Navn LIKE '%" + name + "%' "; |
SQL += " AND Udstyr.Navn LIKE '%" + name + "%' "; |
250 |
if (inits != "") |
//if (inits != "") |
251 |
SQL += " AND Person.Initialer = '" + inits + "' "; |
// SQL += " AND Person.Initialer = '" + inits + "' "; |
252 |
|
|
253 |
CRecordset rs(&db); |
CRecordset rs(&db); |
254 |
rs.Open(AFX_DB_USE_DEFAULT_TYPE, SQL); |
rs.Open(AFX_DB_USE_DEFAULT_TYPE, SQL); |
278 |
rs.Close(); |
rs.Close(); |
279 |
} |
} |
280 |
|
|
281 |
|
// now I have the equipment rows the user asked for, now I need some more checkout and |
282 |
|
// reservation data for each piece of equipment |
283 |
|
|
284 |
for (int i=0; i<buffer.size(); i++) { |
for (int i=0; i<buffer.size(); i++) { |
285 |
//fill Equipment::checkouts |
//fill Equipment::checkouts |
286 |
|
|