📄 news1.asp
字号:
<!--#include file="../include/dbopenbd.asp"-->
<!--#include file="checkadmin.asp"-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="manage.css" type="text/css">
<script language="JavaScript" type="text/JavaScript">
function CheckAll(form) {
for (var i=0;i<form.elements.length;i++) {
var e = form.elements[i];
if (e.name != 'chkall') e.checked = form.chkall.checked;
}
}
</script>
</head>
<BODY background="../images/admin/back.gif">
<%
allpages=0
page=1
totalrec=0
per_page_num=20
url="news1.asp"
Set rs = conn.Execute("select * from s_config")
newstitle1=rs("newstitle1")
newstitle2=rs("newstitle2")
newstitle3=rs("newstitle3")
newstitle4=rs("newstitle4")
newstitle5=rs("newstitle5")
rs.close
set rs=nothing
nclass=trim(request("nclass"))
if nclass<>"" and nclass<>"1" and nclass<>"2" and nclass<>"3" and nclass<>"4" and nclass<>"5" then
mGoBack "没有相关新闻,单击“确定”返回上一页!"
end if
'参数
action=request("action")
'列表显示情况
if action="" then call news_index()
'添加、修改的显示和提交处理开始
id=request("id")
'提交
if action="newsok" then call newsok()
'显示
if action="modify" then call newsmodify()
'多选功能处理开始
ids=replace(request("id"),"'","")
if ids="" then mGoBack "您什么也没有选择,单击“确定”返回上一页!"
'关闭
if action="关闭" then call newsclose()
'打开
if action="打开" then call newsopen()
'删除
if action="删除" then call newsdel()
sub news_index()
%>
<table width="98%" border="1" cellpadding="3" bordercolor="#333333" style="border-collapse: collapse;word-break:break-all">
<form action=news1.asp method=post name="newslist">
<tr class=backs><td colspan=5 class=td height=18>新闻文章管理</td></tr>
<tr bgcolor="#003366" align=center>
<td width=5%>选</td>
<td width=50%>标题(单击标题编辑新闻)</td>
<td width=15%>类别</td>
<td width=15%>发布时间</td>
<td width=15%>状态</td></tr>
<%
sql = "select * from s_news"
if nclass<>"" then sql = sql + " where NewsClass='" & nclass &"'"
sql=sql+" order by uup desc, PubDate desc"
pages = per_page_num
set rs=Server.CreateObject("ADODB.RecordSet")
rs.cursorlocation = 3 '使用客户端游标,可以使效率提高
rs.open sql,conn,1,1
if rs.eof and rs.bof then
response.write "<tr><td height=18 class=b colspan=5 align=center>暂时没有新闻文章</td></tr>"
else
totalrec = RS.RecordCount
rs.pageSize = pages
allPages = rs.pageCount
page = Request("page")
If not isNumeric(page) then page=1
if isEmpty(page) or int(page) <= 1 then
page = 1
elseif int(page) >= allPages then
page = allPages
end if
rs.AbsolutePage = page
do while not rs.eof and pages>0
%>
<tr><td height=18 class=b><input type='checkbox' value='<%=Cstr(rs("NewsId"))%>' name=id></td><td><a href="news1.asp?action=modify&id=<%=Cstr(rs("NewsId"))%>" title='编辑这篇新闻文章' ><%=rs("NewsTitle")%></a></td>
<td>
<%
if rs("NewsClass")="1" then
response.write newstitle1
elseif rs("NewsClass")="2" then
response.write newstitle2
elseif rs("NewsClass")="3" then
response.write newstitle3
elseif rs("NewsClass")="4" then
response.write newstitle4
elseif rs("NewsClass")="5" then
response.write newstitle5
end if
%>
</td><td><%=split(rs("PubDate")," ")(0)%>
</td><td> <% if rs("Online")=true then response.write "显示 " else response.write "<font color=red><b>隐藏</b></font>" end if%><% if rs("uup")=100 then response.write " 固顶" end if%></td></tr>
<%
pages=pages-1
rs.movenext
loop
end if
rs.close
conn.close
set rs=nothing
set coon=nothing
%>
<tr><td colspan=5 class=b>
<input type='checkbox' name=chkall onclick='CheckAll(this.form)'>全选
<input type="submit" name="action" value="关闭" onclick="{if(confirm('确定隐藏这条新闻吗?')){this.document.newslist.submit();return true;}return false;}"> <input type="submit" name="action" value="打开" onclick="{if(confirm('确定要显示这条新闻吗?')){this.document.newslist.submit();return true;}return false;}">
<input type="submit" name="action" value="删除" onclick="{if(confirm('该操作不可恢复!\n\n确定删除选定的新闻?')){this.document.newslist.submit();return true;}return false;}">
<input type="button" name="action" onclick="javascript:location.href='news1.asp?action=modify';" value="添加新闻">
</td></tr>
</form></table>
<%
call listPages()
response.end
end sub
sub listPages()
response.write "<br> 总新闻数:"&totalrec& " 每页:"& per_page_num&" 条记录 "
if allpages <= 1 then exit sub
if page = 1 then
response.write " <font color=#878787>首页 上页</font>"
else
response.write " <a href='"&request.ServerVariables("script_name")&"?page=1'>首页</a> "
response.write " <a href='"&request.ServerVariables("script_name")&"?page="&page-1&"'>上页</a> "
end if
if page = allpages then
response.write "<font color=#878787>下页 末页</font>"
else
response.write " <a href='"&request.ServerVariables("script_name")&"?page="&page+1&"'>下页</a> "
response.write " <a href='"&request.ServerVariables("script_name")&"?page="&allpages&"'>末页</a> "
end if
response.write " 第"&page&"/"&allpages&"页"
end sub
sub newsopen()
sql="update s_news set online=1 where NewsId in ("&ids&")"
conn.execute sql
mGoTo url,"所选新闻文章已被打开!"
end sub
sub newsclose()
sql="update s_news set online=0 where NewsId in ("&ids&")"
conn.execute sql
mGoTo url,"所选新闻文章已被关闭!"
end sub
sub newsdel()
sql="delete from s_news where NewsId in ("&ids&")"
conn.execute sql
mGoTo url,"所选新闻已被删除,单击“确定”返回新闻列表!"
end sub
sub newsok()
Set rs=Server.CreateObject("ADODB.Recordset")
if id="" then
sql = "select * from s_news where 1=2"
rs.open sql,conn,1,3
rs.Addnew
else
sql = "select * from s_news where NewsId="&id
rs.open sql,conn,1,3
end if
rs("NewsTitle")=request.form("NewsTitle")
rs("NewsContain")=request.form("NewsContain")
if request.form("PubDate")="" then
rs("PubDate")=now()
else
rs("PubDate")=request.form("PubDate")
end if
if request.form("OffDate")="" then
rs("OffDate")=Null
else
rs("OffDate")=request.form("OffDate")
end if
rs("NewsClass")=request.form("NewsClass")
rs("Online")=request.form("Online")
rs("Source")=request.form("Source")
rs("uup")=request.form("uup")
rs.update
rs.close
conn.close
set rs=nothing
set conn=nothing
mGoTo url,"操作成功,单击“确定”返回新闻列表!"
end sub
sub newsmodify()
if id<>"" then
set rs = server.createobject("adodb.recordset")
sql = "select * from s_news where NewsId="&id
rs.open sql,conn,1,1
if not (rs.eof and rs.bof) then
NewsTitle=rs("NewsTitle")
NewsClass=rs("NewsClass")
NewsContain=rs("NewsContain")
Source=rs("Source")
pubdate=rs("pubdate")
offdate=rs("offdate")
Online=rs("Online")
uup=rs("uup")
end if
rs.close
set rs=nothing
end if
%>
<table width="98%" border="1" style="border-collapse: collapse; border-style: dotted; border-width: 0px" bordercolor="#333333" cellspacing="0" cellpadding="2">
<form name="editnews" method="post" action='news1.asp?action=newsok&id=<%=id%>'>
<tr class=backs><td class=td height=18>编辑新闻文章</td></tr>
<TR><TD>新闻标题:<input name="NewsTitle" type="text" value="<%=NewsTitle%>" size="50" maxlength="50"></TD></TR>
<TR><TD>新闻类别:<select name="NewsClass">
<option value="1" <%if NewsClass="1" then%>selected<%end if%>><%=newstitle1%></option>
<%if newstitle2<>"" then%><option value="2" <%if NewsClass="2" then%>selected<%end if%>><%=newstitle2%></option><%end if%>
<%if newstitle3<>"" then%><option value="3" <%if NewsClass="3" then%>selected<%end if%>><%=newstitle3%></option><%end if%>
<%if newstitle4<>"" then%><option value="4" <%if NewsClass="4" then%>selected<%end if%>><%=newstitle4%></option><%end if%>
<%if newstitle5<>"" then%><option value="5" <%if NewsClass="5" then%>selected<%end if%>><%=newstitle5%></option><%end if%>
</select>
</TD></TR>
<TR><TD>新闻内容<font color="#666666">(支持超文本)</font>:</TD></TR>
<TR><TD>
<textarea name="NewsContain" rows="10" style="width:100%;"><%=NewsContain%></textarea>
</TD></TR>
<TR><TD>新闻来源:<input name="Source" type="text" value="<%=Source%>" size="20" maxlength="20"></TD></TR>
<TR><TD>生效日期:<input name="PubDate" type="text" value="<%=pubdate%>" size="20" maxlength="20"></TD></TR>
<TR><TD>失效日期:<input name="OffDate" type="text" value="<%=offdate%>" size="20" maxlength="20"></TD></TR>
<TR><TD>是否固顶:<input type="radio" name="uup" value="0" checked>否<input type="radio" name="uup" value="1" <%if uup=1 then%>checked<%end if%>> 是</TD></TR>
<TR><TD>是否在线:<input type="radio" name="Online" value="0" checked>否<input type="radio" name="Online" value="1" <%if Online=true then%>checked<%end if%>> 是 </TD></TR>
<TR><TD><input type="submit" name="submit" value="提交修改"> <input type="reset" name="Submit2" value="重新修改"></TD></TR>
</form></TABLE>
<%
response.end
end sub
%>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -