00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
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