文章目录
- 前言
- 一、项目设计
- 1. 模块设计
- 系统的主要功能性需求
- 2. 实现效果
- 二、部分源码
- 项目源码
前言
今天学长向大家分享一个 java web项目:
基于Java的敬老院管理系统设计与实现
一、项目设计
1. 模块设计
站在护工角度来看,他们迫切希望,在运用该系统以后,可以更加方便的修改个人详细信息;可以更加方便的查看自己负责的老人信息;可以更加方便的进行床位入住的管理。
根据对以上角色需求的分析,本系统主要的功能包括:登录、用户信息管理、老人信息管理、事故记录、请假记录、床位分配、入住费用,护工薪资和护工请假。
系统的主要功能性需求
(1)登录:用户登录是系统的基础功能,用户只有登录系统之后,才能进行其他操作,这也是从系统的安全性角度充分考虑和认证的。本系统只有一个管理员,他是养老院的负责人,通过他可以增添新员工。管理员、员工输入各自相应的姓名以及密码且选择对应的身份即可登录系统。
(2)老人信息管理:员工在登录系统后,可以在相应的界面进行对老人个人信息的修改,包括个人身份证号,姓名,密码,年龄以及电话号码等。
(3)床位分配管理:主要是管理员对入住状况管理。
(4)用户信息管理:主要是管理员对整个宾馆员工个人信息的增删改查。
(5)事故记录:主要是管理员查看老人出现事故的相关服务的增删改查。
(6)请假记录:主要是管理员查看老人请假的相关服务的增删改查。
(7)护工薪资管理:主要是负责人对护工的薪资信息进行增删改查以及护工对自己薪资信息的查看。
(8)护工请假管理:主要是负责人对护工请假记录的增删改查以及护工对自己薪资信息的查看。
(9)入住费用:主要记录老人入住时缴费记录以及缴费金额。
具体的系统功能图如图
2. 实现效果
二、部分源码
部分代码示例:
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
}
}