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