基于javaweb+mysql的jsp+servlet在线药店管理系统(java+jsp+bootstrap+jquery+mysql)

基于javaweb+mysql的jsp+servlet在线药店管理系统(java+jsp+bootstrap+jquery+mysql)

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

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

适用

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

功能说明

基于javaweb+mysql的JSP+Servlet在线药店管理系统(java+jsp+bootstrap+jquery+mysql)

项目介绍

基于jsp+servlet在线药店管理系统。 该项目是一个后管系统,只有一个管理员角色,功能比较简单,适合java初学者或者学生做课程设计等;

主要功能包括:

用户登录、注册;系统管理、药品管理、顾客信息管理、供货商管理、订单管理等;

环境需要

1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。 2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA; 3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可 4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS; 5.是否Maven项目: 否;查看源码目录中是否包含pom.xml;若包含,则为maven项目,否则为非maven项目 6.数据库:MySql 5.7版本;

技术栈

  1. 后端:servlet 2. 前端:JSP+bootstrap+jQuery

使用说明

  1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven; 若为maven项目,导入成功后请执行maven clean;maven install命令,配置tomcat,然后运行; 3. 将项目中c3p0.properties配置文件中的数据库配置改为自己的配置 4. 运行项目,输入http://localhost:8080/shop 登录 5. 账户admin 密码123456
	public void showCustomerByCid(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("this is showCustomerByCid....");
		int cid=Integer.parseInt(request.getParameter("cid"));
		Customer customer=customerService.showCustomerByCid(cid);
		if(customer!=null)
		{
			request.setAttribute("customer",customer);
			request.getRequestDispatcher("customer/edit.jsp").forward(request, response);
		}
	}

	public void updateCustomer(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("this is  updateCustomer...");
		try {
			int cid=Integer.parseInt(request.getParameter("cid"));
			String cname=request.getParameter("cname");
			String csex=request.getParameter("csex");
			int cage=Integer.parseInt(request.getParameter("cage"));
			String cphone= request.getParameter("cphone");
			String cemail= request.getParameter("cemail");
			String caddress= request.getParameter("caddress");
			Customer customer=new Customer();
			customer.setCid(cid);
			customer.setCname(cname);
			customer.setCsex(csex);
			customer.setCage(cage);
			customer.setCphone(cphone);
			customer.setCemail(cemail);
			customer.setCaddress(caddress);
			//System.out.println(customer);//检查。
			boolean z=customerService.updateCustomer(customer);
			if(z)
			{
				showCustomerByPage(request,response);
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	public void updateCustomerByCid(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
			String cphone= request.getParameter("cphone");
			String cemail= request.getParameter("cemail");
			String caddress= request.getParameter("caddress");
			Customer customer=new Customer();
			customer.setCname(cname);
			customer.setCsex(csex);
			customer.setCage(cage);
			customer.setCphone(cphone);
			customer.setCemail(cemail);
			customer.setCaddress(caddress);
			//System.out.println(customer);//检查。
			boolean z=customerService.insertCustomer(customer);
			if(z)
			{
				showCustomerByPage(request,response);
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	public void deleteCustomerByCid(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("this is deleteCustomerByCid....");
		int cid=Integer.parseInt(request.getParameter("cid"));

		boolean z= customerService.deleteCustomerByCid(cid);
		System.out.println("z:"+z);
		if(z)
		{
			showCustomerByPage(request,response);
		}

	}
	public void showCustomer(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("this is showCustomer.....");
		List<Customer> customer=customerService.showCustomer();
		request.setAttribute("customer", customer);
		request.getRequestDispatcher("customer/index.jsp").forward(request, response);
	}

	public void showCustomerByPage(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("this is showCustomerByPage.....");
		String current_page=request.getParameter("current_page");
		//先有鸡还是先有蛋。
		int count_rows=customerService.counts();
		PageTools pt=new PageTools(current_page, count_rows);

		List<Customer> customer=customerService.showCustomerByPage(pt);
		System.out.println("========"+admin);
		HttpSession session = request.getSession();
		session.setAttribute("admin", admin);
		request.getRequestDispatcher("index.jsp").forward(request, response);
	}

	public void logout(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("this is logout...");

		HttpSession session = request.getSession();
		session.invalidate();
		response.sendRedirect("login.jsp");
	}

}
package servlet;

/**
 * Servlet implementation class DrugServlet
 */
@WebServlet("/drugServlet.do")
public class DrugServlet extends BaseServlet {
	private static final long serialVersionUID = 1L;
	private DrugService drugService=new DrugService();

	public void insertDrug(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("this is insertDrug....");
		try {
			String did=request.getParameter("did");
	}

	public void deleteSupplierBySname(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("this is deleteSupplierBySname....");
		String sname=request.getParameter("sname");
		boolean z= supplierService.deleteSupplierBySname(sname);
		System.out.println("z:"+z);
		if(z)
		{
			showSupplierByPage(request,response);
		}
	}

	public void showSupplier(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("this is showSupplier.....");
		List<Supplier> supplier=supplierService.showSupplier();
		request.setAttribute("supplier", supplier);
		request.getRequestDispatcher("supplier/index.jsp").forward(request, response);
	}

	public void showSupplierByPage(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("this is showSupplierByPage.....");
		String current_page=request.getParameter("current_page");
		//先有鸡还是先有蛋。
		int count_rows=supplierService.counts();
		PageTools pt=new PageTools(current_page, count_rows);

		List<Supplier> supplier=supplierService.showSupplierByPage(pt);
		request.setAttribute("pt", pt);
		request.setAttribute("supplier",supplier);
		request.getRequestDispatcher("supplier/index.jsp").forward(request, response);
	}

	public void showSupplierBySname(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("this is showSupplierBySname....");
		String sname=request.getParameter("sname");
		Supplier supplier=supplierService.showSupplierBySname(sname);
		if(supplier!=null)
		{
			request.setAttribute("supplier",supplier);
			request.getRequestDispatcher("supplier/edit.jsp").forward(request, response);
		}
	}

	public void updateSupplier(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("this is  updateSupplier...");
		try {
			String sname=request.getParameter("sname");
			String sphone=request.getParameter("sphone");
			int cage=Integer.parseInt(request.getParameter("cage"));
			String cphone= request.getParameter("cphone");
			String cemail= request.getParameter("cemail");
			String caddress= request.getParameter("caddress");
			Customer customer=new Customer();
			customer.setCid(cid);
			customer.setCname(cname);
			customer.setCsex(csex);
			customer.setCage(cage);
			customer.setCphone(cphone);
			customer.setCemail(cemail);
			customer.setCaddress(caddress);
			//System.out.println(customer);//检查。
			boolean z=customerService.updateCustomer(customer);
			if(z)
			{
				showCustomerByPage(request,response);
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	public void updateCustomerByCid(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("this is updateCustomerByCid....");
		int cid=Integer.parseInt(request.getParameter("cid"));
		//System.out.println(did);

		Customer customer=customerService.showCustomerByCid(cid);
		if(customer!=null)
		{
			request.setAttribute("customer", customer);
			request.getRequestDispatcher("customer/edit.jsp").forward(request, response);
		}
	}

}
package servlet;

	}

	public void deleteCustomerByCid(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("this is deleteCustomerByCid....");
		int cid=Integer.parseInt(request.getParameter("cid"));

		boolean z= customerService.deleteCustomerByCid(cid);
		System.out.println("z:"+z);
		if(z)
		{
			showCustomerByPage(request,response);
		}

	}
	public void showCustomer(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("this is showCustomer.....");
		List<Customer> customer=customerService.showCustomer();
		request.setAttribute("customer", customer);
		request.getRequestDispatcher("customer/index.jsp").forward(request, response);
	}

	public void showCustomerByPage(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("this is showCustomerByPage.....");
		String current_page=request.getParameter("current_page");
		//先有鸡还是先有蛋。
		int count_rows=customerService.counts();
		PageTools pt=new PageTools(current_page, count_rows);

		List<Customer> customer=customerService.showCustomerByPage(pt);
		request.setAttribute("pt", pt);
		request.setAttribute("customer",customer);
		request.getRequestDispatcher("customer/index.jsp").forward(request, response);
	}
	public void showCustomerByCid(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("this is showCustomerByCid....");
		int cid=Integer.parseInt(request.getParameter("cid"));
		Customer customer=customerService.showCustomerByCid(cid);
		if(customer!=null)
		{
			request.setAttribute("customer",customer);
			request.getRequestDispatcher("customer/edit.jsp").forward(request, response);
		}
	}

	public void updateCustomerByCid(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("this is updateCustomerByCid....");
		int cid=Integer.parseInt(request.getParameter("cid"));
		//System.out.println(did);

		Customer customer=customerService.showCustomerByCid(cid);
		if(customer!=null)
		{
			request.setAttribute("customer", customer);
			request.getRequestDispatcher("customer/edit.jsp").forward(request, response);
		}
	}

}
package servlet;

/**
 * Servlet implementation class OrderServlet
 */
@WebServlet("/orderServlet.do")
public class OrderServlet extends BaseServlet{
	private static final long serialVersionUID = 1L;
	private OrderService orderService=new OrderService();

	public void insertOrder(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("this is insertOrder....");
		try {
			//int oid=Integer.parseInt(request.getParameter("oid"));
			String did=request.getParameter("did");
			boolean z=orderService.insertOrder(order);
			if(z)
			{
				showOrderByPage(request,response);
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	public void deleteOrderByOid(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("this is deleteOrderByOid....");
		int oid=Integer.parseInt(request.getParameter("oid"));
		boolean z= orderService.deleteOrderByOid(oid);
		System.out.println("z:"+z);
		if(z)
		{
			showOrderByPage(request,response);
		}
	}

	public void showOrder(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("this is showOrder.....");
		List<Order> order=orderService.showOrder();
		request.setAttribute("order", order);
		request.getRequestDispatcher("order/index.jsp").forward(request, response);
	}

	public void showOrderByPage(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("this is showOrderByPage.....");
		String current_page=request.getParameter("current_page");
		//先有鸡还是先有蛋。
		int count_rows=orderService.counts();
		PageTools pt=new PageTools(current_page, count_rows);

		List<Order> order=orderService.showOrderByPage(pt);
		//System.out.println(order);
		request.setAttribute("pt", pt);
		request.setAttribute("order",order);
		request.getRequestDispatcher("order/index.jsp").forward(request, response);
	}

	public void showOrderByOid(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("this is showOrderByDid....");
		int oid=Integer.parseInt(request.getParameter("oid"));
		Order order=orderService.showOrderByOid(oid);
		if(order!=null)
	}

	public void deleteSupplierBySname(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("this is deleteSupplierBySname....");
		String sname=request.getParameter("sname");
		boolean z= supplierService.deleteSupplierBySname(sname);
		System.out.println("z:"+z);
		if(z)
		{
			showSupplierByPage(request,response);
		}
	}

	public void showSupplier(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("this is showSupplier.....");
		List<Supplier> supplier=supplierService.showSupplier();
		request.setAttribute("supplier", supplier);
		request.getRequestDispatcher("supplier/index.jsp").forward(request, response);
	}

	public void showSupplierByPage(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("this is showSupplierByPage.....");
		String current_page=request.getParameter("current_page");
		//先有鸡还是先有蛋。
		int count_rows=supplierService.counts();
		PageTools pt=new PageTools(current_page, count_rows);

		List<Supplier> supplier=supplierService.showSupplierByPage(pt);
		request.setAttribute("pt", pt);
		request.setAttribute("supplier",supplier);
		request.getRequestDispatcher("supplier/index.jsp").forward(request, response);
	}

	public void showSupplierBySname(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("this is showSupplierBySname....");
		String sname=request.getParameter("sname");
		Supplier supplier=supplierService.showSupplierBySname(sname);
		if(supplier!=null)
		{
			request.setAttribute("supplier",supplier);

	public void deleteSupplierBySname(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("this is deleteSupplierBySname....");
		String sname=request.getParameter("sname");
		boolean z= supplierService.deleteSupplierBySname(sname);
		System.out.println("z:"+z);
		if(z)
		{
			showSupplierByPage(request,response);
		}
	}

	public void showSupplier(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("this is showSupplier.....");
		List<Supplier> supplier=supplierService.showSupplier();
		request.setAttribute("supplier", supplier);
		request.getRequestDispatcher("supplier/index.jsp").forward(request, response);
	}

	public void showSupplierByPage(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("this is showSupplierByPage.....");
		String current_page=request.getParameter("current_page");
		//先有鸡还是先有蛋。
		int count_rows=supplierService.counts();
		PageTools pt=new PageTools(current_page, count_rows);

		List<Supplier> supplier=supplierService.showSupplierByPage(pt);
		request.setAttribute("pt", pt);
		request.setAttribute("supplier",supplier);
		request.getRequestDispatcher("supplier/index.jsp").forward(request, response);
	}

	public void showSupplierBySname(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("this is showSupplierBySname....");
		String sname=request.getParameter("sname");
		Supplier supplier=supplierService.showSupplierBySname(sname);
		if(supplier!=null)
		{
			request.setAttribute("supplier",supplier);
			request.getRequestDispatcher("supplier/edit.jsp").forward(request, response);
		}
	}

	public void updateSupplier(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("this is  updateSupplier...");
		try {
			String sname=request.getParameter("sname");
			String sphone=request.getParameter("sphone");
			String saddress= request.getParameter("saddress");
			Supplier supplier=new Supplier();
			supplier.setSname(sname);
			supplier.setSphone(sphone);
		PageTools pt=new PageTools(current_page, count_rows);

		List<Supplier> supplier=supplierService.showSupplierByPage(pt);
		request.setAttribute("pt", pt);
		request.setAttribute("supplier",supplier);
		request.getRequestDispatcher("supplier/index.jsp").forward(request, response);
	}

	public void showSupplierBySname(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("this is showSupplierBySname....");
		String sname=request.getParameter("sname");
		Supplier supplier=supplierService.showSupplierBySname(sname);
		if(supplier!=null)
		{
			request.setAttribute("supplier",supplier);
			request.getRequestDispatcher("supplier/edit.jsp").forward(request, response);
		}
	}

	public void updateSupplier(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("this is  updateSupplier...");
		try {
			String sname=request.getParameter("sname");
			String sphone=request.getParameter("sphone");
			String saddress= request.getParameter("saddress");
			Supplier supplier=new Supplier();
			supplier.setSname(sname);
			supplier.setSphone(sphone);
			supplier.setSaddress(saddress);
			//System.out.println(supplier);//检查。
			boolean z=supplierService.updateSupplier(supplier);
			if(z)
			{
				showSupplierByPage(request,response);
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	public void updateSupplierBySname(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("this is updateSupplierBySname....");
		String sname=request.getParameter("sname");
		//System.out.println(did);

		Supplier supplier=supplierService.showSupplierBySname(sname);
		if(supplier!=null)
		{
			request.setAttribute("supplier", supplier);
			request.getRequestDispatcher("supplier/edit.jsp").forward(request, response);
			boolean z=adminService.updateAdmin(admin);
			if(z)
			{
				showAdminByPage(request,response);
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	public void updateAdminByAid(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("this is updateAdminByAid....");
		int aid=Integer.parseInt(request.getParameter("aid"));
		//System.out.println(did);

		Admin admin=adminService.showAdminByAid(aid);
		if(admin!=null)
		{
			request.setAttribute("admin", admin);
			request.getRequestDispatcher("admin/edit.jsp").forward(request, response);
		}
	}

	//注册
	public void regist(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("this is regist...");

		String aname = request.getParameter("aname");// 真实姓名
		String apassword = request.getParameter("apassword");
		String aphone = request.getParameter("aphone");
		String aaddress = request.getParameter("aaddress");

		Admin admin = new Admin();
		admin.setAname(aname);
		admin.setApassword(apassword);
		admin.setAphone(aphone);
		admin.setAaddress(aaddress);

		boolean z = adminService.insertAdmin(admin);
		if (z) {
			response.sendRedirect("login.jsp");
		} else {
			request.setAttribute("error", "注册失败");
			request.getRequestDispatcher("regist.jsp").forward(request, response);
		}
	}


/**
 * Servlet implementation class CustomerServlet
 */
@WebServlet("/customerServlet.do")
public class CustomerServlet extends BaseServlet {
	private static final long serialVersionUID = 1L;
	private CustomerService customerService=new CustomerService();

	public void insertCustomer(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("this is insertCustomer....");
		try {
			String cname=request.getParameter("cname");
			String csex=request.getParameter("csex");
			int cage=Integer.parseInt(request.getParameter("cage"));
			String cphone= request.getParameter("cphone");
			String cemail= request.getParameter("cemail");
			String caddress= request.getParameter("caddress");
			Customer customer=new Customer();
			customer.setCname(cname);
			customer.setCsex(csex);
			customer.setCage(cage);
			customer.setCphone(cphone);
			customer.setCemail(cemail);
			customer.setCaddress(caddress);
			//System.out.println(customer);//检查。
			boolean z=customerService.insertCustomer(customer);
			if(z)
			{
				showCustomerByPage(request,response);
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	public void deleteCustomerByCid(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("this is deleteCustomerByCid....");
 * Servlet implementation class SupplierServlet
 */
@WebServlet("/supplierServlet.do")
public class SupplierServlet extends BaseServlet {
	private static final long serialVersionUID = 1L;

	private SupplierService supplierService=new SupplierService();

	public void insertSupplier(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("this is insertSupplier....");
		try {
			String sname=request.getParameter("sname");
			String sphone=request.getParameter("sphone");
			String saddress= request.getParameter("saddress");
			Supplier supplier=new Supplier();
			supplier.setSname(sname);
			supplier.setSphone(sphone);
			supplier.setSaddress(saddress);
			System.out.println(supplier);//检查。
			boolean z=supplierService.insertSupplier(supplier);
			if(z)
			{
				showSupplierByPage(request,response);
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	public void deleteSupplierBySname(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("this is deleteSupplierBySname....");
		String sname=request.getParameter("sname");
		boolean z= supplierService.deleteSupplierBySname(sname);
		System.out.println("z:"+z);
		if(z)
		{
			showSupplierByPage(request,response);
		}
	}

	public void showSupplier(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("this is showSupplier.....");
		List<Supplier> supplier=supplierService.showSupplier();
		request.setAttribute("supplier", supplier);
		request.getRequestDispatcher("supplier/index.jsp").forward(request, response);
	}

	public void showSupplierByPage(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("this is showSupplierByPage.....");
		String current_page=request.getParameter("current_page");

	public void updateOrder(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("this is updateOrder...");
		try {
			int oid=Integer.parseInt(request.getParameter("oid"));
			String did=request.getParameter("did");
			int oquantity=Integer.parseInt(request.getParameter("oquantity"));
			String oprice=request.getParameter("oprice");

			int cid=Integer.parseInt(request.getParameter("cid"));

			String od =request.getParameter("prodate");
			java.sql.Date odate=java.sql.Date.valueOf(od);

			Order order=new Order();
			order.setOid(oid);
			order.setDid(did);
			order.setOquantity(oquantity);
			order.setOprice(oprice);
			order.setCid(cid);
			order.setOdate(odate);
			//System.out.println(order);//检查。
			boolean z=orderService.updateOrder(order);
			if(z)
			{
				showOrderByPage(request,response);
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	public void updateOrderByOid(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("this is updateOrderByOid....");
		int oid=Integer.parseInt(request.getParameter("oid"));
		Order order=orderService.showOrderByOid(oid);
		if(order!=null)
		{
			request.setAttribute("order", order);
			request.getRequestDispatcher("order/edit.jsp").forward(request, response);
		}
	}
}
package servlet;

		Admin admin = adminService.checkLogin(aname, apassword);
		System.out.println("========"+admin);
		HttpSession session = request.getSession();
		session.setAttribute("admin", admin);
		request.getRequestDispatcher("index.jsp").forward(request, response);
	}

	public void logout(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("this is logout...");

		HttpSession session = request.getSession();
		session.invalidate();
		response.sendRedirect("login.jsp");
	}

}
package servlet;

/**
 * Servlet implementation class DrugServlet
 */
@WebServlet("/drugServlet.do")
public class DrugServlet extends BaseServlet {
	private static final long serialVersionUID = 1L;
	private DrugService drugService=new DrugService();

	public void insertDrug(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("this is insertDrug....");
		try {
			String did=request.getParameter("did");
			String dname=request.getParameter("dname");
			String dclass=request.getParameter("dclass");
			String dprice=request.getParameter("dprice");

			String pro = request.getParameter("prodate");
			//SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
			java.sql.Date prodate=java.sql.Date.valueOf(pro);

			String did=request.getParameter("did");
			String dname=request.getParameter("dname");
			String dclass=request.getParameter("dclass");
			String dprice=request.getParameter("dprice");

			String pro = request.getParameter("prodate");
			//SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
			java.sql.Date prodate=java.sql.Date.valueOf(pro);

			String ex = request.getParameter("exdate");
			java.sql.Date exdate=java.sql.Date.valueOf(ex);

			int requantity=Integer.parseInt(request.getParameter("requantity"));
			String sname= request.getParameter("sname");
			String function= request.getParameter("function");
			Drug drug=new Drug();
			drug.setDid(did);
			drug.setDname(dname);
			drug.setDclass(dclass);
			drug.setDprice(dprice);
			drug.setProdate(prodate);
			drug.setExdate(exdate);
			drug.setRequantity(requantity);
			drug.setSname(sname);
			drug.setFunction(function);

			System.out.println(drug);//检查。
			boolean z=drugService.insertDrug(drug);
			if(z)
			{
				showDrugByPage(request,response);
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	public void deleteDrugByDid(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("this is deleteDrugByDid....");
		System.out.println("this is logout...");

		HttpSession session = request.getSession();
		session.invalidate();
		response.sendRedirect("login.jsp");
	}

}
package servlet;

/**
 * Servlet implementation class DrugServlet
 */
@WebServlet("/drugServlet.do")
public class DrugServlet extends BaseServlet {
	private static final long serialVersionUID = 1L;
	private DrugService drugService=new DrugService();

	public void insertDrug(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("this is insertDrug....");
		try {
			String did=request.getParameter("did");
			String dname=request.getParameter("dname");
			String dclass=request.getParameter("dclass");
			String dprice=request.getParameter("dprice");

			String pro = request.getParameter("prodate");
			//SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
			java.sql.Date prodate=java.sql.Date.valueOf(pro);

			String ex = request.getParameter("exdate");
			java.sql.Date exdate=java.sql.Date.valueOf(ex);

			int requantity=Integer.parseInt(request.getParameter("requantity"));
			String sname= request.getParameter("sname");
			String function= request.getParameter("function");
			Drug drug=new Drug();
			drug.setDid(did);
			drug.setDname(dname);
	}

	public void showCustomerByPage(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("this is showCustomerByPage.....");
		String current_page=request.getParameter("current_page");
		//先有鸡还是先有蛋。
		int count_rows=customerService.counts();
		PageTools pt=new PageTools(current_page, count_rows);

		List<Customer> customer=customerService.showCustomerByPage(pt);
		request.setAttribute("pt", pt);
		request.setAttribute("customer",customer);
		request.getRequestDispatcher("customer/index.jsp").forward(request, response);
	}
	public void showCustomerByCid(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("this is showCustomerByCid....");
		int cid=Integer.parseInt(request.getParameter("cid"));
		Customer customer=customerService.showCustomerByCid(cid);
		if(customer!=null)
		{
			request.setAttribute("customer",customer);
			request.getRequestDispatcher("customer/edit.jsp").forward(request, response);
		}
	}

	public void updateCustomer(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("this is  updateCustomer...");
		try {
			int cid=Integer.parseInt(request.getParameter("cid"));
			String cname=request.getParameter("cname");
			String csex=request.getParameter("csex");
			int cage=Integer.parseInt(request.getParameter("cage"));
			String cphone= request.getParameter("cphone");
			String cemail= request.getParameter("cemail");
			String caddress= request.getParameter("caddress");
			Customer customer=new Customer();
			customer.setCid(cid);
			customer.setCname(cname);
			customer.setCsex(csex);
			customer.setCage(cage);
			customer.setCphone(cphone);
			customer.setCemail(cemail);
			customer.setCaddress(caddress);
			//System.out.println(customer);//检查。
			boolean z=customerService.updateCustomer(customer);
			if(z)
			{
				showCustomerByPage(request,response);
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		}
	}

	public void deleteAdminByAid(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("this is deleteAdminByAid....");
		int aid=Integer.parseInt(request.getParameter("aid"));
		boolean z= adminService.deleteAdminByAid(aid);
		System.out.println("z:"+z);
		if(z)
		{
			showAdminByPage(request,response);
		}
	}

	public void showAdmin(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("this is showAdmin.....");
		List<Admin> admin=adminService.showAdmin();
		request.setAttribute("admin", admin);
		request.getRequestDispatcher("admin/index.jsp").forward(request, response);
	}

	public void showAdminByPage(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("this is showAdminByPage.....");
		String current_page=request.getParameter("current_page");
		//先有鸡还是先有蛋。
		int count_rows=adminService.counts();
		PageTools pt=new PageTools(current_page, count_rows);

		List<Admin> admin=adminService.showAdminByPage(pt);
		request.setAttribute("pt", pt);
		request.setAttribute("admin",admin);
		request.getRequestDispatcher("admin/index.jsp").forward(request, response);
	}

	public void showAdminByAid(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("this is showAdminByAid....");
		int aid=Integer.parseInt(request.getParameter("aid"));
		Admin admin=adminService.showAdminByAid(aid);
		if(admin!=null)
		{
			request.setAttribute("admin",admin);
			request.getRequestDispatcher("admin/edit.jsp").forward(request, response);
		}
	}

	public void updateAdmin(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("this is updateAdmin...");
		try {
			int aid=Integer.parseInt(request.getParameter("aid"));
			String aname=request.getParameter("aname");
			String apassword=request.getParameter("apassword");
			showSupplierByPage(request,response);
		}
	}

	public void showSupplier(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("this is showSupplier.....");
		List<Supplier> supplier=supplierService.showSupplier();
		request.setAttribute("supplier", supplier);
		request.getRequestDispatcher("supplier/index.jsp").forward(request, response);
	}

	public void showSupplierByPage(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("this is showSupplierByPage.....");
		String current_page=request.getParameter("current_page");
		//先有鸡还是先有蛋。
		int count_rows=supplierService.counts();
		PageTools pt=new PageTools(current_page, count_rows);

		List<Supplier> supplier=supplierService.showSupplierByPage(pt);
		request.setAttribute("pt", pt);
		request.setAttribute("supplier",supplier);
		request.getRequestDispatcher("supplier/index.jsp").forward(request, response);
	}

	public void showSupplierBySname(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("this is showSupplierBySname....");
		String sname=request.getParameter("sname");
		Supplier supplier=supplierService.showSupplierBySname(sname);
		if(supplier!=null)
		{
			request.setAttribute("supplier",supplier);
			request.getRequestDispatcher("supplier/edit.jsp").forward(request, response);
		}
	}

	public void updateSupplier(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("this is  updateSupplier...");
		try {
			String sname=request.getParameter("sname");
			String sphone=request.getParameter("sphone");
			String saddress= request.getParameter("saddress");
			Supplier supplier=new Supplier();
			supplier.setSname(sname);
			supplier.setSphone(sphone);
			supplier.setSaddress(saddress);
			//System.out.println(supplier);//检查。
			boolean z=supplierService.updateSupplier(supplier);
			if(z)
			e.printStackTrace();
		}
	}

	public void updateAdminByAid(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("this is updateAdminByAid....");
		int aid=Integer.parseInt(request.getParameter("aid"));
		//System.out.println(did);

		Admin admin=adminService.showAdminByAid(aid);
		if(admin!=null)
		{
			request.setAttribute("admin", admin);
			request.getRequestDispatcher("admin/edit.jsp").forward(request, response);
		}
	}

	//注册
	public void regist(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("this is regist...");

		String aname = request.getParameter("aname");// 真实姓名
		String apassword = request.getParameter("apassword");
		String aphone = request.getParameter("aphone");
		String aaddress = request.getParameter("aaddress");

		Admin admin = new Admin();
		admin.setAname(aname);
		admin.setApassword(apassword);
		admin.setAphone(aphone);
		admin.setAaddress(aaddress);

		boolean z = adminService.insertAdmin(admin);
		if (z) {
			response.sendRedirect("login.jsp");
		} else {
			request.setAttribute("error", "注册失败");
			request.getRequestDispatcher("regist.jsp").forward(request, response);
		}
	}

	// checkLogin
	public void checkLogin(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("this is checkLogin...");


		Admin admin=adminService.showAdminByAid(aid);
		if(admin!=null)
		{
			request.setAttribute("admin", admin);
			request.getRequestDispatcher("admin/edit.jsp").forward(request, response);
		}
	}

	//注册
	public void regist(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("this is regist...");

		String aname = request.getParameter("aname");// 真实姓名
		String apassword = request.getParameter("apassword");
		String aphone = request.getParameter("aphone");
		String aaddress = request.getParameter("aaddress");

		Admin admin = new Admin();
		admin.setAname(aname);
		admin.setApassword(apassword);
		admin.setAphone(aphone);
		admin.setAaddress(aaddress);

		boolean z = adminService.insertAdmin(admin);
		if (z) {
			response.sendRedirect("login.jsp");
		} else {
			request.setAttribute("error", "注册失败");
			request.getRequestDispatcher("regist.jsp").forward(request, response);
		}
	}

	// checkLogin
	public void checkLogin(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("this is checkLogin...");

		String aname = request.getParameter("aname");
		String apassword = request.getParameter("apassword");

		}
	}
}
package servlet;

/**
 * Servlet implementation class CustomerServlet
 */
@WebServlet("/customerServlet.do")
public class CustomerServlet extends BaseServlet {
	private static final long serialVersionUID = 1L;
	private CustomerService customerService=new CustomerService();

	public void insertCustomer(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("this is insertCustomer....");
		try {
			String cname=request.getParameter("cname");
			String csex=request.getParameter("csex");
			int cage=Integer.parseInt(request.getParameter("cage"));
			String cphone= request.getParameter("cphone");
			String cemail= request.getParameter("cemail");
			String caddress= request.getParameter("caddress");
			Customer customer=new Customer();
			customer.setCname(cname);
			customer.setCsex(csex);
			customer.setCage(cage);
			customer.setCphone(cphone);
			customer.setCemail(cemail);
			customer.setCaddress(caddress);
			//System.out.println(customer);//检查。
			boolean z=customerService.insertCustomer(customer);
			if(z)
			{
 * Servlet implementation class OrderServlet
 */
@WebServlet("/orderServlet.do")
public class OrderServlet extends BaseServlet{
	private static final long serialVersionUID = 1L;
	private OrderService orderService=new OrderService();

	public void insertOrder(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("this is insertOrder....");
		try {
			//int oid=Integer.parseInt(request.getParameter("oid"));
			String did=request.getParameter("did");
			int oquantity=Integer.parseInt(request.getParameter("oquantity"));
			String oprice=request.getParameter("oprice");

			int cid=Integer.parseInt(request.getParameter("cid"));

			String od =request.getParameter("prodate");
			java.sql.Date odate=java.sql.Date.valueOf(od);

			Order order=new Order();
			//order.setOid(oid);
			order.setDid(did);
			order.setOquantity(oquantity);
			order.setOprice(oprice);
			order.setCid(cid);
			order.setOdate(odate);

			System.out.println(order);//检查。
			boolean z=orderService.insertOrder(order);
			if(z)
			{
				showOrderByPage(request,response);
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	public void deleteOrderByOid(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("this is deleteOrderByOid....");
		int oid=Integer.parseInt(request.getParameter("oid"));
		boolean z= orderService.deleteOrderByOid(oid);
		System.out.println("z:"+z);
		if(z)
		{
			showOrderByPage(request,response);
		}
	}

	public void showOrder(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("this is showOrder.....");

/**
 * Servlet implementation class AdminServlet
 */
@WebServlet("/adminServlet.do")
public class AdminServlet extends BaseServlet {
	private static final long serialVersionUID = 1L;
	private AdminService adminService=new AdminService();

	public void insertAdmin(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("this is insertAdmin....");
		try {
			String aname=request.getParameter("aname");
			String apassword=request.getParameter("apassword");
			String aphone= request.getParameter("aphone");
			String aaddress= request.getParameter("aaddress");
			Admin admin=new Admin();
			admin.setAname(aname);
			admin.setApassword(apassword);
			admin.setAphone(aphone);
			admin.setAaddress(aaddress);
			//System.out.println(admin);//检查。
			boolean z=adminService.insertAdmin(admin);
			if(z)
			{
				showAdminByPage(request,response);
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	public void deleteAdminByAid(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("this is deleteAdminByAid....");
		int aid=Integer.parseInt(request.getParameter("aid"));
		boolean z= adminService.deleteAdminByAid(aid);
		System.out.println("z:"+z);
		if(z)
		{
			showAdminByPage(request,response);
		}
	}

	public void showAdmin(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("this is showAdmin.....");
		List<Admin> admin=adminService.showAdmin();
		request.setAttribute("admin", admin);

请添加图片描述

请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值