Main Page | Class Hierarchy | Class List | Directories | File List | Class Members | Related Pages

Faculty.cpp

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 #include "Faculty.h"
00021 int Faculty::selectSQL = 0;
00022 
00023 int Faculty::insertSQL = 0;
00024 int Faculty::updateSQL = 0;
00025 int Faculty::deleteSQL = 0;
00026 
00027 int Faculty::uniqueNameSQL = 0;
00028 int Faculty::uniqueAbbrevSQL = 0;
00029 
00030 int Faculty::errorSQL = 0;
00031 
00032 void Faculty::PrepareSQL(sql * dbConn)
00033 {
00034         if (dbConn != 0)
00035         {
00036                 selectSQL = dbConn->prepare("SELECT id, name, abbrev FROM basic.faculty WHERE institute_id = ? ORDER BY name",*dbConn->useModuleConn());
00037                 insertSQL = dbConn->prepare("basic.faculty_insert",3,*dbConn->useModuleConn());
00038                 updateSQL = dbConn->prepare("basic.faculty_update",4,*dbConn->useModuleConn());
00039                 deleteSQL = dbConn->prepare("basic.faculty_delete",1,*dbConn->useModuleConn());
00040                 
00041                 uniqueNameSQL   = dbConn->prepare("basic.is_faculty_name_unique"
00042                                                  ,2
00043                                                  ,*dbConn->useModuleConn());
00044                 uniqueAbbrevSQL = dbConn->prepare("basic.is_faculty_abbrev_unique"
00045                                                  ,2
00046                                                  ,*dbConn->useModuleConn());
00047                 
00048                 errorSQL = dbConn->prepare("basic.faculty_error",1,*dbConn->useModuleConn());
00049         }
00050 }
00051 
00052 Faculty::Faculty()
00053 :DataClass()
00054 {
00055         name   = "";
00056         abbrev = "";
00057         p_rtti = FACULTY_CLASS;
00058 }
00059 
00060 Faculty::Faculty(int pID, QString pName, QString pAbbrev, Institute * pParent)
00061 :DataClass(pID)
00062 {
00063         name = pName;
00064         abbrev = pAbbrev;
00065         parent = pParent;
00066         p_rtti = FACULTY_CLASS;
00067 }
00068 
00069 void Faculty::bindValues(int preparedSQL, int start)
00070 {
00071         sql::Instance()->bind(start,name,preparedSQL);
00072         sql::Instance()->bind(++start,abbrev);
00073         sql::Instance()->bind(++start,getInstID());
00074 }
00075 
00076 bool Faculty::uniqueName(QString name, int parentID)
00077 {
00078         sql::Instance()->bind(0,name,uniqueNameSQL);
00079         sql::Instance()->bind(1,parentID);
00080         return unique(uniqueNameSQL);
00081 }
00082 
00083 bool Faculty::uniqueAbbrev(QString abbrev, int parentID)
00084 {
00085         sql::Instance()->bind(0,abbrev,uniqueAbbrevSQL);
00086         sql::Instance()->bind(1,parentID);
00087         return unique(uniqueAbbrevSQL);
00088 }
00089 

Generated on Thu Apr 6 16:27:16 2006 for time-table by  doxygen 1.4.4