基于javaweb+jsp的医院住院管理系统

基于javaweb+jsp的医院住院管理系统

JavaWeb JavaBean JSP MVC MySQL Tomcat JavaScript Bootstrap.

基础JSP+Servlet或JSP+SSM(Spring、SpringMVC、MyBatis)框架或JSP+SSM+Maven(pom.xml)框架或SpringBoot…均可

开发工具:eclipse/idea/myeclipse/sts等均可配置运行

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

import com.demo.service.BingfangService;
import com.demo.service.impl.BingfangServiceImpl;
import com.demo.vo.Bingfang;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

                <td>${vo.zhuyuanSex}td>
                <td>${vo.zhuyuanKeshi}td>
                <td>${vo.zhuyuanBingfanghao}td>
                <td>${vo.zhuyuanTime}td>
                <td>${vo.zhuyuanYishi}td>
                <td title="${vo.zhuyuanText}">
                <c:choose>
                    <c:when test="${fn:length(vo.zhuyuanText) > 19}">
                        <c:out value="${fn:substring(vo.zhuyuanText, 0, 19)}..."/>
                    c:when>
                    <c:otherwise>
                        <c:out value="${vo.zhuyuanText}"/>
                    c:otherwise>
                c:choose>
                td>
                <td>
                    <button class="btn btn-rect btn-grad btn-danger btn-sm" style="padding: 0px 1px;" onclick="window.location.href='ZhuyuanServlet?action=get&id=${vo.id}'">详情button> 
                    <button class="btn btn-rect btn-grad btn-default btn-sm" style="padding: 0px 1px;"
                            if test="${loginUser.userType != '管理员'}">disabled="disabled" title="没有权限!!!"c:if>
                    οnclick="window.location.href='ZhuyuanServlet?action=editPre&id=${vo.id}'">编辑button> 
                    <button class="btn btn-rect btn-grad btn-danger btn-sm" style="padding: 0px 1px;" if test="${loginUser.userType != '管理员'}">disabled="disabled" title="没有权限!!!"c:if> οnclick="if(window.confirm('将要删除:${vo.zhuyuanName}?'))window.location.href='ZhuyuanServlet?action=delete&id=${vo.id}'">删除button>
                td>
            tr>
        c:forEach>
    /**
     * 处理Get请求
     *
     * @param request
     * @param response
     * @throws ServletException
     * @throws IOException
     */
    @Override
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);//Get请求和Post请求的处理是一样的,所以把request、response转交给Post方法就好
    }

    /**
     * 根据参数,查询出条例条件的记录集合,最后将数据返回给调用处或者将数据集合设置到session域里,再跳转到对应的列表页面
     *
     * @param request
     * @param response
     */
    private void redirectList(HttpServletRequest request, HttpServletResponse response) throws IOException {
        //查询列和关键字
        String searchColumn = Util.decode(request, "searchColumn");
        String keyword = Util.decode(request, "keyword");
        int totalCount = 0;
        String condition = "";
        String sqlList;
        if (params.get("searchColumn") != null && !"".equals(params.get("searchColumn"))) {
            condition += " and `" + params.get("searchColumn") + "` like '%" + params.get("keyword") + "%'";
        }
        try {
            Connection c = Util.getConnection();
            PreparedStatement ps;
            ResultSet rs;
            String limit = (params.get("startIndex") != null && params.get("pageSize") != null) ? " limit " + params.get("startIndex") + "," + params.get("pageSize") : "";
                sqlList = "select * from `t_zhuyuan` where 1=1 " + condition + " order by id asc " + limit + ";";
                ps = c.prepareStatement(sqlList);
                rs = ps.executeQuery();
                while (rs.next()) {
                    Zhuyuan vo = new Zhuyuan();
                    vo.setId(rs.getLong("id"));
                    vo.setZhuyuanName(rs.getString("zhuyuan_name"));
                    vo.setZhuyuanHao(rs.getString("zhuyuan_hao"));
                    vo.setZhuyuanSex(rs.getString("zhuyuan_sex"));
                    vo.setZhuyuanKeshi(rs.getString("zhuyuan_keshi"));
import com.demo.util.Util;
import com.demo.vo.User;

import javax.imageio.ImageIO;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.OutputStream;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;

//@WebServlet("/AuthServlet")
    }

    //@Override
    public boolean delete(long id) {
        try {
            Connection c = Util.getConnection();
            Statement s = c.createStatement();
            String sql = "delete from `t_zhuyuan` where id = " + id;
            s.execute(sql);
            s.close();
            c.close();
            return true;
        } catch (Exception e) {
            e.printStackTrace();
    public void add(Zhuyuan vo) {
        String sql = "insert into `t_zhuyuan` (`zhuyuan_name`,`zhuyuan_hao`,`zhuyuan_sex`,`zhuyuan_keshi`,`zhuyuan_bingfanghao`,`zhuyuan_time`,`zhuyuan_yishi`,`zhuyuan_text`) values(?,?,?,?,?,?,?,?)";
        try {
            Connection c = Util.getConnection();
            PreparedStatement ps = c.prepareStatement(sql);
            
            ps.setString(1, vo.getZhuyuanName());
            ps.setString(2, vo.getZhuyuanHao());
            ps.setString(3, vo.getZhuyuanSex());
            ps.setString(4, vo.getZhuyuanKeshi());
            ps.setString(5, vo.getZhuyuanBingfanghao());
            ps.setString(6, vo.getZhuyuanTime());
            c.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return vo;
    }

    //@Override
    public Map<String, Object> list(Map<String, Object> params) {
        List<User> list = new ArrayList();
        int totalCount = 0;
        String condition = "";
        String sqlList;
        if (params.get("searchColumn") != null && !"".equals(params.get("searchColumn"))) {
            condition += " and `" + params.get("searchColumn") + "` like '%" + params.get("keyword") + "%'";
        }
        try {
            Connection c = Util.getConnection();
import java.io.IOException;
import java.io.OutputStream;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;

//@WebServlet("/AuthServlet")
public class AuthServlet extends HttpServlet {
    @Override
    public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //过滤编码
        request.setCharacterEncoding("UTF-8");
        response.setCharacterEncoding("UTF-8");
    <br>
    <table class="table table-striped table-hover table-bordered">
        <thead>
        <tr class="index-content-table-th">
            <th>姓名th>
            <th>住院号th>
            <th>性别th>
            <th>科室th>
            <th>病房号th>
            <th>入院时间th>
            <th>护理医师th>
            <th>备注th>
            <th>操作th>
    function check() {
        //根据ID获取值
        if (document.getElementById("zhuyuanName").value.trim().length == 0) {
            alert("姓名不能为空!");
            return false;
        }
        if (document.getElementById("zhuyuanHao").value.trim().length == 0) {
            alert("住院号不能为空!");
            return false;
        }
        if (document.getElementById("zhuyuanKeshi").value.trim().length == 0) {
            alert("科室不能为空!");
            return false;
        }
        if (document.getElementById("zhuyuanBingfanghao").value.trim().length == 0) {
            alert("病房号不能为空!");
            return false;
        }
        if (document.getElementById("zhuyuanTime").value.trim().length == 0) {
            alert("入院时间不能为空!");
            return false;
        }
        if (document.getElementById("zhuyuanYishi").value.trim().length == 0) {
            alert("护理医师不能为空!");
            Connection c = Util.getConnection();
            PreparedStatement ps;
            ResultSet rs;
            String limit = (params.get("startIndex") != null && params.get("pageSize") != null) ? " limit " + params.get("startIndex") + "," + params.get("pageSize") : "";
                sqlList = "select * from `t_user` where 1=1 " + condition + " order by id asc " + limit + ";";
                ps = c.prepareStatement(sqlList);
                rs = ps.executeQuery();
                while (rs.next()) {
                    User vo = new User();
                    vo.setId(rs.getLong("id"));
                    vo.setUsername(rs.getString("username"));
                    vo.setPassword(rs.getString("password"));
                    vo.setRealName(rs.getString("real_name"));
                    vo.setUserSex(rs.getString("user_sex"));
                    vo.setUserPhone(rs.getString("user_phone"));
                    vo.setUserText(rs.getString("user_text"));
                    vo.setUserType(rs.getString("user_type"));
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 住院模块的DAO层(数据层)的具体实现类,对ZhuyuanDAO接口中定义的增删改查等抽象方法作出具体的功能实现
 */
public class ZhuyuanDAOImpl implements ZhuyuanDAO {

    //@Override
    public void add(Zhuyuan vo) {
        String sql = "insert into `t_zhuyuan` (`zhuyuan_name`,`zhuyuan_hao`,`zhuyuan_sex`,`zhuyuan_keshi`,`zhuyuan_bingfanghao`,`zhuyuan_time`,`zhuyuan_yishi`,`zhuyuan_text`) values(?,?,?,?,?,?,?,?)";
        try {
            Connection c = Util.getConnection();
            PreparedStatement ps = c.prepareStatement(sql);
            
            ps.setString(1, vo.getZhuyuanName());
            ps.setString(2, vo.getZhuyuanHao());
            ps.setString(3, vo.getZhuyuanSex());
            ps.setString(4, vo.getZhuyuanKeshi());
            ps.setString(5, vo.getZhuyuanBingfanghao());
                vo.setBingfangCount(rs.getString("bingfang_count"));
                vo.setBingfangPrice(rs.getString("bingfang_price"));
                vo.setBingfangText(rs.getString("bingfang_text"));
            }
            c.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return vo;
    }

    //@Override
    public Map<String, Object> list(Map<String, Object> params) {
        List<Bingfang> list = new ArrayList();
        int totalCount = 0;
        String condition = "";
        String sqlList;
        if (params.get("searchColumn") != null && !"".equals(params.get("searchColumn"))) {
            tr>
            <tr>
                <td width="12%">住院号:td><td><input class="index-content-table-td-add" type="text" id="zhuyuanHao" name="zhuyuanHao" value=""/>td>
            tr>
            <tr>
                <td width="12%">性别:td>
                <td>
                        <input name="zhuyuanSex" type="radio" value="" checked="checked"/>       
                        <input name="zhuyuanSex" type="radio" value=""/>       
                td>
            tr>
            <tr>
                <td width="12%">科室:td><td><input class="index-content-table-td-add" type="text" id="zhuyuanKeshi" name="zhuyuanKeshi" value=""/>td>
            tr>
            <tr>
                <td width="12%">病房号:td><td><input class="index-content-table-td-add" type="text" id="zhuyuanBingfanghao" name="zhuyuanBingfanghao" value=""/>td>
            tr>
            <tr>
                <td width="12%">入院时间:td><td><input class="index-content-table-td-add" type="text" id="zhuyuanTime" name="zhuyuanTime" value=""/>td>
            tr>
            <tr>
                <td width="12%">护理医师:td><td><input class="index-content-table-td-add" type="text" id="zhuyuanYishi" name="zhuyuanYishi" value=""/>td>
            tr>
            <tr>
    //@Override
    public boolean delete(long id) {
        try {
            Connection c = Util.getConnection();
            Statement s = c.createStatement();
            String sql = "delete from `t_user` where id = " + id;
            s.execute(sql);
            s.close();
            c.close();
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
     * 处理Get请求
     *
     * @param request
     * @param response
     * @throws ServletException
     * @throws IOException
     */
    @Override
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);//Get请求和Post请求的处理是一样的,所以把request、response转交给Post方法就好
    }

    /**
     * 根据参数,查询出条例条件的记录集合,最后将数据返回给调用处或者将数据集合设置到session域里,再跳转到对应的列表页面
            c.close();
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }

    //@Override
    public Zhuyuan get(Serializable id) {
        Zhuyuan vo = null;
        try {
            Connection c = Util.getConnection();
            Statement s = c.createStatement();
            String sql = "select * from `t_zhuyuan` where id = " + id;
            ResultSet rs = s.executeQuery(sql);
            if (rs.next()) {
                vo = new Zhuyuan();
                vo.setId(rs.getLong("id"));
                vo.setZhuyuanName(rs.getString("zhuyuan_name"));
                vo.setZhuyuanHao(rs.getString("zhuyuan_hao"));
                vo.setZhuyuanSex(rs.getString("zhuyuan_sex"));
                vo.setZhuyuanKeshi(rs.getString("zhuyuan_keshi"));
                vo.setZhuyuanBingfanghao(rs.getString("zhuyuan_bingfanghao"));
 * 住院模块的DAO层(数据层)的具体实现类,对ZhuyuanDAO接口中定义的增删改查等抽象方法作出具体的功能实现
 */
public class ZhuyuanDAOImpl implements ZhuyuanDAO {

    //@Override
    public void add(Zhuyuan vo) {
        String sql = "insert into `t_zhuyuan` (`zhuyuan_name`,`zhuyuan_hao`,`zhuyuan_sex`,`zhuyuan_keshi`,`zhuyuan_bingfanghao`,`zhuyuan_time`,`zhuyuan_yishi`,`zhuyuan_text`) values(?,?,?,?,?,?,?,?)";
        try {
            Connection c = Util.getConnection();
            PreparedStatement ps = c.prepareStatement(sql);
            
            ps.setString(1, vo.getZhuyuanName());
            ps.setString(2, vo.getZhuyuanHao());
            ps.setString(3, vo.getZhuyuanSex());
            ps.setString(4, vo.getZhuyuanKeshi());
            ps.setString(5, vo.getZhuyuanBingfanghao());
            ps.setString(6, vo.getZhuyuanTime());
            ps.setString(7, vo.getZhuyuanYishi());
 * 而后再调用FeiyongService业务层的方法来处理具体的业务,最后将处理完成的结果返回或跳转至相应页面
 */
//@WebServlet("/FeiyongServlet")
public class FeiyongServlet extends HttpServlet {

    /**
     * 处理Post请求
     *
     * @param request
     * @param response
     * @throws ServletException
     * @throws IOException
     */
    @Override
    public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //过滤编码
        request.setCharacterEncoding("UTF-8");
        response.setCharacterEncoding("UTF-8");
        String action = Util.decode(request, "action");
        if ("add".equals(action)) {//增加
            Notice vo = new Notice();
            //取出页面传进来的各个数据,并设置到Notice对象的属性里
            vo.setNoticeName(Util.decode(request, "noticeName"));
            vo.setNoticeText(Util.decode(request, "noticeText"));
            vo.setNoticeType(Util.decode(request, "noticeType"));
            vo.setCreateDate(Util.decode(request, "createDate"));
            NoticeService noticeService = new NoticeServiceImpl();
            //调用Service层增加方法(add),增加记录
            noticeService.add(vo);
            this.redirectList(request, response);
        } else if ("delete".equals(action)) {//删除
            //取出表要删除的公告记录的主键
            long id = Long.parseLong(Util.decode(request, "id"));
import java.io.Serializable;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**

        Integer totalRecord = (Integer) map.get("totalCount");//根据查询条件取出对应的总记录数,用于分页
        String pageNum = Util.decode(request, "pageNum");//封装分页参数
        com.demo.util.PageBean<Object> pb = new com.demo.util.PageBean(Integer.valueOf(pageNum != null ? pageNum : "1"), totalRecord);
        params.put("startIndex", pb.getStartIndex());
        params.put("pageSize", pb.getPageSize());
        List list = (List) zhuyuanService.list(params).get("list");//根据分页参数startIndex、pageSize查询出来的最终结果list
        pb.setServlet("ZhuyuanServlet");
        pb.setSearchColumn(searchColumn);
        pb.setKeyword(keyword);
        pb.setList(list);
        request.getSession().setAttribute("pageBean", pb);
        request.getSession().setAttribute("list", pb.getList());

        response.sendRedirect("zhuyuan_list.jsp");
    }
     * @param request
     * @param response
     * @throws ServletException
     * @throws IOException
     */
    @Override
    public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //过滤编码
        request.setCharacterEncoding("UTF-8");
        response.setCharacterEncoding("UTF-8");
        String action = Util.decode(request, "action");
        if ("add".equals(action)) {//增加
            Feiyong vo = new Feiyong();
            //取出页面传进来的各个数据,并设置到Feiyong对象的属性里
            vo.setFeiyongNo(Util.decode(request, "feiyongNo"));
            vo.setFeiyongZhuyuanhao(Util.decode(request, "feiyongZhuyuanhao"));
            vo.setFeiyongName(Util.decode(request, "feiyongName"));
            vo.setFeiyongJine(Util.decode(request, "feiyongJine"));
            vo.setFeiyongJiaofeifangshi(Util.decode(request, "feiyongJiaofeifangshi"));
            vo.setFeiyongJiaofeishijian(Util.decode(request, "feiyongJiaofeishijian"));
            vo.setFeiyongText(Util.decode(request, "feiyongText"));
            FeiyongService feiyongService = new FeiyongServiceImpl();
            //调用Service层增加方法(add),增加记录
            feiyongService.add(vo);
            //  验证码的随机字体
            String[] fontNames = {"Times New Roman", "Book antiqua", "Arial"};
            for (int i = 0; i < 4; i++) {
                //  随机设置当前验证码的字符的字体
                g.setFont(new Font(fontNames[random.nextInt(3)], Font.ITALIC, height));
                //  随机获得当前验证码的字符
                char codeChar = codeChars.charAt(random.nextInt(charsLength));
                validationCode.append(codeChar);
                //  随机设置当前验证码字符的颜色
                g.setColor(getRandomColor(10, 100));
                //  在图形上输出验证码字符,x和y都是随机生成的
                g.drawString(String.valueOf(codeChar), 16 * i + random.nextInt(7), height - random.nextInt(6));
            }
            HttpSession session = request.getSession();
package com.demo.servlet;

import com.demo.util.Util;
import com.demo.service.ZhuyuanService;
import com.demo.service.impl.ZhuyuanServiceImpl;
import com.demo.vo.Zhuyuan;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


运行环境

Java≥6、Tomcat≥7.0、MySQL≥5.5

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

技术框架

JavaWeb JavaBean JSP MVC MySQL Tomcat JavaScript Bootstrap.

基础JSP+Servlet或JSP+SSM(Spring、SpringMVC、MyBatis)框架或JSP+SSM+Maven(pom.xml)框架或SpringBoot…均可

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

登录、注册、退出、用户模块、公告模块、病房模块、费用模块、住院模块的增删改查管理

基于javaweb+jsp的医院住院管理系统_第1张图片

基于javaweb+jsp的医院住院管理系统_第2张图片

基于javaweb+jsp的医院住院管理系统_第3张图片

基于javaweb+jsp的医院住院管理系统_第4张图片

基于javaweb+jsp的医院住院管理系统_第5张图片

基于javaweb+jsp的医院住院管理系统_第6张图片

基于javaweb+jsp的医院住院管理系统_第7张图片

基于javaweb+jsp的医院住院管理系统_第8张图片

基于javaweb+jsp的医院住院管理系统_第9张图片

基于javaweb+jsp的医院住院管理系统_第10张图片

基于javaweb+jsp的医院住院管理系统_第11张图片

基于javaweb+jsp的医院住院管理系统_第12张图片

基于javaweb+jsp的医院住院管理系统_第13张图片

↖[获取源码方式]见左侧

你可能感兴趣的:(javaweb,jsp,mysql,servlet,ssm)