📄 select.jsp
字号:
<%@ page language="java" import="java.util.*" pageEncoding="gbk"%>
<%@ page import="com.qyg.shop.product.*" %>
<%@ page import="com.qyg.shop.user.*" %>
<%@ page import="java.sql.*" %>
<%@ page import="com.qyg.shop.sales.*" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'select.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<script type="text/javascript" language=javascript>
function check(){
if (document.all("radio").value==""){
alert("请选择您要查询的消费记录");
return false;
}
return true;
}
</script>
</head>
<body bgcolor="D9EAFC">
<p align=center><br><br>
历史记录查询: <br>
<form action="servlet/ActionServlet" name=form1 onsubmit="return check()">
<input type="hidden" name="action" value="select"/>
<input type="radio" name="radio" value="one"/>你最近的消费总额
<br><br>
<input type="radio" name="radio" value="all"/>你的历史消费总额
<br><br>
<input type=submit name=hsubmit value="查询">
</form>
<br>
<%
String radio = request.getParameter("radio");
if(radio==null){
out.print("请选择您要查询的消费记录");
return;
}
User user = (User)session.getAttribute("loginUser");
if(user==null){
out.print("您还未登录,请先<a href='exit.jsp'>登录</a>");
return;
}
ArrayList<Sales> v=null;
double sum=0;
if(radio!=null&&radio.equals("one")){
out.print("以下是最近的消费总额:<br><br>");
SalesDAO sdao = new SalesManageDAO();
String sql = "select * from sales where sales_userId="+user.getId()+" order by sales_id desc limit 0,5";
v = sdao.getSalesBySQL(sql);
}
else if(radio!=null&&radio.equals("all")){
out.print("以下是您的历史消费总额:<br><br>");
SalesDAO sdao = new SalesManageDAO();
String sql = "select * from sales where sales_userId="+user.getId()+" order by sales_date desc";
v = sdao.getSalesBySQL(sql);
}
else{
out.print("<font color='red' size=5>请选择您要查询的消费记录</font>");
return;
}
for(int i=0;i<v.size();i++){
ProductDAO pdao = new ProductManageDAO();
Product p = pdao.getProductById(v.get(i).getSales_productId());
sum += p.getProduct_price()*v.get(i).getSales_productNum();
}
out.print(sum+" 元");
%>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -