基于javaweb+jsp的设备维修管理系统

基于javaweb+jsp的设备维修管理系统

JavaWeb JavaBean JSP MVC MySQL Tomcat JavaScript Bootstrap Ajax

基础JSP+Servlet或JSP+SSM(Spring、SpringMVC、MyBatis)框架或JSP+SSM+Maven(pom.xml)框架或SpringBoot…均可

开发工具:eclipse/idea/myeclipse/sts等均可配置运行

适用

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

                div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-grad btn-danger" data-dismiss="modal">关闭button>
                div>
            form>
        div>
    div>
div>


<div class="modal fade" id="modal-edit" tabindex="-1" role="dialog"
     aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <form action="NoticeServlet" onsubmit="return editCheck()">
                <div class="modal-header">
                    <h4 class="modal-title">删除设备h4>
                div>
                <div class="modal-body">
                    确认要删除该设备记录吗?
                    <div class="form-group hidden">
                        <label class="control-label">(hidden)label>
                        <input type="hidden" class="form-control" name="action" value="delete">
                        <input type="text" class="form-control" name="id" id="delete-id">
                    div>
                div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-grad btn-danger" data-dismiss="modal">取消button>
                    <button type="submit" class="btn btn-grad btn-success">删除button>
                div>
        })
    })
    function searchList() {
        window.location.href = "WeixiuServlet?action=list&searchColumn="+document.getElementById("searchColumn").value+"&keyword=" + document.getElementById("search_keyword").value;
    }
    //增加表单提交之前进行检查,如果return false,则不允许提交
    function addCheck() {
        //根据ID获取值
        if (document.getElementById("add-weixiuNo").value.trim().length == 0) {
            alert("设备编号不能为空");
            return false;
        }
        if (document.getElementById("add-weixiuName").value.trim().length == 0) {
            alert("设备名称不能为空");
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">×span>
                    button>
                    <h4 class="modal-title">更新公告h4>
                div>
                <div class="modal-body">
                    <div class="form-group hidden">
                        <label class="control-label">(hidden)label>
                        <input type="text" class="form-control" name="action" value="edit">
                        <input type="text" readonly class="form-control" name="id" id="edit-id">
                    div>
                    <div class="form-group">
                        <label for="edit-noticeName" class="control-label">标题:label>
                        <input type="text" class="form-control" name="noticeName" id="edit-noticeName">
                    div>
                    <div class="form-group">
                        <label for="edit-noticeText" class="control-label">内容:label>
                        <textarea style="height: 100px;" class="form-control" name="noticeText" id="edit-noticeText">textarea>
                    div>
                    <div class="form-group">
                        <label for="edit-noticeType" class="control-label">类型:label>
                        <input type="text" class="form-control" name="noticeType" id="edit-noticeType">
                    div>
                    <div class="form-group">
                UserService userService = new UserServiceImpl();
                userService.update(loginUser);
                msg = "修改成功!";
            }
            request.getSession().setAttribute("alert_msg", msg);
            request.getRequestDispatcher("reset_password.jsp").forward(request, response);
        } else {
            response.sendRedirect("login.jsp");
        }
    }

    /**
     * 处理Get请求
     *
     * @param request
     * @param response
     * @throws ServletException
     * @throws IOException
     */
    @Override
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }
            Connection c = Util.getConnection();
            PreparedStatement ps = c.prepareStatement(sql);
            
            ps.setString(1, vo.getNoticeName());
            ps.setString(2, vo.getNoticeText());
            ps.setString(3, vo.getNoticeType());
            ps.setString(4, vo.getCreateDate());
            ps.setLong(5, vo.getId());
            ps.execute();
            ps.close();
            c.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    //@Override
    public boolean delete(long id) {
        try {
            Connection c = Util.getConnection();
            Statement s = c.createStatement();
            String sql = "delete from `t_notice` where id = " + id;

    //@Override
    public boolean delete(long id) {
        try {
            Connection c = Util.getConnection();
            Statement s = c.createStatement();
            String sql = "delete from `t_notice` where id = " + id;
            s.execute(sql);
            s.close();
            c.close();
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }
        com.demo.util.PageBean<Object> pb = new com.demo.util.PageBean(Integer.valueOf(pageNum != null ? pageNum : "1"), totalRecord);
        params.put("startIndex", pb.getStartIndex());
        params.put("pageSize", pb.getPageSize());
        List list = (List) noticeService.list(params).get("list");//根据分页参数startIndex、pageSize查询出来的最终结果list
        pb.setServlet("NoticeServlet");
        pb.setSearchColumn(searchColumn);
        pb.setKeyword(keyword);
        pb.setList(list);
        request.getSession().setAttribute("pageBean", pb);
        request.getSession().setAttribute("list", pb.getList());

        response.sendRedirect("notice_list.jsp");
    }
div>


<div class="modal fade" id="modal-delete" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <form action="ShebeiServlet">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">×span>
                    button>
                    <h4 class="modal-title">删除设备h4>
                div>
                <div class="modal-body">
                    确认要删除该设备记录吗?
                    <div class="form-group hidden">
                        <label class="control-label">(hidden)label>
     */
    @Override
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }

    // 返回一个随机颜色(Color对象)
    private Color getRandomColor(int minColor, int maxColor) {
        Random random = new Random();
        // 保存minColor最大不会超过255
        if (minColor > 255)
            minColor = 255;
        //  保存minColor最大不会超过255
        if (maxColor > 255)
            maxColor = 255;
        //  获得红色的随机颜色值
import java.util.Map;

/**
 * 维修模块的DAO层(数据层)的具体实现类,对WeixiuDAO接口中定义的增删改查等抽象方法作出具体的功能实现
 */
public class WeixiuDAOImpl implements WeixiuDAO {

    //@Override
    public void add(Weixiu vo) {
        String sql = "insert into `t_weixiu` (`weixiu_no`,`weixiu_name`,`weixiu_guzhang`,`weixiu_feiyong`,`weixiu_date`,`weixiu_ren`,`weixiu_phone`,`weixiu_status`,`weixiu_text`) values(?,?,?,?,?,?,?,?,?)";
        try {
            Connection c = Util.getConnection();
            PreparedStatement ps = c.prepareStatement(sql);
            
            ps.setString(1, vo.getWeixiuNo());
                    div>
                    <div class="form-group">
                        <label class="control-label">类型:label>
                        <input name="userType" id="add-userType_管理员" type="radio" value="管理员" checked="checked"/>管理员
                        <input name="userType" id="add-userType_普通用户" type="radio" value="普通用户"/>普通用户
                    div>
                div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-grad btn-danger" data-dismiss="modal">取消button>
                    <button type="submit" class="btn btn-grad btn-success">提交button>
                div>
            form>
        div>
    div>
div>


<div class="modal fade" id="modal-info" tabindex="-1" role="dialog"
     aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <form>
            success: function (voString) {
                let vo = eval('(' + voString + ')');
                modal.find('#info-shebeiName').text(vo.shebeiName);
                modal.find('#info-shebeiNo').text(vo.shebeiNo);
                modal.find('#info-shebeiType').text(vo.shebeiType);
                modal.find('#info-shebeiCangjia').text(vo.shebeiCangjia);
                modal.find('#info-shebeiIndate').text(vo.shebeiIndate);
                modal.find('#info-shebeiInprice').text(vo.shebeiInprice);
                modal.find('#info-shebeiDept').text(vo.shebeiDept);
                modal.find('#info-shebeiStatus').text(vo.shebeiStatus);
            }
        })
    })
    function searchList() {
        window.location.href = "ShebeiServlet?action=list&searchColumn="+document.getElementById("searchColumn").value+"&keyword=" + document.getElementById("search_keyword").value;
    }
    //增加表单提交之前进行检查,如果return false,则不允许提交
    function addCheck() {
        //根据ID获取值
        if (document.getElementById("add-shebeiName").value.trim().length == 0) {
            alert("名称不能为空");
            return false;
            Statement s = c.createStatement();
            String sql = "select * from `t_notice` where id = " + id;
            ResultSet rs = s.executeQuery(sql);
            if (rs.next()) {
                vo = new Notice();
                vo.setId(rs.getLong("id"));
                vo.setNoticeName(rs.getString("notice_name"));
                vo.setNoticeText(rs.getString("notice_text"));
                vo.setNoticeType(rs.getString("notice_type"));
                vo.setCreateDate(rs.getString("create_date"));
            }
            c.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return vo;
    }

            alert("密码不能为空");
            return false;
        }
        if (document.getElementById("edit-realName").value.trim().length == 0) {
            alert("姓名不能为空");
            return false;
        }
        if (document.getElementById("edit-userPhone").value.trim().length == 0) {
            alert("手机不能为空");
            return false;
        }
        return true;
    }
script>
html>
<%@ page contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
DOCTYPE html>
<html>
            String codeChars = "0123456789";// 图形验证码的字符集合,系统将随机从这个字符串中选择一些字符作为验证码
            //  获得验证码集合的长度
            int charsLength = codeChars.length();
            //  下面三条记录是关闭客户端浏览器的缓冲区
            //  这三条语句都可以关闭浏览器的缓冲区,但是由于浏览器的版本不同,对这三条语句的支持也不同
            //  因此,为了保险起见,建议同时使用这三条语句来关闭浏览器的缓冲区
            response.setHeader("ragma", "No-cache");
            response.setHeader("Cache-Control", "no-cache");
            response.setDateHeader("Expires", 0);
            //  设置图形验证码的长和宽(图形的大小)
            int width = 90, height = 20;
            BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
        return vo;
    }

    //@Override
    public Map<String, Object> list(Map<String, Object> params) {
        List<User> list = new ArrayList();
        int totalCount = 0;
        String condition = "";
        String sqlList;
        if (params.get("searchColumn") != null && !"".equals(params.get("searchColumn"))) {
            condition += " and `" + params.get("searchColumn") + "` like '%" + params.get("keyword") + "%'";
        }
        try {
            Connection c = Util.getConnection();
            PreparedStatement ps;
            ResultSet rs;
            String limit = (params.get("startIndex") != null && params.get("pageSize") != null) ? " limit " + params.get("startIndex") + "," + params.get("pageSize") : "";
            ps.close();
            c.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        Map<String, Object> result = new HashMap();
        result.put("list", list);
        result.put("totalCount", totalCount);
        return result;
    }
}
package com.demo.util;
        <br>
        <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
            <div class="row">
                <div class="col-sm-7">
                    <div class="input-group">
                        <input class="form-control" type="hidden" id="searchColumn" name="searchColumn" value="weixiu_name"/>
                        <input class="form-control" type="text" id="search_keyword" name="search_keyword" placeholder="设备名称"/> <span class="input-group-btn"><button class="btn btn-grad btn-info" type="button" onclick="searchList()">搜索button>span>
                    div>
                div>
                <div class="col-sm-5">

    // 返回一个随机颜色(Color对象)
    private Color getRandomColor(int minColor, int maxColor) {
        Random random = new Random();
        // 保存minColor最大不会超过255
        if (minColor > 255)
            minColor = 255;
        //  保存minColor最大不会超过255
        if (maxColor > 255)
            maxColor = 255;
        //  获得红色的随机颜色值
        int red = minColor + random.nextInt(maxColor - minColor);
        //  获得绿色的随机颜色值
        int green = minColor + random.nextInt(maxColor - minColor);
        //  获得蓝色的随机颜色值
        int blue = minColor + random.nextInt(maxColor - minColor);
        return new Color(red, green, blue);
    }
            String sql = "delete from `t_shebei` where id = " + id;
            s.execute(sql);
            s.close();
            c.close();
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }

    //@Override
    public Shebei get(Serializable id) {
        Shebei vo = null;
        try {
            Connection c = Util.getConnection();
            Statement s = c.createStatement();
            String sql = "select * from `t_shebei` where id = " + id;
            ResultSet rs = s.executeQuery(sql);
            if (rs.next()) {
                vo = new Shebei();
                vo.setId(rs.getLong("id"));
        try {
            Connection c = Util.getConnection();
            Statement s = c.createStatement();
            String sql = "select * from `t_weixiu` where id = " + id;
            ResultSet rs = s.executeQuery(sql);
            if (rs.next()) {
                vo = new Weixiu();
                vo.setId(rs.getLong("id"));
                vo.setWeixiuNo(rs.getString("weixiu_no"));
                vo.setWeixiuName(rs.getString("weixiu_name"));
                vo.setWeixiuGuzhang(rs.getString("weixiu_guzhang"));
                vo.setWeixiuFeiyong(rs.getString("weixiu_feiyong"));
                vo.setWeixiuDate(rs.getString("weixiu_date"));
                vo.setWeixiuRen(rs.getString("weixiu_ren"));
                vo.setWeixiuPhone(rs.getString("weixiu_phone"));
                vo.setWeixiuStatus(rs.getString("weixiu_status"));
                vo.setWeixiuText(rs.getString("weixiu_text"));
            }
            c.close();
     */
    @Override
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);//Get请求和Post请求的处理是一样的,所以把request、response转交给Post方法就好
    }

    /**
     * 根据参数,查询出条例条件的记录集合,最后将数据返回给调用处或者将数据集合设置到session域里,再跳转到对应的列表页面
     *
     * @param request
                            <td style="width: 15%;">维修费用:td>
                            <td><b id="info-weixiuFeiyong">b>td>
                        tr>
                        <tr>
                            <td style="width: 15%;">维修日期:td>
                            <td><b id="info-weixiuDate">b>td>
                        tr>
                        <tr>
                            <td style="width: 15%;">维修人:td>
                            <td><b id="info-weixiuRen">b>td>
                        tr>
                        <tr>
                            <td style="width: 15%;">维修人电话:td>
                            <td><b id="info-weixiuPhone">b>td>
                        tr>
                        <tr>
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
    function searchList() {
        window.location.href = "WeixiuServlet?action=list&searchColumn="+document.getElementById("searchColumn").value+"&keyword=" + document.getElementById("search_keyword").value;
    }
    //增加表单提交之前进行检查,如果return false,则不允许提交
    function addCheck() {
        //根据ID获取值
        if (document.getElementById("add-weixiuNo").value.trim().length == 0) {
            alert("设备编号不能为空");
            return false;
        }
        if (document.getElementById("add-weixiuName").value.trim().length == 0) {
            alert("设备名称不能为空");
            return false;
        }
        if (document.getElementById("add-weixiuGuzhang").value.trim().length == 0) {
            alert("故障不能为空");
            return false;
        }
        if (document.getElementById("add-weixiuFeiyong").value.trim().length == 0) {
            alert("维修费用不能为空");
            return false;
        }
            vo.setWeixiuGuzhang(Util.decode(request, "weixiuGuzhang"));
            vo.setWeixiuFeiyong(Util.decode(request, "weixiuFeiyong"));
            vo.setWeixiuDate(Util.decode(request, "weixiuDate"));
            vo.setWeixiuRen(Util.decode(request, "weixiuRen"));
            vo.setWeixiuPhone(Util.decode(request, "weixiuPhone"));
            vo.setWeixiuStatus(Util.decode(request, "weixiuStatus"));
            vo.setWeixiuText(Util.decode(request, "weixiuText"));
            WeixiuService weixiuService = new WeixiuServiceImpl();
            //调用Service层增加方法(add),增加记录
            weixiuService.add(vo);
            this.redirectList(request, response);
        } else if ("delete".equals(action)) {//删除

运行环境

Java≥6、Tomcat≥7.0、MySQL≥5.5

开发工具

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

技术框架

JavaWeb JavaBean JSP MVC MySQL Tomcat JavaScript Bootstrap Ajax

基础JSP+Servlet或JSP+SSM(Spring、SpringMVC、MyBatis)框架或JSP+SSM+Maven(pom.xml)框架或SpringBoot…均可

适用

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

功能说明

登录、注册、退出、用户模块、公告模块、设备模块、维修模块的增删改查管理

基于javaweb+jsp的设备维修管理系统_第1张图片

基于javaweb+jsp的设备维修管理系统_第2张图片

基于javaweb+jsp的设备维修管理系统_第3张图片

基于javaweb+jsp的设备维修管理系统_第4张图片

基于javaweb+jsp的设备维修管理系统_第5张图片

基于javaweb+jsp的设备维修管理系统_第6张图片

基于javaweb+jsp的设备维修管理系统_第7张图片

基于javaweb+jsp的设备维修管理系统_第8张图片

基于javaweb+jsp的设备维修管理系统_第9张图片

基于javaweb+jsp的设备维修管理系统_第10张图片

基于javaweb+jsp的设备维修管理系统_第11张图片

基于javaweb+jsp的设备维修管理系统_第12张图片

基于javaweb+jsp的设备维修管理系统_第13张图片

↖[获取源码方式]见左侧

你可能感兴趣的:(javaweb,mysql,jsp,servlet,ssm)