——————————DescriptionStart——————————
运行环境 Java≥8、MySQL≥5.7、Tomcat≥8
开发工具 eclipse/idea/myeclipse/sts等均可配置运行
适用 课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb的SSH医药管理系统药品管理药品库存进销存(java+ssh+mysql+jsp+tomcat)
Java医药管理系统源码
源码描述: 一、源码介绍 医药系统的后台管理功能,医药管理,类别管理,购买药物等 二、主要功能 实现了添加药品,查看药品,高级查询,查看库存,添加类别,查看类别,类别统计,购买药品,销售管理,进货需求管理,系统管理。 三、注意事项 开发环境为jdk1.8,数据库为mysql
登录: admin 123456
——————————CodeStart——————————
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 throws Exception { UserDao dao = new UserDao(); List list = dao.findByHQL("from User" ); if (list != null ) { request.setAttribute("list" , list); } return mapping.findForward("findAllSuccess" ); } public ActionForward userDelete (ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { UserForm uf = (UserForm) form; if (uf.getId() > 0 ) { User u = (User) request.getSession().getAttribute("user" ); if (u != null ) { if (uf.getId() != u.getId()) { UserDao dao = new UserDao(); dao.deleteByHQL("delete from User u where u.id = " + uf.getId()); }else { ActionMessages errors = new ActionMessages(); errors.add("" ,new ActionMessage("user.delete.error" )); this .saveErrors(request, errors); return mapping.findForward("error" ); } } } return mapping.findForward("userFind" ); } public ActionForward userEdit (ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { UserForm uf = (UserForm) form; if (uf.getId() > 0 ) { UserDao dao = new UserDao(); User user = dao.loadUser(uf.getId());
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 med.setPhotoPath(fname); } catch (Exception e) { e.printStackTrace(); } } dao.saveOrUpdate(med); return mapping.findForward("addSuccess" ); } public ActionForward update (ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { MedicineForm df = (MedicineForm) form; MedicineDao dao = new MedicineDao(); Medicine med = dao.loadMedicine(df.getId()); int medCount = med.getMedCount(); med.setMedCount(medCount + df.getMedCount()); return mapping.findForward("addSuccess" ); } public ActionForward findMedicineByMedNo (ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { MedicineForm df = (MedicineForm) form; Medicine med = null ; if (df != null && df.getMedNo() != null ) { MedicineDao dao = new MedicineDao(); med = dao.findMedicineByMedNo(df.getMedNo()); } if (med != null ) { BeanUtils.copyProperties(df, med); request.setAttribute("med" , "med" ); return mapping.findForward("medUpdate" ); } else { CategoryDao cd = new CategoryDao(); List list = cd.findByHQL("from Category" ); request.setAttribute("cs" , list); return mapping.findForward("medSave" ); } }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 throws Exception { ActionForward forword = new ActionForward("/login.jsp" , true ); return forword; } public ActionForward userExit (ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { request.getSession().removeAttribute("user" ); return mapping.findForward("login" ); } public ActionForward userAdd (ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { UserForm uf = (UserForm) form; if (uf != null ) { if (uf.getPassword().equals(uf.getRePassword())){ User user = new User(); BeanUtils.copyProperties(user, uf); user.setCreateTime(new Date()); UserDao dao = new UserDao(); dao.save(user); } } return mapping.findForward("userFind" ); } public ActionForward userFind (ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { UserDao dao = new UserDao(); List list = dao.findByHQL("from User" ); if (list != null ) { request.setAttribute("list" , list); } return mapping.findForward("findAllSuccess" ); }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 public ActionForward view (ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { String id = request.getParameter("id" ); Medicine med = null ; if (id != null && !"" .equals(id)) { MedicineDao dao = new MedicineDao(); med = dao.loadMedicineAndCategory(Integer.parseInt(id)); } request.setAttribute("med" , med); return mapping.findForward("view" ); } public ActionForward edit (ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { MedicineForm df = (MedicineForm) form; Medicine med = null ; if (df.getId() > 0 ) { MedicineDao dao = new MedicineDao(); med = dao.loadMedicineAndCategory(df.getId()); BeanUtils.copyProperties(df, med); df.setCategoryId(med.getCategory().getId()); } CategoryDao categoryDao = new CategoryDao(); List cs = categoryDao.findByHQL("from Category" ); request.setAttribute("cs" , cs); return mapping.findForward("medSave" ); } public ActionForward query (ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { MedicineForm df = (MedicineForm) form; String currPage = request.getParameter("currPage" ); String action = request.getContextPath() + "/baseData/med.do?command=query" ; Map mapQuery = QueryUtil.queryMedicine(df, currPage, action); String hql = (String) mapQuery.get("hql" ); action = (String) mapQuery.get("action" ); Object[] where = (Object[]) mapQuery.get("where" ); Map map = this .getPage(hql, recPerPage, currPage, action, where); request.setAttribute("list" , map.get("list" ));
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 public ActionForward sequence (ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { SellDao dao = new SellDao(); List list = dao.sellSeq(); if (list != null && list.size() > 0 ) { request.setAttribute("list" , list); } return mapping.findForward("sequence" ); } public ActionForward findByMedId (ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { String id = request.getParameter("id" ); String currPage = request.getParameter("currPage" ); String action = request.getContextPath() + "/sell/sell.do?command=findByMedId" ; String hql = "from SellDetail s" ; Object[] where = null ; if (id != null && !id.isEmpty()) { hql += " where s.med.id = ? order by s.sellTime desc" ; action += "&id=" + id; where = new Object[] { Integer.getInteger(id) }; } Map map = this .getPage(hql, recPerPage, currPage, action, where); request.setAttribute("list" , map.get("list" )); request.setAttribute("pagingBar" , map.get("bar" )); return mapping.findForward("findAllSuccess" ); } }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 if (user != null && uf.getOldPassword().equals(user.getPassword())) { if (uf.getPassword().equals(uf.getRePassword())) { UserDao dao = new UserDao(); user.setPassword(uf.getPassword()); dao.saveOrUpdate(user); } }else { ActionMessages errors = new ActionMessages(); errors.add("" ,new ActionMessage("user.oldpassword.error" )); this .saveErrors(request, errors); return mapping.findForward("error" ); } } return mapping.findForward("userFind" ); } public ActionForward initialization (ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { UserDao dao = new UserDao(); dao.initialization(); request.getSession().invalidate(); ActionForward forward = new ActionForward("/login.jsp" ,true ); return forward; } }
——————————PayStart——————————
项目链接: https://javayms.github.io?id=202124172208201mi https://javayms.pages.dev?id=202124172208201mi