forked from kishanrajput23/Java-Projects-Collections
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathordershistory.jsp
107 lines (72 loc) · 1.82 KB
/
ordershistory.jsp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<jsp:useBean id="user" scope="session" class="obs.User"/>
<%@page import="java.sql.*"%>
<html>
<style>
a.topic {font:700 11pt verdana;color:white}
td {font:10pt verdana}
th {font:700 10pt verdana;background-color:green;color:white}
</style>
<body bgcolor="beige">
<h1>Orders History </h1>
<div style="background-color:green}">
<table width="100%">
<tr align="center">
<td>
<a class="topic" href="ordershistory.jsp?type=a">All Orders </a>
<td>
<a class="topic" href="ordershistory.jsp?type=n">New Orders </a>
<td>
<a class="topic" href="ordershistory.jsp?type=p">Processed Orders</a>
<td>
<a class="topic" href="ordershistory.jsp?type=d">Dispatched Orders</a>
<td>
<a class="topic" href="ordershistory.jsp?type=c">Completed Orders </a>
</tr>
</table>
</div>
<%
String type = request.getParameter("type");
String cmd = "select ordid, orddate, totamt,decode(status,'n','New','p','Processed','d','Dispatched','Completed') textstatus,status from orders where userid = " + user.getUserid();
if ( type != null)
{
if ( type.equals("n"))
cmd += " and status = 'n'";
else
if ( type.equals("p"))
cmd += " and status = 'p'";
else
if ( type.equals("d"))
cmd += " and status = 'd'";
else
if ( type.equals("c"))
cmd += " and status = 'c'";
}
Connection con = user.getConnection();
Statement st = con.createStatement();
ResultSet rs = st.executeQuery(cmd);
%>
<p>
<table width="100%" cellpadding=2 border=1>
<tr>
<th> Order Id
<th> Order Date
<th> Total Amount
<th> Status
</tr>
<%
while ( rs.next())
{
%>
<tr>
<td> <a href="orderitems.jsp?ordid=<%=rs.getInt(1)%>&status=<%=rs.getString(5)%>"> <%=rs.getInt(1)%> </a>
<td> <%= rs.getString(2)%>
<td> <%= rs.getInt(3)%>
<td> <%= rs.getString(4)%>
</tr>
<%
}
rs.close();
st.close();
con.close();
%>
</table>