今日总结——老年人评估1

今天有些懈怠,照着之前写过的项目,写那个老年人评测评估,完成了两个表的增删改查,但是前端业务逻辑还没有搞定,还有些问题,下面是部分源码
用户类

package org.example.oldmandemo3;

public class user {
    private String id;
    private String password;
    private String type;

    public user(String id, String password, String type) {
        this.id = id;
        this.password = password;
        this.type = type;
    }

    public user(String id, String password) {
        this.password = password;
        this.id = id;
    }
    public user() {
    }
    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }
}
下面是登录部分源码:

package org.example.oldmandemo3;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;

@WebServlet("/denglu")
public class denglu extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("UTF-8");
        response.setCharacterEncoding("UTF-8");
        String id = request.getParameter("id");
        String password = request.getParameter("password");
        user user = new user(id, password);
        Dao dao = new Dao();
        String type = null;
        try {
            type = dao.denglu(user);
        } catch (SQLException | ClassNotFoundException e) {
            throw new ServletException(e);
        }
        if ("尚未注册".equals(type) || "密码错误".equals(type)) {
            response.sendRedirect("index.jsp");
        } else {
            request.getSession().setAttribute("id", id);
            request.getSession().setAttribute("type", type);
            response.sendRedirect("mainpage.jsp");
        }
    }
}

注册部分:
package org.example.oldmandemo3;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;

@WebServlet("/zhuce")
public class adduser extends HttpServlet {
    protected void doPost(HttpServletRequest request,HttpServletResponse response) throws IOException {
        request.setCharacterEncoding("UTF-8");
        String id = request.getParameter("id");
        String password = request.getParameter("password");
        String type = "老年人或其亲属";
        user user=new user(id,password,type);
        Dao dao=new Dao();
        try {
            if(dao.adduser1(user))
            {
                response.sendRedirect("index.jsp");
            }
            else
                response.sendRedirect("zhuce.jsp");
        } catch (SQLException | ClassNotFoundException e) {
            throw new RuntimeException(e);
        }
    }
}
这是第二个注册部分,这个要管理员开户才能创建
package org.example.oldmandemo3;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;

@WebServlet("/adduser")
public class adduser2 extends HttpServlet {
    protected void doPost(HttpServletRequest request,HttpServletResponse response) throws IOException {
        request.setCharacterEncoding("UTF-8");
        String id = request.getParameter("id");
        String password = request.getParameter("password");
        String type = "评估员";
        user user=new user(id,password,type);
        Dao dao=new Dao();
        try {
            if(dao.adduser2(user))
            {
                response.sendRedirect("mainpage.jsp");
            }
            else
                response.sendRedirect("zhuce2.jsp");
        } catch (SQLException | ClassNotFoundException e) {
            throw new RuntimeException(e);
        }
    }
}

基础数据类
package org.example.oldmandemo3;

import java.sql.Date;

public class basic {
        private String number;
        private Date date;
        private String reason;
        public basic(String number, Date date, String reason) {
            this.number = number;
            this.date = date;
            this.reason = reason;
        }

        public Date getDate() {
            return date;
        }

        public String getNumber() {
            return number;
        }

        public String getReason() {
            return reason;
        }
}
页面部分,我只写了基础功能,然后让ai美化了一下
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>老年人能力评估系统-老年人能力评估基本信息表填写</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #f4f4f4;
            margin: 0;
            padding: 0;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
        }
        .container {
            background-color: #fff;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
            width: 350px;
        }
        h2 {
            text-align: center;
            color: #333;
        }
        .form-group {
            margin-bottom: 15px;
        }
        label {
            display: block;
            margin-bottom: 5px;
            color: #666;
        }
        input[type="text"], input[type="date"], select {
            width: 100%;
            padding: 8px;
            box-sizing: border-box;
            border: 1px solid #ccc;
            border-radius: 4px;
        }
        input[type="submit"] {
            width: 100%;
            padding: 10px;
            background-color: #0056b3;
            border: none;
            border-radius: 4px;
            color: white;
            font-size: 16px;
            cursor: pointer;
        }
        input[type="submit"]:hover {
            background-color: #0056b3;
        }
    </style>
</head>
<body>
<form action="addbasic" method="post">
    <div class="container">
        <h2>老年人能力评估基本信息表填写</h2>

        <div class="form-group">
            <label for="number">评估编号:</label>
            <input name="number" type="text" id="number">
        </div>

        <div class="form-group">
            <label for="date">评估基准日期:</label>
            <input name="date" type="date" id="date">
        </div>

        <div class="form-group">
            <label for="reason">评估原因:</label>
            <select name="reason" id="reason">
                <option value="接受服务前初评">接受服务前初评</option>
                <option value="接受服务后的常规评估">接受服务后的常规评估</option>
                <option value="状况发生变化后的即时评估">状况发生变化后的即时评估</option>
                <option value="因评估结果有疑问进行的复评">因评估结果有疑问进行的复评</option>
            </select>
        </div>

        <div class="form-group">
            <input type="submit" value="完成">
        </div>
    </div>
</form>

</body>
</html>
这是查看基本信息表
<%@ page import="java.util.List" %>
<%@ page import="org.example.oldmandemo3.basic" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
  <title>老年人能力评估系统-老年人能力评估基本信息表查询</title>
  <meta charset="UTF-8">
  <style>
    body {
      font-family: Arial, sans-serif;
      background-color: #f4f4f9;
      margin: 0;
      padding: 0;
      display: flex;
      justify-content: center;
      align-items: center;
      height: 100vh;
    }
    .container {
      background-color: rgba(255, 255, 255, 0.9);
      padding: 20px;
      border-radius: 8px;
      box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
      width: 100%;
      max-width: 800px;
      text-align: left;
    }
    h2 {
      font-size: 1.5em;
      margin-bottom: 20px;
      text-align: center;
    }
    form {
      display: flex;
      flex-direction: column;
      gap: 10px;
    }
    label {
      font-weight: bold;
      margin-bottom: 5px;
    }
    input[type="text"], input[type="date"], select {
      padding: 8px;
      border: 1px solid #ccc;
      border-radius: 4px;
      box-sizing: border-box;
      width: 100%;
    }
    input[type="submit"] {
      padding: 10px;
      background-color: #007BFF;
      color: white;
      border: none;
      border-radius: 4px;
      cursor: pointer;
      font-size: 16px;
      transition: background-color 0.3s ease;
    }
    input[type="submit"]:hover {
      background-color: #0056b3;
    }
    table {
      width: 100%;
      border-collapse: collapse;
      margin-top: 20px;
    }
    th, td {
      border: 1px solid #ddd;
      padding: 8px;
      text-align: left;
    }
    th {
      background-color: #f2f2f2;
    }
    tr:nth-child(even) {
      background-color: #f9f9f9;
    }
    tr:hover {
      background-color: #eaeaea;
    }
    .scrollable-container {
      overflow-x: auto;
    }
  </style>
</head>
<body>
<div class="container">
  <h2>查看老年人能力评估基本信息表</h2>
  <form action="checkbasic" method="get">
    <label for="number">评估编号:</label>
    <input name="number" type="text" id="number"><br>
    <input type="submit" value="查看">
  </form>
  <div class="scrollable-container">
    <table>
      <tr>
        <th>评估编号</th>
        <th>评估基准日期</th>
        <th>评估原因</th>
        <th>操作</th>
      </tr>
      <%
        List<basic> data = (List<basic>) request.getAttribute("data");
        if (data != null && !data.isEmpty()) {
          for (basic d : data) { %>
      <tr>
        <td><%= d.getNumber() %></td>
        <td><%= d.getDate() %></td>
        <td><%= d.getReason() %></td>
        <td>
          <form action="deletebasic" method="post" class="delete-form">
            <input name="number" type="hidden" value="<%= d.getNumber() %>">
            <input type="submit" value="删除">
          </form>
          <form action="changebasic" method="post" class="edit-form">
            <input name="number" type="hidden" value="<%= d.getNumber() %>">
            <label for="date">评估基准日期:</label>
            <input name="date" type="text" id="date" value="<%= d.getDate() %>">
            <label for="reason">评估原因</label>
            <select name="reason" id="reason">
              <option value="接受服务前初评" <%= "接受服务前初评".equals(d.getReason()) ? "selected" : "" %>>接受服务前初评</option>
              <option value="接受服务后的常规评估" <%= "接受服务后的常规评估".equals(d.getReason()) ? "selected" : "" %>>接受服务后的常规评估</option>
              <option value="状况发生变化后的即时评估" <%= "状况发生变化后的即时评估".equals(d.getReason()) ? "selected" : "" %>>状况发生变化后的即时评估</option>
              <option value="因评估结果有疑问进行的复评" <%= "因评估结果有疑问进行的复评".equals(d.getReason()) ? "selected" : "" %>>因评估结果有疑问进行的复评</option>
            </select>
            <input type="submit" value="修改">
          </form>
        </td>
      </tr>
      <% }
      } else { %>
      <tr>
        <td colspan="4" style="text-align:center;">暂无数据</td>
      </tr>
      <% } %>
    </table>
  </div>
</div>
</body>
</html>
package org.example.oldmandemo3;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;
import java.util.List;

@WebServlet("/checkbasic")
public class checkbasic extends HttpServlet {
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("UTF-8");
        response.setCharacterEncoding("UTF-8");

        String number = request.getParameter("number");
        Dao dao = new Dao();
        try {
            List<basic> data=dao.checkbasic(number);
            request.setAttribute("data", data);
        } catch (SQLException | ClassNotFoundException e) {
            e.printStackTrace();
        }
        request.getRequestDispatcher("checkbasic.jsp").forward(request, response);
    }
}

剩下有的代码还有些问题需要调整

posted @   离璨霂  阅读(6)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· winform 绘制太阳,地球,月球 运作规律
· AI与.NET技术实操系列(五):向量存储与相似性搜索在 .NET 中的实现
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· 上周热点回顾(3.3-3.9)
· AI 智能体引爆开源社区「GitHub 热点速览」
点击右上角即可分享
微信分享提示