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

Module.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 
00021 #include "Module.h"
00022 
00023 int Module::insertSQL = 0;
00024 int Module::updateSQL = 0;
00025 int Module::deleteSQL = 0;
00026 
00027 int Module::uniqueNameSQL = 0;
00028 int Module::uniqueNomenclatureSQL = 0;
00029 
00030 int Module::errorSQL = 0;
00031 
00032 void Module::PrepareSQL(sql * dbConn)
00033 {
00034         if (dbConn != 0)
00035         {
00036                 insertSQL = dbConn->prepare("basic.module_insert",5,*dbConn->useModuleConn());
00037                 updateSQL = dbConn->prepare("basic.module_update",6,*dbConn->useModuleConn());
00038                 deleteSQL = dbConn->prepare("basic.module_delete",1,*dbConn->useModuleConn());
00039                 
00040                 uniqueNameSQL         = dbConn->prepare("basic.is_module_name_unique"
00041                                                        ,2
00042                                                        ,*dbConn->useModuleConn());
00043                 uniqueNomenclatureSQL = dbConn->prepare("basic.is_module_nomenclature_unique"
00044                                                        ,2
00045                                                        ,*dbConn->useModuleConn());
00046                 
00047                 errorSQL = dbConn->prepare("basic.module_error",1,*dbConn->useModuleConn());
00048         }
00049 }
00050 
00051 Module::Module()
00052 :DataClass()
00053 {
00054         name          = "";
00055         nomenclature  = "";
00056         duration      = 0;
00057         weeklyPeriods = 0;
00058         semester      = 0;
00059         p_rtti = MODULE_CLASS;
00060 }
00061 
00062 Module::Module(int pID
00063                                   ,Programme * pParent
00064                                   ,QString pName
00065                                   ,QString pNomenclature
00066                                   ,int pDuration
00067                                   ,int pWeeklyPeriods
00068                                   ,short pSemester)
00069 :DataClass(pID)
00070 {
00071         name          = pName;
00072         nomenclature  = pNomenclature;
00073         duration      = pDuration;
00074         weeklyPeriods = pWeeklyPeriods;
00075         semester      = pSemester;
00076         parent        = pParent;
00077         p_rtti        = MODULE_CLASS;
00078 }
00079 
00080 void Module::bindValues(int preparedSQL, int start)
00081 {
00082         sql::Instance()->bind(start,name,preparedSQL);
00083         sql::Instance()->bind(++start,nomenclature);
00084         sql::Instance()->bind(++start,getProgID());
00085         sql::Instance()->bind(++start,duration);
00086         sql::Instance()->bind(++start,weeklyPeriods);
00087 }
00088 
00089 bool Module::uniqueName(QString name, int parentID)
00090 {
00091         sql::Instance()->bind(0,name,uniqueNameSQL);
00092         sql::Instance()->bind(1,parentID);
00093         return unique(uniqueNameSQL);
00094 }
00095 
00096 bool Module::uniqueNomenclature(QString nomenclature, int parentID)
00097 {
00098         sql::Instance()->bind(0,nomenclature,uniqueNomenclatureSQL);
00099         sql::Instance()->bind(1,parentID);
00100         return unique(uniqueNomenclatureSQL);
00101 }
00102 

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