本文主要是介绍Java Jsp MVC+mysql实现的物资租赁管理系统(管理员管理 客户管理 建材管理 租赁管理 财务管理),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
博客目录
- 物资租赁管理系统
- 功能截图
- 技术点介绍
- 系统流程图
- 源码
- 写在最后
物资租赁管理系统
背景:
物资租赁站长期大量出租各型钢管、扣件、塔吊等建筑施工设备。针对租赁器材品种繁多,租赁搭配麻烦,费用计算复杂。这些问题难题导致公司运营盈利管理不清晰,以及人工负担重,租赁过程中容易出错等问题,急切需要一款满足自身需求的管理软件,以提高办公效率。
功能截图
主要实现的功能点:
管理员管理
客户管理
建材管理
租赁管理
财务管理
登录页面:
主页面:
客户列表界面:
添加客户页面:
技术点介绍
JDK:1.7
开发工具:MyEclipse
运行环境:Tomcat
数据库:MySQL
系统流程图
源码
1、Dao类:GoodsDao.java
package dao;import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;import bean.Bean;public class GoodsDAO extends DB {private Connection conn = null;private PreparedStatement pstmt = null;private ResultSet rs = null;public int add(Bean bean){try{conn = this.getConn();String sql = "insert into goods(name,money,num,description) " +"values(?,?,?,?) ";pstmt = conn.prepareStatement(sql);pstmt.setString(1, bean.getName());pstmt.setInt(2, bean.getMoney());pstmt.setInt(3, bean.getNum());pstmt.setString(4, bean.getDescription());return pstmt.executeUpdate();} catch (Exception e){// TODO Auto-generated catch blocke.printStackTrace();return 0;}finally{this.closeAll(conn, pstmt, rs);}}public int update(Bean bean,int id){try{conn = this.getConn();String sql = "update goods set name=?,money=?,num=?,description=? where id=?";pstmt = conn.prepareStatement(sql);pstmt.setString(1, bean.getName());pstmt.setInt(2, bean.getMoney());pstmt.setInt(3, bean.getNum());pstmt.setString(4, bean.getDescription());pstmt.setInt(5, id);return pstmt.executeUpdate();} catch (Exception e){// TODO Auto-generated catch blocke.printStackTrace();return 0;}finally{this.closeAll(conn, pstmt, rs);}}public int updatenumj(int id){try{conn = this.getConn();String sql = "update goods set num = num-1 where id=?";pstmt = conn.prepareStatement(sql);pstmt.setInt(1, id);return pstmt.executeUpdate();} catch (Exception e){// TODO Auto-generated catch blocke.printStackTrace();return 0;}finally{this.closeAll(conn, pstmt, rs);}}public int updatenuma(int id){try{conn = this.getConn();String sql = "update goods set num = num+1 where id=?";pstmt = conn.prepareStatement(sql);pstmt.setInt(1, id);return pstmt.executeUpdate();} catch (Exception e){// TODO Auto-generated catch blocke.printStackTrace();return 0;}finally{this.closeAll(conn, pstmt, rs);}}public List<Bean> list(){List<Bean> list = new ArrayList<Bean>(); Bean bean = null; try{conn = this.getConn(); String sql = "select * from goods ";pstmt = conn.prepareStatement(sql); rs = pstmt.executeQuery(); while (rs.next()){bean= new Bean(); bean.setId(rs.getInt("id"));bean.setName(rs.getString("name"));bean.setMoney(rs.getInt("money"));bean.setNum(rs.getInt("num"));bean.setDescription(rs.getString("description"));list.add(bean);}return list; } catch (Exception e){e.printStackTrace();return null; }finally{this.closeAll(conn, pstmt, rs); }}public List<Bean> listit0(){List<Bean> list = new ArrayList<Bean>(); Bean bean = null; try{conn = this.getConn(); String sql = "select * from goods where num > 0";pstmt = conn.prepareStatement(sql); rs = pstmt.executeQuery(); while (rs.next()){bean= new Bean(); bean.setId(rs.getInt("id"));bean.setName(rs.getString("name"));bean.setMoney(rs.getInt("money"));bean.setNum(rs.getInt("num"));bean.setDescription(rs.getString("description"));list.add(bean);}return list; } catch (Exception e){e.printStackTrace();return null; }finally{this.closeAll(conn, pstmt, rs); }}public Bean edit(int id){Bean bean = null; try{conn = this.getConn(); String sql = "select * from goods where id='"+ id +"' ";pstmt = conn.prepareStatement(sql); rs = pstmt.executeQuery(); while (rs.next()){bean= new Bean(); bean.setId(rs.getInt("id"));bean.setName(rs.getString("name"));bean.setMoney(rs.getInt("money"));bean.setNum(rs.getInt("num"));bean.setDescription(rs.getString("description"));}return bean; } catch (Exception e){e.printStackTrace();return null; }finally{this.closeAll(conn, pstmt, rs); }}public List<Bean> search(String id){List<Bean> list = new ArrayList<Bean>(); Bean bean = null; try{conn = this.getConn(); String sql = "select * from client where id= '"+ id +"'";pstmt = conn.prepareStatement(sql); rs = pstmt.executeQuery(); while (rs.next()){bean= new Bean(); bean.setId(rs.getInt("id"));bean.setName(rs.getString("name"));bean.setPhone(rs.getString("phone"));bean.setMail(rs.getString("mail"));bean.setScore(rs.getString("score"));bean.setType(rs.getString("type"));bean.setState(rs.getString("state"));bean.setDecision(rs.getString("decision"));list.add(bean);}return list; } catch (Exception e){e.printStackTrace();return null; }finally{this.closeAll(conn, pstmt, rs); }}public int delete(int id){int i = 0;try{conn = this.getConn();String sql = "delete from goods where id = ?";pstmt = conn.prepareStatement(sql);pstmt.setInt(1, id);i = pstmt.executeUpdate();this.closeAll(conn, pstmt, rs);} catch (Exception e){e.printStackTrace();}return i;}}
ComplainDAO.java
package dao;import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;import bean.Bean;public class ComplainDAO extends DB {private Connection conn = null;private PreparedStatement pstmt = null;private ResultSet rs = null;public int add(Bean bean){try{conn = this.getConn();String sql = "insert into complain(name,content,time,phone) " +"values(?,?,?,?) ";pstmt = conn.prepareStatement(sql);pstmt.setString(1, bean.getName());pstmt.setString(2, bean.getContent());pstmt.setString(3, bean.getTime());pstmt.setString(4, bean.getPhone());return pstmt.executeUpdate();} catch (Exception e){// TODO Auto-generated catch blocke.printStackTrace();return 0;}finally{this.closeAll(conn, pstmt, rs);}}public int update(Bean bean,int id){try{conn = this.getConn();String sql = "update goods set name=?,score=? where id=?";pstmt = conn.prepareStatement(sql);pstmt.setString(1, bean.getName());pstmt.setString(2, bean.getScore());pstmt.setInt(3, id);return pstmt.executeUpdate();} catch (Exception e){// TODO Auto-generated catch blocke.printStackTrace();return 0;}finally{this.closeAll(conn, pstmt, rs);}}public List<Bean> list(){List<Bean> list = new ArrayList<Bean>(); Bean bean = null; try{conn = this.getConn(); String sql = "select * from complain ";pstmt = conn.prepareStatement(sql); rs = pstmt.executeQuery(); while (rs.next()){bean= new Bean(); bean.setId(rs.getInt("id"));bean.setName(rs.getString("name"));bean.setContent(rs.getString("content"));bean.setTime(rs.getString("time"));bean.setPhone(rs.getString("phone"));list.add(bean);}return list; } catch (Exception e){e.printStackTrace();return null; }finally{this.closeAll(conn, pstmt, rs); }}public Bean edit(int id){Bean bean = null; try{conn = this.getConn(); String sql = "select * from goods where id='"+ id +"' ";pstmt = conn.prepareStatement(sql); rs = pstmt.executeQuery(); while (rs.next()){bean= new Bean(); bean.setId(rs.getInt("id"));bean.setName(rs.getString("name"));bean.setScore(rs.getString("score"));}return bean; } catch (Exception e){e.printStackTrace();return null; }finally{this.closeAll(conn, pstmt, rs); }}public List<Bean> search(String id){List<Bean> list = new ArrayList<Bean>(); Bean bean = null; try{conn = this.getConn(); String sql = "select * from client where id= '"+ id +"'";pstmt = conn.prepareStatement(sql); rs = pstmt.executeQuery(); while (rs.next()){bean= new Bean(); bean.setId(rs.getInt("id"));bean.setName(rs.getString("name"));bean.setPhone(rs.getString("phone"));bean.setMail(rs.getString("mail"));bean.setScore(rs.getString("score"));bean.setType(rs.getString("type"));bean.setState(rs.getString("state"));bean.setDecision(rs.getString("decision"));list.add(bean);}return list; } catch (Exception e){e.printStackTrace();return null; }finally{this.closeAll(conn, pstmt, rs); }}public int delete(int id){int i = 0;try{conn = this.getConn();String sql = "delete from complain where id = ?";pstmt = conn.prepareStatement(sql);pstmt.setInt(1, id);i = pstmt.executeUpdate();this.closeAll(conn, pstmt, rs);} catch (Exception e){e.printStackTrace();}return i;}}
2、业务处理Servlet:
GoodsServlet.java
package servlet;import java.io.IOException;
import java.io.PrintWriter;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 bean.Bean;
import dao.ClientDAO;
import dao.GoodsDAO;public class GoodsServlet extends HttpServlet {private static final long serialVersionUID = 1L;public void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {doPost(request, response);}public void doPost(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {response.setContentType("text/html; charset=UTF-8");request.setCharacterEncoding("utf-8");HttpSession session = request.getSession();PrintWriter out = response.getWriter();Bean bean = new Bean();GoodsDAO dao = new GoodsDAO();int kind = Integer.parseInt(request.getParameter("kind"));if (kind == 1) {String name = request.getParameter("name");int money = Integer.parseInt(request.getParameter("money"));int num = Integer.parseInt(request.getParameter("num"));String description = request.getParameter("description");bean.setName(name);bean.setMoney(money);bean.setNum(num);bean.setDescription(description);int i = dao.add(bean);if (i > 0) {out.print("<script>alert('操作成功!');location.href='admin/goods_add.jsp';</script>");} else {out.print("<script>alert('操作失败!');history.go(-1);</script>");}} else if (kind == 2) {int id = Integer.parseInt(request.getParameter("id"));String name = request.getParameter("name");int money = Integer.parseInt(request.getParameter("money"));int num = Integer.parseInt(request.getParameter("num"));String description = request.getParameter("description");bean.setName(name);bean.setMoney(money);bean.setNum(num);bean.setDescription(description);int i = dao.update(bean, id);if (i > 0) {out.print("<script>alert('操作成功!');location.href='admin/goods_edit.jsp?id="+ id + "';</script>");} else {out.print("<script>alert('操作失败!');history.go(-1);</script>");}} else if (kind == 3) {int id = Integer.parseInt(request.getParameter("id"));int i = dao.delete(id);if (i > 0) {out.print("<script>alert('操作成功!');location.href='admin/goods_list.jsp';</script>");} else {out.print("<script>alert('操作失败!');history.go(-1);</script>");}}}}
ComplainServlet.java
package servlet;import java.io.IOException;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.Date;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 bean.Bean;
import dao.ComplainDAO;
import dao.GoodsDAO;public class ComplainServlet extends HttpServlet {private static final long serialVersionUID = 1L;public void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {doPost(request, response);}public void doPost(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {response.setContentType("text/html; charset=UTF-8");request.setCharacterEncoding("utf-8");HttpSession session = request.getSession();PrintWriter out = response.getWriter();Bean bean = new Bean();ComplainDAO dao = new ComplainDAO();int kind = Integer.parseInt(request.getParameter("kind"));if (kind == 1) {String name = request.getParameter("name");String phone = request.getParameter("phone");String content = request.getParameter("content");SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");String time = sd.format(new Date());bean.setName(name);bean.setPhone(phone);bean.setContent(content);bean.setTime(time);int i = dao.add(bean);if (i > 0) {out.print("<script>alert('操作成功!');location.href='admin/complain_add.jsp';</script>");} else {out.print("<script>alert('操作失败!');history.go(-1);</script>");}} else if (kind == 2) {int id = Integer.parseInt(request.getParameter("id"));String name = request.getParameter("name");String score = request.getParameter("score");bean.setName(name);bean.setScore(score);int i = dao.update(bean, id);if (i > 0) {out.print("<script>alert('操作成功!');location.href='admin/goods_edit.jsp?id="+ id + "';</script>");} else {out.print("<script>alert('操作失败!');history.go(-1);</script>");}} else if (kind == 3) {int id = Integer.parseInt(request.getParameter("id"));int i = dao.delete(id);if (i > 0) {out.print("<script>alert('操作成功!');location.href='admin/complain_list.jsp';</script>");} else {out.print("<script>alert('操作失败!');history.go(-1);</script>");}}}}
写在最后
需要全部源码和详细文档,可以加博主V交流(Code2Life2)
这篇关于Java Jsp MVC+mysql实现的物资租赁管理系统(管理员管理 客户管理 建材管理 租赁管理 财务管理)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!