基于javaweb+mysql的jsp+servlet医院门诊收费管理系统(java+jsp+jdbc+mysql)
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+mysql的JSP+Servlet医院门诊收费管理系统(java+jsp+jdbc+mysql)
一、项目简述
功能:登录,门诊划价,收费,报表,药品管理等等功能。
二、项目运行
运行环境: Jdk1.8 + Tomcats . 5 + mysql + Eclispe ( IntelliJ IDEA ,Eclispe , MyEclispe , sts 都支持)。
项目技术: JSP + Entity + Servlet + html + css + Javascript + JQuery + Ajax +Fileupload 等等。
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String ProductShortName = (String)request.getParameter("ProductShortName");
if(ProductShortName != null) {
List<Product> list = CashSystemFactory.getProductDao().findByShortName(ProductShortName);
if(list.size() > 0) {
request.setAttribute("ProductInfo", list.get(0));
request.getRequestDispatcher("makePay.jsp").forward(request, response);
return;
}
}
response.sendRedirect("makePay.jsp");
}
}
/**
* Servlet implementation class CreatePayServlet
*/
@WebServlet("/CreatePayServlet")
public class CreatePayServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public CreatePayServlet() {
super();
// TODO Auto-generated constructor stub
}
}
}
/**
* Servlet implementation class LoginServlet
*/
@WebServlet("/RegisterServlet")
public class RegisterServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public RegisterServlet() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request,response);
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String UserName = request.getParameter("UserName");
String Password = request.getParameter("Password");
String UserTel = request.getParameter("UserTel");
/**
* Servlet implementation class PayServlet
*/
@WebServlet("/PayServlet")
public class PayServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public PayServlet() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
int PayListID = Integer.parseInt(request.getParameter("PayListID"));
User user = (User)request.getSession().getAttribute("User");
if(user == null) {
request.getRequestDispatcher("login.jsp").forward(request, response);
return;
}
if(user.getUserID() == CashSystemFactory.getPayListDao(user).getPayListByID(user.getUserID(), PayListID).getUserID()) {
CashSystemFactory.getPayBackDao().createPayBack(PayListID);
response.sendRedirect("finishedPay.jsp");
}else {
response.sendRedirect("index.jsp");
}
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request, response);
}
/**
* Servlet implementation class PayServlet
*/
@WebServlet("/PayServlet")
public class PayServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public PayServlet() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
int PayListID = Integer.parseInt(request.getParameter("PayListID"));
User user = (User)request.getSession().getAttribute("User");
if(user == null) {
request.getRequestDispatcher("login.jsp").forward(request, response);
return;
}
if(user.getUserID() == CashSystemFactory.getPayListDao(user).getPayListByID(user.getUserID(), PayListID).getUserID()) {
CashSystemFactory.getPayBackDao().createPayBack(PayListID);
response.sendRedirect("finishedPay.jsp");
}else {
response.sendRedirect("index.jsp");
}
}
/**
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.getWriter().append("Do not request me directly! :D");
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String UserName = request.getParameter("UserName");
if(UserName != null && UserName.length() > 0) {
User u = new User(UserName, null);
int PayListID = CashSystemFactory.getPayListDao(u).makePayList();
if(u.getUserID() > 0) {
request.getSession().setAttribute("NewPayListID", PayListID);
request.getSession().setAttribute("User", u);
}
}
response.sendRedirect("makePay.jsp");
}
}
/**
* Servlet implementation class LoginServlet
*/
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String ProductShortName = (String)request.getParameter("ProductShortName");
if(ProductShortName != null) {
List<Product> list = CashSystemFactory.getProductDao().findByShortName(ProductShortName);
if(list.size() > 0) {
request.setAttribute("ProductInfo", list.get(0));
request.getRequestDispatcher("makePay.jsp").forward(request, response);
return;
}
}
response.sendRedirect("makePay.jsp");
}
}
/**
* Servlet implementation class CreatePayServlet
*/
@WebServlet("/CreatePayServlet")
public class CreatePayServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public CreatePayServlet() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.getWriter().append("Do not request me directly! :D");
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String UserName = request.getParameter("UserName");
/**
* Servlet implementation class DeleteProductServlet
*/
@WebServlet("/DeleteProductServlet")
public class DeleteProductServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public DeleteProductServlet() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
int PayListID = Integer.parseInt(request.getParameter("PayListID"));
int ProductID = Integer.parseInt(request.getParameter("ProductID"));
User user = (User)request.getSession().getAttribute("User");
// 这里我们不检查有效性了
CashSystemFactory.getPayListDao(user).removeProduct(new PayList(user.getUserID(), PayListID, null), new Product(ProductID, 0));
response.sendRedirect("makePay.jsp");
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
}
/**
* Servlet implementation class LoginServlet
*/
@WebServlet("/RegisterServlet")
public class RegisterServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public RegisterServlet() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request,response);
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String UserName = request.getParameter("UserName");
String Password = request.getParameter("Password");
user = new User();
request.getSession().setAttribute("FakeUser", null);
}
if(user == null) {
request.getRequestDispatcher("login.jsp").forward(request, response);
return;
}
request.setAttribute("PayListInfo", CashSystemFactory.getPayListDao(user).getPayListByID(user.getUserID(), PayListID));
request.getRequestDispatcher(from + ".jsp").forward(request, response);
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request, response);
}
}
/**
* Servlet implementation class ProductInfoAddServlet
*/
@WebServlet("/ProductInfoAddServlet")
public class ProductInfoAddServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public ProductInfoAddServlet() {
/**
* Servlet implementation class PayServlet
*/
@WebServlet("/PayServlet")
public class PayServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public PayServlet() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
int PayListID = Integer.parseInt(request.getParameter("PayListID"));
User user = (User)request.getSession().getAttribute("User");
if(user == null) {
request.getRequestDispatcher("login.jsp").forward(request, response);
return;
}
if(user.getUserID() == CashSystemFactory.getPayListDao(user).getPayListByID(user.getUserID(), PayListID).getUserID()) {
CashSystemFactory.getPayBackDao().createPayBack(PayListID);
response.sendRedirect("finishedPay.jsp");
}else {
response.sendRedirect("index.jsp");
}
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request, response);
}
}
response.sendRedirect("login.jsp");
}
}
/**
* Servlet implementation class CanclePayServlet
*/
@WebServlet("/CanclePayServlet")
public class CanclePayServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public CanclePayServlet() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
int PayListID = Integer.parseInt(request.getParameter("PayListID"));
CashSystemFactory.getPayBackDao().setCancled(CashSystemFactory.getPayBackDao().getPayBackByID(PayListID));
response.sendRedirect("canclePay_admin.jsp");
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request, response);
}
}
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
int PayListID = Integer.parseInt(request.getParameter("PayListID"));
CashSystemFactory.getPayBackDao().setCancled(CashSystemFactory.getPayBackDao().getPayBackByID(PayListID));
response.sendRedirect("canclePay_admin.jsp");
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request, response);
}
}
/**
* Servlet implementation class ClearEnvServlet
*/
@WebServlet("/ClearEnvServlet")
public class ClearEnvServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setCharacterEncoding("utf-8");
// 首先把信息都拿上 创建对象后调用方法更新
int ProductID = Integer.parseInt(request.getParameter("ProductID"));
String ProductName = request.getParameter("ProductName");
String ProductShortName = request.getParameter("ProductShortName");
int ProductNums = Integer.parseInt(request.getParameter("ProductNums"));
double ProductPrice = Double.parseDouble(request.getParameter("ProductPrice"));
Product p = new Product(ProductID, ProductNums, ProductName, ProductShortName, ProductPrice);
CashSystemFactory.getProductDao().modifyProduct(p);
response.sendRedirect("productManage.jsp");
}
}
/**
* Servlet implementation class PayListInfoServlet
*/
@WebServlet("/PayListInfoServlet")
public class PayListInfoServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public PayListInfoServlet() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
int PayListID = Integer.parseInt(request.getParameter("PayListID"));
String from = request.getParameter("from");//这里有安全隐患
User user = (User)request.getSession().getAttribute("User");
if(request.getSession().getAttribute("FakeUser") != null) {
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
int PayListID = Integer.parseInt(request.getParameter("PayListID"));
String ProductShortName = request.getParameter("ProductShortName");
int Count = Integer.parseInt(request.getParameter("Count"));
User user = (User) request.getSession().getAttribute("User");
String msg = null;
if (user != null && ProductShortName != null) {
List<Product> list = CashSystemFactory.getProductDao().findByShortName(ProductShortName);
if(list.size() >= 1) {
Product product = list.get(0);
if (product != null) {
product.setCount(Count);
msg = CashSystemFactory.getPayListDao(user)
.addProduct(new PayList(user.getUserID(), PayListID, null), product);
}
}
}else {
response.sendRedirect("clearEnv");
return;
}
if(msg != null)
msg = "来自数据库触发器的消息:" + msg;
request.getSession().setAttribute("message", msg);
response.sendRedirect("makePay.jsp");
}
}
/**
* Servlet implementation class ProductInfoUpdateServlet
*/
@WebServlet("/ProductInfoUpdateServlet")
public class ProductInfoUpdateServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
/**
* Servlet implementation class DeleteProductServlet
*/
@WebServlet("/DeleteProductServlet")
public class DeleteProductServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public DeleteProductServlet() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
int PayListID = Integer.parseInt(request.getParameter("PayListID"));
int ProductID = Integer.parseInt(request.getParameter("ProductID"));
User user = (User)request.getSession().getAttribute("User");
// 这里我们不检查有效性了
CashSystemFactory.getPayListDao(user).removeProduct(new PayList(user.getUserID(), PayListID, null), new Product(ProductID, 0));
response.sendRedirect("makePay.jsp");
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request, response);
}
}
/**
* Servlet implementation class CanclePayServlet
*/
@WebServlet("/CanclePayServlet")
public class CanclePayServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public CanclePayServlet() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
int PayListID = Integer.parseInt(request.getParameter("PayListID"));
CashSystemFactory.getPayBackDao().setCancled(CashSystemFactory.getPayBackDao().getPayBackByID(PayListID));
response.sendRedirect("canclePay_admin.jsp");
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request, response);
}
}
/**
* Servlet implementation class LoginServlet
*/
@WebServlet("/LoginServlet")
public class LoginServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public LoginServlet() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.getWriter().append("Do not request me directly! :P");
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String UserName = request.getParameter("UserName");
String Password = request.getParameter("Password");
User u = CashSystemFactory.getUserDao().Login(new User(UserName, Password));
if(u.getUserID() == 0) {
//登陆失败
response.getWriter().append("Login error!");
}else {
//登陆成功
request.getSession().setAttribute("User", u);
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request,response);
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String UserName = request.getParameter("UserName");
String Password = request.getParameter("Password");
String UserTel = request.getParameter("UserTel");
User user = new User(UserName, Password);
user.setUserTel(UserTel);
CashSystemFactory.getUserDao().Regist(user);
response.sendRedirect("login.jsp");
}
}
/**
* Servlet implementation class CanclePayServlet
*/
@WebServlet("/CanclePayServlet")
public class CanclePayServlet extends HttpServlet {
private static final long serialVersionUID = 1L;