<!-- #include file="../BBR_BodyTop.asp" -->

<%
on error goto 0
dim req_newsid,req_newsclassid,req_newstitle,rsNews
dim newstitle,newsclassid,newsupdatetime,newsviewtimes,newscontent
req_newsid=checkstr(request.querystring("newsid"))
req_newsclassid=checkstr(request.querystring("newsclassid"))
req_newstitle=checkstr(request.querystring("newstitle"))
if not isNum(req_newsid) then req_newsid=0
if not isNum(req_newsclassid) then req_newsclassid=0
if clng(req_newsid)>0 then
	sql="update cnBBR_news set newsviewtimes=0 where newsviewtimes is null"
	conn.execute(sql)
	sql="select * from cnBBR_news where newsid="& req_newsid
	set rsNews=conn.execute(sql)
	if rsNews.eof or rsNews.bof then
		call AlertInfo("未找到此文章！返回...","bbr_news.asp",1)
	else
		newstitle=rsNews("newstitle")
		newsclassid=rsNews("newsclassid")
		newsupdatetime=rsNews("updatetime")
		newsviewtimes=clng(rsNews("newsviewtimes"))+1
		newscontent=unCheckStr(rsNews("newscontent"))
	end if	
	rsNews.close
	set rsNews=nothing
	
	sql="update cnBBR_news set newsviewtimes=newsviewtimes+1 where newsid="& req_newsid
	conn.execute(sql)
else
	newsclassid=req_newsclassid
	
	'默认的页面显示信息量
	dim DefaultPageSize
	DefaultPageSize=20

	'默认的显示样式,0为列表，1为图片
	dim DefaultDisplayStyle
	DefaultDisplayStyle=1

	dim act,resultStr,RecordsDataArray
	act=Checkstr(Request.Form("act"))

	'信息分页显示
	dim SqlNowPage,SqlPageSize
	SqlPageSize=defaultPageSize

	dim SqlStr,SqlTableName,SqlField_ID,SqlWhereStr,SqlInnerOrderStr,SqlOuterOrderStr,SqlOrderDirection
	SqlTableName="cnBBR_News"
	SqlField_ID="newsid"	'自增字段
	SqlWhereStr=""
	SqlOrderDirection="desc"
	SqlInnerOrderStr=" order by "& SqlField_ID &" "& SqlOrderDirection
	SqlOuterOrderStr=" order by "& SqlField_ID &" "& oppOrderDirection(SqlOrderDirection)
	if req_newstitle<>"" then SqlWhereStr=SqlWhereStr &" and newstitle like '%"& req_newstitle &"%'"
	if clng(req_newsclassid)>0 then SqlWhereStr=SqlWhereStr &" and newsclassid="&  req_newsclassid
	'ConnOpen()
	dim CountSqlStr,rsCountTotal,TotalRecordCount,TotalPages
	CountSqlStr="select count("& SqlField_ID &") as c from "& SqlTableName &" where "& SqlField_ID &">0 "& SqlWhereStr
	set rsCountTotal=Conn.execute(CountSqlStr)
	TotalRecordCount=rsCountTotal(0)
	rsCountTotal.Close
	set rsCountTotal=nothing
	if not isNum(TotalRecordCount) then TotalRecordCount=0
	if TotalRecordCount<=0 then
	   TotalPages=0
	else
	   TotalPages=TotalRecordCount\SqlPageSize
	   if (TotalRecordCount mod SqlPageSize)>0 then TotalPages=TotalPages+1
	end if

	dim tempSelectedRecords,tempReadDirection
	SqlNowPage=returnValidPage(CheckStr(Request("Page")),totalPages)

	if Clng(SqlNowPage)<=Clng(TotalPages\2) then
	   tempReadDirection=1
	   tempSelectedRecords=abs(SqlNowPage*SqlPageSize)
	   if tempSelectedRecords<SqlPageSize then tempSelectedRecords=SqlPageSize
	   SqlStr="select top "& SqlPageSize &" * from "& SqlTableName &" where "& SqlField_ID &" in (select top "& TempSelectedRecords &" "& SqlField_ID &" from "& SqlTableName &" where "& SqlField_ID &">0 "& SqlWhereStr & SqlInnerOrderStr &")"& SqlOuterOrderStr
	else
	   tempReadDirection=-1
	   tempSelectedRecords=abs((TotalPages-SqlNowPage)*SqlPageSize+(TotalRecordCount mod SqlPageSize))
	   if tempSelectedRecords<SqlPageSize then tempSelectedRecords=SqlPageSize
	   SqlInnerOrderStr=" order by "& SqlField_ID &" "& oppOrderDirection(SqlOrderDirection)
	   SqlOuterOrderStr=" order by "& SqlField_ID &" "& SqlOrderDirection
	   SqlStr="select top "& SqlPageSize &" * from "& SqlTableName &" where "& SqlField_ID &" in (select top "& TempSelectedRecords &" "& SqlField_ID &" from "& SqlTableName &" where "& SqlField_ID &">0 "& SqlWhereStr & SqlInnerOrderStr &")"& SqlOuterOrderStr
	end if
	Set rs=Conn.execute(sqlStr)
	if not(rs.eof or rs.bof) then RecordsDataArray=rs.GetRows
	rs.close
	set rs=nothing

	function DisplayRecords(ByVal DataArray,ByVal readDirection)
	  dim i,j,readBegin,readEnd,readstep
	  dim RecordsStr
	  if isArray(DataArray) then
		'显示信息分类列表
		RecordsStr=RecordsStr & "<table id=""infoli"" width=""98%"" cellpadding=""0"" cellspacing=""0"" align=""center"" border=""0"">"& Vbcrlf
		' 确定数组读取方向顺序
		if readDirection=1 then
		   readBegin=UBound(DataArray, 2)
		   readEnd=0
		   readstep=-1
		else
		   readBegin=0
		   readEnd=UBound(DataArray, 2)
		   readstep=1
		end if
		   
		for i = readBegin To readEnd step readstep
			' 每一列
				RecordsStr=RecordsStr & "<tr>" & vbcrlf
				RecordsStr=RecordsStr & "<td style=""height: 28px; line-height: 28px; padding: 0px 0px 0px 20px; background: #FFFFFF url('/img/liNav.gif') no-repeat 0px 6px; border-bottom: 1px #C0D0E6 dashed; text-align: left"">"& Vbcrlf
				RecordsStr=RecordsStr & " <a href="""& PageParams("newsclassid",DataArray(7,i)) &"&newsid="& DataArray(0,i) &""" style=""color: "& DataArray(4,i) &""">"& DataArray(1,i) &"</a>"& Vbcrlf
				RecordsStr=RecordsStr & "</td>"
				RecordsStr=RecordsStr & "</tr>" & vbcrlf
		next
		RecordsStr=RecordsStr & "</table>"
	  else
		RecordsStr=RecordsStr & "<div style=""height: 58px; font-size: 9pt; line-height: 58px; border: 1px solid #DFDFEF; padding: 0px 8px 0px 8px; background: #FCFCF9; text-align: center;"">没有找到相关记录</div>"& Vbcrlf
	  end if
	  DisplayRecords=RecordsStr
	end function
end if

function displayNewsLeftBar(byval curClassID)
	if NewsClassValueStr<>"" then
		dim arrNewsClassIDs,arrNewsClassNames,cirNewsClassi,curClassIDStr
		arrNewsClassIDs=NewsClassValueStr
		arrNewsClassIDs=replace(arrNewsClassIDs,"，",",")
		arrNewsClassIDs=split(arrNewsClassIDs,",")
		arrNewsClassNames=NewsClassStr
		arrNewsClassNames=replace(arrNewsClassNames,"，",",")
		arrNewsClassNames=split(arrNewsClassNames,",")
		if isNull(curClassID) then curClassID=0
		if ubound(arrNewsClassIDs)=ubound(arrNewsClassNames) then
			for cirNewsClassi=0 to ubound(arrNewsClassIDs)
				curClassIDStr=""
				if clng(trim(arrNewsClassIDs(cirNewsClassi)))=clng(curClassID) then curClassIDStr="class=""li_active"""
				response.write "<li><a "& curClassIDStr &" href=""bbr_news.asp?newsclassid="& trim(arrNewsClassIDs(cirNewsClassi)) &""">"& arrNewsClassNames(cirNewsClassi) &"</a></li>"& vbcrlf
			next
		end if
	end if
end function

dim newsclassname
newsclassname=selecter("",req_newsclassid,NewsClassValueStr,NewsClassStr)
if newsclassname<>"" then BBR_PageTitle=newsclassname &" -"& BBR_PageTitle
if newstitle<>"" then BBR_PageTitle=newstitle &" - "& BBR_PageTitle
if BBR_PageTitle="" then BBR_PageTitle="新闻与公告"
response.write Cnbbr_Head
%>

<div class="wbox" style="background: #F6F9FE; overflow: hidden; zoom:1">
	<div class="left">
		<div class="articlelist_logo">
			<div class="articlelist_logo_left"><a target="_blank" href="./"><img src="<%=SYS_SetupDirectory%>images/shoplogo.gif" alt="<%=SYS_WEBName%>"/></a></div>
			<div class="articlelist_logo_right articlelist_logo_right_width">
				<h5 class="font_weight"><a href="<%=SYS_SetupDirectory%>" target="_blank"><%=SYS_WEBName%></a></h5>
				<p>新闻与公告</p>
			</div>
			<div class="clear"></div>
		</div>
		<div class="articlelist_kind articlelist_kind_height">
			<ul><%=displayNewsLeftBar(newsclassid)%></ul>
			<div class="clear"></div>
		</div>
    </div>
    <div class="right">
      	<div class="container">
			<%
			if clng(req_newsid)>0 then
			%>
			<h2 style="line-height: 26px; text-indent: 10px; background: #FAFCFF;"><%=newstitle%></h2>
			<div style="width:100%; height:38px; line-height:38px; text-align:right">点击次数：<%=newsviewtimes%>次 &nbsp; 更新时间：<%=newsupdatetime%> &nbsp; </div>
			<div class="articlelist_content" id="articlelist_content">
				<!--  content begin -->
				<%=newscontent%>
				<!--  content end -->
				<p>&nbsp;</p>
				<p>&nbsp;</p>
				<p>&nbsp;</p>
			</div>
			<%
			else
					'显示信息分页
					if newsclassname="" then
						newsclassname="所有信息"
					else
						newsclassname="当前分类："& newsclassname
					end if
					
					response.write DisplayPageBar("page",SqlNowPage,totalRecordCount,totalPages,newsclassname,1)
					response.write DisplayRecords(RecordsDataArray,tempReadDirection)
					response.write DisplayPageBar("page",SqlNowPage,totalRecordCount,totalPages,"",1)
			end if
			%>
		</div>
    </div>
	<div class="clear"></div>
</div>
<%
response.write Cnbbr_Bottom
%>
