mirror of
https://github.com/FatttSnake/ClassroomInteraction.git
synced 2026-04-06 07:21:28 +08:00
StudentUI:Center,interface,Chat
TeacherUI:Attend,interface,CheckIn,ClassList,SendMessage,SignIn,TeacherTest
This commit is contained in:
@@ -18,6 +18,8 @@ import java.io.FileReader;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
public class Center {
|
public class Center {
|
||||||
@@ -41,7 +43,9 @@ public class Center {
|
|||||||
private String getSignInCode;
|
private String getSignInCode;
|
||||||
private MessageObject messageObject;
|
private MessageObject messageObject;
|
||||||
private boolean flag = false;
|
private boolean flag = false;
|
||||||
|
private ChatReceiveListener chatReceiveListener;
|
||||||
private Chat chat;
|
private Chat chat;
|
||||||
|
private List<String> messageAll = new ArrayList<>();
|
||||||
|
|
||||||
public Center(String stuNo) {
|
public Center(String stuNo) {
|
||||||
this.stuNo = stuNo;
|
this.stuNo = stuNo;
|
||||||
@@ -56,10 +60,9 @@ public class Center {
|
|||||||
|
|
||||||
if (studentNet != null) {
|
if (studentNet != null) {
|
||||||
if (flag == false) {
|
if (flag == false) {
|
||||||
chat = new Chat(studentNet,stuNo,stuName);
|
chat = new Chat(studentNet,stuNo,stuName,chatReceiveListener);
|
||||||
flag = true;
|
flag = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
chat.start();
|
chat.start();
|
||||||
} else {
|
} else {
|
||||||
JOptionPane.showMessageDialog(null,"没有连接至教师");
|
JOptionPane.showMessageDialog(null,"没有连接至教师");
|
||||||
@@ -104,6 +107,20 @@ public class Center {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
chatReceiveListener = new ChatReceiveListener() {
|
||||||
|
@Override
|
||||||
|
public void onReceive(MessageObject messageObject) {
|
||||||
|
//签到
|
||||||
|
if (messageObject.getMessageType() == MessageType.CheckIn) {
|
||||||
|
getSignInCode = messageObject.getCode();
|
||||||
|
LOGGER.info(messageObject.getCode());
|
||||||
|
}
|
||||||
|
//随机抽人
|
||||||
|
if (messageObject.getMessageType() == MessageType.Select) {
|
||||||
|
JOptionPane.showMessageDialog(null, "恭喜以下同学被选中:\n\t\n" + messageObject.getCount());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
JOptionPane.showMessageDialog(null,"连接失败");
|
JOptionPane.showMessageDialog(null,"连接失败");
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ public class Chat {
|
|||||||
private static JFrame frame = new JFrame("留言");
|
private static JFrame frame = new JFrame("留言");
|
||||||
private static final Logger LOGGER = LogManager.getLogger();
|
private static final Logger LOGGER = LogManager.getLogger();
|
||||||
|
|
||||||
public Chat(StudentNet studentNet,String stuNo,String stuName) {
|
public Chat(StudentNet studentNet,String stuNo,String stuName,ChatReceiveListener chatReceiveListener) {
|
||||||
//发送消息
|
//发送消息
|
||||||
sendButton.addActionListener(new ActionListener() {
|
sendButton.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
@@ -46,6 +46,7 @@ public class Chat {
|
|||||||
if(messageObject.getMessageType()==MessageType.ChatToAll){
|
if(messageObject.getMessageType()==MessageType.ChatToAll){
|
||||||
receiveText.append("教师:"+LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy年MM月dd日 HH时mm分ss秒"))+'\n'+messageObject.getMessage()+"\n");
|
receiveText.append("教师:"+LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy年MM月dd日 HH时mm分ss秒"))+'\n'+messageObject.getMessage()+"\n");
|
||||||
}
|
}
|
||||||
|
chatReceiveListener.onReceive(messageObject);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package com.cfive.classroom.student;
|
||||||
|
|
||||||
|
import com.cfive.classroom.library.net.util.MessageObject;
|
||||||
|
|
||||||
|
public interface ChatReceiveListener {
|
||||||
|
void onReceive(MessageObject messageObject);
|
||||||
|
}
|
||||||
@@ -27,7 +27,6 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class Attend {
|
public class Attend {
|
||||||
private static final Attend attend = new Attend();
|
|
||||||
private static final JFrame frame = new JFrame("考勤情况");
|
private static final JFrame frame = new JFrame("考勤情况");
|
||||||
private JPanel rootPanel;
|
private JPanel rootPanel;
|
||||||
private JTabbedPane tabbedPane1;
|
private JTabbedPane tabbedPane1;
|
||||||
@@ -36,7 +35,6 @@ public class Attend {
|
|||||||
private JTable table_already;
|
private JTable table_already;
|
||||||
private JTable table_undo;
|
private JTable table_undo;
|
||||||
private JButton bt_refresh;
|
private JButton bt_refresh;
|
||||||
private TeacherNet teacherNet;
|
|
||||||
private String courseID;
|
private String courseID;
|
||||||
private final List<Attendance> attendancesList = new ArrayList<>();
|
private final List<Attendance> attendancesList = new ArrayList<>();
|
||||||
private final List<Attendance> alreadyList = new ArrayList<>();
|
private final List<Attendance> alreadyList = new ArrayList<>();
|
||||||
@@ -44,34 +42,9 @@ public class Attend {
|
|||||||
private DefaultTableModel undoTableModel, alreadyTableModel;
|
private DefaultTableModel undoTableModel, alreadyTableModel;
|
||||||
private static final Logger LOGGER = LogManager.getLogger();
|
private static final Logger LOGGER = LogManager.getLogger();
|
||||||
|
|
||||||
public Attend() {
|
|
||||||
//学生签到信息监听
|
public Attend(TeacherNet teacherNet, String courseID) {
|
||||||
if(teacherNet!=null){
|
this.courseID = courseID;
|
||||||
teacherNet.setOnReceiveListener(new ReceiveListener() {
|
|
||||||
@Override
|
|
||||||
public void onReceive(MessageObject messageObject) {
|
|
||||||
if(messageObject.getStuNo()!=null){
|
|
||||||
//判断该信息类型是否为签到并且签到状态是否为已签
|
|
||||||
if (messageObject.getMessageType() == MessageType.CheckIn && messageObject.getAttStatus() == AttStatus.signed) {
|
|
||||||
try {
|
|
||||||
//将学生签到状态修改进数据表中
|
|
||||||
DatabaseHelper.updateAttendance(messageObject.getStuNo(), messageObject.getAttStatus(),messageObject.getLocalDateTime());
|
|
||||||
} catch (NoConfigException e) {
|
|
||||||
JOptionPane.showMessageDialog(null, "没有数据库配置文件", "警告", JOptionPane.ERROR_MESSAGE);
|
|
||||||
LOGGER.error("No configuration", e);
|
|
||||||
} catch (SQLException e) {
|
|
||||||
JOptionPane.showMessageDialog(null, "数据库出错", "警告", JOptionPane.ERROR_MESSAGE);
|
|
||||||
LOGGER.error("SQLException", e);
|
|
||||||
} catch (DependenciesNotFoundException e) {
|
|
||||||
LOGGER.error("DependenciesNotFoundException", e);
|
|
||||||
}
|
|
||||||
//刷新表格
|
|
||||||
bt_refresh.doClick();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
//已签表格的鼠标点击事件
|
//已签表格的鼠标点击事件
|
||||||
table_already.addMouseListener(new MouseAdapter() {
|
table_already.addMouseListener(new MouseAdapter() {
|
||||||
@@ -92,6 +65,7 @@ public class Attend {
|
|||||||
table_already.getModel().setValueAt(modifyStat, row, col);
|
table_already.getModel().setValueAt(modifyStat, row, col);
|
||||||
//将修改在数据库中更改
|
//将修改在数据库中更改
|
||||||
try {
|
try {
|
||||||
|
LOGGER.info("test");
|
||||||
DatabaseHelper.updateAttendance(String.valueOf(table_already.getModel().getValueAt(row, 0)), attStatus, null);
|
DatabaseHelper.updateAttendance(String.valueOf(table_already.getModel().getValueAt(row, 0)), attStatus, null);
|
||||||
} catch (NoConfigException ex) {
|
} catch (NoConfigException ex) {
|
||||||
JOptionPane.showMessageDialog(null, "没有数据库配置文件", "警告", JOptionPane.ERROR_MESSAGE);
|
JOptionPane.showMessageDialog(null, "没有数据库配置文件", "警告", JOptionPane.ERROR_MESSAGE);
|
||||||
@@ -162,89 +136,31 @@ public class Attend {
|
|||||||
alreadyList.clear();
|
alreadyList.clear();
|
||||||
undoList.clear();
|
undoList.clear();
|
||||||
//重新加载
|
//重新加载
|
||||||
try {
|
readData();
|
||||||
attendancesList.addAll(DatabaseHelper.selectAttendanceByCourse(Long.parseLong(courseID))); //导入该课程考勤名单
|
|
||||||
for (Attendance attendance : attendancesList) {
|
|
||||||
if (attendance.getAttStatus() == AttStatus.signed) { //筛选出已签到的考勤列表
|
|
||||||
alreadyList.add(attendance);
|
|
||||||
} else {
|
|
||||||
undoList.add(attendance);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (DependenciesNotFoundException ex) {
|
|
||||||
throw new RuntimeException(ex);
|
|
||||||
} catch (NoConfigException ex) {
|
|
||||||
throw new RuntimeException(ex);
|
|
||||||
} catch (SQLException ex) {
|
|
||||||
throw new RuntimeException(ex);
|
|
||||||
}
|
|
||||||
//已签考勤表格
|
|
||||||
alreadyTableModel = new DefaultTableModel(t1_columnTitle, 0) {
|
|
||||||
@Override
|
|
||||||
public boolean isCellEditable(int row, int column) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
if (alreadyList != null) {
|
|
||||||
for (Attendance attendance : alreadyList) {
|
|
||||||
String attID = attendance.getAttID();
|
|
||||||
String stuID = String.valueOf(attendance.getStudent().getStuID());
|
|
||||||
String stuName = String.valueOf(attendance.getStudent().getStuName());
|
|
||||||
LocalDateTime attTime = attendance.getAttTime();
|
|
||||||
AttStatus attStatus = attendance.getAttStatus();
|
|
||||||
String attTime1 = attTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
|
||||||
Object row[] = {attID,stuID, stuName, attTime1,String.valueOf(attStatus)};
|
|
||||||
alreadyTableModel.addRow(row);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
attend.table_already.setModel(alreadyTableModel);
|
|
||||||
|
|
||||||
//未签考勤表格
|
|
||||||
undoTableModel = new DefaultTableModel(t2_columnTitle, 0);
|
|
||||||
for (Attendance attendance : undoList) {
|
|
||||||
String attID = attendance.getAttID();
|
|
||||||
String stuID = String.valueOf(attendance.getStudent().getStuID());
|
|
||||||
String stuName = String.valueOf(attendance.getStudent().getStuName());
|
|
||||||
AttStatus attStatus = attendance.getAttStatus();
|
|
||||||
Object row[] = {attID, stuID, stuName, String.valueOf(attStatus)};
|
|
||||||
undoTableModel.addRow(row);
|
|
||||||
}
|
|
||||||
attend.table_undo.setModel(undoTableModel);
|
|
||||||
//设置第一列隐藏
|
|
||||||
TableColumn tableColumn = attend.table_undo.getColumnModel().getColumn(0);
|
|
||||||
tableColumn.setWidth(0);
|
|
||||||
tableColumn.setMinWidth(0);
|
|
||||||
tableColumn.setPreferredWidth(0);
|
|
||||||
tableColumn.setMaxWidth(0);
|
|
||||||
attend.table_undo.getTableHeader().getColumnModel().getColumn(0).setMaxWidth(0);
|
|
||||||
attend.table_undo.getTableHeader().getColumnModel().getColumn(0).setMinWidth(0);
|
|
||||||
attend.table_undo.setCellSelectionEnabled(true);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
frame.setContentPane(attend.rootPanel);
|
|
||||||
frame.setSize(600, 400);
|
|
||||||
frame.setLocationRelativeTo(null);
|
|
||||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
|
||||||
frame.pack();
|
|
||||||
frame.setVisible(false);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void start(TeacherNet teacherNet1, String courseID) {
|
public void start() {
|
||||||
frame.setContentPane(attend.rootPanel);
|
frame.setContentPane(rootPanel);
|
||||||
frame.setSize(600, 400);
|
frame.setSize(600, 400);
|
||||||
frame.setLocationRelativeTo(null);
|
frame.setLocationRelativeTo(null);
|
||||||
frame.setResizable(false);
|
frame.setResizable(false);
|
||||||
attend.teacherNet = teacherNet1;
|
|
||||||
attend.courseID = courseID;
|
readData();
|
||||||
|
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||||
|
frame.setVisible(true);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void readData(){
|
||||||
try {
|
try {
|
||||||
attendancesList.addAll(DatabaseHelper.selectAttendanceByCourse(Long.parseLong(courseID))); //导入该课程考勤名单
|
attendancesList.addAll(DatabaseHelper.selectAttendanceByCourse(Long.parseLong(courseID))); //导入该课程考勤名单
|
||||||
LOGGER.debug("attendanceList:" + attendancesList);
|
|
||||||
for (Attendance attendance : attendancesList) {
|
for (Attendance attendance : attendancesList) {
|
||||||
if (attendance.getAttStatus() == AttStatus.signed) { //筛选出已签到的考勤列表
|
if (attendance.getAttStatus() == AttStatus.signed) { //筛选出已签到的考勤列表
|
||||||
alreadyList.add(attendance);
|
alreadyList.add(attendance);
|
||||||
@@ -268,7 +184,7 @@ public class Attend {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if (alreadyList != null) {
|
if (!alreadyList.isEmpty()) {
|
||||||
for (Attendance attendance : alreadyList) {
|
for (Attendance attendance : alreadyList) {
|
||||||
String attID = attendance.getAttID();
|
String attID = attendance.getAttID();
|
||||||
String stuID = String.valueOf(attendance.getStudent().getStuID());
|
String stuID = String.valueOf(attendance.getStudent().getStuID());
|
||||||
@@ -280,18 +196,19 @@ public class Attend {
|
|||||||
alreadyTableModel.addRow(row);
|
alreadyTableModel.addRow(row);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
attend.table_already.setModel(alreadyTableModel);
|
table_already.setModel(alreadyTableModel);
|
||||||
TableColumn tableColumn1 = attend.table_already.getColumnModel().getColumn(0);
|
//设置未签表格的第一列考勤号隐藏
|
||||||
|
TableColumn tableColumn1 = table_already.getColumnModel().getColumn(0);
|
||||||
tableColumn1.setWidth(0);
|
tableColumn1.setWidth(0);
|
||||||
tableColumn1.setMinWidth(0);
|
tableColumn1.setMinWidth(0);
|
||||||
tableColumn1.setPreferredWidth(0);
|
tableColumn1.setPreferredWidth(0);
|
||||||
tableColumn1.setMaxWidth(0);
|
tableColumn1.setMaxWidth(0);
|
||||||
attend.table_already.getTableHeader().getColumnModel().getColumn(0).setMaxWidth(0);
|
table_already.getTableHeader().getColumnModel().getColumn(0).setMaxWidth(0);
|
||||||
attend.table_already.getTableHeader().getColumnModel().getColumn(0).setMinWidth(0);
|
table_already.getTableHeader().getColumnModel().getColumn(0).setMinWidth(0);
|
||||||
attend.table_already.setCellSelectionEnabled(true);
|
table_already.setCellSelectionEnabled(true);
|
||||||
|
|
||||||
//未签考勤表格
|
//未签考勤表格
|
||||||
if(undoList!=null){ //判断该课程是否有学生名单
|
if (!undoList.isEmpty()) { //判断该课程是否有学生名单
|
||||||
undoTableModel = new DefaultTableModel(t2_columnTitle, 0) {
|
undoTableModel = new DefaultTableModel(t2_columnTitle, 0) {
|
||||||
@Override
|
@Override
|
||||||
public boolean isCellEditable(int row, int column) {
|
public boolean isCellEditable(int row, int column) {
|
||||||
@@ -306,25 +223,20 @@ public class Attend {
|
|||||||
Object row[] = {attID, stuID, stuName, String.valueOf(attStatus)};
|
Object row[] = {attID, stuID, stuName, String.valueOf(attStatus)};
|
||||||
undoTableModel.addRow(row);
|
undoTableModel.addRow(row);
|
||||||
}
|
}
|
||||||
attend.table_undo.setModel(undoTableModel);
|
table_undo.setModel(undoTableModel);
|
||||||
//设置未签表格的第一列考勤号隐藏
|
//设置未签表格的第一列考勤号隐藏
|
||||||
TableColumn tableColumn2 = attend.table_undo.getColumnModel().getColumn(0);
|
TableColumn tableColumn2 = table_undo.getColumnModel().getColumn(0);
|
||||||
tableColumn2.setWidth(0);
|
tableColumn2.setWidth(0);
|
||||||
tableColumn2.setMinWidth(0);
|
tableColumn2.setMinWidth(0);
|
||||||
tableColumn2.setPreferredWidth(0);
|
tableColumn2.setPreferredWidth(0);
|
||||||
tableColumn2.setMaxWidth(0);
|
tableColumn2.setMaxWidth(0);
|
||||||
attend.table_undo.getTableHeader().getColumnModel().getColumn(0).setMaxWidth(0);
|
table_undo.getTableHeader().getColumnModel().getColumn(0).setMaxWidth(0);
|
||||||
attend.table_undo.getTableHeader().getColumnModel().getColumn(0).setMinWidth(0);
|
table_undo.getTableHeader().getColumnModel().getColumn(0).setMinWidth(0);
|
||||||
attend.table_undo.setCellSelectionEnabled(true);
|
table_undo.setCellSelectionEnabled(true);
|
||||||
} else {
|
} else {
|
||||||
JOptionPane.showMessageDialog(null, "该课程学生名单未导入", "提醒!", JOptionPane.INFORMATION_MESSAGE);
|
JOptionPane.showMessageDialog(null, "该课程学生名单未导入", "提醒!", JOptionPane.INFORMATION_MESSAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
|
||||||
frame.setVisible(true);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package com.cfive.classroom.teacher;
|
||||||
|
|
||||||
|
import com.cfive.classroom.library.net.util.MessageObject;
|
||||||
|
|
||||||
|
public interface ChatReceiveListener {
|
||||||
|
void onReceive(MessageObject messageObject);
|
||||||
|
}
|
||||||
@@ -7,13 +7,9 @@ import org.apache.logging.log4j.LogManager;
|
|||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.*;
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
import java.awt.event.KeyAdapter;
|
|
||||||
import java.awt.event.KeyEvent;
|
|
||||||
|
|
||||||
public class CheckIn {
|
public class CheckIn {
|
||||||
private static final CheckIn checkIn = new CheckIn();
|
|
||||||
private static final JFrame frame = new JFrame("发布签到码");
|
private static final JFrame frame = new JFrame("发布签到码");
|
||||||
private JPanel rootPanel;
|
private JPanel rootPanel;
|
||||||
private JTextField textField1;
|
private JTextField textField1;
|
||||||
@@ -23,10 +19,9 @@ public class CheckIn {
|
|||||||
private JButton bt_confim;
|
private JButton bt_confim;
|
||||||
private JButton bt_cancel;
|
private JButton bt_cancel;
|
||||||
private String n1, n2, n3, n4, number;
|
private String n1, n2, n3, n4, number;
|
||||||
private TeacherNet teacherNet;
|
|
||||||
private static final Logger LOGGER = LogManager.getLogger();
|
private static final Logger LOGGER = LogManager.getLogger();
|
||||||
|
|
||||||
public CheckIn() {
|
public CheckIn(TeacherNet teacherNet) {
|
||||||
//取消按钮的监听
|
//取消按钮的监听
|
||||||
bt_cancel.addActionListener(new ActionListener() {
|
bt_cancel.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
@@ -71,16 +66,41 @@ public class CheckIn {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
//确定按钮的点击事件
|
|
||||||
bt_confim.addActionListener(new ActionListener() {
|
//回车键的监听:发布签到码
|
||||||
|
textField4.addKeyListener(new KeyListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void keyTyped(KeyEvent e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void keyPressed(KeyEvent e) {
|
||||||
|
if(e.getKeyChar()==KeyEvent.VK_ENTER){
|
||||||
//获取签到码广播出去
|
//获取签到码广播出去
|
||||||
number = textField1.getText() + textField2.getText() + textField3.getText() + textField4.getText();
|
number = textField1.getText() + textField2.getText() + textField3.getText() + textField4.getText();
|
||||||
if (number != null) {
|
if (number != null) {
|
||||||
teacherNet.sendAllMessage(new MessageObject(null, null, number, null, null, null, null, MessageType.CheckIn));
|
teacherNet.sendAllMessage(new MessageObject(null, null, number, null, null, null, null, MessageType.CheckIn));
|
||||||
JOptionPane.showMessageDialog(null, "签到码发布成功", "消息", JOptionPane.INFORMATION_MESSAGE);
|
JOptionPane.showMessageDialog(null, "签到码发布成功", "消息", JOptionPane.INFORMATION_MESSAGE);
|
||||||
frame.dispose();
|
frame.setVisible(false);
|
||||||
|
} else {
|
||||||
|
JOptionPane.showMessageDialog(null, "签到码不能为空", "错误", JOptionPane.ERROR_MESSAGE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void keyReleased(KeyEvent e) {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
//确定按钮的点击事件
|
||||||
|
bt_confim.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
number = textField1.getText() + textField2.getText() + textField3.getText() + textField4.getText();
|
||||||
|
if (number != null) {
|
||||||
|
teacherNet.sendAllMessage(new MessageObject(null, null, number, null, null, null, null, MessageType.CheckIn));
|
||||||
|
JOptionPane.showMessageDialog(null, "签到码发布成功", "消息", JOptionPane.INFORMATION_MESSAGE);
|
||||||
|
frame.setVisible(false);
|
||||||
} else {
|
} else {
|
||||||
JOptionPane.showMessageDialog(null, "签到码不能为空", "错误", JOptionPane.ERROR_MESSAGE);
|
JOptionPane.showMessageDialog(null, "签到码不能为空", "错误", JOptionPane.ERROR_MESSAGE);
|
||||||
}
|
}
|
||||||
@@ -90,18 +110,14 @@ public class CheckIn {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
frame.setContentPane(checkIn.rootPanel);
|
|
||||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
|
||||||
frame.pack();
|
|
||||||
frame.setVisible(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void start(TeacherNet teacherNet1) {
|
public void start() {
|
||||||
frame.setContentPane(checkIn.rootPanel);
|
frame.setContentPane(rootPanel);
|
||||||
frame.setSize(600, 400);
|
frame.setSize(600, 400);
|
||||||
frame.setLocationRelativeTo(null);
|
frame.setLocationRelativeTo(null);
|
||||||
frame.setResizable(false);
|
frame.setResizable(false);
|
||||||
checkIn.teacherNet = teacherNet1;
|
|
||||||
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||||
frame.setVisible(true);
|
frame.setVisible(true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ public class ClassList {
|
|||||||
bt_enter.addActionListener(new ActionListener() {
|
bt_enter.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
LOGGER.info(workerNo);
|
||||||
if (!Objects.equals(classList.comboBox.getSelectedItem(), "--请选择--")) { //判断是否有选择内容
|
if (!Objects.equals(classList.comboBox.getSelectedItem(), "--请选择--")) { //判断是否有选择内容
|
||||||
String select = classList.comboBox.getSelectedItem().toString();
|
String select = classList.comboBox.getSelectedItem().toString();
|
||||||
courseID = select.substring(0, select.indexOf(" "));
|
courseID = select.substring(0, select.indexOf(" "));
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.cfive.classroom.teacher;
|
package com.cfive.classroom.teacher;
|
||||||
|
|
||||||
import com.cfive.classroom.library.database.DatabaseHelper;
|
import com.cfive.classroom.library.database.DatabaseHelper;
|
||||||
|
import com.cfive.classroom.library.database.bean.AttStatus;
|
||||||
import com.cfive.classroom.library.database.bean.Student;
|
import com.cfive.classroom.library.database.bean.Student;
|
||||||
import com.cfive.classroom.library.database.util.DependenciesNotFoundException;
|
import com.cfive.classroom.library.database.util.DependenciesNotFoundException;
|
||||||
import com.cfive.classroom.library.database.util.NoConfigException;
|
import com.cfive.classroom.library.database.util.NoConfigException;
|
||||||
@@ -16,6 +17,7 @@ import java.awt.event.ActionEvent;
|
|||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
@@ -32,10 +34,12 @@ public class Main {
|
|||||||
private JTextField subName_show;
|
private JTextField subName_show;
|
||||||
private String workNo, courseID;
|
private String workNo, courseID;
|
||||||
private final List<Student> studentList = new ArrayList<>();
|
private final List<Student> studentList = new ArrayList<>();
|
||||||
|
private final List<String> messageAll = new ArrayList<>();
|
||||||
;
|
;
|
||||||
private String[] student;
|
private String[] student;
|
||||||
private TeacherNet teacherNet;
|
private TeacherNet teacherNet;
|
||||||
private final Logger LOGGER = LogManager.getLogger();
|
private final Logger LOGGER = LogManager.getLogger();
|
||||||
|
private ChatReceiveListener chatReceiveListener;
|
||||||
|
|
||||||
public Main() {
|
public Main() {
|
||||||
|
|
||||||
@@ -59,8 +63,8 @@ public class Main {
|
|||||||
bt_sendMessage.addActionListener(new ActionListener() {
|
bt_sendMessage.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
SendMessage sendMessage = new SendMessage();
|
SendMessage sendMessage = new SendMessage(teacherNet,chatReceiveListener);
|
||||||
sendMessage.start(teacherNet);
|
sendMessage.start(messageAll);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -68,8 +72,8 @@ public class Main {
|
|||||||
bt_checkIn.addActionListener(new ActionListener() {
|
bt_checkIn.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
CheckIn checkIn = new CheckIn();
|
CheckIn checkIn = new CheckIn(teacherNet);
|
||||||
checkIn.start(teacherNet);
|
checkIn.start();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -77,8 +81,8 @@ public class Main {
|
|||||||
bt_attendance.addActionListener(new ActionListener() {
|
bt_attendance.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
Attend attend = new Attend();
|
Attend attend = new Attend(teacherNet, courseID);
|
||||||
attend.start(teacherNet, courseID);
|
attend.start();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -152,26 +156,82 @@ public class Main {
|
|||||||
});
|
});
|
||||||
|
|
||||||
//主界面线程监听
|
//主界面线程监听
|
||||||
if(teacherNet!=null){
|
// if (teacherNet != null) {
|
||||||
teacherNet.setOnReceiveListener(new ReceiveListener() {
|
teacherNet.setOnReceiveListener(new ReceiveListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(MessageObject messageObject) {
|
public void onReceive(MessageObject messageObject) {
|
||||||
if (messageObject.getStuNo() != null) {
|
if (messageObject.getStuNo() != null) {
|
||||||
//学生端举手监听
|
//学生端举手监听
|
||||||
if (messageObject.getMessageType() == MessageType.RaiseHand) {
|
if (messageObject.getMessageType() == MessageType.RaiseHand) {
|
||||||
|
LOGGER.info("举手test");
|
||||||
JOptionPane.showMessageDialog(null, "学生 " + messageObject.getStuName() + " 向您举手", "温馨提示!", JOptionPane.INFORMATION_MESSAGE);
|
JOptionPane.showMessageDialog(null, "学生 " + messageObject.getStuName() + " 向您举手", "温馨提示!", JOptionPane.INFORMATION_MESSAGE);
|
||||||
}
|
}
|
||||||
//学生留言监听
|
//学生留言监听
|
||||||
if (messageObject.getMessageType() == MessageType.Chat) {
|
if (messageObject.getMessageType() == MessageType.Chat) {
|
||||||
|
LOGGER.info("留言test");
|
||||||
JOptionPane.showMessageDialog(null, messageObject.getMessage(), "学生 " + messageObject.getStuName() + " 向您留言", JOptionPane.INFORMATION_MESSAGE);
|
JOptionPane.showMessageDialog(null, messageObject.getMessage(), "学生 " + messageObject.getStuName() + " 向您留言", JOptionPane.INFORMATION_MESSAGE);
|
||||||
|
messageAll.add("学生 "+messageObject.getStuName()+": "+messageObject.getLocalDateTime().format(DateTimeFormatter.ofPattern("yyyy年MM月dd日 HH时mm分ss秒"))+'\n'+messageObject.getMessage()+'\n');
|
||||||
|
}
|
||||||
|
//学生签到信息监听,判断该信息类型是否为签到并且签到状态是否为已签
|
||||||
|
if (messageObject.getMessageType() == MessageType.CheckIn && messageObject.getAttStatus() == AttStatus.signed) {
|
||||||
|
try {
|
||||||
|
LOGGER.info("收到签到 " + messageObject.toString());
|
||||||
|
//将学生签到状态修改进数据表中
|
||||||
|
String attID = DatabaseHelper.selectFromAttendance(Long.parseLong(messageObject.getStuNo()), Long.parseLong(courseID)).getAttID();
|
||||||
|
DatabaseHelper.updateAttendance(attID, messageObject.getAttStatus(), messageObject.getLocalDateTime());
|
||||||
|
} catch (NoConfigException e) {
|
||||||
|
JOptionPane.showMessageDialog(null, "没有数据库配置文件", "警告", JOptionPane.ERROR_MESSAGE);
|
||||||
|
LOGGER.error("No configuration", e);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
JOptionPane.showMessageDialog(null, "数据库出错", "警告", JOptionPane.ERROR_MESSAGE);
|
||||||
|
LOGGER.error("SQLException", e);
|
||||||
|
} catch (DependenciesNotFoundException e) {
|
||||||
|
LOGGER.error("DependenciesNotFoundException", e);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
chatReceiveListener = new ChatReceiveListener() {
|
||||||
|
@Override
|
||||||
|
public void onReceive(MessageObject messageObject) {
|
||||||
|
if (messageObject.getStuNo() != null) {
|
||||||
|
//学生端举手监听
|
||||||
|
if (messageObject.getMessageType() == MessageType.RaiseHand) {
|
||||||
|
LOGGER.info("举手test");
|
||||||
|
JOptionPane.showMessageDialog(null, "学生 " + messageObject.getStuName() + " 向您举手", "温馨提示!", JOptionPane.INFORMATION_MESSAGE);
|
||||||
|
}
|
||||||
|
//学生留言监听
|
||||||
|
if (messageObject.getMessageType() == MessageType.Chat) {
|
||||||
|
LOGGER.info("留言test");
|
||||||
|
JOptionPane.showMessageDialog(null, messageObject.getMessage(), "学生 " + messageObject.getStuName() + " 向您留言", JOptionPane.INFORMATION_MESSAGE);
|
||||||
|
messageAll.add("学生 "+messageObject.getStuName()+": "+messageObject.getLocalDateTime().format(DateTimeFormatter.ofPattern("yyyy年MM月dd日 HH时mm分ss秒"))+'\n'+messageObject.getMessage()+'\n');
|
||||||
|
}
|
||||||
|
//学生签到信息监听,判断该信息类型是否为签到并且签到状态是否为已签
|
||||||
|
if (messageObject.getMessageType() == MessageType.CheckIn && messageObject.getAttStatus() == AttStatus.signed) {
|
||||||
|
try {
|
||||||
|
LOGGER.info("收到签到 " + messageObject.toString());
|
||||||
|
//将学生签到状态修改进数据表中
|
||||||
|
String attID = DatabaseHelper.selectFromAttendance(Long.parseLong(messageObject.getStuNo()), Long.parseLong(courseID)).getAttID();
|
||||||
|
DatabaseHelper.updateAttendance(attID, messageObject.getAttStatus(), messageObject.getLocalDateTime());
|
||||||
|
} catch (NoConfigException e) {
|
||||||
|
JOptionPane.showMessageDialog(null, "没有数据库配置文件", "警告", JOptionPane.ERROR_MESSAGE);
|
||||||
|
LOGGER.error("No configuration", e);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
JOptionPane.showMessageDialog(null, "数据库出错", "警告", JOptionPane.ERROR_MESSAGE);
|
||||||
|
LOGGER.error("SQLException", e);
|
||||||
|
} catch (DependenciesNotFoundException e) {
|
||||||
|
LOGGER.error("DependenciesNotFoundException", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
frame.setContentPane(main.rootPanel);
|
frame.setContentPane(main.rootPanel);
|
||||||
@@ -187,7 +247,6 @@ public class Main {
|
|||||||
frame.setResizable(false);
|
frame.setResizable(false);
|
||||||
main.workNo = workerNo;
|
main.workNo = workerNo;
|
||||||
main.courseID = courseID;
|
main.courseID = courseID;
|
||||||
//开启主界面即读取端口号
|
|
||||||
main.workNo_show.setText(workerNo);
|
main.workNo_show.setText(workerNo);
|
||||||
main.subName_show.setText(subName);
|
main.subName_show.setText(subName);
|
||||||
|
|
||||||
|
|||||||
@@ -6,24 +6,22 @@ import com.cfive.classroom.library.net.util.MessageType;
|
|||||||
import com.cfive.classroom.library.net.util.ReceiveListener;
|
import com.cfive.classroom.library.net.util.ReceiveListener;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.*;
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
import java.awt.event.ComponentAdapter;
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class SendMessage {
|
public class SendMessage {
|
||||||
private static final SendMessage sendMessage=new SendMessage();
|
|
||||||
|
|
||||||
private static JFrame frame = new JFrame("发送消息");
|
private static final JFrame frame = new JFrame("发送消息");
|
||||||
private JPanel rootPanel;
|
private JPanel rootPanel;
|
||||||
private JTextArea messageInput;
|
private JTextArea messageInput;
|
||||||
private JButton bt_sendMessage;
|
private JButton bt_sendMessage;
|
||||||
private JTextArea messageShow;
|
private JTextArea messageShow;
|
||||||
private TeacherNet teacherNet;
|
|
||||||
|
|
||||||
public SendMessage() {
|
public SendMessage(TeacherNet teacherNet,ChatReceiveListener chatReceiveListener) {
|
||||||
//接收学生发过来的留言
|
//接收学生发过来的留言
|
||||||
if(teacherNet!=null){
|
if(teacherNet!=null){
|
||||||
teacherNet.setOnReceiveListener(new ReceiveListener() {
|
teacherNet.setOnReceiveListener(new ReceiveListener() {
|
||||||
@@ -31,10 +29,10 @@ public class SendMessage {
|
|||||||
public void onReceive(MessageObject messageObject) {
|
public void onReceive(MessageObject messageObject) {
|
||||||
if(messageObject.getStuNo()!=null){
|
if(messageObject.getStuNo()!=null){
|
||||||
if(messageObject.getMessageType()==MessageType.Chat){
|
if(messageObject.getMessageType()==MessageType.Chat){
|
||||||
LocalDateTime sendTime = LocalDateTime.now();
|
messageShow.append("学生 "+messageObject.getStuName()+": "+messageObject.getLocalDateTime().format(DateTimeFormatter.ofPattern("yyyy年MM月dd日 HH时mm分ss秒"))+'\n'+messageObject.getMessage()+'\n');
|
||||||
messageShow.append("学生 "+messageObject.getStuName()+": "+sendTime.format(DateTimeFormatter.ofPattern("yyyy年MM月dd日 HH时mm分ss秒"))+'\n'+messageObject.getMessage()+'\n');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
chatReceiveListener.onReceive(messageObject);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -60,19 +58,17 @@ public class SendMessage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
frame.setContentPane(sendMessage.rootPanel);
|
|
||||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
|
||||||
frame.pack();
|
|
||||||
frame.setVisible(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void start(TeacherNet teacherNet1){
|
public void start(List<String> messageFromStu){
|
||||||
frame.setContentPane(sendMessage.rootPanel);
|
frame.setContentPane(rootPanel);
|
||||||
frame.setSize(600,400);
|
frame.setSize(600,400);
|
||||||
frame.setLocationRelativeTo(null);
|
frame.setLocationRelativeTo(null);
|
||||||
frame.setResizable(false);
|
frame.setResizable(false);
|
||||||
|
for (String message : messageFromStu) {
|
||||||
|
messageShow.append(message);
|
||||||
|
}
|
||||||
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||||
frame.setVisible(true);
|
frame.setVisible(true);
|
||||||
sendMessage.teacherNet = teacherNet1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ import org.apache.logging.log4j.Logger;
|
|||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
|
import java.awt.event.KeyEvent;
|
||||||
|
import java.awt.event.KeyListener;
|
||||||
import java.net.NoRouteToHostException;
|
import java.net.NoRouteToHostException;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
import java.security.spec.InvalidKeySpecException;
|
import java.security.spec.InvalidKeySpecException;
|
||||||
@@ -34,38 +36,74 @@ public class SignIn {
|
|||||||
frame.setSize(600,400);
|
frame.setSize(600,400);
|
||||||
frame.setLocationRelativeTo(null);
|
frame.setLocationRelativeTo(null);
|
||||||
frame.setResizable(false);
|
frame.setResizable(false);
|
||||||
|
|
||||||
|
//回车键登录监听
|
||||||
|
sigIn.password_input.addKeyListener(new KeyListener() {
|
||||||
|
@Override
|
||||||
|
public void keyTyped(KeyEvent e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void keyPressed(KeyEvent e) {
|
||||||
|
if(e.getKeyChar()==KeyEvent.VK_ENTER){
|
||||||
|
if(sigIn.isPwRight()){
|
||||||
|
ClassList classList = new ClassList();
|
||||||
|
classList.start(sigIn.workerNo); //将工号传参到下一个界面
|
||||||
|
frame.dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void keyReleased(KeyEvent e) {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
//登录按钮监听
|
||||||
sigIn.login_Button.addActionListener(new ActionListener() {
|
sigIn.login_Button.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
if(sigIn.isPwRight()){
|
||||||
|
ClassList classList = new ClassList();
|
||||||
|
classList.start(sigIn.workerNo); //将工号传参到下一个界面
|
||||||
|
frame.dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
|
frame.setVisible(true);
|
||||||
|
}
|
||||||
|
private boolean isPwRight(){
|
||||||
sigIn.workerNo=String.valueOf(sigIn.workerNo_input.getText());
|
sigIn.workerNo=String.valueOf(sigIn.workerNo_input.getText());
|
||||||
sigIn.password=String.valueOf(sigIn.password_input.getPassword());
|
sigIn.password=String.valueOf(sigIn.password_input.getPassword());
|
||||||
if(sigIn.workerNo.length()==0||sigIn.password.length()==0){ //判断用户名和密码是否为空
|
if(sigIn.workerNo.length()==0||sigIn.password.length()==0){ //判断用户名和密码是否为空
|
||||||
JOptionPane.showMessageDialog(null,"用户名和密码不能为空","提示!!",JOptionPane.ERROR_MESSAGE);
|
JOptionPane.showMessageDialog(null,"用户名和密码不能为空","提示!!",JOptionPane.ERROR_MESSAGE);
|
||||||
|
return false;
|
||||||
}else{
|
}else{
|
||||||
//根据输入的工号和密码利用加盐位进行判断
|
//根据输入的工号和密码利用加盐位进行判断
|
||||||
try {
|
try {
|
||||||
if (DatabaseHelper.checkPasswdInTeacher(Long.valueOf(sigIn.workerNo), sigIn.password)) {
|
if (DatabaseHelper.checkPasswdInTeacher(Long.valueOf(sigIn.workerNo), sigIn.password)) {
|
||||||
ClassList classList = new ClassList();
|
isConnectedToDatabase = true;
|
||||||
classList.start(sigIn.workerNo); //将工号传参到下一个界面
|
return true;
|
||||||
frame.setVisible(false);
|
|
||||||
} else {
|
} else {
|
||||||
JOptionPane.showMessageDialog(null, "密码错误,请重新输入", "错误!!", JOptionPane.ERROR_MESSAGE);
|
JOptionPane.showMessageDialog(null, "密码错误,请重新输入", "错误!!", JOptionPane.ERROR_MESSAGE);
|
||||||
sigIn.password_input.setText(""); //清空输入框内容
|
sigIn.password_input.setText(""); //清空输入框内容
|
||||||
}
|
|
||||||
isConnectedToDatabase = true;
|
isConnectedToDatabase = true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
} catch (NoConfigException ex) {
|
} catch (NoConfigException ex) {
|
||||||
JOptionPane.showMessageDialog(null, "没有数据库配置文件", "警告", JOptionPane.ERROR_MESSAGE);
|
JOptionPane.showMessageDialog(null, "没有数据库配置文件", "警告", JOptionPane.ERROR_MESSAGE);
|
||||||
LOGGER.error("No configuration", e);
|
LOGGER.error("No configuration", ex);
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
JOptionPane.showMessageDialog(null, "数据库出错", "警告", JOptionPane.ERROR_MESSAGE);
|
LOGGER.error("SQLException", ex);
|
||||||
LOGGER.error("SQLException", e);
|
|
||||||
} catch (DependenciesNotFoundException ex) {
|
} catch (DependenciesNotFoundException ex) {
|
||||||
JOptionPane.showMessageDialog(null, "未查询到该数据", "错误", JOptionPane.ERROR_MESSAGE);
|
JOptionPane.showMessageDialog(null, "未查询到该数据", "错误", JOptionPane.ERROR_MESSAGE);
|
||||||
LOGGER.error("DependenciesNotFoundException", e);
|
LOGGER.error("DependenciesNotFoundException", ex);
|
||||||
} catch (NoSuchAlgorithmException ex) {
|
} catch (NoSuchAlgorithmException ex) {
|
||||||
LOGGER.error("NoSuchAlgorithmException", e);
|
LOGGER.error("NoSuchAlgorithmException", ex);
|
||||||
} catch (InvalidKeySpecException ex) {
|
} catch (InvalidKeySpecException ex) {
|
||||||
LOGGER.error("InvalidKeySpecException", e);
|
LOGGER.error("InvalidKeySpecException", ex);
|
||||||
} finally {
|
} finally {
|
||||||
if (!isConnectedToDatabase) {
|
if (!isConnectedToDatabase) {
|
||||||
JOptionPane.showMessageDialog(null, "无法连接到数据库", "错误", JOptionPane.ERROR_MESSAGE);
|
JOptionPane.showMessageDialog(null, "无法连接到数据库", "错误", JOptionPane.ERROR_MESSAGE);
|
||||||
@@ -73,12 +111,7 @@ public class SignIn {
|
|||||||
isConnectedToDatabase = false;
|
isConnectedToDatabase = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
|
||||||
frame.setVisible(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ public class TeacherTest {
|
|||||||
@Test
|
@Test
|
||||||
void modifyPw(){
|
void modifyPw(){
|
||||||
try {
|
try {
|
||||||
DatabaseHelper.changePasswdInTeacher(Long.valueOf("1002"),"10021002");
|
DatabaseHelper.changePasswdInTeacher(Long.valueOf("1004"),"10041004");
|
||||||
} catch (NoConfigException e) {
|
} catch (NoConfigException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user