📄 siteannounce.asp
字号:
<%@language=vbscript codepage=936 %>
<!--#include file="../inc/conn.asp"-->
<!--#include file="AdminChkPurview.asp"-->
<%
dim Action
strFileName="SiteAnnounce.asp?"
%>
<html>
<head>
<title>公告管理</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" type="text/css" href="../inc/Admin_Style.css">
<script language = "JavaScript">
function CheckAll(form)
{
for (var i=0;i<form.elements.length;i++)
{
var e = form.elements[i];
if (e.Name != "chkAll"&&e.disabled!=true)
e.checked = form.chkAll.checked;
}
}
function ConfirmDel()
{
if(document.myform.Action.value=="Del")
{
if(confirm("确定要删除选中的公告吗?"))
return true;
else
return false;
}
}
function CheckForm()
{
if (document.form1.Title.value=="")
{
alert("公告名称不能为空!");
document.form1.Title.focus();
return false;
}
if (document.form1.Content.value=="")
{
alert("公告内容不能为空!");
document.form1.Content.focus();
return false;
}
if (document.form1.Content.value.length>2048000)
{
alert("公告内容太长,超出了ACCESS数据库的限制(2048K)!建议将文章分成几部分录入。");
document.form1.Content.focus();
return false;
}
if (document.form1.Author.value=="")
{
alert("公告地址不能为空!");
document.myform.Author.focus();
return false;
}
return true;
}
</script>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" class="border">
<tr>
<td height="22" colspan="2" align="center" class="title"><strong>网 站 公 告 管 理</strong></td>
</tr>
<tr class="tdbg">
<td width="70" height="30"><strong>管理导航:</strong></td>
<td height="30"><a href="SiteAnnounce.asp?Action=Add">添加新公告</a> | <a href="SiteAnnounce.asp">网站公告</a></td>
</tr>
</table>
<%
Action=Trim(Request("Action"))
if Action="Add" then
call AddAnnounce()
elseif Action="SaveAdd" then
call SaveAdd()
elseif Action="Modify" then
call Modify()
elseif Action="SaveModify" then
call SaveModify()
elseif Action="SetNew" then
call SetNew()
elseif Action="CancelNew" then
call CancelNew()
elseif Action="Del" then
call DelAnnounce()
else
call main()
end if
sub main()
%>
<%
Set rs= Server.CreateObject("ADODB.Recordset")
sql="select * from totalk order by id desc"
rs.open sql,conn,1,1
%>
<table width="100%" border="0" align="center" cellpadding="2" cellspacing="1" Class="border">
<form name="myform" method="POST" action=<% =strFileName %> onSubmit="return ConfirmDel();">
<tr class="title">
<td width="29" height="22" align="center"><strong>选择</strong></td>
<td width="56" height="22" align="center"><strong>公告ID</strong></td>
<td width="407" height="22" align="center"><strong>标 题</strong></td>
<td width="76" align="center"><strong>最新公告</strong></td>
<td width="100" height="22" align="center"><strong>发布人</strong></td>
<td width="165" height="22" align="center"><strong>发布时间</strong></td>
<td width="106" height="22" align="center"><strong>操作</strong></td>
</tr>
<%
if not(rs.bof and rs.eof) then
do while not rs.eof
%>
<tr class="tdbg" onMouseOut="this.style.backgroundColor=''" onMouseOver="this.style.backgroundColor='#cccccc'" style="padding: 0px 2px;">
<td align="center">
<input type="checkbox" value=<%=rs("ID")%> name="AnnounceID" style="border: 0px;background-color: #eeeeee;">
</td>
<td align="center"><%=rs("id")%></td>
<td><%=rs("title")%></td>
<td align="center"><%if rs("Selected")=true then response.write "<font color=#009900>新</font>" end if%></td>
<td align="center"><%=rs("user")%></td>
<td align="center"><%=rs("times")%></td>
<td align="center">
<%
response.write "<a href='" & strFileName & "Action=Modify&ID=" & rs("ID") & "'>修改</a> "
response.write "<a href='" & strFileName & "Action=Del&AnnounceID=" & rs("ID") & "' onClick=""return confirm('确定要删除此公告吗?');"">删除</a>"
%>
</td>
</tr>
<%
rs.movenext
loop
%>
<tr class="tdbg">
<td colspan=7 height="30">
<input name="chkAll" type="checkbox" id="chkAll" onclick=CheckAll(this.form) value="checkbox" style="border: 0px;background-color: #eeeeee;">
<input name="Action" type="hidden" id="Action" value="del">
选中所有公告
<font color="#FF6600">说明:</font>只有将公告设为最新公告后才会在前台显示 </td>
</tr>
<tr class="tdbg">
<td colspan=7 height="30"> 将选定的公告:
<input type="submit" value=" 删 除 " name="submit" onClick="document.myform.Action.value='Del'" style="cursor: hand;background-color: #cccccc;">
<input type="submit" value=" 设为最新公告 " name="submit" onClick="document.myform.Action.value='SetNew'" style="cursor: hand;background-color: #cccccc;">
<input type="submit" value=" 取消最新公告 " name="submit" onClick="document.myform.Action.value='CancelNew'" style="cursor: hand;background-color: #cccccc;">
</td>
</tr>
</form>
</table>
<% end if%>
<%
end sub
sub AddAnnounce()
%>
<table width="100%" border="0" align="center" cellpadding="2" cellspacing="1" class="border">
<form name="form1" method="post" action=<% =strFileName %> onSubmit="return CheckForm();">
<tr>
<td height="22" colspan="2" align="center" class="title"><strong>添 加 公 告</strong></td>
</tr>
<tr class="tdbg">
<td width="20%" align="right"><strong>标题:</strong></td>
<td width="80%">
<input type="text" name="Title" size="66" id="Title" value=""> </td>
</tr>
<tr class="tdbg">
<td align="right"><strong>内容:</strong></td>
<td>
<textarea name="Content" cols="66" rows="10" id="Content"></textarea>
</td>
</tr>
<tr class="tdbg">
<td align="right"><strong>发布人:</strong></td>
<td>
<input name="Author" type="text" id="Author" value="管理员" size="20" maxlength="20"> </td>
</tr>
<tr class="tdbg">
<td align="right"> </td>
<td>
<input name="IsSelected" type="checkbox" id="IsSelected" value="True" checked style="border: 0px;background-color: #eeeeee;">
设为最新公告</td>
</tr>
<tr class="tdbg">
<td height="40" colspan="2" align="center">
<input name="Action" type="hidden" id="Action" value="SaveAdd">
<input type="submit" name="Submit" value=" 添 加 " style="cursor: hand;background-color: #cccccc;"> </td>
</tr>
</form>
</table>
<%
end sub
sub Modify()
ID=trim(request("ID"))
if ID="" then
response.write "<li>请指定要修改的公告ID!</li>"
else
ID=Clng(ID)
end if
sql="select * from totalk where ID=" & ID
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,1
if rs.bof and rs.eof then
response.write "<li>请指定要修改的公告ID!</li>"
rs.close
set rs=nothing
exit sub
end if
%>
<table width="100%" border="0" align="center" cellpadding="2" cellspacing="1" class="border">
<form name="form1" method="post" action=<% =strFileName %> onSubmit="return CheckForm();">
<tr>
<td height="22" colspan="2" align="center" class="title"><strong>修 改 公 告</strong></td>
</tr>
<tr class="tdbg">
<td width="20%" align="right"><strong>标题:</strong></td>
<td width="80%">
<input type="text" name="Title" size="66" id="Title" value="<% =rs("Title") %>"></td>
</tr>
<tr class="tdbg">
<td align="right"><strong>内容:</strong></td>
<td>
<textarea name="Content" cols="66" rows="10" id="Content"><% =rs("conten") %></textarea>
</td>
</tr>
<tr class="tdbg">
<td align="right"><strong>发布人:</strong></td>
<td>
<input name="Author" type="text" id="Author" value="<% =rs("user") %>" size="20" maxlength="20"> </td>
</tr>
<tr class="tdbg">
<td align="right"> </td>
<td>
<input name="IsSelected" type="checkbox" id="IsSelected" value="True" <% if rs("Selected")=true then response.write "checked"%> style="border: 0px;background-color: #eeeeee;">
设为最新公告</td>
</tr>
<tr class="tdbg">
<td height="40" colspan="2" align="center">
<input name="Action" type="hidden" id="Action" value="SaveModify">
<input type="submit" name="Submit" value=" 保 存 " style="cursor: hand;background-color: #cccccc;">
<input name="ID" type="hidden" id="ID" value="<%=rs("ID")%>">
</td>
</tr>
</form>
</table>
<%
end sub
sub SaveAdd()
dim Title,Content,Author,sql
Title=trim(request("Title"))
Content=trim(request("Content"))
Author=trim(request("Author"))
IsSelected=trim(request("IsSelected"))
if IsSelected="True" then
IsSelected=True
else
IsSelected=False
end if
sql="select * from totalk"
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,3
rs.addnew
rs("Title")=Title
rs("conten")=Content
rs("user")=Author
rs("Selected")=IsSelected
rs.update
rs.close
set rs=nothing
''call CloseConn()
response.redirect "SiteAnnounce.asp"
end sub
sub SaveModify()
dim ID,Title,Content,Author,DateAndTime,IsSelected,ChannelID,ShowType
ID=trim(request("ID"))
Title=trim(request("Title"))
Content=trim(request("Content"))
Author=trim(request("Author"))
IsSelected=trim(request("IsSelected"))
if IsSelected="True" then
IsSelected=True
else
IsSelected=false
end if
sql="select * from totalk where ID=" & ID
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,3
rs("Title")=Title
rs("conten")=Content
rs("user")=Author
rs("Selected")=IsSelected
rs.update
rs.close
set rs=nothing
'call CloseConn()
response.redirect strFileName
end sub
sub SetNew()
dim ID
ID=Trim(Request("AnnounceID"))
if Instr(ID,",")>0 then
dim arrID,i
arrID=split(ID,",")
for i=0 to Ubound(arrID)
conn.execute "Update totalk set Selected=True Where ID=" & CLng(arrID(i))
next
else
conn.execute "Update totalk set Selected=True Where ID=" & CLng(ID)
end if
response.redirect strFileName
end sub
sub CancelNew()
dim ID
ID=Trim(Request("AnnounceID"))
if Instr(ID,",")>0 then
dim arrID,i
arrID=split(ID,",")
for i=0 to Ubound(arrID)
conn.execute "Update totalk set Selected=False Where ID=" & CLng(arrID(i))
next
else
conn.execute "Update totalk set Selected=False Where ID=" & CLng(ID)
end if
response.redirect strFileName
end sub
sub DelAnnounce()
dim ID
ID=Trim(Request("AnnounceID"))
response.write "修改"
if Instr(ID,",")>0 then
dim arrID,i
arrID=split(ID,",")
for i=0 to Ubound(arrID)
conn.execute "delete from totalk where ID=" & CLng(arrID(i))
next
else
conn.execute "delete from totalk where ID=" & CLng(ID)
end if
response.redirect strFileName
end sub
%>
<!--#include file="AdminFooder.asp"-->
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -