%@ Language=VBScript %>
<% Option Explicit %>
<%
'Open connection string using App variable
Dim sConn, con, ProjID, sFilter
sConn=Application("TMAConnectString")
Set con=Server.CreateObject("ADODB.Connection")
con.ConnectionString=sConn
con.Open
Const MaxPerPage=10
ProjID=Session("ProjID")
sFilter=Request("Filter")
Function QAGrabber(str,MaxChars,QAType)
QAGrabber=iif(Len(str)<=MaxChars, str, Left(str, InStr(MaxChars, str & " ", " ")))
If Len(str) >= MaxChars then 'add ellipses
If QAType="Q" then
If Right(str,1) = "?" then
QAGrabber=Left(QAGrabber,Len(QAGrabber)-1) & "...?"
Else
QAGrabber=QAGrabber & "..."
End If
Else
QAGrabber=QAGrabber & "..."
End If
End If
End Function
%>
The Modular Advantage: Client Area
<%
'Create a recordset object instance and retrieve the information from the table
Dim rs, SQL, sTitle, sLink, intPage
intPage=Request.QueryString("Page")
If intPage="" or intPage=0 then
'If Len(intPage<1) or intPage=0 then
intPage=1
Else
intPage=Cint(Request.QueryString("Page"))
End If
'Open the main recordset
Set rs = Server.CreateObject("ADODB.Recordset")
rs.CursorType = adOpenStatic
rs.CursorLocation = adUseClient
rs.LockType = adLockPessimistic
SQL="SELECT * FROM Questions " _
& "WHERE ProjectID=" & ProjID & " "
If sFilter="unans" then 'select unanswered questions only
sTitle="View Unanswered Questions"
SQL=SQL & "AND Answer is Null "
sLink="View All Questions"
Else
sTitle="View All Questions"
sLink="View Unanswered Questions Only"
End If
SQL=SQL & "ORDER BY Type, QuestionDate DESC"
rs.Open SQL, con
If rs.EOF then
Response.Write("
")
Else
'Count the number of records & determine number of pages
Dim intRecCount, intID, intNumPages, sngDiv, intCnt
QAClass="#FFFFFF"
intRecCount=rs.RecordCount
sngDiv=intRecCount/MaxPerPage
intNumPages=Fix(sngDiv)
If (intNumPages-sngDiv) < 0 then
intNumpages=intNumPages+1
End If
%>
<% 'Top page numbers %>
Go to page:
<%
For intCnt=1 to intNumPages
If intCnt=intPage then
%>
<%=intCnt%>
<%
Else
%>
<%=intCnt%>
<%
End If
Next
%>
(10 questions per page)
<%=intRecCount%> questions currently in database
Type
Date
Posted
Question
Date
Answered
Answer
<%
Dim QAClass
QAClass="QAWhite"
'Fix number of Questions to list per page by setting up for/next loop or count. Check to see if EOF within loop.
Dim intQuestionCount, intPageNum, intLoopCnt, intFirstQuestion, sQuestion, sAnswer
intQuestionCount=0
intPageNum=intPage
intLoopCnt=0
'Look for starting Question, based on page number
If intPageNum=1 then
intFirstQuestion=0
Else
intFirstQuestion=(intPageNum-1)*MaxPerPage
For intLoopCnt=1 to intFirstQuestion
rs.MoveNext
Next
End If
Do While Not (rs.EOF or intQuestionCount=MaxPerPage)
sQuestion=QAGrabber(rs("Question"),50,"Q")
sAnswer=QAGrabber(rs("Answer"),50,"A")
%>
<%
rs.MoveNext
If QAClass="QAWhite" then
QAClass="QAGray"
Else
QAClass="QAWhite"
End If
%>
<%
intQuestionCount=intQuestionCount+1
Loop
%>
<% 'Top page numbers %>
Go to page:
<%
For intCnt=1 to intNumPages
If intCnt=intPage then
%>
<%=intCnt%>
<%
Else
%>
<%=intCnt%>
<%
End If
Next
%>
(10 Questions per page)