00001 /*************************************************************************** 00002 * Copyright (C) 2006 by Graeme Foster * 00003 * email foster.graeme@gmail.com * 00004 * * 00005 * This program is free software; you can redistribute it and/or modify * 00006 * it under the terms of the GNU General Public License as published by * 00007 * the Free Software Foundation; either version 2 of the License, or * 00008 * (at your option) any later version. * 00009 * * 00010 * This program is distributed in the hope that it will be useful, * 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00013 * GNU General Public License for more details. * 00014 * * 00015 * You should have received a copy of the GNU General Public License * 00016 * along with this program; if not, write to the * 00017 * Free Software Foundation, Inc., * 00018 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 00019 ***************************************************************************/ 00020 00021 #ifndef __ROOM_H 00022 #define __ROOM_H 00023 00024 #include "DataClass.h" 00025 #include "Institute.h" 00026 00027 class Room : public DataClass 00028 { 00029 private: 00030 QString name; 00031 QString code; 00032 int capacity; 00033 00034 protected: // Properties 00035 friend class RoomItem; 00036 static int insertSQL; 00037 static int updateSQL; 00038 static int deleteSQL; 00039 static int uniqueCodeSQL; 00040 static int errorSQL; 00041 00042 public: 00043 // Constructor 00044 Room(); 00045 Room(int pID, QString name, QString code, int capacity, Institute * parent); 00046 static void PrepareSQL(sql * dbConn); 00047 // Get Methods 00048 inline QString getDescription()const{return getName();} 00049 inline QString getName()const{return name;} 00050 inline QString getCode()const{return code;} 00051 inline int getCapacity(){return capacity;} 00052 inline Institute * getInstitute() {return static_cast<Institute *>(parent);} 00053 inline QString getInstName()const; 00054 inline int getInstID(){return getParentID();} 00055 // Set Methods 00056 inline bool setName(QString pName){name = pName; return true;} 00057 inline bool setCode(QString pCode){code = pCode; return true;} 00058 inline bool setCapacity(int pCapacity){capacity = pCapacity; return true;} 00059 // Methods to determine if the field is unique 00060 static bool uniqueCode(QString code, int parentID); 00061 protected: 00062 void bindValues(int preparedSQL, int start); 00063 }; 00064 00065 inline QString Room::getInstName()const 00066 { 00067 if (parent!= 0) 00068 return static_cast<Institute *>(parent)->getName(); 00069 else 00070 return QString(); 00071 } 00072 #endif