cktp.asp
来自「1.理解Winsock编程模型; 2.掌握Winsock编程的基本方法」· ASP 代码 · 共 400 行
ASP
400 行
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="conn.asp"-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>石家庄经济学院信息工程学院!</title>
<link rel="STYLESHEET" href="images/css.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;
}
}
function news(URL)
{ window.open(URL,"news","toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no,resizable=yes,copyhistory=yes,width=550,height=300");
}
</script>
</head>
<body>
<table width="788" border="0" align="center" cellpadding="2" cellspacing="2">
<tr>
<td><table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#222222" width="100%">
<tr>
<td width="100%"><span class="style2">当前位置:<a href="admin.asp" class="style2"><font color="black">网站管理中心</font></a>--新闻管理</span></td>
</tr>
<tr>
<td>
<table width=100% border="1" cellpadding=0 cellspacing="0" bordercolor="#333333" style="border-collapse: collapse;border:dotted 1px">
<form name=Newslist action=cktp.asp method=post>
<tr bgcolor="#003366">
<td bgcolor="#FFFFFF" ><span class="style2">选</span></td>
<td bgcolor="#FFFFFF"><span class="style2">预览号</span></td>
<td bgcolor="#FFFFFF">状态</td>
<td bgcolor="#FFFFFF">修改</td>
<td bgcolor="#FFFFFF">位置</td>
<td bgcolor="#FFFFFF"><span class="style2">添加时间</span></td>
</tr>
<%
sousuo=request("sousuo")
dim rs,msg_per_page
dim sql
msg_per_page = 10 '定义每页显示记录条数
if sousuo="" or sousuo="++选择所居位置++" then
sql = "select * from hw order by PubDate desc"
else
sql = "select * from hw where weizhi='"&sousuo&"' order by PubDate desc"
end if
set rs=Server.CreateObject("ADODB.RecordSet")
rs.cursorlocation = 3 '使用客户端游标,可以使效率提高
rs.pagesize = msg_per_page '定义分页记录集每页显示记录数
rs.open sql,conn,3,2
if err.number<>0 then '错误处理
response.write "数据库操作失败:" & err.description
err.clear
else
if not (rs.eof and rs.bof) then '检测记录集是否为空
totalrec = RS.RecordCount 'totalrec:总记录条数
if rs.recordcount mod msg_per_page = 0 then '计算总页数,recordcount:数据的总记录数
n = rs.recordcount\msg_per_page 'n:总页数
else
n = rs.recordcount\msg_per_page+1
end if
currentpage = request("page") 'currentpage:当前页
If currentpage <> "" then
currentpage = cint(currentpage)
if currentpage < 1 then
currentpage = 1
end if
if err.number <> 0 then
err.clear
currentpage = 1
end if
else
currentpage = 1
End if
if currentpage*msg_per_page > totalrec and not((currentpage-1)*msg_per_page < totalrec)then
currentPage=1
end if
rs.absolutepage = currentpage 'absolutepage:设置指针指向某页开头
rowcount = rs.pagesize 'pagesize:设置每一页的数据记录数
dim i
dim k
%>
<%
do while not rs.eof and rowcount>0
%>
<tr>
<td class=b><input type='checkbox' value='<%=Cstr(rs("ID"))%>' name=id></td>
<td><a href="<%=rs("hw_name")%>" target="_blank"><font color="#000000"><%=rs("ID")%></font></a></td>
<% if rs("online")=true then %>
<td><font color="black">在线</font></td>
<% else %>
<td><font color="black">离线</font></td>
<% end if %>
<td><a href="cktp.asp?action=修改&id=<%=Cstr(rs("ID"))%>" >修改</a></td>
<td><font color="black"><%=rs("weizhi")%></font></td>
<td><font color="black"><%=rs("PubDate")%></font></td>
</tr>
<%
rowcount=rowcount-1
rs.movenext
loop
end if
end if
rs.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('该操作不可恢复!\n\n确定删除选定的图片?')){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('确定打开选定的图片在线?')){this.document.Newslist.submit();return true;}return false;}">
<select name="weizhi">
<option>居上</option>
<option>居中</option>
<option>居下</option>
</select>
<input type="submit" name="action" value="位置改变" onclick="{if(confirm('确定改变选定的图片位置?')){this.document.Newslist.submit();return true;}return false;}">
</td>
<td class=b colspan=2> </td>
</tr>
<tr>
<td class=b><div align="center"><font color="#000000">按类型搜索:</font>
</div></td>
<td class=b><select name="sousuo">
<option>++选择所居位置++</option>
<option>居上</option>
<option>居中</option>
<option>居下</option>
</select></td>
<td class=b> </td>
<td class=b> </td>
<td class=b><input type="submit" name="Submit" value="搜索"></td>
<td class=b colspan=2>
</td>
</tr>
</form>
</table>
<%call listPages()%>
<%
sub listPages()
if n <= 1 then exit sub
%>
<p><font color=black face="arial">>></font>
<%if currentpage = 1 then%>
<font color=black>首页</font>
<%else%>
<a href="<%=request.ServerVariables("script_name")%>?page=1">
<font color=black face="arial">首页</font></a>
<a href="<%=request.ServerVariables("script_name")%>?page=<%=currentpage-1%>">
<font color=black face="arial" >前页</font></a>
<%end if%>
<%if currentpage = n then%>
<font color=black face="arial" >后页</font>
<%else%>
<a href="<%=request.ServerVariables("script_name")%>?page=<%=currentpage+1%>"><font color=black face="arial" >下页</font></a>
<a href="<%=request.ServerVariables("script_name")%>?page=<%=n%>"><font color=black face="arial" >末页</font></a>
<%end if%>
<font color=black face="arial" >
总:<%=currentpage%>/<%=n%>页 <%=msg_per_page%>新闻/页 共:<%=totalrec%>新闻</font></p>
<%end sub%>
<%
action=request("action")
if action="关闭" then
NewsId=replace(request("id")," ","")
call prodclose()
end if
if action="打开" then
NewsId=replace(request("id")," ","")
call prodopen()
end if
if action="删除" then
delid=replace(request("id")," ","")
call proddel()
end if
if action="修改" then
id=replace(request("id")," ","")
call modify()
end if
if action="位置改变" then
NewsID=replace(request("id")," ","")
weizhi=request("weizhi")
call gaibianwz()
end if
if action="提交" then
weiguang=request("weiguang")
hw_pic=request("hw_pic")
hw2=request("hw2")
online=request("online")
if hw_pic="" then
%>
<script language="javascript">
if (confirm("请您选择图片的正确路径!"))
location.href="cktp.asp";
</script>
<%
end if
call tijiao()
end if
%>
</table></td>
</tr>
</table>
</body>
</html>
<%
sub proddel()
if delid="" or isnull(delid) then
Response.write "<BLOCKQUOTE><br><br>操作失败,没有选择合适参数!<A HREF='cktp.asp'><b>点击返回</b></A><BR><br><meta http-equiv=refresh content=""2;URL=cktp.asp""></BLOCKQUOTE>"
else
conn.execute("delete from hw where ID in ("&delid&")")
if err.number<>0 then '错误处理
response.write "<font color=black>数据库操作失败:</font>" & err.description
err.clear
else
conn.close
set conn=nothing
Response.write "<tr><td colspan=8><BLOCKQUOTE><br><br><font color=black>图片删除成功!</font><A HREF='cktp.asp'><b><font color=black>点击返回</font></b></A><BR><br><meta http-equiv=refresh content=""2;URL=cktp.asp""></BLOCKQUOTE></td></tr>"
end if
end if
end sub
sub modify()
if id="" then
response.write "非法图片编号"
response.write "<meta http-equiv=refresh content=""1;URL=cktp.asp"">"
else
'修改图片资料
%>
<form name="form" method="post" action="cktp.asp">
<table width="100%" border="0" cellpadding="2" cellspacing="5" style="border-collapse: collapse" bordercolor="#222222">
<tr>
<td colspan="2"> <font color="#FF0000">商品图片</font>
<input type="text" name="hw_pic" value size="46" class=input>首页摆放位置:
<select name="hw2" id="hw2">
<option>居上</option>
<option>居中</option>
<option>居下</option>
</select><br>
是否在线:是
<input type="radio" name="online" value="1">
否
<input name="online" type="radio" value="0" checked>
<input type="hidden" name="weiguang" value="<%=id%>" size="46" class=input>
<input type="hidden" name="action" value="提交" size="46">
</td>
</tr>
<tr>
<td colspan="2"><IFRAME src="wangrui.asp" frameBorder=0 width="100%" height="30" scrolling=no height=21></IFRAME></td>
</tr>
</table>
<input type="submit" name="aa" value="提交">
</form>
<%
end if
end sub
sub tijiao()
Set rs=Server.CreateObject("ADODB.Recordset")
sql="select * from hw where ID="&weiguang
rs.open sql,conn,3,2
rs("hw_name")=hw_pic
rs("PubDate")=now()
rs("weizhi")=hw2
if online="1" then
rs("online")=true
end if
rs.update
%>
<script language="javascript">
if (confirm("图片信息修改成功!"))
location.href="cktp.asp";
</script>
<%
end sub
sub prodopen()
if NewsId="" or isnull(NewsId) then
Response.write "<BLOCKQUOTE><br><br>操作失败,没有选择合适参数!<A HREF='cktp.asp'><b>点击返回</b></A><BR><br><meta http-equiv=refresh content=""2;URL=cktp.asp""></BLOCKQUOTE>"
else
Set rs=Server.CreateObject("ADODB.Recordset")
sql="select * from hw where ID in ("&NewsId&")"
rs.open sql,conn,3,2
if err.number<>0 then '错误处理
response.write "数据库操作失败:" & err.description
err.clear
else
if rs.eof and rs.bof then
response.write "<script language='javascript'>"
response.write "alert('该图片不存在,或者被删除了!');"
response.write "location.href='cktp.asp';"
response.write "</script>"
else
Do while not rs.eof
rs("online")=true
rs.update
rs.movenext
loop
response.write "<script language='javascript'>"
response.write "alert('图片 在线显示 设置成功!');"
response.write "location.href='cktp.asp';"
response.write "</script>"
end if
rs.close
conn.close
set rs=nothing
set conn=nothing
end if
end if
end sub
sub prodclose()
if NewsId="" or isnull(NewsId) then
Response.write "<BLOCKQUOTE><br><br>操作失败,没有选择合适参数!<A HREF='cktp.asp'><b>点击返回</b></A><BR><br><meta http-equiv=refresh content=""2;URL=cktp.asp""></BLOCKQUOTE>"
else
Set rs=Server.CreateObject("ADODB.Recordset")
sql="select * from hw where ID in ("&NewsId&")"
rs.open sql,conn,3,2
if err.number<>0 then '错误处理
response.write "数据库操作失败:" & err.description
err.clear
else
if rs.eof and rs.bof then
response.write "<script language='javascript'>"
response.write "alert('该图片不存在,或者被删除了!');"
response.write "location.href='cktp.asp';"
response.write "</script>"
else
Do while not rs.eof
rs("online")=false
rs.update
rs.movenext
loop
response.write "<script language='javascript'>"
response.write "alert('图片 离线 设置成功!');"
response.write "location.href='cktp.asp';"
response.write "</script>"
end if
rs.close
conn.close
set rs=nothing
set conn=nothing
end if
end if
end sub
sub gaibianwz()
if NewsId="" or isnull(NewsId) then
Response.write "<BLOCKQUOTE><br><br>操作失败,没有选择合适参数!<A HREF='cktp.asp'><b>点击返回</b></A><BR><br><meta http-equiv=refresh content=""2;URL=cktp.asp""></BLOCKQUOTE>"
else
Set rs=Server.CreateObject("ADODB.Recordset")
sql="select * from hw where ID in ("&NewsId&")"
rs.open sql,conn,3,2
if err.number<>0 then '错误处理
response.write "数据库操作失败:" & err.description
err.clear
else
if rs.eof and rs.bof then
response.write "<script language='javascript'>"
response.write "alert('该图片不存在,或者被删除了!');"
response.write "location.href='cktp.asp';"
response.write "</script>"
else
Do while not rs.eof
rs("weizhi")=weizhi
rs.update
rs.movenext
loop
response.write "<script language='javascript'>"
response.write "alert('图片 位置 改变成功!');"
response.write "location.href='cktp.asp';"
response.write "</script>"
end if
rs.close
conn.close
set rs=nothing
set conn=nothing
end if
end if
end sub
%>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?