Design and implementation of nursing home management system based on Java

Posted by homer09001 on Fri, 24 Dec 2021 05:33:54 +0100

preface

Today, senior students share a java web project:

Design and implementation of nursing home management system based on Java

1, Project design

1. Module design

From the perspective of nursing workers, they urgently hope that after using the system, they can modify their personal details more conveniently; It is more convenient to view the information of the elderly in charge; The management of bed occupancy can be more convenient.

According to the analysis of the above role requirements, the main functions of the system include: login, user information management, elderly information management, accident record, leave record, bed allocation, occupancy fee, nursing worker salary and nursing worker leave.

Main functional requirements of the system

(1) Login: user login is the basic function of the system. Users can only perform other operations after logging in to the system, which is fully considered and authenticated from the perspective of system security. There is only one administrator in this system. He is the person in charge of the nursing home. Through him, new employees can be added. Administrators and employees can log in to the system by entering their respective names and passwords and selecting their corresponding identities.

(2) information management for the elderly: after the login system, the staff can modify the personal information of the elderly at the corresponding interface, including personal ID number, name, password, age and telephone number.

(3) Bed allocation management: mainly the administrator's management of occupancy status.

(4) User information management: it mainly refers to the addition, deletion, modification and query of the personal information of the entire hotel staff by the administrator.

(5) Accident record: it is mainly used by the administrator to view the addition, deletion, modification and query of relevant services for the elderly.

(6) Leave record: it is mainly used by the administrator to view the addition, deletion, modification and query of the related services of the elderly asking for leave.

(7) Nursing worker salary management: it is mainly used by the person in charge to add, delete, modify and query the salary information of nursing workers, and to view their own salary information.

(8) Leave management of nursing workers: it mainly refers to the person in charge's addition, deletion, modification and query of nursing workers' leave records and the nursing workers' view of their own salary information.

(9) Check in fee: it mainly records the payment records and payment amount of the elderly when they check in.

The specific system function diagram is shown in the figure

2. Achieve results




2, Partial source code

Some code examples:

package com.action;

import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.List;
import java.util.StringTokenizer;

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 com.bean.ComBean; 
import com.util.Constant;
import com.util.MD5;

public class AdminServlet extends HttpServlet {

	/**
	 * Constructor of the object.
	 */
	public AdminServlet() {
		super();
	}

	/**
	 * Destruction of the servlet. <br>
	 */
	public void destroy() {
		super.destroy(); // Just puts "destroy" string in log
		// Put your code here
	}

	/**
	 * The doGet method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to get.
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 * @throws ServletException if an error occurred
	 * @throws IOException if an error occurred
	 */
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		doPost(request,response);
	}

	/**
	 * The doPost method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to post.
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 * @throws ServletException if an error occurred
	 * @throws IOException if an error occurred
	 */
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		response.setContentType(Constant.CONTENTTYPE);
		request.setCharacterEncoding(Constant.CHARACTERENCODING);
		String date=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(Calendar.getInstance().getTime());
		String date2=new SimpleDateFormat("yyyy-MM-dd").format(Calendar.getInstance().getTime());
		try{
			String method=request.getParameter("method").trim();
			ComBean cBean = new ComBean();
			HttpSession session = request.getSession();   
			if(method.equals("one")){//�û���¼
				String username = request.getParameter("username");
				String password = request.getParameter("password");  
				String sf = request.getParameter("sf");  
				String sql="select realname from admin where username='"+username+"' and  password='"+password+"'  and  sf='"+sf+"' ";
				String str=cBean.getString(sql);
				if(str==null){
					request.setAttribute("message", "��¼��Ϣ����");
					request.getRequestDispatcher("index.jsp").forward(request, response); 
				}
				else{
					session.setAttribute("user", username); 
					session.setAttribute("sf", sf); 
					request.getRequestDispatcher("admin/index.jsp").forward(request, response); 
				}  
			}
			else if(method.equals("uppwd")){//�޸�����
				String username=(String)session.getAttribute("user"); 
				String oldpwd = request.getParameter("oldpwd"); 
				String newpwd = request.getParameter("newpwd"); 
				String str=cBean.getString("select id from admin where username='"+username+"' and  password='"+oldpwd+"'");
				if(str==null){
					request.setAttribute("message", "ԭʼ������Ϣ����");
					request.getRequestDispatcher("admin/system/editpwd.jsp").forward(request, response); 
				}
				else{
					int flag=cBean.comUp("update admin set password='"+newpwd+"' where username='"+username+"'");
					if(flag == Constant.SUCCESS){ 
						request.setAttribute("message", "�����ɹ���");
						request.getRequestDispatcher("admin/system/editpwd.jsp").forward(request, response); 
					}
					else { 
						request.setAttribute("message", "����ʧ�ܣ�");
						request.getRequestDispatcher("admin/system/editpwd.jsp").forward(request, response); 
					}
				}
			}
			else if(method.equals("adminexit")){//�˳���¼
				session.removeAttribute("user");  session.removeAttribute("sf");
				request.getRequestDispatcher("index.jsp").forward(request, response); 
			}
			else if(method.equals("addm")){//����ϵͳ�û�
				String username = request.getParameter("username"); 
				String password = request.getParameter("password"); 
				String realname = request.getParameter("realname"); 
				String sex = request.getParameter("sex"); 
				String age = request.getParameter("age"); 
				String address = request.getParameter("address"); 
				String tel = request.getParameter("tel"); 
				String str=cBean.getString("select id from admin where username='"+username+"'");
				if(str==null){ 
						int flag=cBean.comUp("insert into admin(username,password,realname,sex,age,address,tel,addtime ) " +
								"values('"+username+"','"+password+"','"+realname+"','"+sex+"','"+age+"','"+address+"','"+tel+"','"+date+"' )");
						if(flag == Constant.SUCCESS){ 
							request.setAttribute("message", "�����ɹ���");
							request.getRequestDispatcher("admin/system/index.jsp").forward(request, response); 
						}
						else { 
							request.setAttribute("message", "����ʧ�ܣ�");
							request.getRequestDispatcher("admin/system/index.jsp").forward(request, response); 
						} 
				}
				else{
					request.setAttribute("message", "���û����Ѵ��ڣ�");
					request.getRequestDispatcher("admin/system/index.jsp").forward(request, response); 
				} 
			}
			else if(method.equals("upm")){//�޸�ϵͳ�û�
				String id = request.getParameter("id");
				String password = request.getParameter("password");
				String realname = request.getParameter("realname"); 
				String sex = request.getParameter("sex"); 
				String age = request.getParameter("age"); 
				String address = request.getParameter("address"); 
				String tel = request.getParameter("tel");  
				int flag=cBean.comUp("update admin set password='"+password+"',realname='"+realname+"',sex='"+sex+"',age='"+age+"'," +
						"address='"+address+"',tel='"+tel+"' where id='"+id+"'");
				if(flag == Constant.SUCCESS){ 
					request.setAttribute("message", "�����ɹ���");
					request.getRequestDispatcher("admin/system/index.jsp").forward(request, response); 
				}
				else { 
					request.setAttribute("message", "����ʧ�ܣ�");
					request.getRequestDispatcher("admin/system/index.jsp").forward(request, response); 
				}
			}
			else if(method.equals("delm")){//ɾ��ϵͳ�û�
				String id = request.getParameter("id");  
				int flag=cBean.comUp("delete from admin where id='"+id+"'");
				if(flag == Constant.SUCCESS){ 
					request.setAttribute("message", "�����ɹ���");
					request.getRequestDispatcher("admin/system/index.jsp").forward(request, response); 
				}
				else { 
					request.setAttribute("message", "����ʧ�ܣ�");
					request.getRequestDispatcher("admin/system/index.jsp").forward(request, response); 
				}
			} 
			else{//�޲�������ת������ҳ��
				request.getRequestDispatcher("error.jsp").forward(request, response);
			}
		}catch(Exception e){
			e.printStackTrace();
			request.getRequestDispatcher("error.jsp").forward(request, response);
		}
		
	}

	/**
	 * Initialization of the servlet. <br>
	 *
	 * @throws ServletException if an error occure
	 */
	public void init() throws ServletException {
		// Put your code here
	}

}

Topics: Java