Search in sources :

Example 51 with User

use of com.zyf.bean.User 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);
}
Also used : Urine(com.zyf.bean.Urine) User(com.zyf.bean.User) HttpSession(javax.servlet.http.HttpSession) UrineDao(com.zyf.dao.UrineDao) RequestDispatcher(javax.servlet.RequestDispatcher)

Example 52 with User

use of com.zyf.bean.User 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);
}
Also used : JsonArray(com.google.gson.JsonArray) Urine(com.zyf.bean.Urine) User(com.zyf.bean.User) HttpSession(javax.servlet.http.HttpSession) JsonObject(com.google.gson.JsonObject) List(java.util.List) UrineDao(com.zyf.dao.UrineDao) PrintWriter(java.io.PrintWriter)

Example 53 with User

use of com.zyf.bean.User in project HeartWatchdogJsp by Viczyf.

the class UserServlet method enter.

public void enter(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    String username = request.getParameter("uname");
    // 获取密码
    String password = request.getParameter("passwd");
    String scale = request.getParameter("scale");
    System.out.println("enter,scale" + scale);
    // 实例化UserDao对象
    HttpSession session = request.getSession();
    String rand = session.getAttribute("code").toString();
    String input = request.getParameter("code");
    UserDao userDao = new UserDao();
    // 根据用户密码查询用户
    User user = userDao.login(username, password);
    // 判断user是否为空
    if (!rand.equals(input)) {
        request.setAttribute("info", "验证码输入错误");
        request.getRequestDispatcher("login.jsp").forward(request, response);
    } else if (user != null) {
        // 将用户对象放入session中
        request.getSession().setAttribute("lastlogin", user.getLastLogin());
        request.getSession().setAttribute("user", user);
        request.getSession().setAttribute("scale", scale);
        String enterdate = MyTools.changeTime(new Date());
        userDao.userEnterDate(enterdate, user);
        // 转发到result.jsp页面
        request.getRequestDispatcher("homepage.jsp").forward(request, response);
    } else {
        // 登录失败
        request.setAttribute("info", "错误:用户名或密码错误!");
        request.getRequestDispatcher("login.jsp").forward(request, response);
    }
}
Also used : User(com.zyf.bean.User) UserDao(com.zyf.dao.UserDao) HttpSession(javax.servlet.http.HttpSession) Date(java.util.Date)

Aggregations

User (com.zyf.bean.User)53 HttpSession (javax.servlet.http.HttpSession)51 RequestDispatcher (javax.servlet.RequestDispatcher)28 List (java.util.List)18 PrintWriter (java.io.PrintWriter)17 JsonObject (com.google.gson.JsonObject)12 JsonArray (com.google.gson.JsonArray)11 InfoDao (com.zyf.dao.InfoDao)9 Info (com.zyf.bean.Info)7 ExaminationDao (com.zyf.dao.ExaminationDao)7 Info24 (com.zyf.bean.Info24)6 Info24Dao (com.zyf.dao.Info24Dao)6 RelaDao (com.zyf.dao.RelaDao)6 UserDao (com.zyf.dao.UserDao)6 Examination (com.zyf.bean.Examination)5 MedicalhistoryDao (com.zyf.dao.MedicalhistoryDao)5 Medicalhistory (com.zyf.bean.Medicalhistory)4 Urine (com.zyf.bean.Urine)4 FileDao (com.zyf.dao.FileDao)4 UrineDao (com.zyf.dao.UrineDao)4