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

📄 pay1.asp

📁 数据库课程设计
💻 ASP
字号:
<%@ LANGUAGE="VBScript" %>
<script language="vbscript" src="details.vbs"></script>
<html>
<head><title>购书清单</title>
<script language="vbscript">
<!--
' 注释:定义表单[fpay]的提交事件,用于数据验证
   Function fpay_OnSubmit
      Dim ermsg
      ermsg = ""
      If fpay.affirm.value = "" Then
         ermsg = "[认证码]不能为空!请先输入..."
         fpay.affirm.focus
      ElseIf fpay.affirm.value <> fhd.affirm.value Then
         ermsg = "[认证码]不能正确!请重新输入..."
         fpay.affirm.value = ""
         fpay.affirm.focus
      ElseIf fpay.name.value = "" Then
         ermsg = "[签收人]不能为空!请先输入..."
         fpay.name.focus
      ElseIf fpay.address.value = "" Then
         ermsg = "[地址]不能为空!请先输入..."
         fpay.address.focus
      End If
      
      If ermsg = "" Then
         fpay_OnSubmit = True
      Else
         Alert(ermsg)
         fpay_OnSubmit = False
      End If
   End Function
-->
</script>
</head>
<body bgcolor="#FFFF99"><body background="img\backgd.jpg"></body>
<center>
<font size="5" face="楷体_GB2312"><b>购书结算</b></font><hr>
<%
   If Request("ISBNs") = "" Or Request("nums") = "" Then ' 避免非法调用
      Response.Write("<p><b>您还没有订购任何图书!请订购后重试...</b>")
      Response.Write("<a href=# onclick='vbscript:window.close'>关闭窗口</a>")
   Else
   ' 注释:获得用户信息
      userid = "guest" : rank = "0" : affirm = "guest"
      address = "" : name = "" : zip = "" : tel = "" : email = ""
      Set objRS = Session("objRS")
      If Session("userid") <> "" Then
         mysql = "SELECT affirmcode, name, zipcode, address, tel, email " & _
                   "FROM customer " & _
                  "WHERE id = '" & Session("userid") & "'"
         objRS.Source = mysql
         objRS.Open
         If objRS.RecordCount > 0 Then
            userid = Session("userid")
            rank = Session("rank")
            name = objRS("name")
            affirm = objRS("affirmcode")
            zip = objRS("zipcode")
            address = objRS("address")
            tel = objRS("tel")
            email = objRS("email")
         End If
         objRS.Close
      End If
   ' 注释:根据用户身份确定打折系数
      If rank > 1 Then
         rebate = 0.7
      ElseIf rank = 1 Then
         rebate = 0.8
      Else
         rebate = 0.9
      End If
   ' 注释:获得购书信息
      aISBN = Split(Request("ISBNs"), ";")
      anum = Split(Request("nums"), ";")
      isbnstr = ""
      For Each isbn IN aISBN
         If isbnstr = "" Then
            isbnstr = "'" & isbn & "'"
         Else
            isbnstr = isbnstr & ",'" & isbn & "'"
         End If
      Next
      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 " & _
               "WHERE a.ISBN IN (" & isbnstr & ")"
      objRS.Source = mysql
      objRS.Open
   ' 注释:显示购书信息
      sum = 0 : prices = ""
      For i = 1 To objRS.RecordCount
         If i = 1 Then  ' 显示表头信息
            outstr = _
               "<form name=fpay action=pay2.asp method=post>" & _
               "【<b>您的购书清单</b>】" & _
               "<table border=1 width='80%' bgcolor=#ccffcc>" & _
               "<tr><th>书 名</th><th>书 号</th><th>作 者</th>" & _
               "<th>出版社</th><th>定 价</th><th>数 量</th></tr>"
         End If
      ' 注释:获得价格信息
         price = CSng(objRS("price"))
         sum = sum + price * CSng(anum(i - 1))
         price = price * rebate
         If prices = "" Then
            prices = CStr(price)
         Else
            prices = prices & ";" & CStr(price)
         End If
      ' 注释:生成购书清单
         outstr = outstr & _
            "<tr>" & _
            "<td><a href=detail.asp?ISBN=" & objRS("ISBN")  & ">" & _
             objRS("btitle") & "</a></td>" & _
            "<td>" & objRS("ISBN") & "</td>" & _
            "<td>" & objRS("author") & "</td>" & _
            "<td>" & objRS("ptitle") & "</td>" & _
            "<td>¥" & objRS("price") & "元</td>" & _
            "<td align=center>" & anum(i - 1) & "本</td>" & _
            "</tr>"
         objRS.MoveNext
      Next
      objRS.Close
      outstr = outstr & _
         "<tr><th colspan=6 align=left>总计:" & sum & "元 " & _
         "<font color=red>您是"
      If rank > 1 Then
         outstr = outstr & _
         "高级会员!享受7折优惠—需支付" & sum*0.7 & "元,可节省" & sum*0.3 & "元"
      ElseIf rank = 1 Then
         outstr = outstr & _
         "普通会员!享受8折优惠—需支付" & sum*0.8 & "元,可节省" & sum*0.2 & "元"
      Else
         outstr = outstr & _
         "普通顾客!享受9折优惠—需支付" & sum*0.9 & "元,可节省" & sum*0.1 & "元"
      End If
      sum = sum * rebate
   ' 注释:显示购书清单
      outstr = outstr & "</font></th></tr></table>"
      Response.Write(outstr)
      Set objRS = Nothing
%>
<!-- 生成订购者信息表单 -->
<p><hr><table>
<tr><th colspan="2" align="left">
<font color="blue">会员信息(请检查是否正确!)</font>
</th></tr>
<tr><th align="right">会员名:</th><td>
<input name="userid" type="text" size="30" readonly value=<% =userid %>>
</td></tr>
<tr><th align="right">认证码:</th><td>
<input name="affirm" type="password" size="30"
<% If rank = "0" Then %>
   readonly value="guest"
<% End If %>
><font color="red"> *</font></td></tr>
<tr><th align="right">付款方式:</th><td>
<select name="paytype">
<option value="现金支付">现金支付&nbsp;&nbsp;</option>
<option value="邮寄货款">邮寄货款</option>
<option value="网上银行">网上银行</option>
<option value="短信支付">短信支付</option>
</select></th></tr>
<tr><th colspan="2" align="left">
<font color="blue">配送信息(必须认真填写!)</font>
</th></tr>
<tr><th align="right">签收人:</th><td>
<input name="name" type="text" maxlength="20" size="30" value=<% =name %>>
<font color="red">*</font></td></tr>
<tr><th align="right">配送地址:</th><td>
<input name="address" type="text" maxlength="50" size="30" value=<% =address %>>
<font color="red">*</font></td></tr>
<tr><th align="right">邮编:</th><td>
<input name="zip" type="text" maxlength="6" size="30" value=<% =zip %>>
</td></tr>
<tr><th align="right">联系电话:</th><td>
<input name="tel" type="text" maxlength="50" size="30" value=<% =tel %>>
</td></tr>
<tr><th align="right">E-Mail:</th><td>
<input name="email" type="text" maxlength="50" size="30" value=<% =email %>>
</td></tr>
</table><hr>
<input type="submit" value=" 提 交 ">
<input type="reset" value=" 充 填 ">
<!-- 用隐藏控件保存购书信息 -->
<input name="ISBNs" type="hidden" value=<% =Request("ISBNs") %>>
<input name="nums" type="hidden" value=<% =Request("nums") %>>
<input name="prices" type="hidden" value=<% =prices %>>
<input name="sum" type="hidden" value=<% =sum %>>
</form>
<!-- 用隐藏控件保存[认证码],该信息不需要提交 -->
<form name="fhd">
<input name="affirm" type="hidden" value=<% =affirm %>>
</form>
<% End If %>
</center>
</body>
</html>

⌨️ 快捷键说明

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