10月31号

发布时间 2023-11-05 22:37:33作者: 贾贾鱼

其余部分的源代码

findde.jsp

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>删除</title>
</head>
<body>
<form action="delete.jsp" method="post" target="_self">
    <table bgcolor="yellow" border="5" cellpadding="10" cellspacing="10"  style="margin: 10px auto; color: darkorange; border-collapse: collapse" align="center" width="500">
        <tr>
            <td>请输入要查询的计划编号</td>
            <td><input type="text" placeholder="请输入查询内容" name="key"></td>
        </tr>
        <tr>
            <th colspan=2><input type="submit" value="查询"></th>
        </tr>
    </table>
</form>
</body>
</html>

delete.jsp

<%@ page import="java.sql.DriverManager" %>
<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.Statement" %>
<%@ page import="java.sql.ResultSet" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>删除生产计划</title>
</head>
<body>
<%
    String name=request.getParameter("name");
    String talk=request.getParameter("talk");
    String way=request.getParameter("way");
    String otime=request.getParameter("opentime");
    String ctime=request.getParameter("closetime");
    String tech=request.getParameter("tech");
    pageContext.setAttribute("s1",name);
    pageContext.setAttribute("s2",talk);
    pageContext.setAttribute("s3",way);
    pageContext.setAttribute("s4",otime);
    pageContext.setAttribute("s5",ctime);
    pageContext.setAttribute("s6",tech);
%>
<form action="deletefinish.jsp" method="post" target="_self">
    <table bgcolor="yellow" border="5" cellpadding="10" cellspacing="10"  style="margin: 10px auto; color: darkorange; border-collapse: collapse" align="center" width="500">
        <tr>
            <th colspan=2>查询结果</th>
        </tr>
        <%
            String key=request.getParameter("key");

            //1.注册驱动
            Class.forName("com.mysql.cj.jdbc.Driver");
            // 2.使用我自己的数据库 test 获取链接
            String url = "jdbc:mysql://localhost:3306/test";
            String username = "root";
            String password = "123456";
            Connection connection = DriverManager.getConnection(url, username, password);
            //获取执行sql的对象statement
            Statement statement = connection.createStatement();

            String sql="select * from plan where 计划编号 = '"+key+"'";
            ResultSet res=statement.executeQuery(sql);
            int flag=0;
            pageContext.setAttribute("p",key);
            while(res.next()){
                String s1=res.getString("计划名称");
                String s2=res.getString("计划概述");
                String s3=res.getString("排产方式");
                String s4=res.getString("开始时间");
                String s5=res.getString("结束时间");
                String s6=res.getString("包含工艺");
                pageContext.setAttribute("p1",s1);
                pageContext.setAttribute("p2",s2);
                pageContext.setAttribute("p3",s3);
                pageContext.setAttribute("p4",s4);
                pageContext.setAttribute("p5",s5);
                pageContext.setAttribute("p6",s6);
                flag++;
        %>
        <input type="hidden" name="key" value="${p}">
        <tr>
            <td>计划名称:</td>
            <td><input type="hidden" name="name" value="${p1}">${p1}</td>
        </tr>
        <tr>
            <td>计划概述:</td>
            <td><input type="hidden" name="talk" value="${p2}">${p2}</td>
        </tr>
        <tr>
            <td>排产方式:</td>
            <td><input type="hidden" name="way" value="${p3}">${p3}</td>
        </tr>
        <tr>
            <td>开始时间:</td>
            <td><input type="hidden" name="otime" value="${p4}">${p4}</td>
        </tr>
        <tr>
            <td>结束时间:</td>
            <td><input type="hidden" name="ctime" value="${p5}">${p5}</td>
        </tr>
        <tr>
            <td>包含工艺:</td>
            <td><input type="hidden" name="tech" value="${p6}">${p6}</td>
        </tr>
        <%
            }
            if(flag==0){
        %>
        <tr>
            <th colspan=2>该生产计划不存在</th>
        </tr>
        <form action="index1.jsp" target="_self">
            <tr>
                <th colspan=6><input type="submit" value="返回首页"></th>
            </tr>
        </form>
        <%
            }
        %>
        <tr>
            <th colspan=2><input type="submit" value="删除"></th>
        </tr>
    </table>
</form>
</body>
</html>

deletefinish.jsp

<%@ page import="java.sql.*" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>删除成功</title>
</head>
<h1 style="color: red; text-align: center">删除成功</h1>

<body>
<form action="index1.jsp" method="post" target="_self">
    <table bgcolor="yellow" border="5" cellpadding="10" cellspacing="10"  style="margin: 10px auto; color: darkorange; border-collapse: collapse" align="center" width="500">
        <tr>
            <th colspan=7>生产计划</th>
        </tr>
        <td>计划编号</td>
        <td>计划名称</td>
        <td>计划概述</td>
        <td>排产方式</td>
        <td>开始时间</td>
        <td>结束时间</td>
        <td>包含工艺</td>
        <%
            String key=request.getParameter("key");
            String name=request.getParameter("name");
            String talk=request.getParameter("talk");
            String way=request.getParameter("way");
            String otime=request.getParameter("otime");
            String ctime=request.getParameter("ctime");
            String tech=request.getParameter("tech");

            try{
                Class.forName("com.mysql.cj.jdbc.Driver");
                // 2.使用我自己的数据库 test 获取链接
                String url = "jdbc:mysql://localhost:3306/test";
                String username = "root";
                String password = "123456";
                Connection connection = DriverManager.getConnection(url, username, password);
                //获取执行sql的对象statement
                Statement statement = connection.createStatement();

                String sql="delete from plan where 计划编号 = '"+key+"' and 计划名称 = '"+name+"' and 计划概述 = '"+talk+"' and 排产方式 = '"+way+"' and 开始时间 = '"+otime+"' and 结束时间 = '"+ctime+"' and 包含工艺 = '"+tech+"'";

                statement.executeUpdate(sql);
            try{
                String sql2="select * from student";
                ResultSet res=statement.executeQuery(sql2);
                while(res.next()){
                    String s1=res.getString("计划编号");
                    String s2=res.getString("计划名称");
                    String s3=res.getString("计划概述");
                    String s4=res.getString("排产方式");
                    String s5=res.getString("开始时间");
                    String s6=res.getString("结束时间");
                    String s7=res.getString("包含工艺");
                    pageContext.setAttribute("p1",s1);
                    pageContext.setAttribute("p2",s2);
                    pageContext.setAttribute("p3",s3);
                    pageContext.setAttribute("p4",s4);
                    pageContext.setAttribute("p5",s5);
                    pageContext.setAttribute("p6",s6);
                    pageContext.setAttribute("p7",s7);
        %>
        %>
        <tr>
            <td>${p1}</td>
            <td>${p2}</td>
            <td>${p3}</td>
            <td>${p4}</td>
            <td>${p5}</td>
            <td>${p6}</td>
            <td>${p7}</td>
        </tr>
        <%
                }
            }catch (Exception e){
                System.out.println(e);
            }
            }catch (Exception e){
                    System.out.println(e);
                }
        %>
        <tr>
            <th colspan=7><input type="submit" value="返回首页"></th>
        </tr>
    </table>
</form>
</body>
</html>

find.jsp

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>查询</title>
</head>
<body>
<form action="findfinish.jsp" method="post" target="_self">
    <table bgcolor="yellow" border="5" cellpadding="10" cellspacing="10"  style="margin: 10px auto; color: darkorange; border-collapse: collapse" align="center" width="500">
        <tr>
            <td>请输入要查询的计划编号</td>
            <td><input type="text" placeholder="请输入查询内容" name="id"></td>
        </tr>
        <tr>
            <td>请输入要查询的计划名称</td>
            <td><input type="text" placeholder="请输入查询内容" name="name"></td>
        </tr>
        <tr>
            <td>请输入要查询的排产方式</td>
            <td>
                <input type="radio" name="way" value="串行排产">串行排产&nbsp
                <input type="radio" name="way" value="并行排产">并行排产&nbsp
                <input type="radio" name="way" value="串并行排产">串并行排产
            </td>
        </tr>
        <tr>
            <td>请输入要查询的包含工艺</td>
            <td>
                <input type="checkbox" name="tech" value="锯">&nbsp
                <input type="checkbox" name="tech" value="热">&nbsp
                <input type="checkbox" name="tech" value="车">&nbsp
                <input type="checkbox" name="tech" value="铣">&nbsp
                <input type="checkbox" name="tech" value="钳">&nbsp
                <input type="checkbox" name="tech" value="去">&nbsp
                <input type="checkbox" name="tech" value="珩">&nbsp
                <input type="checkbox" name="tech" value="表镀铬">表镀铬&nbsp
                <input type="checkbox" name="tech" value="表喷砂">表喷砂&nbsp
                <input type="checkbox" name="tech" value="综检">综检&nbsp
                <input type="checkbox" name="tech" value="洗">&nbsp
                <input type="checkbox" name="tech" value="包">&nbsp
                <input type="checkbox" name="tech" value="入">&nbsp
                <input type="checkbox" name="tech" value="装"></td>
        </tr>
        <tr>
            <th colspan=2><input type="submit" value="查询"></th>
        </tr>
    </table>
</form>
</body>
</html>

findfinish.jsp

<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.DriverManager" %>
<%@ page import="java.sql.Statement" %>
<%@ page import="java.sql.ResultSet" %><%--
  Created by IntelliJ IDEA.
  User: 惠普
  Date: 2023/10/30
  Time: 15:15
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>查询结果</title>
</head>
<body>
<%
  String[] tech=request.getParameterValues("tech");

  String id=request.getParameter("id");
  String name=request.getParameter("name");
  String way=request.getParameter("way");
  String t="";
  for(int i=0;i<tech.length;i++){
    t+=tech[i];
  }
  pageContext.setAttribute("s1",id);
  pageContext.setAttribute("s2",name);
  pageContext.setAttribute("s3",way);
  pageContext.setAttribute("s4",t);
%>
<form action="index1.jsp" method="post" target="_self">
  <table bgcolor="yellow" border="5" cellpadding="10" cellspacing="10"  style="margin: 10px auto; color: darkorange; border-collapse: collapse" align="center" width="500">
    <tr>
      <th colspan=2>查询结果</th>
    </tr>
    <%

      //1.注册驱动
      Class.forName("com.mysql.cj.jdbc.Driver");
      // 2.使用我自己的数据库 test 获取链接
      String url = "jdbc:mysql://localhost:3306/test";
      String username = "root";
      String password = "123456";
      Connection connection = DriverManager.getConnection(url, username, password);
      //获取执行sql的对象statement
      Statement statement = connection.createStatement();

      String sql="select * from plan where 计划编号 like '%"+id+"%' and 计划名称 like '%"+name+"%' and 排产方式 like '%"+way+"%' and 包含工艺 like '%"+t+"%'";
      ResultSet res=statement.executeQuery(sql);
      int flag=0;
      while(res.next()){
        String s7=res.getString("计划编号");
        String s1=res.getString("计划名称");
        String s2=res.getString("计划概述");
        String s3=res.getString("排产方式");
        String s4=res.getString("开始时间");
        String s5=res.getString("结束时间");
        String s6=res.getString("包含工艺");
        pageContext.setAttribute("p1",s1);
        pageContext.setAttribute("p2",s2);
        pageContext.setAttribute("p3",s3);
        pageContext.setAttribute("p4",s4);
        pageContext.setAttribute("p5",s5);
        pageContext.setAttribute("p6",s6);
        pageContext.setAttribute("p7",s7);
        flag++;
    %>
    <tr>
      <td>计划编号:</td>
      <td><input type="hidden" name="id" value="${p7}">${p7}</td>
    </tr>
    <tr>
      <td>计划名称:</td>
      <td><input type="hidden" name="name" value="${p1}">${p1}</td>
    </tr>
    <tr>
      <td>计划概述:</td>
      <td><input type="hidden" name="talk" value="${p2}">${p2}</td>
    </tr>
    <tr>
      <td>排产方式:</td>
      <td><input type="hidden" name="way" value="${p3}">${p3}</td>
    </tr>
    <tr>
      <td>开始时间:</td>
      <td><input type="hidden" name="otime" value="${p4}">${p4}</td>
    </tr>
    <tr>
      <td>结束时间:</td>
      <td><input type="hidden" name="ctime" value="${p5}">${p5}</td>
    </tr>
    <tr>
      <td>包含工艺:</td>
      <td><input type="hidden" name="tech" value="${p6}">${p6}</td>
    </tr>
    <%
      }
      if(flag==0){
    %>
    <tr>
      <th colspan=2>该生产计划不存在</th>
    </tr>
    <%
      }
    %>
    <tr>
      <th colspan=2><input type="submit" value="返回首页"></th>
    </tr>
  </table>
</form>
</body>
</html>

look.jsp

<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.DriverManager" %>
<%@ page import="java.sql.Statement" %>
<%@ page import="java.sql.ResultSet" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>查看表内所有信息</title>
</head>
<body>
<form action="index1.jsp" method="post" target="_self">
    <table bgcolor="yellow" border="5" cellpadding="10" cellspacing="10"  style="margin: 10px auto; color: darkorange; border-collapse: collapse" align="center" width="500">
        <tr>
            <th colspan=7>生产计划浏览</th>
        </tr>
        <td>计划编号</td>
        <td>计划名称</td>
        <td>计划概述</td>
        <td>排产方式</td>
        <td>开始时间</td>
        <td>结束时间</td>
        <td>包含工艺</td>
        <%
            String id=request.getParameter("id");
            String name=request.getParameter("name");
            String talk=request.getParameter("talk");
            String way=request.getParameter("way");
            String otime=request.getParameter("opentime");
            String ctime=request.getParameter("closetime");
            String tech=request.getParameter("tech");
            pageContext.setAttribute("s1",id);
            pageContext.setAttribute("s2",name);
            pageContext.setAttribute("s3",talk);
            pageContext.setAttribute("s4",way);
            pageContext.setAttribute("s5",otime);
            pageContext.setAttribute("s6",ctime);
            pageContext.setAttribute("s7",tech);

        %>
            <tr>
                <td>${s1}</td>
                <td>${s2}</td>
                <td>${s3}</td>
                <td>${s4}</td>
                <td>${s5}</td>
                <td>${s6}</td>
                <td>${s7}</td>
            </tr>
        <%


            try{
                Class.forName("com.mysql.cj.jdbc.Driver");
                // 2.使用我自己的数据库 test 获取链接
                String url = "jdbc:mysql://localhost:3306/test";
                String username = "root";
                String password = "123456";
                Connection connection = DriverManager.getConnection(url, username, password);
                //获取执行sql的对象statement
                Statement statement = connection.createStatement();
                String sql2="select * from plan";
                ResultSet res=statement.executeQuery(sql2);
                while(res.next()){
                    String s1=res.getString("计划编号");
                    if(s1.equals(id)) break;
                    String s2=res.getString("计划名称");
                    String s3=res.getString("计划概述");
                    String s4=res.getString("排产方式");
                    String s5=res.getString("开始时间");
                    String s6=res.getString("结束时间");
                    String s7=res.getString("包含工艺");
                    pageContext.setAttribute("p1",s1);
                    pageContext.setAttribute("p2",s2);
                    pageContext.setAttribute("p3",s3);
                    pageContext.setAttribute("p4",s4);
                    pageContext.setAttribute("p5",s5);
                    pageContext.setAttribute("p6",s6);
                    pageContext.setAttribute("p7",s7);
        %>
        <tr>
            <td>${p1}</td>
            <td>${p2}</td>
            <td>${p3}</td>
            <td>${p4}</td>
            <td>${p5}</td>
            <td>${p6}</td>
            <td>${p7}</td>
        </tr>
        <%
                }
            }catch (Exception e){
                System.out.println(e);
            }
        %>
        <tr>
            <th colspan=7><input type="submit" value="返回首页"></th>
        </tr>
    </table>

</form>
</body>
</html>

index2.jsp  (输入格式有误时所跳转的页面)

<%--
  Created by IntelliJ IDEA.
  User: 惠普
  Date: 2023/10/30
  Time: 16:24
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<form action="add.jsp" target="_self">
    <table bgcolor="yellow" border="5" cellpadding="10" cellspacing="10"  style="margin: 10px auto; color: darkorange; border-collapse: collapse" align="center" width="500">
        <tr>
            <td>
                输入有误,请重新输入
            </td>
        </tr>
        <tr>
            <td><input type="submit" value="重新输入"></td>
        </tr>
    </table>
</form>
</body>
</html>