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

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

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