⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 delhw.asp

📁 图书管理系统功能完善,界面美观.这是基于ASP做的一个简单的系统,同大家一起分享.
💻 ASP
字号:
<%
'如果用户没有登陆,则结束响应
if session("admin_name")="" then response.end

'记录集对象
set rs=server.createobject("adodb.recordset")
%>
<!--#include file="conn.asp"-->
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312">
<link href=../style.css rel=stylesheet type=text/css>
</head>

<%
'如果是进行删除操作
if request("action")="del" then
	'获得指定的商品记录
	sql="select * from hw where hw_id="&request("hw_id")
	'打开记录集
	rs.open sql,conn,3,3

	'如果记录集为空
	if rs.eof then
		'重转向delhw.asp页面
	response.redirect "delhw.asp"
    else
		'删除指定的新闻记录
		rs.delete
		'更新数据库
		rs.update
    end if
    
	'关闭记录集
    rs.close

	'提示用户删除成功
	'显示返回链接
    response.write "货物删除成功"
    response.write "<br>"
    response.write "<a href=delhw.asp>返回</a>"
else
	'分页显示所有的商品信息
%>
<table border="0" width="100%" cellspacing="1" height="10">
<%
	'获得指定的页数
	page=request.querystring("page")

	'如果页数为空,或者不是数字
	'或者为数字但小于1,都将页数设置为1
	if page="" then page=1
	if not(isnumeric(page)) then page=1
	page=int(page)
	if page<1 then page=1
 
	'查询hw数据表,获得所有商品记录
	sql="select * from hw order by hw_id desc"
	'打开记录集
	rs.open sql,conn,3,3

	'如果记录集为空,则显示没有货物资料
	if rs.eof then
		response.write "暂且没有货物资料"
		response.end
	else
		'设置每页显示记录条数
		rs.pagesize=10
		'总的记录条数
		totalrec=rs.recordcount
		'总的页数
		totalpage=rs.pagecount

		'如果当前页数大于总页数,则将其设置为总页数
		if page>totalpage then page=totalpage

		'设置记录集的当前页数
		rs.absolutepage=page

		i=0
		'数组定义
		dim hw_id(),hw_name(),hw_cash(),hw_pic(),hw_date()

		'循环将记录集中的每一条记录的相关字段保存到相应数组中
		do while not rs.eof and (i<rs.pagesize)
			i=i+1
			redim preserve hw_id(i),hw_name(i),hw_cash(i),hw_pic(i),hw_date(i)
			'商品的id号
			hw_id(i)=rs("hw_id")
			'货物名称
			hw_name(i)=rs("hw_name")
			'商品价格
			hw_cash(i)=rs("hw_cash")
			'商品示例图片
			hw_pic(i)=rs("hw_pic")
			'加入日期
			hw_date(i)=rs("hw_date")

			'移至下一条记录
			rs.movenext
		loop
	end If
	
	'关闭记录集
	rs.close

	'循环记录集中每件商品的信息和操作链接
	for i = 1 to ubound(hw_id)
%>
	<tr>
	<td width="100%"><img border="0" src="../<%=hw_pic(i)%>" width="100" height="100">
	<br>商品编号:<%=hw_id(i)%><br>
	商品名称:<%=hw_name(i)%><br>
	商品价格:<%=hw_cash(i)%><br>
	加入日期:<%=hw_date(i)%><br>
	<a href="delhw.asp?hw_id=<%=hw_id(i)%>&action=del">删除此商品</a></td>
	</tr>
	<tr>
    <td width="100%"></td>
	</tr>
<%
	next
%>
	<tr>         
	<td width=478>        
	<p align="left">共<font color=red><%=totalpage%></font>页 第<%=page%>页        
	<font color=666666><%if page-1>0 then%>
	<a href="delhw.asp?page=<%=page-1%>">上一页</a>
	<%else%><font color=666666>上一页</font><%end if%>
	<%if page+1<=totalpage then%>
	<a href="delhw.asp?page=<%=page+1%>">下一页</a>
	<%else%><font color=666666>下一页</font><%end if%></font></p>    
	</td>     
	</tr>  
	<tr>
    <td width="100%"></td>
  </tr>
</table>
<%
end If

'释放记录集对象
set rs=nothing

'关闭数据库连接,释放对象
conn.close
set conn=nothing
%>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -