/asp/freeapps/pollmentor/include_classes.asp
<%
''''''''''' (C) Stefan Holmberg 1999 - 2006
''''''''''' Free to use if these sourcecode lines is not deleted
''''''''''' http://www.aspcode.net
Dim TheContext
Set TheContext = new Context
Class Context
Private m_AllPolls
Sub Class_Initialize()
set m_AllPolls = Nothing
End Sub
Sub Class_Terminate()
set m_AllPolls = Nothing
End Sub
Public Property Get AllPolls()
If m_AllPolls Is Nothing Then
Set m_AllPolls = Server.CreateObject ("Scripting.Dictionary")
Dim oRSFarms
Dim oZone
Dim oConn
Set oConn = PollMentor_GetDatabaseConn()
Set oRSFarms = oConn.Execute("select * from [" & Poll_GetTablePrefix() & "poll]" )
While Not oRSFarms.EOF
Set oZone = new Poll
oZone.InitFromRS( oRSFarms )
oRSFarms.MoveNext
m_AllPolls.Add oZone.Id, oZone
Wend
oRSFarms.Close
Set oRSFarms = Nothing
End If
oConn.Close
Set oConn = Nothing
Set AllPolls = m_AllPolls
End Property
End Class
Class Poll
Private m_Id
Private m_Question
Private m_Answer1
Private m_Count1
Private m_Answer2
Private m_Count2
Private m_Answer3
Private m_Count3
Private m_Answer4
Private m_Count4
Private m_Answer5
Private m_Count5
Private m_Answer6
Private m_Count6
Private m_Answer7
Private m_Count7
Private m_Answer8
Private m_Count8
Private m_CreatedWhen
Private m_Active
Public Property Get Id()
Id = m_Id
End Property
Public Property Get Total()
Total = CInt(Count1) + CInt(Count2) + CInt(Count3)+ CInt(Count4)+ CInt(Count5)+ CInt(Count6)+ CInt(Count7)+ CInt(Count8)
If Total = 0 Then
Total = 1
End If
End Property
Public Property Get MaxValue()
MaxValue = 1
If Count1 > MaxValue Then
MaxValue = Count1
End If
If Count2 > MaxValue Then
MaxValue = Count2
End If
If Count3 > MaxValue Then
MaxValue = Count3
End If
If Count4 > MaxValue Then
MaxValue = Count4
End If
If Count5 > MaxValue Then
MaxValue = Count5
End If
If Count6 > MaxValue Then
MaxValue = Count6
End If
If Count7 > MaxValue Then
MaxValue = Count7
End If
If Count8 > MaxValue Then
MaxValue = Count8
End If
End Property
Public Property Get Question()
Question = m_Question
End Property
Public Property Get Answer1()
Answer1 = m_Answer1
End Property
Public Property Get Count1()
Count1 = m_Count1
End Property
Public Property Get Answer2()
Answer2 = m_Answer2
End Property
Public Property Get Count2()
Count2 = m_Count2
End Property
Public Property Get Answer3()
Answer3 = m_Answer3
End Property
Public Property Get Count3()
Count3 = m_Count3
End Property
Public Property Get Answer4()
Answer4 = m_Answer4
End Property
Public Property Get Count4()
Count4 = m_Count4
End Property
Public Property Get Answer5()
Answer5 = m_Answer5
End Property
Public Property Get Count5()
Count5 = m_Count5
End Property
Public Property Get Answer6()
Answer6 = m_Answer6
End Property
Public Property Get Count6()
Count6 = m_Count6
End Property
Public Property Get Answer7()
Answer7 = m_Answer7
End Property
Public Property Get Count7()
Count7 = m_Count7
End Property
Public Property Get Answer8()
Answer8 = m_Answer8
End Property
Public Property Get Count8()
Count8 = m_Count8
End Property
Public Property Get CreatedWhen()
CreatedWhen = m_CreatedWhen
End Property
Public Property Get Active()
Active = m_Active
End Property
Public Function Open(nId)
Dim sRet, strSQL
Dim oConn, oRS, nCount
Dim strTrue
Dim strFalse
If PollMentor_GetDatabaseType = "SQLServer" Then
strTrue = "1"
strFalse = "0"
Else
strTrue = "True"
strFalse = "False"
End If
Set oConn = PollMentor_GetDatabaseConn()
strSQL = "select * from " & Poll_GetTablePrefix() & "poll where "
If nID = -1 Then
strSQL = strSQL & " active=" & strTrue
Else
strSQL = strSQL & " id=" & nID
End If
Set oRS = oConn.Execute(strSQL)
If oRS.EOF Then
Open = False
Else
InitFromRS(oRS)
Open = True
End If
oRS.Close
Set oRS = Nothing
oConn.Close
Set oConn = Nothing
End Function
Public Sub InitFromRS(oRS)
m_Id = oRS("id")
m_Question = oRS("Question")
m_Answer1 = oRS("Answer1")
m_Count1 = oRS("Count1")
m_Answer2 = oRS("Answer2")
m_Count2= oRS("Count2")
m_Answer3 = oRS("Answer3")
m_Count3 = oRS("Count3")
m_Answer4 = oRS("Answer4")
m_Count4 = oRS("Count4")
m_Answer5 = oRS("Answer5")
m_Count5 = oRS("Count5")
m_Answer6 = oRS("Answer6")
m_Count6 = oRS("Count6")
m_Answer7 = oRS("Answer7")
m_Count7 = oRS("Count7")
m_Answer8 = oRS("Answer8")
m_Count8 = oRS("Count8")
m_CreatedWhen = oRS("createdwhen")
m_active = oRS("active")
End Sub
End Class
%>