刘家诚:
今天我在课上终于实现了排班换班的功能
我一开始的思路是通过一个mysql语句来直接实现数据表中两行数据的调换,但是在经过两天的尝试下,这个方案被我放弃了,因为我的数据表和语句的问题,sql语句交换行数据的操作在我的数据表中并不能实现,于是今天我尝试换了另外一种思路,我试着利用两条sql语句先获取数据,再进行数据更近的方式来进行转换,在尝试修改完各种数据后,成功实现了这个功能
<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.PreparedStatement" %>
<%@ page import="java.sql.ResultSet" %>
<%@ page import="java.sql.SQLException" %><%--
Created by IntelliJ IDEA.
User: JC
Date: 2023/5/15
Time: 17:14
To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<jsp:useBean id="util" class="test.scheduling" scope="page" />
<%
String id1=(String) session.getAttribute("id");
String id2=(String)request.getParameter("m");
if (id1.equals(id2))
{
out.print("<script language='javaScript'> alert('数据错误');</script>");
response.setHeader("refresh", "0;url=schedule.jsp");
}
else {
Connection connection = util.getConnection();
String a = null;
String b = null;
PreparedStatement preparedStatement = null;
PreparedStatement pr = null;
ResultSet rs = null;
try {
String sql = "select * from schedule ";
preparedStatement = connection.prepareStatement(sql);
rs = preparedStatement.executeQuery();
while (rs.next()) {
String s1 = rs.getObject(1).toString();
if (s1.equals(id1)) {
a = rs.getObject(2).toString();
}
if (s1.equals(id2)) {
b = rs.getObject(2).toString();
}
}
String sql1 = "UPDATE schedule\n" +
"set e_id = CASE\n" +
" WHEN id = ? THEN ?\n" +
" WHEN id = ? THEN ?\n" +
" ELSE e_id\n" +
"END\n" +
"WHERE id IN (?, ?);";
pr = connection.prepareStatement(sql1);
pr.setString(1, id1);
pr.setString(2, b);
pr.setString(3, id2);
pr.setString(4, a);
pr.setString(5, id1);
pr.setString(6, id2);
int count = pr.executeUpdate();
if (count > 0) {
out.print("<script language='javaScript'> alert('换班成功');</script>");
response.setHeader("refresh", "0;url=schedule.jsp");
} else {
out.print("<script language='javaScript'> alert('换班失败');</script>");
response.setHeader("refresh", "0;url=schedule.jsp");
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
util.close(rs);
util.close(preparedStatement);
util.close(connection);
}
out.print("<script language='javaScript'> alert('换班成功');</script>");
response.setHeader("refresh", "0;url=schedule.jsp");
}
%>
</body>
</html>
田铭庚:
今天我将android端基本界面逻辑进行了相关的排版与处理,已经完成“查询班次表”的全部逻辑处理和功能实现。
package com.example.myapplication;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Button;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
public class SecondActivity extends AppCompatActivity {
Button bt_delete,bt_insert,bt_update;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_holiday);
bt_delete = this.findViewById(R.id.bt_delete);
bt_insert =this.findViewById(R.id.bt_insert);
bt_update =this.findViewById(R.id.bt_update);
bt_delete.setOnClickListener(v -> {
Intent intent = new Intent();
intent.setClass(SecondActivity.this,SearchActivity.class);
startActivity(intent);
Toast.makeText(SecondActivity.this,"",Toast.LENGTH_SHORT).show();
});
bt_insert.setOnClickListener(v -> {
Intent intent = new Intent();
intent.setClass(SecondActivity.this, SearchActivity.class);
startActivity(intent);
Toast.makeText(SecondActivity.this,"请假",Toast.LENGTH_SHORT).show();
});
bt_update.setOnClickListener(v -> {
Intent intent = new Intent();
intent.setClass(SecondActivity.this, SearchActivity.class);
startActivity(intent);
Toast.makeText(SecondActivity.this,"更改请假原因",Toast.LENGTH_SHORT).show();
});
}
}
黄敏仪:
今天我把web页面进行了美化处理,对表单元素以及表格都通过layui提供的框架进行优化处理,添加了新的数据表单,用来添加临时的员工调动消息,但是还没把之间的逻辑关系联系起来。
换班前
换班后