0
点赞
收藏
分享

微信扫一扫

基于javaweb+jsp的蛋糕房订购信息管理系统

罗蓁蓁 2022-03-30 阅读 34

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>
            </form>
        </div>
    </div>
</div>

<!-- edit -->
<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="UserServlet" onsubmit="return editCheck()">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</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="add-userText" class="control-label">备注:</label>
                        <textarea style="height: 100px;" class="form-control" name="userText" id="add-userText"></textarea>
                    </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-line btn-warning" data-dismiss="modal">取消</button>
                    <button type="submit" class="btn btn-line btn-success">提交</button>
                </div>
            </form>
        </div>
    </div>
</div>

<!-- info -->
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-line btn-warning" data-dismiss="modal">关闭</button>
                </div>
            </form>
        </div>
    </div>
</div>

<!-- edit -->
<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="ShangpingServlet" onsubmit="return editCheck()">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                    <h4 class="modal-title">更新蛋糕</h4>
                </div>
                <div class="modal-body">
                    <div class="form-group hidden">
        String sql = "update `t_notice` set `notice_name` = ? ,`notice_text` = ? ,`notice_type` = ? ,`create_date` = ?  where `id` = ?";
        try {
            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();
                        <tr>
                            <td style="width: 15%;">类目:</td>
                            <td><b id="info-shangpingLeimu"></b></td>
                        </tr>
                    </table>
                    <br>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-line btn-warning" data-dismiss="modal">关闭</button>
                </div>
            </form>
        </div>
    </div>
</div>

<!-- edit -->
<div class="modal fade" id="modal-edit" tabindex="-1" role="dialog"
     aria-labelledby="myModalLabel">
     *
     * @param request
     * @param response
     * @throws ServletException
     * @throws IOException
     */
    @Override
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);//Get请求和Post请求的处理是一样的,所以把request、response转交给Post方法就好
    }

    /**
                modal.find('#info-userType').text(vo.userType);
            }
        })
    })
    function searchList() {
        window.location.href = "UserServlet?action=list&searchColumn="+document.getElementById("searchColumn").value+"&keyword=" + document.getElementById("search_keyword").value;
    }
    //增加表单提交之前进行检查,如果return false,则不允许提交
    function addCheck() {
        //根据ID获取值
        if (document.getElementById("add-username").value.trim().length == 0) {
            alert("用户名不能为空");
            return false;
        }
        if (document.getElementById("add-password").value.trim().length == 0) {
                    </c:otherwise>
                </c:choose>
                </td>
                <td>${vo.shangpingJiage}</td>
                <td>${vo.shangpingLeimu}</td>
                            <th style="text-align: center;">
                                <button class="btn btn-line btn-danger btn-sm" data-id="${vo.id}"
                                        data-toggle="modal" data-target="#modal-info">详情
                                </button>
                                <button class="btn btn-line btn-warning btn-sm"
                                                <c:if test="${loginUser.userType != '管理员'}">disabled="disabled" title="没有权限!!!"</c:if>
                                        data-id="${vo.id}"
                                        data-toggle="modal" data-target="#modal-edit">编辑
                                </button>
                                <button class="btn btn-line btn-default btn-sm" <c:if test="${loginUser.userType != '管理员'}">disabled="disabled" title="没有权限!!!"</c:if> data-id="${vo.id}"
                                        data-toggle="modal" data-target="#modal-delete">删除
        //  获得绿色的随机颜色值
        int green = minColor + random.nextInt(maxColor - minColor);
        //  获得蓝色的随机颜色值
        int blue = minColor + random.nextInt(maxColor - minColor);
        return new Color(red, green, blue);
    }
}
package com.demo.servlet;

import com.demo.util.Util;
import com.demo.service.OrderService;
import com.demo.service.impl.OrderServiceImpl;
import com.demo.vo.Order;
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;

<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="UserServlet" onsubmit="return editCheck()">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</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-username" class="control-label">用户名:</label>
                        <input type="text" class="form-control" name="username" id="edit-username">
                    </div>
                    <div class="form-group">
                        <label for="edit-password" class="control-label">密码:</label>
                        <input type="text" class="form-control" name="password" id="edit-password">
<!-- delete -->
<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="OrderServlet">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</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="hidden" class="form-control" name="action" value="delete">
                        <input type="text" class="form-control" name="id" id="delete-id">
                    </div>
                </div>
public class OrderServlet extends HttpServlet {

    /**
     * 处理Post请求
     *
     * @param request
     * @param response
     * @throws ServletException
     * @throws IOException
     */
    @Override
    public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //过滤编码
        request.setCharacterEncoding("UTF-8");
        response.setCharacterEncoding("UTF-8");
        String action = Util.decode(request, "action");
        if ("add".equals(action)) {//增加
            Order vo = new Order();
            //取出页面传进来的各个数据,并设置到Order对象的属性里
            vo.setCakeName(Util.decode(request, "cakeName"));
            vo.setBuyerName(Util.decode(request, "buyerName"));
            vo.setBuyerSex(Util.decode(request, "buyerSex"));
            vo.setBuyerPhone(Util.decode(request, "buyerPhone"));
            vo.setBuyerAddress(Util.decode(request, "buyerAddress"));
        return str.trim();
    }
}
<%@ 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>
<head>
    <meta charset="UTF-8">
    <title>订购管理</title>
    <link rel="stylesheet" href="css/bootstrap.css">
    <link rel="stylesheet" href="css/main.css">
    <script src="js/jquery-3.5.1.js"></script>
    <script src="js/bootstrap.js"></script>
</head>

                    </div>
                    <div class="form-group">
                        <label class="control-label">性别:</label>
                               <input name="buyerSex" id="edit-buyerSex_男" type="radio" value=""/><input name="buyerSex" id="edit-buyerSex_女" type="radio" value=""/><input name="buyerSex" id="edit-buyerSex_保密" type="radio" value="保密"/>保密
                    </div>
                    <div class="form-group">
                        <label for="edit-buyerPhone" class="control-label">电话:</label>
                        <input type="text" class="form-control" name="buyerPhone" id="edit-buyerPhone">
                    </div>
                    <div class="form-group">
                        <label for="edit-buyerAddress" class="control-label">地址:</label>
                        <input type="text" class="form-control" name="buyerAddress" id="edit-buyerAddress">
                    </div>
                    <div class="form-group">
                        <label for="edit-buyTime" class="control-label">订购时间:</label>
                        <input type="text" class="form-control" name="buyTime" id="edit-buyTime">
                    </div>
                    <div class="form-group">
                        <label for="edit-cakePrice" class="control-label">价格:</label>
                        <input type="text" class="form-control" name="cakePrice" id="edit-cakePrice">
                    </div>
                    <div class="form-group hidden">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <form action="UserServlet" onsubmit="return editCheck()">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</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-username" class="control-label">用户名:</label>
                        <input type="text" class="form-control" name="username" id="edit-username">
                    </div>
            url: 'NoticeServlet?action=get&id=' + id,
            type: "get",
            success: function (voString) {
                let vo = eval('(' + voString + ')');
                        modal.find('#edit-id').val(vo.id);
                        modal.find('#edit-noticeName').val(vo.noticeName);
                        modal.find('#edit-noticeText').val(vo.noticeText);
                        modal.find('#edit-noticeType').val(vo.noticeType);
                        modal.find('#edit-createDate').val(vo.createDate);
            }
        })
    })
    $('#modal-info').on('show.bs.modal', function (event) {
        let button = $(event.relatedTarget);
        let id = button.data('id');
            String limit = (params.get("startIndex") != null && params.get("pageSize") != null) ? " limit " + params.get("startIndex") + "," + params.get("pageSize") : "";
                sqlList = "select * from `t_order` where 1=1 " + condition + " order by id asc " + limit + ";";
                ps = c.prepareStatement(sqlList);
                rs = ps.executeQuery();
                while (rs.next()) {
                    Order vo = new Order();
                    vo.setId(rs.getLong("id"));
                    vo.setCakeName(rs.getString("cake_name"));
                    vo.setBuyerName(rs.getString("buyer_name"));
                    vo.setBuyerSex(rs.getString("buyer_sex"));
                    vo.setBuyerPhone(rs.getString("buyer_phone"));
                    vo.setBuyerAddress(rs.getString("buyer_address"));
                    vo.setBuyTime(rs.getString("buy_time"));
                    vo.setCakePrice(rs.getString("cake_price"));
                    list.add(vo);
                }
            String sqlCount = "select count(*) from `t_order` where 1=1 " + condition;
            ps = c.prepareStatement(sqlCount);
            rs = ps.executeQuery();
            if (rs.next()) {
                totalCount = rs.getInt(1);
            alert("标题不能为空");
            return false;
        }
        if (document.getElementById("edit-noticeType").value.trim().length == 0) {
            alert("类型不能为空");
            return false;
        }
        if (document.getElementById("edit-createDate").value.trim().length == 0) {
            alert("创建时间不能为空");
            return false;
        }
        return true;
    }
</script>
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("数据库连接失败!!!");
        }
    }
    /**
     * 获取系统当前时间并格式化为字符串
     *
     * @return
     */
    public static String getTime() {
        return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(System.currentTimeMillis());
    }
    /**
     * 判断字符串是不是中文
     *
     * @param c
     * @return
     */
    private static boolean isChinese(char c) {
        Character.UnicodeBlock ub = Character.UnicodeBlock.of(c);
        return (ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS

<!-- add -->
<div class="modal fade" id="modal-add" tabindex="-1" role="dialog"
     aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <form action="ShangpingServlet" onsubmit="return addCheck()">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal"
                            aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                    <h4 class="modal-title" id="myModalLabel">增加蛋糕</h4>
                </div>
    <div class="row">
        <div class="col-sm-3 col-md-2 sidebar">
            <!-- 侧边栏 -->
            <jsp:include page="menu.jsp">
                <jsp:param value="active" name="Shangping_active"/>
            </jsp:include>
        </div>
        <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="shangping_name"/>
                        <input class="form-control" type="text" id="search_keyword" name="search_keyword" placeholder="名称"/> <span class="input-group-btn"><button class="btn btn-line btn-info" type="button" onclick="searchList()">搜索</button></span>
                    </div>
                </div>
                <div class="col-sm-5">
                    <button type="button" <c:if test="${loginUser.userType != '管理员'}">disabled="disabled" title="没有权限!!!"</c:if> class="btn btn-line btn-success" data-toggle="modal" data-target="#modal-add">添加蛋糕
                    </button>
                </div>
                    </div>
                    <div class="form-group">
                        <label for="edit-buyerPhone" class="control-label">电话:</label>
                        <input type="text" class="form-control" name="buyerPhone" id="edit-buyerPhone">
                    </div>
                    <div class="form-group">
                        <label for="edit-buyerAddress" class="control-label">地址:</label>
                        <input type="text" class="form-control" name="buyerAddress" id="edit-buyerAddress">
                    </div>
                    <div class="form-group">
                        <label for="edit-buyTime" class="control-label">订购时间:</label>
                        <input type="text" class="form-control" name="buyTime" id="edit-buyTime">
                    </div>
                    <div class="form-group">
                        <label for="edit-cakePrice" class="control-label">价格:</label>
                        <input type="text" class="form-control" name="cakePrice" id="edit-cakePrice">
                    </div>
                    <div class="form-group hidden">
                        <label for="edit-createTime" class="control-label">创建时间:</label>
                        <input type="text" class="form-control" name="createTime" id="edit-createTime">
                    </div>
                </div>
                                                <c:if test="${loginUser.userType != '管理员'}">disabled="disabled" title="没有权限!!!"</c:if>
                                        data-id="${vo.id}"
                                        data-toggle="modal" data-target="#modal-edit">编辑
                                </button>
                                <button class="btn btn-line btn-default btn-sm" <c:if test="${loginUser.userType != '管理员'}">disabled="disabled" title="没有权限!!!"</c:if> data-id="${vo.id}"
                                        data-toggle="modal" data-target="#modal-delete">删除
                                </button>
                            </th>
                        </tr>
                    </c:forEach>
                    </tbody>
                </table>
            c.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        Map<String, Object> result = new HashMap();
        result.put("list", list);
        result.put("totalCount", totalCount);
        return result;
    }
}

运行环境

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…均可

适用

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

功能说明

登录、注册、退出、用户模块、公告模块、订购模块、蛋糕模块的增删改查管理

20220319001514

20220319001515

20220319001516

20220319001517

20220319001518

20220319001519

20220319001520

20220319001521

20220319001522

20220319001523

document

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

举报

相关推荐

0 条评论