/[H6]/DatabaseLayer.cpp
ViewVC logotype

Diff of /DatabaseLayer.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 25 by torben, Fri Sep 1 03:09:15 2006 UTC revision 26 by torben, Fri Sep 1 03:24:34 2006 UTC
# Line 218  vector<Equipment> DatabaseLayer::Search( Line 218  vector<Equipment> DatabaseLayer::Search(
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 \
# Line 240  vector<Equipment> DatabaseLayer::Search( Line 242  vector<Equipment> DatabaseLayer::Search(
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);
# Line 276  vector<Equipment> DatabaseLayer::Search( Line 278  vector<Equipment> DatabaseLayer::Search(
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                                    

Legend:
Removed from v.25  
changed lines
  Added in v.26

  ViewVC Help
Powered by ViewVC 1.1.20