Search in sources :

Example 1 with Medicalhistory

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

the class MedicalhistoryServlet method hisList.

public void hisList(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    MedicalhistoryDao dao = new MedicalhistoryDao();
    HttpSession session = request.getSession();
    User user = (User) session.getAttribute("user");
    int uid = user.getUid();
    List hisList = dao.queryList(uid);
    JsonArray array = new JsonArray();
    for (int i = 0; i < hisList.size(); i++) {
        Medicalhistory mhis = (Medicalhistory) hisList.get(i);
        JsonObject ob = new JsonObject();
        ob.addProperty("id", i + 1);
        ob.addProperty("city", mhis.getCity());
        ob.addProperty("date", mhis.getDate());
        ob.addProperty("hospital", mhis.getHospital());
        ob.addProperty("office", mhis.getOffice());
        ob.addProperty("doctor", mhis.getDoctor());
        ob.addProperty("conclusion", mhis.getConclusion());
        ob.addProperty("edit", "<a href=\"MedicalhistoryServlet?action=single&id=" + mhis.getId() + "\" target=\"_blank\">编辑</a>");
        ob.addProperty("del", "<a href=\"MedicalhistoryServlet?action=del&id=" + mhis.getId() + "\">删除</a>");
        array.add(ob);
    }
    PrintWriter out = response.getWriter();
    out.print(array);
    System.out.print(array);
}
Also used : JsonArray(com.google.gson.JsonArray) User(com.zyf.bean.User) HttpSession(javax.servlet.http.HttpSession) JsonObject(com.google.gson.JsonObject) List(java.util.List) MedicalhistoryDao(com.zyf.dao.MedicalhistoryDao) Medicalhistory(com.zyf.bean.Medicalhistory) PrintWriter(java.io.PrintWriter)

Example 2 with Medicalhistory

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

the class MedicalhistoryServlet method hisAdd.

public void hisAdd(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    MedicalhistoryDao dao = new MedicalhistoryDao();
    HttpSession session = request.getSession();
    User user = (User) session.getAttribute("user");
    int uid = user.getUid();
    String city = request.getParameter("city");
    String date = request.getParameter("date");
    String hospital = request.getParameter("hospital");
    String office = request.getParameter("office");
    String doctor = request.getParameter("doctor");
    String conclusion = request.getParameter("conclusion");
    Medicalhistory his = new Medicalhistory();
    his.setUid(uid);
    his.setCity(city);
    his.setDate(date);
    his.setHospital(hospital);
    his.setOffice(office);
    his.setDoctor(doctor);
    his.setConclusion(conclusion);
    boolean rs = dao.hisAdd(his);
    if (rs) {
        response.setCharacterEncoding("UTF-8");
        PrintWriter out = response.getWriter();
        out.print("<!DOCTYPE html>\n" + "<html>\n" + "<head>\n" + "    <meta charset=\"UTF-8\">\n" + "    <link href=\"css/sweet-alert.css\" rel=\"stylesheet\">\n" + "</head>\n" + "<body>\n" + "<script src=\"js/jquery-3.1.1.js\"></script>\n" + "<script src=\"js/sweet-alert.min.js\"></script>\n" + "<script type=\"text/javascript\">\n" + "    $(document).ready(function(){\n" + "        swal({\n" + "            type:\"success\",\n" + "            title: \"添加成功\",\n" + "            text: '<a href=\"medicalhistory.jsp\" role=\"button\"><font size=\"5\" color=\"green\"> 点此返回</font></a>。<br>3秒后自动返回。',\n" + "            animation:\"slide-from-top\",\n" + "            html: true,\n" + "            timer: 3000,\n" + "            showConfirmButton: false\n" + "        });\n" + "    })\n" + "    window.onload = function(){\n" + "        setTimeout(fun,3000);\n" + "    }\n" + "    function fun(){\n" + "        window.location=\"medicalhistory.jsp\"\n" + "        }\n" + "</script>\n" + "</body>\n" + "</html>");
        out.flush();
        out.close();
    } else {
        response.setCharacterEncoding("UTF-8");
        PrintWriter out = response.getWriter();
        out.print("<!DOCTYPE html>\n" + "<html>\n" + "<head>\n" + "    <meta charset=\"UTF-8\">\n" + "    <link href=\"css/sweet-alert.css\" rel=\"stylesheet\">\n" + "</head>\n" + "<body>\n" + "<script src=\"js/jquery-3.1.1.js\"></script>\n" + "<script src=\"js/sweet-alert.min.js\"></script>\n" + "<script type=\"text/javascript\">\n" + "    $(document).ready(function(){\n" + "        swal({\n" + "            type:\"error\",\n" + "            title: \"添加失败\",\n" + "            text: '<a href=\"medicalhistory.jsp\" role=\"button\"><font size=\"5\" color=\"green\"> 点此返回</font></a>。<br>3秒后自动返回。',\n" + "            animation:\"slide-from-top\",\n" + "            html: true,\n" + "            timer: 3000,\n" + "            showConfirmButton: false\n" + "        });\n" + "    })\n" + "    window.onload = function(){\n" + "        setTimeout(fun,3000);\n" + "    }\n" + "    function fun(){\n" + "        window.location=\"medicalhistory.jsp\"\n" + "        }\n" + "</script>\n" + "</body>\n" + "</html>");
        out.flush();
        out.close();
    }
}
Also used : User(com.zyf.bean.User) HttpSession(javax.servlet.http.HttpSession) MedicalhistoryDao(com.zyf.dao.MedicalhistoryDao) Medicalhistory(com.zyf.bean.Medicalhistory) PrintWriter(java.io.PrintWriter)

Example 3 with Medicalhistory

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

the class MedicalhistoryDao method hisSingle.

public Medicalhistory hisSingle(int id, int uid) {
    String sql = "select * from medicalhistory where id=" + id + " and uid=" + uid;
    ResultSet rs = this.connection.executeQuery(sql);
    Medicalhistory his = null;
    try {
        if (rs.next()) {
            his = new Medicalhistory();
            his.setId(rs.getInt("id"));
            his.setUid(rs.getInt("uid"));
            his.setCity(rs.getString("city"));
            his.setDate(rs.getString("date"));
            his.setHospital(rs.getString("hospital"));
            his.setOffice(rs.getString("office"));
            his.setDoctor(rs.getString("doctor"));
            his.setConclusion(rs.getString("conclusion"));
        }
    } catch (SQLException e) {
        e.printStackTrace();
    }
    return his;
}
Also used : SQLException(java.sql.SQLException) ResultSet(java.sql.ResultSet) Medicalhistory(com.zyf.bean.Medicalhistory)

Example 4 with Medicalhistory

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

the class MedicalhistoryServlet method hisSingle.

public void hisSingle(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    MedicalhistoryDao dao = new MedicalhistoryDao();
    HttpSession session = request.getSession();
    int id = MyTools.strToint(request.getParameter("id"));
    User user = (User) session.getAttribute("user");
    int uid = user.getUid();
    Medicalhistory his = dao.hisSingle(id, uid);
    request.setAttribute("his", his);
    RequestDispatcher rd = request.getRequestDispatcher("medicalhistorymodify.jsp");
    rd.forward(request, response);
}
Also used : User(com.zyf.bean.User) HttpSession(javax.servlet.http.HttpSession) MedicalhistoryDao(com.zyf.dao.MedicalhistoryDao) RequestDispatcher(javax.servlet.RequestDispatcher) Medicalhistory(com.zyf.bean.Medicalhistory)

Example 5 with Medicalhistory

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

the class MedicalhistoryServlet method hisModify.

public void hisModify(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    MedicalhistoryDao dao = new MedicalhistoryDao();
    HttpSession session = request.getSession();
    int id = MyTools.strToint(request.getParameter("id"));
    User user = (User) session.getAttribute("user");
    int uid = user.getUid();
    Medicalhistory his = new Medicalhistory();
    String city = request.getParameter("city");
    String date = request.getParameter("date");
    String hospital = request.getParameter("hospital");
    String office = request.getParameter("office");
    String doctor = request.getParameter("doctor");
    String conclusion = request.getParameter("conclusion");
    his.setId(id);
    his.setUid(uid);
    his.setCity(city);
    his.setDate(date);
    his.setHospital(hospital);
    his.setOffice(office);
    his.setDoctor(doctor);
    his.setConclusion(conclusion);
    boolean rs = dao.hisModify(his);
    if (rs) {
        response.setCharacterEncoding("UTF-8");
        PrintWriter out = response.getWriter();
        out.print("<!DOCTYPE html>\n" + "<html>\n" + "<head>\n" + "    <meta charset=\"UTF-8\">\n" + "    <link href=\"css/sweet-alert.css\" rel=\"stylesheet\">\n" + "</head>\n" + "<body>\n" + "<script src=\"js/jquery-3.1.1.js\"></script>\n" + "<script src=\"js/sweet-alert.min.js\"></script>\n" + "<script type=\"text/javascript\">\n" + "    $(document).ready(function(){\n" + "        swal({\n" + "            type:\"success\",\n" + "            title: \"修改成功\",\n" + "            text: '<a href=\"medicalhistory.jsp\" role=\"button\"><font size=\"5\" color=\"green\"> 点此返回</font></a>。<br>3秒后自动返回。',\n" + "            animation:\"slide-from-top\",\n" + "            html: true,\n" + "            timer: 3000,\n" + "            showConfirmButton: false\n" + "        });\n" + "    })\n" + "    window.onload = function(){\n" + "        setTimeout(fun,3000);\n" + "    }\n" + "    function fun(){\n" + "        window.location=\"medicalhistory.jsp\"\n" + "        }\n" + "</script>\n" + "</body>\n" + "</html>");
        out.flush();
        out.close();
    } else {
        response.setCharacterEncoding("UTF-8");
        PrintWriter out = response.getWriter();
        out.print("<!DOCTYPE html>\n" + "<html>\n" + "<head>\n" + "    <meta charset=\"UTF-8\">\n" + "    <link href=\"css/sweet-alert.css\" rel=\"stylesheet\">\n" + "</head>\n" + "<body>\n" + "<script src=\"js/jquery-3.1.1.js\"></script>\n" + "<script src=\"js/sweet-alert.min.js\"></script>\n" + "<script type=\"text/javascript\">\n" + "    $(document).ready(function(){\n" + "        swal({\n" + "            type:\"error\",\n" + "            title: \"修改失败\",\n" + "            text: '<a href=\"medicalhistory.jsp\" role=\"button\"><font size=\"5\" color=\"green\"> 点此返回</font></a>。<br>3秒后自动返回。',\n" + "            animation:\"slide-from-top\",\n" + "            html: true,\n" + "            timer: 3000,\n" + "            showConfirmButton: false\n" + "        });\n" + "    })\n" + "    window.onload = function(){\n" + "        setTimeout(fun,3000);\n" + "    }\n" + "    function fun(){\n" + "        window.location=\"medicalhistory.jsp\"\n" + "        }\n" + "</script>\n" + "</body>\n" + "</html>");
        out.flush();
        out.close();
    }
}
Also used : User(com.zyf.bean.User) HttpSession(javax.servlet.http.HttpSession) MedicalhistoryDao(com.zyf.dao.MedicalhistoryDao) Medicalhistory(com.zyf.bean.Medicalhistory) PrintWriter(java.io.PrintWriter)

Aggregations

Medicalhistory (com.zyf.bean.Medicalhistory)6 User (com.zyf.bean.User)4 MedicalhistoryDao (com.zyf.dao.MedicalhistoryDao)4 HttpSession (javax.servlet.http.HttpSession)4 PrintWriter (java.io.PrintWriter)3 ResultSet (java.sql.ResultSet)2 SQLException (java.sql.SQLException)2 JsonArray (com.google.gson.JsonArray)1 JsonObject (com.google.gson.JsonObject)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 RequestDispatcher (javax.servlet.RequestDispatcher)1