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

📄 sale4.asp

📁 数据库课程设计
💻 ASP
字号:
<%@ LANGUAGE="VBScript" %>
<html>
<head>
<script language="vbscript">
<!--
' 注释:定义放入购物袋的操作过程
   Sub DoOrder(infstr)
   ' 注释:获取图书订购数量
      ordernum = Prompt("请输入您的订购数量!", "1")
   ' 注释:验证订购数量信息
	  If Not IsNull(ordernum) Then
		 If IsNumeric(ordernum) Then
		 ' 注释:将购书信息以字符串的形式保存在文件sale5.asp隐藏表单控件中
            bookinf = Split(infstr, ";")
            If parent.sale5.fbag.ISBNs.value = "" Then
               parent.sale5.fbag.ISBNs.value = bookinf(0)
               parent.sale5.fbag.titles.value = bookinf(1)
               parent.sale5.fbag.nums.value = ordernum
            Else
               parent.sale5.fbag.ISBNs.value = parent.sale5.fbag.ISBNs.value & ";" & bookinf(0)
               parent.sale5.fbag.titles.value = parent.sale5.fbag.titles.value & ";" & bookinf(1)
               parent.sale5.fbag.nums.value = parent.sale5.fbag.nums.value & ";" & ordernum
            End If
		 ' 注释:更新购物袋的显示
            parent.sale5.fbag.submit
         Else
            Alert("订购数量只能用数字[0-9]表示!请重试...")
         End If
      End If
   End Sub
-->
</script>
</head>
<body bgcolor="#FFFF99">
<form>
<%
' 注释:生成SQL查询语句
   If Request("fid") <> "" Then
      where = "a.typeid='" & Request("fid") & "'"
   ElseIF Request("title") <> "" Then
      where = "a.title LIKE '%" & Request("title") & "%'"
   ElseIF Request("author") <> "" Then
      where = "a.author LIKE '%" & Request("author") & "%'"
   ElseIF Request("ISBN") <> "" Then
      where = "a.ISBN = '" & Request("ISBN") & "'"
   Else
      where = ""
   End If
   mysql = "SELECT a.ISBN, a.title AS btitle, a.author, a.price, " & _
                  "b.title AS ptitle " & _
             "FROM book AS a JOIN Publisher AS b " & _
               "ON PATINDEX('%-' + b.id + '-%',a.ISBN) > 0 "
   If where <> "" Then mysql = mysql & "WHERE " & where
   
' 注释:连接数据库并执行SQL语句
	Set objRS = Session("objRS")
   objRS.Source = mysql
   objRS.Open
' 注释:显示标题信息   
   outstr = "<font size=5 face=楷体_GB2312 color=red><b>"
   If Request("type") <> "" Then
      outstr = outstr & "当前图书分类:" & Request("type")
   Else
      outstr = outstr & "图书列表:"
   End If
   outstr = outstr & "</b></font>"
   Response.Write(outstr)
' 注释:显示检索到的图书信息
   outstr = ""
   If objRS.RecordCount > 0 Then Response.Write("<table>")
   For i = 1 To objRS.RecordCount
      price = CSng(objRS("price"))
      If i > 1 Then outstr = "<tr><td colspan=4>&nbsp;</td></tr>"
      outstr = outstr & _
         "<tr><td colspan=4>" & _
         "<a href=detail.asp?ISBN=" & objRS("ISBN") & _
         " target=_blank title=查看该图书的详细信息>" & _
         "<font size=4 face=楷体_GB2312><b>" & objRS("btitle") & "</b>" & _
         "</a></td></tr>" & _
         "<tr>" &_
            "<th>书号:</th><td>" & objRS("ISBN") & "&nbsp;&nbsp;</td>" & _
            "<th>出版社:</th><td>" & objRS("ptitle") & "</td>" & _
         "</tr><tr>" & _
            "<th>作者:</th><td>" & objRS("author") & "</td>" & _
            "<th>定&nbsp;&nbsp;价:</th><td>¥" & objRS("price") & "元</td>" & _
         "</tr>" & _
         "<tr><td colspan=4>" & _
         "<font color=red>在线订购最低价:" & _
         " 7折 " & price * 0.7 & "元" & _
         " 您可节省" & price * 0.3 & "元" & _
         "</font></td></tr>" & _
         "<tr><td colspan=4>" & _
         "<a href='#' onclick=" & Chr(34) & "DoOrder('" & _
            objRS("ISBN") & ";" & _
            objRS("btitle") & "')" & Chr(34) & _
            "onmousemove=window.status='放入购物袋' onmouseout=window.status=''" & _ 
            ">放入购物袋" & _
         "</a></td></tr>"
      Response.Write(outstr)
      outstr = ""
      objRS.MoveNext
   Next
   If objRS.RecordCount > 0 Then
      Response.Write("</table>")
   Else
      Response.Write("<p><b>还没有相关图书!</b>")
   End If
   
' 注释:关闭数据记录集
   objRS.Close
   Set objRS = Nothing
%>
</form>
</body>
</html>

⌨️ 快捷键说明

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