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 __PROGRAMME_H 00022 #define __PROGRAMME_H 00023 00024 #include "DataClass.h" 00025 #include "Institute.h" 00026 00027 class Programme : public DataClass 00028 { 00029 private: // Properties 00030 QString name; 00031 QString abbrev; 00032 00033 protected: // Properties 00034 friend class ProgItem; 00035 static int insertSQL; 00036 static int updateSQL; 00037 static int deleteSQL; 00038 static int uniqueNameSQL; 00039 static int uniqueAbbrevSQL; 00040 static int errorSQL; 00041 00042 public: 00043 Programme(); 00044 Programme(int pID, QString name, QString abbrev, Institute * parent); 00045 static void PrepareSQL(sql * dbConn); 00046 00047 // Get Methods 00048 inline virtual QString getDescription()const{return getName();} 00049 inline QString getName()const{return name;} 00050 inline QString getAbbrev()const{return abbrev;} 00051 inline Institute * getInstitute() {return static_cast<Institute *>(parent);} 00052 inline QString getInstName()const; 00053 inline int getInstID(){return getParentID();} 00054 // Set Methods 00055 inline bool setName(QString pName){name = pName; return true;} 00056 inline bool setAbbrev(QString pAbbrev){abbrev = pAbbrev; return true;} 00057 // Methods to determine if the field is unique 00058 static bool uniqueName(QString name, int parentID); 00059 static bool uniqueAbbrev(QString abbrev, int parentID); 00060 protected: 00061 void bindValues(int preparedSQL, int start); 00062 }; 00063 00064 inline QString Programme::getInstName()const 00065 { 00066 if (parent!= 0) 00067 return static_cast<Institute *>(parent)->getName(); 00068 else 00069 return QString(); 00070 } 00071 00072 #endif