<!-- #include file=../inc/BBSsetup.asp -->
<!-- #include file=../inc/Board_Popfun.asp -->
<!-- #include file=../inc/Limit_fun.asp -->
<%
DEF_BBS_HomeUrl = "../"
initDatabase
CheckisBoardMaster
CheckAccessLimit
'GBL_CHK_TempStr = ""

SiteHead("   " & DEF_SiteNameString & " - 购买人员")

If GBL_CHK_Flag=1 and GBL_CHK_TempStr = "" Then
	PollUserList
Else
	If Request("submitflag")="" Then
		Response.Write "<br><b>请先登录</b>"
	Else
		Response.Write "<br><p align=left><font color=ff0000 class=RedFont><b>" & GBL_CHK_TempStr & "</b></font>"
	End If
	Response.Write "</p>"
End If

closeDataBase
SiteBottom_Spend

Function PollUserList

	Dim AnnounceID
	AnnounceID = Left(Request("AnnounceID"),14)
	If AnnounceID = "" or isNumeric(AnnounceID) = 0 Then AnnounceID = 0
	AnnounceID = cCur(AnnounceID)
	If AnnounceID = 0 then Exit Function

	Dim Rs,SQL

	GBL_CHK_TempStr=""
	Dim UpDownPageFlag
	UpDownPageFlag = Request("UpDownPageFlag")

	Dim Start,recordCount,key
	recordCount=0
	
	Dim SQLendString

	Start = Left(Trim(Request("Start")),14)
	Start = start
	If isNumeric(Start)=0 or Start="" Then Start=999999999
	Start = cCur(Start)
	If Start = 0 Then Start=999999999

	Dim SQLCountString,whereFlag

	whereFlag = 1
	SQLendString = " where T1.AnnounceID=" & AnnounceID

	SQLCountString = SQLendString
	If UpDownPageFlag = "1" and Start>0 then
		If whereFlag = 1 Then
			SQLendString = SQLendString & " and T1.ID>" & Start
		Else
			SQLendString = SQLendString & " where T1.ID>" & Start
			whereFlag = 1
		End If
	Else
		If whereFlag = 1 Then
			SQLendString = SQLendString & " and T1.ID<" & Start
		Else
			SQLendString = SQLendString & " where T1.ID<" & Start
			whereFlag = 1
		End If
	end If

	If UpDownPageFlag = "1" then
		SQLendString = SQLendString & " Order by T1.ID ASC"
	Else
		SQLendString = SQLendString & " Order by T1.ID DESC"
	End If
	
	Dim MaxRecordID,MinRecordID
	MaxRecordID = 0

	SQL = "select Max(T1.id) from LeadBBS_VoteUser as T1 " & SQLCountString
	Set Rs = Con.ExeCute(SQL)
	GBL_DBNum = GBL_DBNum + 1
	
	If not Rs.Eof Then
		If Rs(0) <> "" Then
			MaxRecordID = cCur(Rs(0))
		Else
			MaxRecordID = 0
		End If
	End If
	Rs.Close
	Set Rs = Nothing
	
	SQL = "select Min(T1.id) from LeadBBS_VoteUser as T1 " & SQLCountString
	Set Rs = Con.ExeCute(SQL)
	GBL_DBNum = GBL_DBNum + 1

	If not Rs.Eof Then
		If Rs(0) <> "" Then
			MinRecordID = cCur(Rs(0))
		else
			MinRecordID = 0
		end If
	End If
	Rs.Close
	Set Rs = Nothing

	Dim FirstID,LastID	
	SQL = "select top 1 PollNum,BoardID from LeadBBS_Announce where ID=" & AnnounceID
	Set Rs = Con.ExeCute(SQL)
	GBL_DBNum = GBL_DBNum + 1
	if rs.eof then
		recordCount=0
	else
		If cCur(Rs(1)) <> GBL_Board_ID Then
			Rs.Close
			Set Rs = Nothing
			Response.Write "错误的提交。"
			Exit Function
		End If
		recordCount=rs(0)
		if recordCount="" or isNull(recordCount) or len(recordCount)<1 Then recordCount=0
		recordCount = cCur(recordCount)
	End If
	Rs.Close
	Set Rs = Nothing
	
	SQL = "select TOP "&DEF_MaxListNum&" T1.ID,T1.UserName,T1.VoteItem from LeadBBS_VoteUser as T1 " & SQLendString
	Set Rs = Con.ExeCute(SQL)
	GBL_DBNum = GBL_DBNum + 1
	Dim Num
	Dim GetData
	If Not rs.Eof Then
		GetData = Rs.GetRows(-1)
		Num = Ubound(GetData,2)
	Else
		Num = -1
	End If
	Rs.close
	Set Rs = Nothing	
	
	Dim i,N
	If Num>=0 Then
		i=1
	
		Dim MinN,MaxN,StepValue
		SQL = ubound(getdata,2)
		If UpDownPageFlag = "1" then
			MinN = SQL
			MaxN = 0
			StepValue = -1
		Else
			MinN = 0
			MaxN = SQL
			StepValue = 1
		End If
		
		LastID = cCur(GetData(0,MaxN))
		FirstID = cCur(GetData(0,MinN))
	
		Dim EndwriteQueryString,PageSplictString
		EndwriteQueryString = "?AnnounceID=" & AnnounceID & "&BoardID=" & GBL_Board_ID
	
		PageSplictString = PageSplictString & "<table><tr><td>&nbsp;"
		If FirstID >= MaxRecordID Then
			PageSplictString = PageSplictString & "<font color=999999>首页</font> " & VbCrLf
			PageSplictString = PageSplictString & " <font color=999999>上页</font> " & VbCrLf
		else
			PageSplictString = PageSplictString & "<a href=BuyUser.asp" & EndwriteQueryString & "&Start=0>首页</a> " & VbCrLf
			PageSplictString = PageSplictString & " <a href=BuyUser.asp" & EndwriteQueryString & "&Start=" & FirstID & "&UpDownPageFlag=1>上页</a> " & VbCrLf
		end if
	
		if LastID<MaxRecordID and LastID<>0 then
		else
		end if
	
		If LastID <= MinRecordID Then
			PageSplictString = PageSplictString & " <font color=999999>下页</font> " & VbCrLf
			PageSplictString = PageSplictString & " <font color=999999>尾页</font> " & VbCrLf
		else
			PageSplictString = PageSplictString & " <a href=BuyUser.asp" & EndwriteQueryString & "&Start=" & LastID & ">下页</a> " & VbCrLf
			PageSplictString = PageSplictString & " <a href=BuyUser.asp" & EndwriteQueryString & "&Start=1&UpDownPageFlag=1>尾页</a> " & VbCrLf
		end if
		
		PageSplictString = PageSplictString & "&nbsp;共<b>" & recordCount & "</b>人"
		If (recordCount mod DEF_MaxListNum)=0 Then
			PageSplictString = PageSplictString & " 计<b>" & clng(recordCount/DEF_MaxListNum) & "</b>页"
		Else
			If recordCount>=DEF_MaxListNum Then
				SQL = fix(recordCount/DEF_MaxListNum)
				If (recordCount mod DEF_MaxListNum) <> 0 Then SQL = SQL + 1
				PageSplictString = PageSplictString & " 计<b>" & SQL & "</b>页"
			Else
				PageSplictString = PageSplictString & " 计<b>1</b>页"
			End If
		End If
		PageSplictString = PageSplictString & " 每页<b>" & DEF_MaxListNum & "</b>人"
		PageSplictString = PageSplictString & "</td></tr></table>"
	
	End If

	%>
	<table cellspacing=0 cellpadding=0 width=100% border=0 height=5>
	<tr> 
		<td colspan="2" height="0"><img src="../images/BLANK.GIF" width="1" height="2"></td>
	</tr>
	</table>
	<%Response.Write "<b>共<font color=ff0000 class=RedFont>" & recordCount & "</font>个人购买了此帖</b>"%>
	<table width="100%" border="0" cellspacing="1" cellpadding="0" bordercolor="#000000" bgcolor=<%=DEF_BBS_Color%> class=TBone>
	  <tbody>
	  <tr height="19" bgcolor="<%=DEF_BBS_TableHeadColor%>" class=TBfour>
	    <td><img src=img/blank.gif width=1 height=3><br>&nbsp;购买人&nbsp;</td>
	    <td><img src=img/blank.gif width=1 height=3><br>&nbsp;花费&nbsp;</td>
	  </tr>
	<%
	If Num = -1 Then
		response.write "<tr bgcolor=" & DEF_BBS_LightestColor & "><td colspan=5 height=30 class=TBBG9>&nbsp; 没有任何人购买此帖!</td></tr>"
	end if
	
	
	Dim TempN

	if Num <> -1 then
		i=1
		LastID = GetData(0,ubound(getdata,2))
		for n= MinN to MaxN Step StepValue
			Response.Write "<tr height=19 bgcolor=" & DEF_BBS_LightestColor & " class=TBBG9><td width=25% valign=top><img src=../images/BLANK.GIF width=1 height=2><br>&nbsp;"
			Response.Write "<a href=../User/LookUserInfo.asp?Name=" & urlencode(GetData(1,n)) & " target=_blank>" & GetData(1,n) & "</a>" & VbCrLf
			Response.Write "</td>"
			Response.Write "<td width=75% >&nbsp;" & htmlencode(GetData(2,n)) & "</td>"
			Response.Write "</tr>" & VbCrLf
			i=i+1
		next
	End If
	If PageSplictString<>"" Then Response.Write "<tr bgcolor=" & DEF_BBS_TableHeadColor & " class=TBfour><td colspan=5>" & PageSplictString & "</td></tr>"
	%>
	      </table>
	<br><%

End Function%>