📄 admin_announce.asp
字号:
<!--#include file="conn.asp"-->
<!--#include file="config.asp"-->
<%
if session("admin")="" then
response.redirect "admin_login.asp"
end if
'11 公告管理
if not checkflag("11") then
call mb("对不起,您没有管理公告的权限!","",0)
end if
dim action:action=request("action")
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>公告管理相关</title>
<script language=javascript src="mouse_up.js"></script>
<link href="admin.css" rel="stylesheet" type="text/css">
</head>
<body leftmargin="5" topmargin="0">
<table width="100%" border="0" align="center" cellpadding="2" cellspacing="0" bgcolor="#000000" vspace="0" hspace="0">
<tr bgcolor="#EFEBEF">
<td height="27"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="86%"><font color="#FF3000">.:: 您可以在这里进行[公告管理]相关操作</font></td>
<td width="14%" height="20" align="center"><a href="javascript:this.location.reload()"><img src="images/refresh.gif" alt="刷新" width="40" height="12" border="0"></a></td>
</tr>
</table></td>
</tr>
<tr >
<td height="1" bgcolor="#000000"></td>
</tr>
</table>
<%
select case action
case "add"
call add()
case "addsave"
call addsave()
case "edit"
call edit()
case "editsave"
call editsave()
case "del"
call del()
case else
call main()
end select
sub add()
%>
<br>
<form action="?action=addsave" method="post" name="add" id="add">
<table width="500" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr align="center" bgcolor="#EFEBEF" >
<td height="25" colspan="2"><font color="#000000">公 告 - 添 加</font></td>
</tr>
<tr bgcolor="#FFFFFF">
<td width="23%" height="25" align="center">公告内容:</td>
<td width="77%" height="25"> <textarea name="announce" cols="45" rows="10" class="input" id="announce"></textarea></td>
</tr>
<tr bgcolor="#FFFFFF">
<td height="25" align="center">最新显示:</td>
<td height="25"><input name="isshow" type="radio" value="true" checked>
是
<input type="radio" name="isshow" value="false">
否</td>
</tr>
<tr bgcolor="#FFFFFF">
<td height="30" colspan="2" align="center"> <input name="Submit" type="submit" class="button" value=" 确定添加 ">
<input name="Submit2" type="reset" class="button" value=" 重新填写 "> </td>
</tr>
</table>
</form>
<%
end sub
sub addsave()
dim announce,isshow
announce=checkstr(trim(request.form("announce")))
isshow=request("isshow")
if announce="" then
call mb("请输入公告内容","",0)
end if
if isshow then
'如果当前添加的公告显示,刚把以前显示的公告更新为不显示
conn.execute("update announce set isshow=false")
end if
set rs=server.createobject("adodb.recordset")
sql="select * from announce where id is null"
rs.open sql,conn,1,3
rs.addnew()
rs("announce")=announce
rs("isshow")=isshow
rs.update
rs.close
call mb("添加公告成功!","admin_announce.asp?action=add",1)
end sub
sub edit()
dim id
id=request("id")
if not isinteger(id) then
call mb("对不起,请指定要编辑的公告!","",0)
end if
set rs=conn.execute("select * from announce where id="&id)
if rs.bof and rs.eof then
call mb("找不到公告!","",0)
end if
%>
<br>
<form action="?action=editsave" method="post" name="edit" id="edit">
<table width="500" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr align="center" bgcolor="#EFEBEF" >
<td height="25" colspan="2"><font color="#000000">公 告 - 编辑</font></td>
</tr>
<tr bgcolor="#FFFFFF">
<td width="23%" height="25" align="center">公告内容:</td>
<td width="77%" height="25"> <textarea name="announce" cols="45" rows="10" class="input" id="announce"><%=rs("announce")%></textarea></td>
</tr>
<tr bgcolor="#FFFFFF">
<td height="25" align="center">最新显示:</td>
<td height="25"><input name="isshow" type="radio" value="true" <%if rs("isshow") then response.write " checked"%>>
是
<input type="radio" name="isshow" value="false" <%if not rs("isshow") then response.write " checked"%>>
否</td>
</tr>
<tr bgcolor="#FFFFFF">
<td height="30" colspan="2" align="center"> <input name="Submit" type="submit" class="button" value=" 确定编辑 ">
<input name="Submit2" type="reset" class="button" value=" 重新填写 "> <input name="id" type="hidden" id="id" value="<%=id%>">
</td>
</tr>
</table>
</form>
<%
rs.close
set rs=nothing
end sub
sub editsave()
dim id:id=request("id")
if not isinteger(id) then
call mb("对不起,请指定要编辑的公告!","",0)
end if
dim announce,isshow
announce=checkstr(trim(request.form("announce")))
isshow=request("isshow")
if announce="" then
call mb("请输入公告内容","",0)
end if
if isshow then
'如果当前编辑的公告显示,刚把以前显示的公告更新为不显示
conn.execute("update announce set isshow=false")
end if
set rs=server.createobject("adodb.recordset")
sql="select * from announce where id="&id
rs.open sql,conn,1,3
if rs.bof and rs.eof then
call mb("找不到要编辑的公告!","",0)
else
rs("announce")=announce
rs("isshow")=isshow
rs.update
end if
rs.close
set rs=nothing
call mb("编辑公告成功!","admin_announce.asp",1)
end sub
sub main()
response.expires=0
set rs=server.createobject("adodb.recordset")
sql="select * from announce order by id desc"
rs.open sql,conn,1,1
dim announce
%>
<br>
<br>
<table width="80%" border="0" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr align="center" bgcolor="#EFEBEF">
<td width="10%">当前显示</td>
<td width="67%" height="25"><font color="#000000">公告内容</font></td>
<td width="13%" height="25"><font color="#000000">添加日期</font></td>
<td width="10%" height="25"><font color="#000000">操 作</font></td>
</tr>
<%do until rs.eof
announce=rs("announce")
announce=replace(announce,chr(13),"<br>")
announce=replace(announce," "," ")
%>
<tr bgcolor="#FFFFFF">
<td>
<%if rs("isshow") then
response.write "<font color=red>√</font>"
else
response.write "×"
end if
%></td>
<td height="23"> <%=announce%></td>
<td height="23"> <%=formatdatetime(rs("dateandtime"),2)%></td>
<td height="23" align="center"> <a href="?action=edit&id=<%=rs("id")%>" title="编辑">编辑</a>
<a href="?action=del&id=<%=rs("id")%>" title="删除公告..." onclick="javascript:if(confirm('是否真的要删除公告吗?\n\n系统提示:删除后不可恢复!')){return true;}else{return false;}">删除</a></td>
</tr>
<%rs.movenext
loop
%>
</table>
<%
rs.close
set rs=nothing
end sub
sub del()
dim id:id=request("id")
if not isinteger(id) then
call mb("请指定要删除的公告!","",0)
end if
conn.execute("delete from announce where id="&id)
call mb("删除公告成功!","admin_announce.asp",1)
end sub
%>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -