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

📄 shopcar.jsp

📁 java开发的在线CD销售系统。开发环境 MyEclipse+Tomat+SQL Server2000
💻 JSP
字号:

<%@ page contentType="text/html;charset=gb2312" %> 
<%@ page import="java.util.*" %>
<%@ page session="true" %>
<%@ page import="cdshop.cd.*"%>
<%@ page import="cdshop.run.op_cd" %>
<%@ page import="cdshop.run.op_buy" %>
<%@ page import="cdshop.util.dataFormat" %>
<jsp:useBean id="cd_list" scope="page" class="cdshop.run.op_cd" />
<jsp:useBean id="classlist" scope="page" class="cdshop.run.op_cdclass" />
<jsp:useBean id="shop" scope="page" class="cdshop.run.op_buy" />
<jsp:useBean id="user" scope="page" class="cdshop.run.op_user" />

<%
String userid = (String) session.getAttribute("userid");
if ( userid == null )
	userid = "";
String modi = request.getParameter("modi");
String del = request.getParameter("del");
String payoutCar = request.getParameter("payout");
String clearCar = request.getParameter("clear");
String mesg = "";

if (modi!=null && !modi.equals("")) {
	if ( !shop.modiShoper(request) ){
		if (shop.getIsEmpty())
			mesg = "你要的修改购买的CD数量不足你的购买数量!";
		else
			mesg = "修改购买数量出错!";
	} else {
		mesg = "修改成功";
	}

}else if ( del != null && !del.equals("") ) {
	if ( !shop.delShoper(request) ) {
		mesg = "删除清单中的CD时出错!" ;
	}
}else if (payoutCar != null && !payoutCar.equals("") ) {
	if (shop.payout(request) ) {
		mesg = "你的购物车中的物品已提交给本店,你的订单号为 "+ shop.getOrderId() + "<br>请及时付款,以便我们发货!";
		session.removeAttribute("shopcar");
	} else {
		if(!shop.getIsLogin())
			mesg = "你还没有登录,请先<a href=login.jsp>登录</a>后再提交";
		else
			mesg = "对不起,提交出错,请稍后重试";
	}
} else if (clearCar != null && ! clearCar.equals("") ) {
	session.removeAttribute("shopcar");
	mesg = "购物车中的物品清单已清空";
}


%>

<script language="javascript">

function openScript(url,name, width, height){
	var Win = window.open(url,name,'width=' + width + ',height=' + height + ',resizable=1,scrollbars=yes,menubar=no,status=yes' );
}
function checklogin() {
	if (document.payout.userid.value=="")
	{
		alert("你还没有登录,请登录后再提交购物清单。");
		return false;
	}
	return true;
}

function check()
{
	if (document.change.amount.value<1){
		alert("你的购买数量有问题");
		document.change.amount.focus();
		return false;
	}
	return true;
}

</script>
<%@include file="inc/head.inc"%>
<%@include file="inc/sub.inc"%>
<table width="778">
  <tr>
     <td width="150" align="center">
     <%@include file="inc/left.inc"%>
     </td>
     <td width="600">
         <b><font color="#0000FF">我的购物车物品清单</font></b></p>
<%
if (!mesg.equals("") )
	out.println("<p ><font color=#ff0000>" + mesg + "</font></p>");

Vector shoplist = (Vector) session.getAttribute("shopcar");
if (shoplist==null || shoplist.size()<0 ){
	if (mesg.equals(""))
		out.println("<p><font color=#ff0000>你还没有选择购买CD!请先购买</font></p>");
} else {
%>
       <table width="100%" border="1" cellspacing="1" cellpadding="1" bordercolor="white">
          <tr align="center" bgcolor="#DEF3CE">
            <td>CD名称</td>
            <td>歌手名</td>
            <td>CD类别</td>
            <td>单价(元)</td>
            <td>会员价(元)</td>
            <td>数量</td>
            <td colspan =2>选择</td>
          </tr>
	<%
	float totalprice =0;
	int totalamount = 0;
	for (int i=0; i<shoplist.size();i++){
		allorder iList = (allorder) shoplist.elementAt(i);
		if (cd_list.getOnecd((int)iList.getcdNo())) {
			cd bk = (cd) cd_list.getcdlist().elementAt(0);
			totalprice = totalprice + bk.getPrice() * iList.getAmount();
			totalamount = totalamount + iList.getAmount();
	%>
          <tr>
            <td><%= dataFormat.toString(bk.getcdName()) %></td>
            <td align="center"><%= dataFormat.toString(bk.getSinger()) %></td>
            <td align="center"><%= dataFormat.toString(bk.getClassname()) %></td>
            <td align="center"><%= bk.getPrice() %></td>
            <td align="center"><font color=red><%= (((int)(10*(bk.getPrice()*user.getUserRate((String) session.getAttribute("userid"))))/10.0)) %></font></td>
		    <form name="change" method="post" action="shopcar.jsp">
            <td align="center">
              <input type="text" name="amount" maxlength="4" size="3" value="<%= iList.getAmount() %>" >
            </td>
            <td align="center" width=55 >
			<input type="hidden" name="cdid" value="<%= iList.getcdNo() %>" >
              <input type="submit" name="modi" value="修改" onclick="return(check());"></td>
			<form name="del" method="post" action="shoperlist.jsp">
			 <input type="hidden" name="cdid" value="<%= iList.getcdNo() %>" >
			 <td align=center width=55> <input type="submit" name="del" value="删除">
            </td></form>
          </tr>
		<% }
	} %>  <tr><td colspan=7 align="right"><br>你选择的CD的总金额:<%= totalprice%>元&nbsp;&nbsp;
	你需要支付:<font color=red><%= (((int)(10*(totalprice*user.getUserRate((String) session.getAttribute("userid"))))/10.0)) %>元</font>&nbsp;&nbsp;
	总数量:<%= totalamount%>本&nbsp;</td></tr>
        </table>
       <p></p>
          <table width="90%" border="0" cellspacing="1" cellpadding="1">
            <tr> <form name="payout" method="post" action="shopcar.jsp">
              <td align="right" valign="bottom"> <a href="cdlist.jsp">继续购买</a>&nbsp;&nbsp;&nbsp;

				<input type="hidden" name="userid" value="<%= userid %>">
				<input type="hidden" name="totalprice" value="<%= totalprice %>">
				<TEXTAREA NAME="musiclist" ROWS="3" COLS="20">附言:</TEXTAREA><br>
				<input type="submit" name="payout" value="提交我的购物车" onclick="javascript:return(checklogin());">&nbsp;</td></form>
				<form name="form1" method="post" action="shopcar.jsp">
			  <td valign="bottom">&nbsp;
                <input type="submit" name="clear" value="清空我的购物车">
              </td></form>
            </tr>
          </table>
        </form>
<% } %>
      </td>
    </tr>
  </table>

<%@include file="inc/tail.inc"%>

⌨️ 快捷键说明

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