📄 productlist.asp
字号:
<!-- #include file="../include/bkconn.asp "-->
<!--#include file="checkUser.asp"-->
<%
function selectTreeList(i,deep)
dim sql
dim rs
dim tempi
dim rsID
set rs=server.createObject("adodb.recordset")
sql="select * from productSort where fatherID="&i
rs.open sql,conn,1,1
if rs.eof then
exit function
else
do while not rs.eof
rsID=rs("id")
rsName=rs("name")
response.write "<option value="&rsID
if rsID=productSort then response.write " selected"
response.write ">"
for tempi=1 to deep
response.write " "
next
response.write rsName&"</option>"
call selectTreeList(rsID,deep+1)
rs.movenext
loop
end if
end function
function getSort(i) '该函数获取类别下的所有子类,符合一般搜索习惯
dim rs,sql
set rs=server.createObject("adodb.recordset")
sql="select * from productSort where fatherID="&i
rs.open sql,conn,1,1
do while not rs.eof
strSort=strSort&","&rs("id") '&rs("name")
call getSort(rs("id"))
rs.movenext
loop
end function
dim productSortDic
'set productSortDic = Server.CreateObject("Scripting.Dictionary")
Set productSortDic = CreateObject("Scripting.Dictionary")
sql="select * from productSort where 1=1"
set productSortRs=conn.Execute (sql)
dim tempName
dim tempID
do while not (productSortRs.eof or err)
tempID=cstr(productSortRs("id"))
tempName=productSortRs("name")
productSortDic.Add tempID,tempName
' response.write " 字典:"&productSortDic.item(cstr(productSortRs("id")))
' response.write " id:"&productSortRs("id")
' response.write " name:"&productSortRs("name")
productSortRs.moveNext
loop
dim rs,sql
dim strSort '保留所选的类的所有子类
dim page,maxPerPage
maxPerPage=10 '每页显示的记录数
myKeyword=trim(Request("myKeyword"))
itemno=trim(Request("itemno"))
productSort=cint(Request("productSort"))
strSort=productSort
CALL getSort(productSort)
page=Request("page")
if (page="" or isempty(page)) then page=1
thisUrl="productList.asp?productSort="&productSort&"&myKeyword="&myKeyword&"&itemno="&itemno
session("adminOldUrl")=thisUrl&"&page="&page
set rs=server.createobject("adodb.recordset")
sql="select * from product where 1=1"
if not (myKeyword="" or isempty(myKeyword) ) then
sql=sql&" and name like '%"&myKeyword&"%'"
end if
if not (itemno="" or isempty(itemno) ) then
sql=sql&" and itemno like '%"&itemno&"%'"
end if
if productSort>0 then
sql=sql&" and productSort in ("&strSort&")"
end if
sql=sql&" order by id desc"
'response.write sql
'response.End
rs.open sql,conn,1,1
rs.pagesize=MaxPerPage
%>
<html>
<head>
<title>后台管理</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="../main.css" type="text/css">
<script language="JavaScript">
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
function jumpTo(i){
if(i==1){
this.document.location="<%=thisUrl%>";}
if(i==2){
this.document.location="<%=thisUrl%>&page=<%=page-1%>";}
if(i==3){
this.document.location="<%=thisUrl%>&page=<%=page+1%>";}
if(i==4){
this.document.location="<%=thisUrl%>&page=<%=rs.pageCount%>";}
}
function recommend(i){
if (confirm("确定 推荐/取消推荐 该商品("+i+"号商品)?")==1){
window.location="recommend.asp?id="+i;
}
}
// -->
</script>
<script language=Javascript src="../include/opennew.js"></script>
</head>
<body bgcolor="#9CC7EF" text="#000000" leftmargin="0" topmargin="4">
<div align="center"><br>
商品管理 </div>
<table width="98%" border="1" bordercolordark=#9CC7EF bordercolorlight=#145AA0 cellspacing="0" cellpadding="4" align="center">
<tr>
<form method="post" action="productList.asp" name="form1">
<td colspan="8" bgcolor="#4296E7"> <div align="right"><font color="#FFFFFF">商品编号
<input type="text" name="itemno" size="16" value="<%=itemno%>">
商品名称</font>
<input type="text" name="myKeyword" size="16" value="<%=myKeyword%>">
<select name="productSort">
<option value="0">全部分类</option>
<%call selectTreeList(0,0)%>
</select>
<input type="submit" name="Submit" value="搜索">
</div></td>
</form>
</tr>
<tr bgcolor="#5EA5E6">
<td width="3%" nowrap> <div align="center"><font color="#FFFFFF">编号</font></div></td>
<td width="24%" nowrap> <div align="center"><font color="#FFFFFF">商品名称</font></div></td>
<td width="3%" nowrap><div align="center"><font color="#FFFFFF">特价</font></div></td>
<td width="3%" nowrap> <div align="center"><font color="#FFFFFF">推荐</font></div></td>
<td width="7%" nowrap> <div align="center"><font color="#FFFFFF">商品类别</font></div></td>
<td width="5%" nowrap> <div align="center"><font color="#FFFFFF">价格(¥)</font></div></td>
<td width="5%" nowrap> <div align="center"><font color="#FFFFFF">订购量</font></div></td>
<td width="11%" nowrap bgcolor="#5EA5E6"> <div align="center"><font color="#FFFFFF">商品图片(小/大)</font></div></td>
</tr>
<%
dim rsID
i=1
if not (rs.eof or err) then rs.move (page-1)*maxPerPage
do while not (rs.eof or err)
rsID=rs("id")
%>
<tr>
<td><%=rsID%> </td>
<td style="cursor:hand" title="点击查看具体信息" onClick="Javascript:window.location='productMod.asp?id=<%=rs("id")%>'" bgcolor="#63B2FF"><%=rs("name")%> </td>
<td>
<%if rs("tejia")=1 then %>
<div align="center"><font color="#FF0000">√</font></div>
<%else %>
<div align="center">×</div>
<%end if%>
<td>
<%if rs("recommend")=1 then %>
<div align="center"><font color="#FF0000">√</font></div>
<%else %>
<div align="center">×</div>
<%end if%>
<td>
<%
'productSortRs.moveFirst
response.write productSortDic.item(cstr(rs("productSort")))
%>
</td>
<td><%=rs("memberPrice")%> </td>
<td><%=rs("buyNum")%></td>
<td> <div align="center">
<%if rs("smallImg")="nothing" then%>
无
<%else %>
有
<%end if %>
<%if rs("bigImg")="nothing" then%>
无
<%else %>
有
<%end if %>
<br>
<%if rs("smallImg")="nothing" then%>
<img src="../images/smallImgAdd.gif" width="20" height="20" title="添加小图片" style="cursor:hand" onClick="opennew('addPicture.asp?type=smallImg&id=<%=rsID%>','addPicture',400,80)" align="absmiddle">
<%else %>
<img src="../images/smallImgMod.gif" width="20" height="20" title="修改小图片" style="cursor:hand" onClick="opennew('addPicture.asp?type=smallImg&id=<%=rsID%>','addPicture',400,80)" align="absmiddle">
<%end if %>
<%if rs("bigImg")="nothing" then%>
<img src="../images/bigImgAdd.gif" width="20" height="20" title="添加大图片" style="cursor:hand" onClick="opennew('addPicture.asp?type=bigImg&id=<%=rsID%>','addPicture',400,80)" align="absmiddle">
<%else %>
<img src="../images/bigImgMod.gif" width="20" height="20" title="修改大图片" style="cursor:hand" onClick="opennew('addPicture.asp?type=bigImg&id=<%=rsID%>','addPicture',400,80)" align="absmiddle">
<%end if %>
</div></td>
</tr>
<%
i=i+1
if i>maxPerPage then exit do
rs.moveNext
loop
%>
<tr bgcolor="#4296E7">
<td colspan="8"> <div align="right"><font color=#FFFFFF><%=rs.recordCount%>
项 第<%=page%>/<%=rs.pageCount%> 页 </font>
<%if page>1 then%>
<input type="button" name="Submit3" value="首页" onClick="Javascript:jumpTo(1)">
<input type="submit" name="Submit4" value="上页" onClick="Javascript:jumpTo(2)">
<%else%>
<input type="button" name="Submit3" value="首页" disabled>
<input type="submit" name="Submit4" value="上页" disabled>
<%end if
if rs.recordCount>page*maxPerPage then%>
<input type="submit" name="Submit5" value="下页" onClick="Javascript:jumpTo(3)">
<input type="submit" name="Submit6" value="末页" onClick="Javascript:jumpTo(4)">
<%else%>
<input type="submit" name="Submit5" value="下页" disabled>
<input type="submit" name="Submit6" value="末页" disabled>
<%end if%>
</div></td>
</tr>
</table>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -