<%
Function MakeAnnounceTop(AnnounceID)

	Dim Rs,SQL,BoardID,RootID,MaxRootID,RootIDBak
	SQL = "Select top 1 ID,RootID,BoardID,ID from LeadBBS_Topic where ID=" & AnnounceID
	Set Rs = Con.ExeCute(SQL)
	GBL_DBNum = GBL_DBNum + 1
	If Not Rs.Eof Then
		RootID = cCur(Rs(1))
		BoardID = cCur(Rs(2))
		RootIDBak = cCur(Rs(3))
		Rs.Close
		Set Rs = Nothing
	Else
		Rs.Close
		Set Rs = Nothing
		Exit function
	End If

	If RootID<DEF_BBS_TOPMinID Then
		Set Rs = Con.ExeCute("Select Max(RootID) from LeadBBS_Topic where BoardID=" & BoardID & " and RootID<" & DEF_BBS_TOPMinID)
		GBL_DBNum = GBL_DBNum + 1
		If Rs.Eof Then
			MaxRootID = 1
		Else
			MaxRootID = Rs(0)
			If isNull(MaxRootID) or MaxRootID="" Then
				MaxRootID=1
			End If
			MaxRootID = cCur(MaxRootID)
		End If
		Rs.Close
		Set Rs = Nothing
	 	Con.ExeCute(" Update LeadBBS_Announce Set RootID=" & MaxRootID+1 & " where ID=" & RootIDBak)
	 	Con.ExeCute(" Update LeadBBS_Topic Set RootID=" & MaxRootID+1 & " where ID=" & RootIDBak)
	 	GBL_DBNum = GBL_DBNum + 2
	End If
	UpdateBoardValue(BoardID)

End Function

Function UpdateBoardValue(BoardID)

	Dim Rs,SQL
	Dim N,AllMinRootID,AllMaxRootID		
	Set Rs = Con.ExeCute("select Min(RootID) from LeadBBS_Topic where BoardID=" & BoardID)
	GBL_DBNum = GBL_DBNum + 1
	If Rs.Eof Then
		AllMinRootID = 0
	Else
		AllMinRootID = Rs(0)
		If isNull(AllMinRootID) Then AllMinRootID = 0
		AllMinRootID = cCur(AllMinRootID)
	End If
	Rs.Close
	Set Rs = Nothing

	Set Rs = Con.ExeCute("select Max(RootID) from LeadBBS_Topic where BoardID=" & BoardID)
	GBL_DBNum = GBL_DBNum + 1
	If Rs.Eof Then
		AllMaxRootID = 0
	Else
		AllMaxRootID = Rs(0)
		If isNull(AllMaxRootID) Then AllMaxRootID = 0
		AllMaxRootID = cCur(AllMaxRootID)
	End If
	Rs.Close
	Set Rs = Nothing
	Con.ExeCute ("Update LeadBBS_Boards Set AllMinRootID=" & AllMinRootID & ",AllMaxRootID=" & AllMaxRootID & " where boardID=" & BoardID)
	UpdateBoardApplicationInfo BoardID,AllMinRootID,12
	UpdateBoardApplicationInfo BoardID,AllMaxRootID,11
	GBL_DBNum = GBL_DBNum + 1

End Function
%>