-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSubmitOrder.java
More file actions
78 lines (60 loc) · 2.55 KB
/
Copy pathSubmitOrder.java
File metadata and controls
78 lines (60 loc) · 2.55 KB
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
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.Vector;
import java.util.*;
import java.text.*;
import sdsu.*;
public class SubmitOrder extends HttpServlet {
private ServletContext context=null;
private RequestDispatcher dispatcher = null;
private String toDo = "";
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
Cookie myCookie=null;
String cookieValue="";
String toDo = "/WEB-INF/jsp/order.jsp";
for(Cookie cookie : request.getCookies()){
if(cookie.getName().equals("jadrn052"))
{
myCookie=cookie;
cookieValue=myCookie.getValue();
}
}
String[] items = cookieValue.split("\\|\\|");
List<String> listitems;
if(items.length==0){
listitems=new ArrayList<String>();
listitems.add(cookieValue);
}
else
{
listitems=new ArrayList<String>(Arrays.asList(items));
}
String sku, query;
int qt, dbqt, newqt;
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DATE, 1);
SimpleDateFormat myformat = new SimpleDateFormat("yyyy-MM-dd");
myformat.setTimeZone(TimeZone.getTimeZone("America/Los_Angeles"));
String date = myformat.format(cal.getTime());
String skuToDelete="";
for(String item : listitems){
sku=item.split("\\|")[0];
skuToDelete+=sku+",";
qt=Integer.parseInt(item.split("\\|")[1]);
query="insert into merchandise_out values('"+sku+"','"+date+"',"+qt+");";
DBHelper.doUpdate(query);
query="select on_hand_quantity from on_hand where sku='"+sku+"';";
dbqt=Integer.parseInt(DBHelper.doQuery(query).get(0)[0]);
newqt= dbqt-qt;
query="update on_hand set last_date_modified='"+date+"', on_hand_quantity="+newqt+" where sku='"+sku+"';";
DBHelper.doUpdate(query);
}
HttpSession session = request.getSession(false);
session.setAttribute("skus", skuToDelete );
response.sendRedirect("http://jadran.sdsu.edu/jadrn052/ordersuccess.jsp");
/*context = getServletContext();
dispatcher = request.getRequestDispatcher(toDo);
dispatcher.forward(request, response); */
}
}