use of com.zyf.dao.UrineDao in project HeartWatchdogJsp by Viczyf.
the class UrineServlet method selectUrine.
public void selectUrine(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
UrineDao urinedao = new UrineDao();
HttpSession session = request.getSession();
// 获取用户对象
User user = (User) session.getAttribute("user");
int id = user.getUid();
List urineList = urinedao.queryUrine(id);
// request.setAttribute("urineList", urineList);
JsonArray array = new JsonArray();
for (int i = 0; i < urineList.size(); i++) {
Urine single = (Urine) urineList.get(i);
JsonObject ob = new JsonObject();
ob.addProperty("id", i + 1);
ob.addProperty("date", single.getDate());
ob.addProperty("read", "<a href=\"UrineServlet?action=single&id=" + single.getId() + " \"target=\"_blank\">查看记录</a>");
ob.addProperty("del", "<a href=\"UrineServlet?action=delete&id=" + single.getId() + "\">删除记录</a>");
array.add(ob);
}
PrintWriter out = response.getWriter();
out.print(array);
System.out.println(array);
// RequestDispatcher rd = request.getRequestDispatcher("urinelist.jsp");
// request.setAttribute("listjson", array);
// rd.forward(request, response);
}
use of com.zyf.dao.UrineDao in project HeartWatchdogJsp by Viczyf.
the class UrineServlet method singleUrine.
public void singleUrine(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
UrineDao urinedao = new UrineDao();
int id = MyTools.strToint(request.getParameter("id"));
HttpSession session = request.getSession();
// 获取用户对象
User user = (User) session.getAttribute("user");
int uid = user.getUid();
Urine urinesingle = urinedao.queryUrineSingle(id, uid);
request.setAttribute("urinesingle", urinesingle);
RequestDispatcher rd = request.getRequestDispatcher("urinesingle.jsp");
rd.forward(request, response);
}
use of com.zyf.dao.UrineDao in project HeartWatchdogJsp by Viczyf.
the class UrineServlet method deleteUrine.
public void deleteUrine(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String message = "";
String forward = "";
String href = "";
UrineDao urinedao = new UrineDao();
int id = MyTools.strToint(request.getParameter("id"));
Urine urine = new Urine();
urine.setId(id);
HttpSession session = request.getSession();
User user = (User) session.getAttribute("user");
int uid = user.getUid();
boolean mark = urinedao.delUrine(urine, uid);
if (mark) {
message = message + "<li>删除记录成功!</li>";
forward = "tishi.jsp";
href = href + "urinetime.jsp";
} else {
message = message + "<li>删除记录失败!</li>";
forward = "tishi.jsp";
href = href + "urinetime.jsp";
}
request.setAttribute("message", message);
request.setAttribute("href", href);
RequestDispatcher rd = request.getRequestDispatcher(forward);
rd.forward(request, response);
}
use of com.zyf.dao.UrineDao in project HeartWatchdogJsp by Viczyf.
the class UrineServlet method select_time_urine.
public void select_time_urine(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
UrineDao urinedao = new UrineDao();
String startdate = request.getParameter("startdate");
String enddate = request.getParameter("enddate");
HttpSession session = request.getSession();
// 获取用户对象
User user = (User) session.getAttribute("user");
int id = user.getUid();
List urineList = urinedao.queryTimeUrine(id, startdate, enddate);
JsonArray array = new JsonArray();
for (int i = 0; i < urineList.size(); i++) {
Urine single = (Urine) urineList.get(i);
JsonObject ob = new JsonObject();
ob.addProperty("id", i + 1);
ob.addProperty("date", single.getDate());
ob.addProperty("read", "<a href=\"UrineServlet?action=single&id=" + single.getId() + " \"target=\"_blank\">查看记录</a>");
ob.addProperty("del", "<a href=\"UrineServlet?action=delete&id=" + single.getId() + "\">删除记录</a>");
array.add(ob);
}
PrintWriter out = response.getWriter();
out.print(array);
// System.out.println(array);
}
Aggregations