IEEE Survey
<%
dim decision
dim facultyNumber
dim count
dim conn
dim RSbuffer, RSFaculty
dim SqlQuery
dim userID, ReportID
dim maxFaID, minFaId, facID
dim fname, mname, lname
dim rank, degree, PESGrade
dim acExp, indExp, otherIndExp
dim actPowerT, actPowerR, actNoPower
dim PEReg
dim ProfSponsoredPowerChair,ProfDeptChair,Prof, asscProf, asstProf,emeritus
dim bachelor,master,professional, PhD, blank1,blank2,blank3
dim member, senior, fellow, lifemember
dim PERegYes, PERegNo
dim goToPage
dim ACTPOWERRESEACH, ACTPOWERTEACHING, ACTNONPOWER, EXPACD, EXPIND, EXPOTHERIND, fname2,mname2,lname2
dim countFac, facIDdel, faid
on error resume next
count = 0
session.Timeout = 360
'get user id from the session object
userID = cint(session("userID"))
if userID = empty then
userID = cint(Request.Form("userID"))
end if
'if still cannot retrieve user id then automatically logged out
if userID = "" or userID = 0 then
Response.redirect("surveyLogin.asp?loginFail=yes")
end if
'get the report id from the session object
reportID =cint(session("reportID"))
if reportID="" then
reportID= cint(Request.Form("reportID"))
end if
session("userID")=cint(userID)
session("reportID")=cint(reportID)
'make connection
set conn = server.CreateObject("ADODB.connection")
conn.Open ConnectionString
decision = trim(Request.Form("decision"))
'get the faculty number from database
sqlQuery = "select * from tbl_IEEE_report where REID="&reportID
set RSbuffer = conn.Execute(sqlQUery)
if RSbuffer("RENOPAGE2")<> "" then
facultyNumber = cint(RSbuffer("RENOPAGE2"))
else
facultyNumber = 1
end if
'Response.Write "facno:"& facultyNumber&" "
'check if this page is the viewable page
if decision <> "move" and decision <> "exit" and decision<>"delete" then
'get the data for this page, if it exist
sqlQuery = "select max(FAID) as maxFaId, min(FAID) as minFaId, count(*) as countFac from tbl_IEEE_faculty where FAREID="&reportID
set RSbuffer = conn.Execute(sqlQuery)
if RSbuffer.eof=false then
if RSBuffer("maxFaID") <> "" then
maxFaId = cint(RSbuffer("maxFaId"))
else
maxFaID = 0
end if
else
maxFaID=0
end if
if RSbuffer.eof=false then
if RSbuffer("minFaId") <> "" then
minFaId = cint(RSbuffer("minFaId"))
else
minFaId = 1
end if
else
minFaid=1
end if
'override the faculty number that was get from survey02pre.asp if the database has more
if facultyNumber < cint(Rsbuffer("countFac")) then
facultyNumber = cint(RSbuffer("countFac"))
end if
'Response.Write "facno:"& facultyNumber&" "
sqlQuery = "select * from tbl_IEEE_faculty where FAREID="&reportID
set RSbuffer = conn.Execute(sqlQuery)
'Response.Write "minFaid="&minFaID&" maxFaid="&maxFaID
%>
ELECTRIC POWER
ENGINEERING EDUCATIONAL RESOURCES SURVEY Power
Engineering Education Committee of IEEE Power Engineering
Society
Reporting period: Fiscal or academic year 05-06
<%
else 'if it is a processing page
if decision="delete" then
if trim(Request.Form("facIDDel")) <> "" then
facIDDel = cint(Request.Form("facIDDel"))
else
Response.Redirect("survey02.asp")
end if
sqlQuery = "delete from tbl_IEEE_faculty where FAID="&facIDDel
'Response.Write(sqlQuery)
conn.execute(sqlQuery)
Response.Redirect("survey02.asp")
else
count= cint(Request.Form("count"))
userID = cint(Request.Form("userID"))
reportID = cint(Request.Form("reportID"))
maxFaId= cint(Request.Form("maxFaId"))
minFaId =cint(Request.Form("minFaID"))
'facID = minFaID
for i=0 to count
facIDVar = "factID"&i
fnameVar = "fname"&i
mnameVar = "mname"&i
lnameVar = "lname"&i
rankVar= "rank"&i
highestDegreeVar ="highestDegree"&i
PERegVar ="PEReg"&i
PESGradeVar ="PESGrade"&i
academicVar ="academic"&i
powerIndustryVar ="powerIndustry"&i
otherIndustryVar ="otherIndustry"&i
PowerTVar="PowerT"&i
PowerRVar="PowerR"&i
NonPowerVar="NonPower"&i
if Request.Form(facIDvar) <> 0 then
facID = cint(Request.Form(facIDvar))
else
facID =maxFaId+1 'to insert new data not updating old data
end if
if trim(Request.Form(fnameVar)) <> "" then
fname2= trim(Request.Form(fnameVar))
else
fname2=" "
end if
if trim(Request.Form(mnameVar)) <> "" then
mname2 = trim(Request.Form(mnameVar))
else
mname2 = " "
end if
if trim(Request.Form(lnameVar)) <> "" then
lname2 = trim(Request.Form(lnameVar))
else
lname2 = " "
end if
if trim(Request.Form(rankVar)) ="ProfSponsoredPowerChair" then
rank = 20
else if trim(Request.Form(rankVar)) = "ProfDeptChair" then
rank = 21
else if trim(Request.Form(rankVar)) = "prof" then
rank = 22
else if trim(Request.Form(rankVar)) = "AsscProf" then
rank = 23
else if trim(Request.Form(rankVar)) = "AsstProf" then
rank = 24
else if trim(Request.Form(rankVar)) = "Emeritus" then
rank = 36
else if trim(request.form(rankVar)) = "Lecturer" then
rank=37
else
rank = 19
end if
end if
end if
end if
end if
end if
end if
if trim(Request.Form(highestDegreeVar)) ="bachelor" then
degree =26
else if trim(Request.Form(highestDegreeVar)) = "master" then
degree =27
else if trim(Request.Form(highestDegreeVar))= "Professional" then
degree= 28
else if trim(Request.Form(highestDegreeVar)) = "PhD" then
degree = 29
else
degree = 25
end if
end if
end if
end if
if trim(Request.Form(PESGradeVar))= "member" then
PESgrade = 31
else if trim(Request.Form(PESGradeVar)) = "senior" then
PESgrade = 32
else if trim(Request.Form(PESGradeVar)) = "fellow" then
PESgrade=33
else if trim(Request.Form(PESGradeVar)) = "lifemember" then
PESgrade = 34
else
PESgrade = 35
end if
end if
end if
end if
if trim(Request.Form(PERegVar))= "yes" then
PEREG = 1
else
PEReg= 0
end if
if trim(Request.Form(academicVar)) <> "" then
EXPACD = cint(Request.Form(academicVar))
else
EXPACD = 0
end if
if trim(Request.Form(powerIndustryVar)) <> "" then
EXPIND = cint(Request.Form(powerIndustryVar))
else
EXPIND = 0
end if
if trim(Request.Form(otherIndustryVar)) <> "" then
EXPOTHERIND = cint(Request.Form(otherIndustryVar))
else
EXPOTHERIND = 0
end if
if trim(Request.Form(powerTVar)) <> "" then
ACTPOWERTEACHING = cint(Request.Form(powerTVar))
else
ACTPOWERTEACHING = 0
end if
if trim(Request.Form(powerRVar)) <> "" then
ACTPOWERRESEARCH = cint(Request.Form(powerRVar))
else
ACTPOWERRESEARCH = 0
end if
if trim(Request.Form(nonpowerVar)) <> "" then
ACTNONPOWER = cint(Request.Form(nonpowerVar))
else
ACTNONPOWER = 0
end if
'check if the same person has been entered
sqlQuery = "select * from tbl_IEEE_faculty where FAFNAME='"&fname2&"' and FAMNAME='"&mname2&"'"
sqlQuery = sqlQuery & " and FALNAME='"&lname2&"' and FACNID="&cint(rank)&" and FACNID2="&cint(degree)
sqlQuery = sqlQuery &" and FAREID="&cint(session(reportID))&" and FAID < " & facID
set RSbuffer = conn.Execute(sqlQuery)
if RSbuffer.eof=false then 'the person has been entered before by this user in the same period
alert("Error: you have entered more than one of the same data")
exit for
Response.Redirect("survey02.asp")
end if
if facId <= maxFaId then
'update old values
if trim(fname2) <> "" and trim(lname2) <> "" then
sqlQuery = "update tbl_IEEE_Faculty set FAFNAME ='"& fname2
sqlQuery = sqlQuery &"', FAMNAME='"& mname2
sqlQuery = sqlQuery&"', FALNAME='"& lname2
sqlQuery = sqlQuery&"', FACNID ="&cint(rank)&", FACNID2="&CINT(degree) &",FACNID3="&cint(PESGRADE)
sqlQuery = sqlQuery&", FAPEREG ="& PEREG
sqlQuery = sqlQuery&",FAEXPACD="& EXPACD
sqlQuery = sqlQuery&",FAEXPIND="& EXPIND
sqlQuery = sqlQuery&",FAEXPOTHERIND="& EXPOTHERIND
sqlQuery = sqlQuery&",FAACTPOWERTEACHING="& ACTPOWERTEACHING
sqlQuery = sqlQuery&",FAACTPOWERRESEARCH="& ACTPOWERRESEARCH
sqlQuery = sqlQuery&",FAACTNOPOWER="& ACTNONPOWER &" where FAID="&facID
Response.Write sqlQuery
conn.Execute(sqlQuery)
'facID = facID+1
'else 'user delete a faculty
' sqlQuery = "delete from tbl_IEEE_faculty where FAID="&facID
'Response.Write sqlQuery
' conn.execute(sqlQuery)
end if
else
if trim(Request.Form(fnameVar))<> "" and trim(Request.Form(lnameVar)) <> "" then
'do insertion for new values
sqlQuery = "insert into tbl_IEEE_faculty(FAREID,FAFNAME,FAMNAME,FALNAME,FACNID,FACNID2,FACNID3"
sqlQuery = sqlQuery&",FAPEREG,FAEXPACD,FAEXPIND,FAEXPOTHERIND,FAACTPOWERTEACHING,FAACTPOWERRESEARCH,FAACTNOPOWER) values "
sqlQuery = sqlQuery&"("&reportID&",'"&fname2&"','"&mname2
sqlQuery = sqlQuery&"','"&lname2&"',"&cint(rank)&","&CINT(degree)&","&CINT(PESGRADE)
sqlQuery = sqlQuery&","&PEREG&","& EXPACD
sqlQuery = sqlQuery&","&EXPIND&","&EXPOTHERIND
sqlQuery = sqlQuery&","&ACTPOWERTEACHING&","&ACTPOWERRESEARCH&","&ACTNONPOWER&")"
Response.Write sqlQuery
conn.Execute(sqlQuery)
end if
end if 'end of facId <= maxFaId then
next
if decision="move" then
'update trackpage number
goToPage = cint(Request.Form("goToPage"))
'pass these vars to the processing part
session("userID")=cint(userID)
session("reportID")=cint(reportID)
if goToPage = 3 then
sqlQuery = "update tbl_IEEE_report set RETRACK = 3 where REID="&reportID
Response.Write sqlQuery
conn.Execute(sqlQuery)
Response.Redirect("survey03.asp")
else if goToPage=2 then
Response.Redirect("survey02.asp")'to save without exiting
else if goToPage =1 then
Response.Redirect("survey01.asp")
else if goToPage =4 then
Response.Redirect("survey04pre.asp")
else if goToPage =5 then
Response.Redirect("survey05.asp")
else if goToPage=7 then
Response.Redirect("survey02pre.asp?msg=change")
end if
end if
end if
end if
end if
end if
else if decision="exit" then
session("userID") = ""
session("reportID") = ""
response.redirect("surveyLogin.asp")
end if
end if
end if 'end of decision = "delete"
end if
set RSbuffer= nothing
set conn = nothing
%>