<!--#include file="Inc.asp"-->
<!--#include file="ydzq.asp"-->
<%
call head()
%>

<%

	IF  Request.QueryString("Action")="view" Then
			call view
		elseiF  Request.QueryString("Action")="del" Then
			call del
		elseiF  Request.QueryString("Action")="edit" Then
			call edit
		elseiF  Request.QueryString("Action")="add" Then
			call add
		elseiF  Request.QueryString("Action")="save" Then
			call save
		else

			call index
		end if
Function index
call saycardd("社区公告管理")
Set Rs = Server.CreateObject("Adodb.Recordset")
Sql = "SELECT * FROM bbs_vice order by id desc"
Rs.Open Sql,conn,1,1
If Not rs.eof	Then
	Dim PageSize,i
	PageSize=10							
	Dim Count,page,pagecount,gopage,parent			
	gopage="bbsvice.asp?sid="&sid&"&amp;saytk="&saytk&"&amp;"
	Count=rs.recordcount
	page=int(request.QueryString ("page"))
	if page<=0 or page="" then page=1		
	pagecount=(count+pagesize-1)\pagesize	
        if page>pagecount then page=pagecount	
	rs.move(pagesize*(page-1))				
	For i=1 To PageSize       						
	If rs.eof Then Exit For				
%><%=i+(page-1)*PageSize%>.<a href='bbsvice.asp?sid=<%=sid%>&amp;Action=view&amp;id=<%=ubb(rs("id"))%>&amp;saytk=<%=saytk%>'><%=ubb(rs("name"))%></a><br/>
<%     
	rs.moveNext						
	Next
	if page-pagecount<0 then response.write "<a href="""&gopage&"page="&page+1&""">下页</a>"
	if page>1 then response.write "<a href="""&gopage&"page="&page-1&""">上页</a>"
	if pagecount>1 then response.write "<br/><b>"&page&"</b>/"&pagecount&""
if saytk=1 then
response.write "页<input name=""page"" format=""*N"" value="""&page&""" type=""text"" maxlength=""5"" emptyok=""true"" size=""3""/><a href="""&gopage&"page=$(page)"">>></a>"
end if
Else
%>
	(没有公告)

<%end if%>
		<%
		Rs.close
		set rs=nothing
		Response.Write("<br/><a href='bbsvice.asp?sid="&sid&"&amp;Action=add&amp;saytk="&saytk&"'>[发布公告]</a><br/>")
end Function
Function add
call saycardd("发布公告")

if saytk>1 then
	Response.write "<form name=""form"" method=""post"" action=""bbsvice.asp?sid="&sid&"&amp;Action=save&amp;edit=add&amp;saytk="&saytk&""">"
end if%>
		标题:<br/><input name="name" maxlength="255" /><br/>
		内容:(支持UBB)<br/><input name="title" /><br/> 
<%if saytk>1 then%>
<input type="submit" name="Submit" value="发布"></form><br/>
<%else%>
		<anchor>发布
		<go href="bbsvice.asp?sid=<%=sid%>&amp;Action=save&amp;edit=add&amp;saytk=<%=saytk%>" method="post">
		<postfield name="name" value="$(name:n)" />
		<postfield name="title" value="$(title:n)" />
		</go>
		</anchor><br/>
<%end if%>
<a href="bbsvice.asp?sid=<%=sid%>&amp;saytk=<%=saytk%>">[公告管理]</a><br/>
	<%
end Function
Function edit
	id=TRim(Request("id"))
	if not isnumeric(id) then id=""
	if id=""  then
call error("ID无效.")
else
			Set Rs = Server.CreateObject("Adodb.Recordset")
			Sql = "SELECT * FROM bbs_vice where id="&id
			Rs.Open Sql,conn,1,1
if not (rs.bof and rs.eof)  then 
call saycardd("公告修改")

if saytk>1 then
	Response.write "<form name=""form"" method=""post"" action=""bbsvice.asp?sid="&sid&"&amp;Action=save&amp;edit=edit&amp;saytk="&saytk&""">"
end if%>
标题:<br/><input name="name" value="<%=rs("name")%>" maxlength="255" /><br/>
内容:(支持UBB)<br/><input name="title" value="<%=rs("txt")%>" /><br/> 
<%if saytk>1 then
response.write "<input type=""hidden"" name=""id"" value="""&id&"""/>"%>
<input type="submit" name="Submit" value="修改"></form><br/>
<%else%>
	<anchor>修改
<go href="bbsvice.asp?sid=<%=sid%>&amp;Action=save&amp;edit=edit&amp;saytk=<%=saytk%>" method="post">
			<postfield name="name" value="$(name:n)" />
			<postfield name="id" value="<%=id%>" />
			<postfield name="title" value="$(title:n)" />
			</go>
			</anchor><br/>
<%end if%>
<a href="bbsvice.asp?sid=<%=sid%>&amp;saytk=<%=saytk%>">[公告管理]</a><br/>
			<%else
			call error("没有该公告!")
end if
			Rs.close
			set rs=nothing
		end if
end Function
Function view
	id=TRim(Request("id"))
	if not isnumeric(id) then id=""
		if id=""  then
		call error("ID无效.")
else
call saycardd("公告管理")
			Set Rs = Server.CreateObject("Adodb.Recordset")
			Sql = "SELECT * FROM bbs_vice where id="&id
			Rs.Open Sql,conn,1,1
			if not (rs.bof and rs.eof)  then %>
				标题:<%=ubb(rs("name"))%><br/>
				内容:<%=ubb(rs("txt"))%><br/>
				时间:<%=ubb(rs("tm"))%><br/>
				<a href='bbsvice.asp?sid=<%=sid%>&amp;Action=edit&amp;id=<%=id%>&amp;saytk=<%=saytk%>'>[编辑]</a> <a href='bbsvice.asp?sid=<%=sid%>&amp;Action=del&amp;id=<%=id%>&amp;saytk=<%=saytk%>'>[删除]</a><br/>
<a href="bbsvice.asp?sid=<%=sid%>&amp;saytk=<%=saytk%>">[公告管理]</a><br/>
			<%else%>
				暂无公告!<br/>
			<%end if
			Rs.close
			set rs=nothing
		end if
end Function
Function  del
	id=TRim(Request("id"))
	if not isnumeric(id) then id=""
 		if id=""  then
		call error("ID无效.")
else
			if Request("del")="true" then
				set rs=server.CreateObject("adodb.recordset")
				Sql = "SELECT * FROM bbs_vice where id="&id
				rs.open sql,conn,1,3
				if not (rs.bof and rs.eof)  then
				rs.delete
				end if
				Rs.close
				set rs=nothing
				call saycardd("删除公告")%>
		已成功删除该公告!<br/>
<a href="bbsvice.asp?sid=<%=sid%>&amp;saytk=<%=saytk%>">[公告管理]</a><br/>
			<%else
			call saycardd("删除公告")
%>
			是否要删除该公告?<br/>
			<a href='bbsvice.asp?sid=<%=sid%>&amp;Action=del&amp;del=true&amp;id=<%=id%>&amp;saytk=<%=saytk%>'>[确定删除]</a><br/><anchor>返回上页<prev/></anchor><br/>
<a href="bbsvice.asp?sid=<%=sid%>&amp;saytk=<%=saytk%>">[公告管理]</a><br/>
<%end if
end if
end Function
Function save
	name=Trim(Request("name"))
	title=Trim(Request("title"))
	id=TRim(Request("id"))
	if not isnumeric(id) then id=""
		if name=""  then errmsg=errmsg&"公告标题不能为空<br/>":flag=0
		if title=""  then errmsg=errmsg&"公告内容不能为空<br/>":flag=0
		if Request("edit")="edit" then
		if id=""  then errmsg=errmsg&"ID无效<br/>":flag=0
		if flag<>"0" then
				set rs=server.CreateObject("adodb.recordset")
				sql="select * from bbs_vice where id="&id
				rs.open sql,conn,1,3
				rs("name")=name
				rs("txt")=title
				rs("tm")=now()
				rs.update()
				Rs.close
				set rs=nothing
				call cardz("修改公告","bbsvice.asp?sid="&sid&"&amp;saytk="&saytk&"")

Response.write "修改公告成功<br/>正在返回,请不要刷新..."

%><a href="bbsvice.asp?sid=<%=sid%>&amp;saytk=<%=saytk%>">[公告管理]</a><br/>
<%else
call saycardd("发布公告出错")
if saytk=1 then
Response.Write(""&errmsg&"<br/><anchor>[返回修改]<prev/></anchor><br/>") 
else
	Response.Write(""&errmsg&"<br/>请返回修改。。。<br/>") 
end if	
		end if
		else
			if flag<>"0" then
				set rs=server.CreateObject("adodb.recordset")
				sql="select * from bbs_vice"
				rs.open sql,conn,1,3
				rs.addnew()
				rs("name")=name
				rs("txt")=title
				rs("tm")=now()
				rs.update()
				Rs.close
				set rs=nothing
				call saycardd("发布公告")
%>

发布公告成功<br/>正在返回,请不要刷新...<br/>

<a href="bbsvice.asp?sid=<%=sid%>&amp;saytk=<%=saytk%>">[公告管理]</a><br/>
<%else
call saycardd("发布公告出错")
if saytk=1 then
Response.Write(""&errmsg&"<br/><anchor>[返回修改]<prev/></anchor><br/>") 
else
	Response.Write(""&errmsg&"<br/>请返回修改。。。<br/>") 
end if	
		end if
		END IF
end Function
%><a href="../index.asp?sid=<%=sid%>&amp;saytk=<%=saytk%>">[后台首页]</a>
<%response.write""
call headsay()%>
