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

📄 gouwu.asp

📁 oracle9i程序事例集
💻 ASP
字号:
<%@LANGUAGE="VBSCRIPT"%>
<style>
<!--
a:link          { color: #4157F1; text-decoration: none }
a:visited       { color: #4157F1; text-decoration: none }
a:active        { color: #668DF4; text-decoration: none }
a:hover         { color: #668DF4; text-decoration: none; position: relative; right: 0px; top: 1px }
-->
</style>
<script language="JavaScript">
<!--
function demo(Page,scrl){
if (false)window.close();
 if  (!window.win || win.closed)  
 {
 win=open(Page,"gouwu","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,top=2,width=450,height=350,scrollbars="+scrl+",resizable=1");
 }
 else{
  win.close();
  win=open(Page,"gouwu","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,top=2,width=450,height=350,scrollbars="+scrl+",resizable=1");
  } 
}
//-->
</script>
<%
  dim conn
  dim connstr
  Set conn=Server.CreateObject("ADODB.Recordset")
  connstr="Driver={Microsoft ODBC for Oracle};server=mylink;uid=system;pwd=system;"
%>
<%
if session("user_name")="" and session("company_name")="" then
response.write "<script language=javascript>alert('对不起,您还没有登陆!');window.close();</script>"
response.End
end if

action=request.QueryString("action")

if session("user_name")<>"" then
  uname=session("user_name")
else
  uname=session("company_name")
end if

proid=request.QueryString("id")

if proid <>"" then
set rs=server.CreateObject("adodb.recordset")
sql="select product_kindnum, product_price, product_stocknum from GSCOTT.product_info_table where product_id='"&proid&"'"

rs.open sql,connstr,3,3
price=cint(rs("product_price"))
stocknum=cint(rs("product_stocknum"))
proname=rs("product_kindnum")
rs.close
end if

select case action
case "add"

if stocknum=0 then
  response.write "<script language=javascript>alert('对不起,您选购的商品“"&proname&"”暂时缺货,请选购其它商品!');window.close();</script>"
  response.end
end if

sql="select * from GSCOTT.shopping_bag_table where sb_consumername='"&uname&"' and sb_proname='"&proname&"'"

rs.open sql,connstr,1,3
if rs.recordcount=1 then
  if stocknum<(cint(rs("sb_amount"))+1) then
    response.write "<script language=javascript>alert('你选购的商品“"&proname&"”暂时缺货,请选购其它商品!');window.close();</script>"
    response.end
  end if
  rs("sb_total")=(clng(rs("sb_amount"))+1)*price
  rs("sb_amount")=cint(rs("sb_amount"))+1
  rs.update
  rs.close
  set rs=nothing
  response.Redirect "gouwu.asp?action=show"
else
  rs.addnew
  rs("sb_proname")=proname
  rs("sb_consumername")=uname
  rs("sb_amount")=1
  rs("sb_price")=price
  rs("sb_total")=price
  rs.update
  rs.close
  set rs=nothing
  response.Redirect "gouwu.asp?action=show"
end if

case "del"
  set rs=server.CreateObject("adodb.recordset")
  pname=request.QueryString("name")
  sql="select * from GSCOTT.shopping_bag_table where sb_consumername='"&uname&"' and sb_proname='"&pname&"'"
  rs.open sql,connstr,3,3
  rs.delete
  rs.close
  set rs=nothing
  response.Redirect "gouwu.asp?action=show"

case "clear"
  set rs=server.CreateObject("adodb.recordset")
  sql="select * from GSCOTT.shopping_bag_table where sb_consumername='"&uname&"'"
  rs.open sql,connstr,3,3
  if rs.eof then
  response.write "<script language=javascript>alert('对不起,您还没有选购商品!');window.close();</script>"
  response.end
  else
  conn.Open connstr
  conn.execute("delete from GSCOTT.shopping_bag_table where sb_consumername='"&uname&"'")
  conn.close
  end if
  rs.close
  set rs=nothing
  response.write "<script language=javascript>alert('您的购物车已经清空!');window.close();</script>"


case "show"
%>
<html>
<head>
<title>我的购物车</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style>
td{font-size:x-small} 
</style>
</head>
<body leftmargin="3" topmargin="5" marginwidth="0" marginheight="0">
<%
set rs=server.CreateObject("adodb.recordset")
sql="select * from GSCOTT.shopping_bag_table where sb_consumername='"&uname&"' order by sb_proname"
rs.open sql,connstr,1,1 
  if rs.eof then
  response.write "<script language=javascript>alert('对不起,您还没有选购商品!');window.close();</script>"
  response.end
  else
%>

<table width="96%" align="center" border="0" cellpadding="2" cellspacing="2">
<tr><td valign=baseline align=center>我的购物车</td></tr>
</table>
<table width="96%" border="0" align="center" cellpadding="1" cellspacing="1" bgcolor="#FFCC00">
  <form name="form1" method="post" action="xgsl.asp">
    <tr bgcolor="#FFE2A6"> 
      <td width=25% height="22"> 
        <div align=center><font color="#666666">商品型号</font></div>
      </td>	  
      <td width=15% height="22"> 
        <div align=center><font color="#666666">单价</font></div>
      </td>
      <td width=15% height="22" bgcolor="#FFE2A6"> 
        <div align=center><font color="#666666">数量</font></div>
      </td>
      <td width=15% height="22"> 
        <div align=center><font color="#666666">总价</font></div>
      </td>
      <td width=10% height="22"> 
        <div align=center><font color="#666666">删除</font></div>
      </td>
    </tr>
<%
  num=rs.recordcount
  jianshu=0
  zongji=0
do while not rs.eof
sql="select product_id from GSCOTT.product_info_table where product_kindnum='"&rs("sb_proname")&"'"
set rs_s=server.CreateObject("adodb.recordset")
rs_s.open sql,connstr,1,1
%>
    <tr bgcolor="#FFF9EC">
	  <td height="22" width="25%"> 
        <div align=center>
		<a href=shp_detail.asp?id=<%=rs_s("product_id")%> target=_blank><%=rs("sb_proname")%></a> 
        </div>
      </td>
      <td height="22" width="15%"> 
        <div align=center> 
          <%=rs("sb_price")%>元
		</div>
      </td>
      <td height="22" width="15%"> 
        <div align=center>
          <input name="<%=rs_s("product_id")%>" value="<%=rs("sb_amount")%>" size=6>
        </div>
      </td>
      <td height="22" width="15%"> 
        <div align=center><font color="#FF3300"><%=rs("sb_total")%></font>元</div>
      </td>
      <td height="22" width="10%"> 
        <div align=center>
		<a href=gouwu.asp?name=<%=rs("sb_proname")%>&action=del> 
        <img src=../img/trash.gif width="15" height="17" border=0>
		</a>
		</div>
      </td>
    </tr>
    <%
      jianshu=jianshu+cint(rs("sb_amount"))
      zongji=zongji+clng(rs("sb_total"))
      rs.movenext
      loop
      rs.close
      set rs=nothing
	  rs_s.close
	  set rs_s=nothing
	%>
    <tr bgcolor="#FFFFFF"> 
      <td height=25 colspan=5> 
        <div align=center>
          <input name="imageField1" type="image" src="../img/cart01.gif" width="93" height="43" border="0" onFocus="this.blur()" onClick="this.form.action='javascript:window.close()';">
		  <input name="imageField2" type="image" src="../img/cart03.gif" width="97" height="43" border="0" onFocus="this.blur()" onClick="this.form.action='xgsl.asp';this.form.submit();">
          <input name="imageField3" type="image" src="../img/cart02.gif" width="107" height="43" border="0" onFocus="this.blur()" onClick="this.form.action='gouwu.asp?action=clear';">
          <input name="imageField4" type="image" src="../img/cart04.gif" width="87" height="43" border="0" onFocus="this.blur()" onClick="javascript:window.open('jszx.asp','jszx','width=650,height=500,toolbar=no, status=no, menubar=no, resizable=yes, scrollbars=yes');window.close()">
        </div>
      </td>
    </tr>
    <tr bgcolor="#FFF9EC"> 
      <td height=36 colspan=5> 
        <div align=center> 购物车里有商品:<%=num%>件 总数:<%=jianshu%>件 共计:<font color=#FF3300><%=zongji%></font>元
          <%if request("lx")<>1 then %>
          <br>
          购物车将在10秒后自动关闭 
          <script language="Javascript">
          function closeinfo(){window.close();}
          setTimeout("closeinfo()", 10000);
          </script>
          <%end if%>
        </div>
      </td>
    </tr>
	</form>
</table>
<% end if %>
</body>
</html>
<%end select%>

⌨️ 快捷键说明

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