📄 productlist.asp
字号:
<!-- #include file = "include/sysbase.asp" -->
<!-- #include file = "../include/config.asp" -->
<%
'========================================================
'
' 将所有厂商添加到下拉列表框中
' 说明:这里只添加ProductType表中SuperId=0的记录
' 参数:
' nTypeId:当前选种的厂商名称ID
' szCtlName:下拉列表框的名称,在获取表单中的数时用
'========================================================
function TypeToSelect(nTypeId, szCtlName)
dim strSQL
dim rsType
dim tempi
dim nID, szName
Response.Write "<SELECT name =""" & szCtlName & """>"
Response.Write "<option value = ""0"">全部分类</option>"
strSQL = "SELECT * FROM ProductType WHERE SuperID = 0"
set rsType = Server.CreateObject("ADODB.RecordSet")
rsType.Open strSQL, conn, adOpenKeyset, adLockReadOnly
if rsType.EOF And rsType.BOF then
'如果没有检索到产品类型
Response.Write "</SELECT>"
rsType.Close()
Set rsType = Nothing
exit function
else
do while not rsType.eof
nID = rsType("id")
szName = rsType("name")
Response.Write "<option value = "& nID
'如果当前的nID与传入的nTypeId相同,则选中它
if CInt(nID) = CInt(nTypeId) then Response.Write " selected"
Response.Write ">"
Response.Write szName &"</option>"
rsType.MoveNext
loop
end if
Response.Write "</SELECT>"
rsType.Close()
Set rsType = Nothing
end function
dim ProductTypeDic, strSQL, rsObj, rsType
dim thisUrl
'文件从此处开始执行,上面只是函数定义和变量定义
'将商品类型编号和名称加入到ProductTypeDic 备用
Set ProductTypeDic = Server.CreateObject("Scripting.Dictionary")
strSQL = "SELECT * FROM ProductType "
set rsType = conn.Execute (strSQL)
dim tempID, tempName
do while not (rsType.eof or err)
tempID = CStr(rsType("id"))
tempName = rsType("Name")
ProductTypeDic.Add tempID, tempName
rsType.MoveNext
loop
'关闭并释放记录集,但不要关闭连接,因为下面还要用到
rsType.Close()
Set rsType = Nothing
dim page, myKeyword, ProductType
'获取查询关键词
myKeyword = RealString(Request.Form("myKeyword"))
'获取所显示的手机厂商
ProductType = RealString(Request.Form("ProductType"))
if ProductType = "" then ProductType = "0"
'获取所示的页号
page = Request.QueryString("page")
if (page = "" or IsEmpty(page)) then page = 1
'thisUrl为分页用
thisUrl = "productList.asp?ProductType=" & ProductType & "&myKeyword=" & myKeyword
Session("adminOldUrl") = thisUrl&"&page = "&page
'组织SQL语句,注意这里WHERE 1=1的妙用
strSQL = "SELECT * FROM product WHERE 1 = 1"
if not (myKeyword = "" or IsEmpty(myKeyword) ) then
strSQL = strSQL & " AND name like '%" & myKeyword& "%' "
end if
if ProductType>0 then
strSQL = strSQL & " AND ProductType =" & ProductType
end if
strSQL = strSQL & " ORDER by id desc"
set rsObj = Server.CreateObject("ADODB.RecordSet")
rsObj.Open strSQL, conn, adOpenKeyset, adLockReadOnly
rsObj.pagesize = conMaxPerPage
%>
<html>
<head>
<title>后台管理</title>
<meta http-equiv = "Content-Type" content = "text/html; charset = gb2312">
<link rel = "stylesheet" href = "include/main.css" type = "text/css">
<script language = "JavaScript">
<!--
function recommend(i){
if (confirm("确定 推荐/取消推荐 该手机("+i+"号手机)?") == 1){
window.location = "proRecommend.asp?id=" + i;
}
}
function deleteMe(i){
if(confirm("确定删除?(无法恢复)") == 1){
window.location = "proDel.asp?id=" + i;
}
}
// -->
</script>
<script language = Javascript src = "../include/opennew.js"></script>
</head>
<body text = "#000000" leftmargin = "0" topmargin = "2">
<div align = center>手机列表</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 = "9" bgcolor = "#4296E7">
<div align = "right">
<input type = "text" name = "myKeyword" size = "16">
<% call TypeToSelect(ProductType, "ProductType") %>
<input type = "submit" name = "Submit" value = "搜索">
</div>
</td>
</form>
</tr>
<!-- 下面这个 tr 标记为手机列表头--->
<tr bgcolor = "#5EA5E6">
<td width = "6%" nowrap>
<div align = "center"><font color = "#FFFFFF">编号</font></div>
</td>
<td nowrap>
<div align = "center"><font color = "#FFFFFF">手机名称</font></div>
</td>
<td width = "2%" nowrap>
<div align = "center"><font color = "#FFFFFF">荐</font></div>
</td>
<td width = "12%" nowrap>
<div align = "center"><font color = "#FFFFFF">手机类别</font></div>
</td>
<td width = "9%" nowrap>
<div align = "center"><font color = "#FFFFFF">会员价(¥)</font></div>
</td>
<td width = "9%" 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 = "15%" nowrap bgcolor = "#5EA5E6">
<div align = "center"><font color = "#FFFFFF">手机图片</font></div>
</td>
<td width = "9%" nowrap bgcolor = "#5EA5E6">
<div align = "center"><font color = "#FFFFFF">删除</font></div>
</td>
</tr>
<%
dim nID, i
dim bShowAdd, sAddPage
i = 1
if not (rsObj.eof or err) then rsObj.move (page-1)*conMaxPerPage
do while not (rsObj.eof or err)
nID = rsObj("id")
%>
<tr>
<td width = "6%"><%=nID%> </td>
<td style = "cursor:hand" title = "点击查看具体信息" onClick = "Javascript:window.location = 'proModify.asp?id=<%=rsObj("id")%>'" ><%=rsObj("name")%> </td>
<%
if rsObj("recommend") = 1 then %>
<td width = '2%' bgcolor = "rgb(210,232,255)" style = 'cursor:hand' onClick = 'recommend(<%=nID%>)'>√
<%
else
%>
<td width = '2%' style = 'cursor:hand' onClick = 'recommend(<%=nID%>)'>×
<%
end if
%>
</td>
<td width = "12%">
<%
Response.Write ProductTypeDic.item(cstr(rsObj("ProductType")))
'Response.Write rsObj("ProductType")
%>
</td>
<td width = "9%"><%=rsObj("memberPrice")%> </td>
<td width = "9%"><%=rsObj("marketPrice")%> </td>
<td width = "7%"><%=rsObj("buyNum")%></td>
<td width = "15%">
<div align = "center">
<%if rsObj("smallImg") = "nothing" then%>
<img src = "../images/smallImgAdd.gif" width = "20" height = "20" title = "添加小图片" style = "cursor:hand" onClick = "opennew('proAddPic.asp?type=smallImg&id=<%=nID%>','addPicture',400,80)" align = "absmiddle">
<%else %>
<img src = "../images/smallImgMod.gif" width = "20" height = "20" title = "修改小图片" style = "cursor:hand" onClick = "opennew('proAddPic.asp?type=smallImg&id=<%=nID%>','addPicture',400,80)" align = "absmiddle">
<%end if %>
<%if rsObj("bigImg") = "nothing" then%>
<img src = "../images/bigImgAdd.gif" width = "20" height = "20" title = "添加大图片" style = "cursor:hand" onClick = "opennew('proAddPic.asp?type=bigImg&id=<%=nID%>','addPicture',400,80)" align = "absmiddle">
<%else %>
<img src = "../images/bigImgMod.gif" width = "20" height = "20" title = "修改大图片" style = "cursor:hand" onClick = "opennew('proAddPic.asp?type=bigImg&id=<%=nID%>','addPicture',400,80)" align = "absmiddle">
<%end if %>
</div>
</td>
<td align=center nowrap >
<a href="javascript:deleteMe(<%=nID%>)">删除</a>
</td>
</tr>
<%
i = i+1
if i>conMaxPerPage then exit do
rsObj.MoveNext
loop
%>
<tr bgcolor = "#4296E7">
<td colspan = "9">
<% bShowAdd = True
sAddPage = "proAdd.asp"
%>
<!-- #include file = "include/pageguide.asp"-->
<%
rsObj.Close()
Set rsObj = Nothing
CloseConn()
%>
</td>
</tr>
</table>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -