📄 admin_notice.asp
字号:
<%if session("password")<>"" then%>
<!-- #include file="inc/top.asp" -->
<!-- #include file="inc/adminmenu.asp" -->
<!-- #include file="inc/conn.asp" -->
<%if Request.form("method")="add" then
dim error,mes,putime,content,puser,i
i=0
putime=Request.Form("year")&"-"&Request.Form("month")&"-"&Request.Form("day")
if ubound(split(putime,"-"))<>2 then
i=i+1
mes=i&".出现未知错误!\n"
error=true
end if
content=checkstr(Request.Form("content"))
if content=empty then
i=i+1
mes=mes&i&".请填写公告内容!\n"
error=true
end if
puser=checkstr(Request.Form("puser"))
if puser=empty then
i=i+1
mes=mes&i&".请填写您的名字!"
error=true
end if
if error=true then
Response.Write("<script language=JavaScript>" & chr(13) & "alert('" & mes & "');" & "history.back()" & "</script>")
Response.end
end if
sql="insert into notice(content,putime,puser)values('"&content&"','"&putime&"','"&puser&"')"
conn.execute(sql)
Response.Write("<script language=JavaScript>" & chr(13) & "alert('公告添加成功');" & "window.location.href = 'admin_notice.asp'" & "</script>")
Response.End
end if
if Request.querystring("method")="del" then
id=Request.querystring("id")
sql="delete from notice where id in ("& id &")"
conn.execute(sql)
Response.Redirect("admin_notice.asp")
end if
if Request.form("method")="mod" then
id=Request.form("id")
i=0
putime=Request.Form("year")&"-"&Request.Form("month")&"-"&Request.Form("day")
if ubound(split(putime,"-"))<>2 then
i=i+1
mes=i&".出现未知错误!\n"
error=true
end if
content=checkstr(Request.Form("content"))
if content=empty then
i=i+1
mes=mes&i&".请填写公告内容!\n"
error=true
end if
puser=checkstr(Request.Form("puser"))
if puser=empty then
i=i+1
mes=mes&i&".请填写您的名字!"
error=true
end if
if error=true then
Response.Write("<script language=JavaScript>" & chr(13) & "alert('" & mes & "');" & "history.back()" & "</script>")
Response.end
end if
sql="update notice set putime='"&putime&"',puser='"&puser&"',content='"&content&"' where id in ("& id &")"
conn.execute(sql)
Response.Write("<script language=JavaScript>" & chr(13) & "alert('公告修改成功');" & "window.location.href = 'admin_notice.asp'" & "</script>")
Response.End
end if
if Request.Querystring("method")="mod" then
sql="select puser,content,putime,id from notice where id in ("&Request.Querystring("id")&")"
set rs=conn.execute(sql)
if rs(0)<>"" then username=rs(0)
if rs(1)<>"" then content=rs(1)
if rs(2)<>"" then
date0=split(rs(2),"-")
year0=Cint(date0(0))
month0=Cint(date0(1))
day0=Cint(date0(2))
end if
method="mod"
id=rs(3)
else
content=""
username=session("username")
method="add"
year0=year(date())
month0=month(date())
day0=day(date())
end if
%>
<table width="752" height="25" align="center" cellpadding="0" cellspacing="0" class="unnamed_rld2">
<tr><td height=20></td></tr>
<form action="" method=post>
<tr>
<td align=center>
<table width=766 border="0" align=center cellpadding="0" cellspacing=0 cellpaddin=0>
<tr><td align=center width=100%><strong>公 告 发 布</strong></td></tr>
<tr><td>
<table cellpadding=0 cellspacing=0 align=left>
<tr>
<td width="30%">发布时间:</td>
<td width="32"><select name=year>
<%
for i=1990 to 2020
if i=year0 then
Response.write("<option selected>"&i&"</option>")
else
Response.write("<option>"&i&"</option>")
end if
next
%>
</select></td><td width=16>年</td>
<td width="50"><select name=month>
<%
for i=1 to 12
if i=month0 then
Response.write("<option selected>"&i&"</option>")
else
Response.write("<option>"&i&"</option>")
end if
next
%>
</select></td><td width=10>月</td>
<td><select name=day>
<%
for i=1 to 31
if i=day0 then
Response.write("<option selected>"&i&"</option>")
else
Response.write("<option>"&i&"</option>")
end if
next
%>
</select></td><td width=16>日</td>
</tr>
</table>
</td></tr>
<tr><td>
<table cellpadding=0 cellspacing=0 width="601">
<tr><td width="13%" valign=top>公告内容:</td><td><textarea name=content cols=50 rows=10><%=content%></textarea></td></tr>
<tr><td width="13%" valign=top>发布人:</td><td><input name=puser value=<%=username%>></td></tr>
<tr><td></td><td valign=top><input type=submit value=<%
if Request.Querystring("method")="mod" then
Response.Write("修改")
else
Response.Write("提交")
end if
%>公告> <input type=reset value=清除重来><input type=hidden name=method value="<%=method%>"><input type=hidden name=id value="<%=id%>"></td></tr>
</table>
</td></tr>
</table>
</td></tr></form><tr><td height=20></td><tr><td>
<table cellpadding=0 cellspacing=0 width=766 border=1 align=center bordercolor=#dddddd>
<tr align=center>
<td>公 告 内 容</td><td width=10%>发布人</td><td width=13%>发布时间</td><td width=13%>操作</td>
</tr>
<%
sql="select top 5 * from notice order by id desc"
set rs=conn.execute(sql)
i=1
do while not (rs.eof or rs.bof)
%>
<tr <%if i mod 2 =1 then Response.Write("bgcolor=#eeeeee")%> valign=top>
<td><%=rs("content")%></td><td align=center><%=rs("puser")%></td><td align=center><%=rs("putime")%></td><td align=center><a href=admin_notice.asp?method=del&id=<%=rs("id")%>>删除</a> <a href=admin_notice.asp?method=mod&id=<%=rs("id")%>>修改</a></td>
</tr>
<%
i = i + 1
rs.movenext
loop
%>
</td>
</tr>
</table>
<tr><td height=20></td></tr>
<!-- #include file="inc/copyright.asp" -->
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -