package com.highcom.action; import java.io.IOException; import java.util.ArrayList; import java.util.Map; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.highcom.dao.OrderDao; import com.highcom.dao.StockDao; import com.highcom.util.Paging; import com.highcom.vo.Order; @SuppressWarnings("serial") public class OrderServlet extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { this.doPost(request, response); } public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String method = request.getParameter("method"); int flag = Integer.parseInt(request.getParameter("flag")); OrderDao od = new OrderDao(); if("query".equals(method)){ String pagNo = request.getParameter("pageNo"); int pageNo = 1 ; if(pagNo!=null){ pageNo = Integer.parseInt(pagNo) ; } int totalNo =(int) od.queryCount(flag); ArrayList<Map<String,Object>> list = od.queryAll(pageNo, flag); request.setAttribute("list", list); request.setAttribute("pageNo", pageNo); request.setAttribute("fg", 0); request.setAttribute("totalPage", Paging.getTotalPage(totalNo)); if(flag==0){ request.getRequestDispatcher("buy.jsp").forward(request, response); }else if(flag==1){ request.getRequestDispatcher("sell.jsp").forward(request, response); }else{ } } else if("insert".equals(method)){ String g_id = request.getParameter("goods"); String p_id = request.getParameter("person"); String goodscount = request.getParameter("goodscount"); String goodsprice = request.getParameter("goodsprice"); String date = request.getParameter("date"); Order or = new Order(); or.setG_id(Long.parseLong(g_id)); or.setP_id(Long.parseLong(p_id)); or.setO_count(Long.parseLong(goodscount)); or.setO_price(Float.parseFloat(goodsprice)); or.setO_date(date); od.insert(or,flag); StockDao sd = new StockDao(); ArrayList<Map<String,Object>> list = sd.queryByid(g_id); if(flag==0){ if(list.size()>0){ sd.edit(or,flag); } else{ sd.insert(or); } response.sendRedirect("OrderServlet?method=query&flag=0"); } else if(flag==1){ sd.edit(or,flag); response.sendRedirect("OrderServlet?method=query&flag=1"); } } else if("queryByid".equals(method)){ String id = request.getParameter("id"); System.out.println(id); ArrayList<Map<String,Object>> list = od.queryByid(id, flag); System.out.println(list); request.setAttribute("list", list); if (flag==0) { request.getRequestDispatcher("buyupdate.jsp").forward(request, response); } else { request.getRequestDispatcher("sellupdate.jsp").forward(request, response); } } else if ("update".equals(method)) { String id = request.getParameter("oid"); long ocount =Long.parseLong(request.getParameter("ocount")); String gid = request.getParameter("gid"); long oldcount = Long.parseLong(request.getParameter("oldcount")); long balance= ocount - oldcount; Order or = new Order(); or.setO_id(Long.parseLong(id)); or.setO_count(ocount); or.setG_id(Long.parseLong(gid)); od.edit(or); StockDao sd = new StockDao(); if(flag==0){ sd.edit(gid,balance,flag); response.sendRedirect("OrderServlet?method=query&flag=0"); }else if(flag==1){ sd.edit(gid,balance,flag); response.sendRedirect("OrderServlet?method=query&flag=1"); } }else if ("queryid".equals(method)) { String pNo = request.getParameter("pageNo"); int pageNo= 1; if (pNo!=null) { pageNo = Integer.parseInt(pNo); } String id = request.getParameter("id"); String name = request.getParameter("name"); System.out.println("-------------------->>"+name); ArrayList<Map<String,Object>> list = od.queryByid(id,name,flag); request.setAttribute("list", list); request.setAttribute("pageNo", pageNo); request.setAttribute("fg", 1); request.setAttribute("totalPage", 1); if (flag==1) { request.getRequestDispatcher("sell.jsp").forward(request,response); } else{ request.getRequestDispatcher("buy.jsp").forward(request,response); } } } }
最近下载更多
Boss绝 LV9
6月25日
2036495585 LV9
2023年10月6日
KrisNo10000 LV2
2023年3月1日
TangWeiyu LV3
2021年12月15日
zxyBEIKE LV1
2021年10月10日
wanglinddad LV55
2021年6月21日
ruoyou168 LV12
2021年5月28日
戴佳臻 LV7
2021年4月26日
陈祥图 LV6
2020年12月31日
zuihaofdfdfdfdddd LV10
2020年12月22日