<!-- #include file="conn.asp" -->
<!-- #include file="admin.asp" -->
<%call ling()
Call Head%>
<%
IF KEY<>0 then
if saytk>1 then
  Call Error("<title>出错</title></head><body><body bgcolor="""&yanse1&"""><p>你的权限不足！")
else
  Call Error("<card title=""出错""><p>你的权限不足！")
  end if
end if

		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 gonggo 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="admin_gonggo.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='admin_gonggo.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='admin_gonggo.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=""admin_gonggo.asp?sid="&sid&"&amp;Action=save&amp;edit=add&amp;saytk="&saytk&""">"
end if%>
		标题:<br/><input name="name" maxlength="255" /><br/>
		内容:(支持UBB)<br/>
<%
if saytk=1 then
Response.write "<input name=""title"" emptyok=""true"" maxlength=""5000""/><br/>"
else
Response.write "<textarea name=""title"" emptyok=""true"" rows=""15"" cols=""15""></textarea><br/>"
end If

if saytk>1 then%>
<input type="submit" name="Submit" value="发布"></form><br/>
<%else%>
		<anchor>发布
		<go href="admin_gonggo.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="admin_gonggo.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%>
	<card id="index" title="出错啦"><p>ID无效.<br/>
	<%else
			Set Rs = Server.CreateObject("Adodb.Recordset")
			Sql = "SELECT * FROM gonggo 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=""admin_gonggo.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("title")%>" /><br/> 
<%if saytk>1 then%>
<input type="hidden" name="id" value="<%=id%>"/>
<input type="submit" name="Submit" value="修改"></form><br/>
<%else%>
	<anchor>修改
<go href="admin_gonggo.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="admin_gonggo.asp?sid=<%=sid%>&amp;saytk=<%=saytk%>">[公告管理]</a><br/>
			<%else%>
			<card id="index" title="出错啦"><p>没有该公告!<br/>
			<%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
if saytk>1 then
Response.write "<title>出错啦</title></head><body><body bgcolor="""&yanse1&"""><p>"
else%>
	<card id="index" title="出错啦"><p>
<%end if%>ID无效.<br/>
		<%else
Call saycardd("公告管理")
			Set Rs = Server.CreateObject("Adodb.Recordset")
			Sql = "SELECT * FROM gonggo where id="&id
			Rs.Open Sql,conn,1,1
			if not (rs.bof and rs.eof)  then %>
				标题:<%=ubb(rs("name"))%><br/>
				内容:<%=ubb(rs("title"))%><br/>
				时间:<%=ubb(rs("YD_time"))%><br/>
				<a href='admin_gonggo.asp?sid=<%=sid%>&amp;Action=edit&amp;id=<%=id%>&amp;saytk=<%=saytk%>'>[编辑]</a> <a href='admin_gonggo.asp?sid=<%=sid%>&amp;Action=del&amp;id=<%=id%>&amp;saytk=<%=saytk%>'>[删除]</a><br/>
<a href="admin_gonggo.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
if saytk>1 then
Response.write "<title>出错啦</title></head><body><body bgcolor="""&yanse1&"""><p>"
else%>
	<card id="index" title="出错啦"><p>
<%end if%>ID无效.<br/>
		<%else
			if Request("del")="true" then
				set rs=server.CreateObject("adodb.recordset")
				Sql = "SELECT * FROM gonggo 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="admin_gonggo.asp?sid=<%=sid%>">[公告管理]</a><br/>
			<%else
Call saycardd("删除公告")%>
			是否要删除该公告?<br/>
			<a href='admin_gonggo.asp?sid=<%=sid%>&amp;Action=del&amp;del=true&amp;id=<%=id%>&amp;saytk=<%=saytk%>'>[确定删除]</a><br/><anchor>返回上页<prev/></anchor><br/>
<a href="admin_gonggo.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 gonggo where id="&id
				rs.open sql,conn,1,3
				rs("name")=name
				rs("title")=title
				rs.update()
				Rs.close
				set rs=nothing
Call saycardd("修改公告")%>
修改公告成功<br/><br/>
<a href="admin_gonggo.asp?sid=<%=sid%>&amp;saytk=<%=saytk%>">[公告管理]</a><br/>
<%else
if saytk>1 then
Response.write "<title>发布公告出错</title></head><body><body bgcolor="""&yanse1&"""><p>"
else
Response.Write("<card id='index' title='发布公告出错' ><p>") 
end if
Response.Write(""&errmsg&"<br/><anchor>[返回修改]<prev/></anchor><br/>") 		
		end if
		else
			if flag<>"0" then
				set rs=server.CreateObject("adodb.recordset")
				sql="select * from gonggo"
				rs.open sql,conn,1,3
				rs.addnew()
				rs("name")=name
				rs("title")=title
				rs("YD_time")=now()
				rs.update()
				Rs.close
				set rs=nothing
	call cardz10("发布公告","admin_gonggo.asp?sid="&sid&"&amp;saytk="&saytk&"")
%>
发布公告成功<br/><br/>
<a href="admin_gonggo.asp?sid=<%=sid%>&amp;saytk=<%=saytk%>">[公告管理]</a><br/>
<%else
if saytk>1 then
Response.write "<title>发布公告出错</title></head><body><body bgcolor="""&yanse1&"""><p>"
else
Response.Write("<card id='index' title='发布公告出错' ><p>") 
end if
Response.Write(""&errmsg&"<br/><anchor>[返回修改]<prev/></anchor><br/>") 	
		end if
		END IF

end Function%>
<a href="index.asp?sid=<%=sid%>&amp;saytk=<%=saytk%>">[后台管理]</a><br/>
报时: <%=String(2-Len(hour(now)),"0") & hour(now) %>:<%=String(2-len(minute(now)),"0") & minute(now) %>
<%response.write""
call head1()%>
