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

📄 shoperlist.jsp

📁 jsp mysql 实现网上购物系统
💻 JSP
字号:
<%@ page contentType="text/html; charset=gb2312" %>
<%@ page import="java.util.*" %>
<%@ page import="java.sql.*" %>
<%@ page session="true" %>
<%@ page import="com.mybusiness.web.book.bookclass" %>
<%@ page import="com.mybusiness.web.book.books"%>
<%@ page import="com.mybusiness.web.booksmn" %>
<%@ page import="com.mybusiness.web.book.indentlist" %>
<jsp:useBean id="book_list" scope="page" class="com.mybusiness.web.booksmn" />
<jsp:useBean id="classlist" scope="page" class="com.mybusiness.web.bookclasslist" />
<jsp:useBean id="shop" scope="page" class="com.mybusiness.web.purchase" />
<jsp:useBean id="data" scope="page" class="com.mybusiness.web.DataBase" />

<%

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 = "你要的修改购买的商品数量不足你的购买数量!";
		else
			mesg = "修改购买数量出错!";
	} else {
		mesg = "修改成功";
	}

}else if ( del != null && !del.equals("") ) {
	if ( !shop.delShoper(request) ) {
		mesg = "删除清单中的商品时出错!" ;
	}
}else if (payoutCar != null && !payoutCar.equals("") ) {
	if (shop.payout(request) ) {
	long USERID=0;
USERID = Long.parseLong(userid);                  
String IndentNo = "";
String sqlStr="";
Vector purchaselist;
Statement stmt = null;	
ResultSet rs = null;
stmt= data.getStatement();
rs= data.getResultSet();
purchaselist = (Vector)session.getAttribute("shopcar");

String Content = request.getParameter("content");
if (Content==null)
	{
			Content="";
	}
Content =  new String(Content.getBytes("ISO-8859-1"),"GBK");
String IP = request.getRemoteAddr();
String TotalPrice = request.getParameter("totalprice");

sqlStr = "select max(id) from My_indent";
rs = stmt.executeQuery(sqlStr);
if (rs.next())
   {
			IndentNo = "HYD" + USERID + "" + rs.getString(1);
	} else {
			IndentNo =  "HYD" + USERID + "0";
	}
rs.close();

sqlStr = "insert into My_indent (IndentNo,UserId,SubmitTime,TotalPrice,content,IPAddress,IsPayoff,IsSales) values ('";
sqlStr = sqlStr + IndentNo + "','";
sqlStr = sqlStr + USERID + "',now(),'";
sqlStr = sqlStr + TotalPrice + "','";
sqlStr = sqlStr + Content + "','";
sqlStr = sqlStr + IP + "',1,1)";
stmt.execute(sqlStr);
sqlStr= "select max(id) from My_indent where UserId = " + USERID;
rs = stmt.executeQuery(sqlStr);
long indentid = 0;
while (rs.next())
	{
				indentid = rs.getLong(1);
	}
rs.close();
for (int i=0; i<purchaselist.size() ;i++ )
	{
				indentlist iList = (indentlist) purchaselist.elementAt(i);
				sqlStr = "insert into My_indentlist (IndentNo,BookNo,Amount) values (";
				sqlStr = sqlStr + indentid + ",'";
				sqlStr = sqlStr + iList.getBookNo() + "','";
				sqlStr = sqlStr + iList.getAmount() + "')";
				stmt.execute(sqlStr);
				sqlStr = "update My_book set leav_number=leav_number - " + iList.getAmount() + " where id = " + iList.getBookNo();
				stmt.execute(sqlStr);
	}
		mesg = "你的购物车中的物品已提交给本店,你的订单号为 "+ IndentNo + "<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 = "购物车中的物品清单已清空";
}



%>

<html>
<head>
<title>商场翱游购物系统--我的购物车</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<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>
<link rel="stylesheet" href="books.css" type="text/css">
</head>

<body  background=images/112.gif text="#000000">
<div align="center">
  <table width="750" border="0" cellspacing="1" cellpadding="1">
    <tr> 
      <td align="center"><img src="images/baners2.gif" width="670" height="120"></td>
      <td align="center" width="80"><a href="#"></a><br>
        <br>
      </td>
    </tr>
  </table>

  <table width="750" border="0" cellspacing="1" cellpadding="1">
    <tr> 
      <td width="200">&nbsp;</td>
      <td width="55"><a href="index.jsp">首页</a></td>
      <td width="100"><a href="booklist.jsp">在线购物</a></td>
      <td width="100"><a href="shoperlist.jsp">我的购物车</a></td>
      <td width="100"><a href="userinfo.jsp">用户信息</a></td>
      <td><a href="login.jsp">用户登录</a></td>
    </tr>
  </table>
  <table width="750" border="0" cellspacing="1" cellpadding="1">
    <tr valign="top"> 
      <td width="150"> 
        <table width="100%" border="0" cellspacing="1" cellpadding="1">
          <tr> 
            <td width="20">&nbsp;</td>
            <td>本店商品分类:</td>
          </tr>
  <% if (classlist.excute()){
		for (int i=0;i<classlist.getClasslist().size();i++){
			bookclass bc = (bookclass) classlist.getClasslist().elementAt(i); %>
          <tr> 
            <td width="20">&nbsp;</td>
            <td><a href="booklist.jsp?classid=<%= bc.getId()%>"><%= bc.getClassName() %></a></td>
          </tr>
  <%	}			
  }%>
          <tr> 
            <td width="20">&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
        </table>
        <p><img src="images/qrjbutton.gif" width="120" height="120"></p>
      </td>
      <td align="center"> 
        <p><br>
         <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>你还没有选择购买商品!请先购买</font></p>");
} else {
%>
       <table width="100%" border="1" cellspacing="1" cellpadding="1" bordercolor="#CC9966">
          <tr align="center"> 
            <td>商品名称</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++){
		indentlist iList = (indentlist) shoplist.elementAt(i);	
		if (book_list.getOnebook((int)iList.getBookNo())) {
			books bk = (books) book_list.getBooklist().elementAt(0);
			totalprice = totalprice + bk.getPrince() * iList.getAmount();
			totalamount = totalamount + iList.getAmount();
	%>
          <tr>
            <td><%= bk.getBookName() %></td>
            <td align="center"><%= bk.getClassname() %></td>
            <td align="center"><%= bk.getPrince() %></td>
		    <form name="change" method="post" action="shoperlist.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="bookid" value="<%= iList.getBookNo() %>" >
              <input type="submit" name="modi" value="修改" onclick="return(check());"></td>
			<form name="del" method="post" action="shoperlist.jsp">
			 <input type="hidden" name="bookid" value="<%= iList.getBookNo() %>" >
			 <td align=center width=55> <input type="submit" name="del" value="删除">
            </td></form>
          </tr>
		<% } 
	} %>  <tr><td colspan=7 align="right"><br>你选择的商品的总金额:<%= totalprice%>元&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="shoperlist.jsp">
              <td align="right" valign="bottom"> <a href="booklist.jsp">继续购物</a>&nbsp;&nbsp;&nbsp; 
                
				<input type="hidden" name="userid" value="<%= userid %>">
				<input type="hidden" name="totalprice" value="<%= totalprice %>">
				<TEXTAREA NAME="content" 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="shoperlist.jsp">
			  <td valign="bottom">&nbsp;
                <input type="submit" name="clear" value="清空我的购物车">
              </td></form>
            </tr>
          </table>
        </form>
<% } %>
      </td>
    </tr>
  </table>
  <table width="70%" border="0" cellspacing="2" cellpadding="2">
    <tr>
      <td align="center">开发:王文耀<br>
        CopyRight@2006 <br>
        Email:<a href="mailto:wwy170@163.com">wwy170@163.com</a></td>
    </tr>
  </table>
  
</div>
</body>
</html>

⌨️ 快捷键说明

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