@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Administrator/Downloads/mysql-connector-java-8.0.16.jar" sourcepath="/JDBC">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>studentguanli</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@ -0,0 +1,2 @@
|
||||
eclipse.preferences.version=1
|
||||
encoding/<project>=UTF-8
|
||||
@ -0,0 +1,14 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=17
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=17
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
|
||||
org.eclipse.jdt.core.compiler.release=enabled
|
||||
org.eclipse.jdt.core.compiler.source=17
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,15 @@
|
||||
package com.system.dao;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
import com.system.javaBean.Attendancesbw;
|
||||
|
||||
public interface AttendancesbwDao {
|
||||
|
||||
public boolean deleteAttendance(String snosbw) throws SQLException;
|
||||
public List<Attendancesbw> selectBySno(String snosbw);
|
||||
public boolean updateById(String idsbw, String snosbw, String namesbw, String cnosbw, String datesbw, String statussbw)throws SQLException;
|
||||
public boolean addAttendance(Attendancesbw attendancesbw) throws SQLException;
|
||||
public List<Attendancesbw> findAll() throws SQLException;
|
||||
}
|
||||
@ -0,0 +1,83 @@
|
||||
package com.system.javaBean;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
public class Attendancesbw {
|
||||
private String idsbw;
|
||||
private String snosbw;
|
||||
private String namesbw;
|
||||
private String cnosbw;
|
||||
private String datesbw;
|
||||
private String statussbw;
|
||||
|
||||
// 默认构造函数
|
||||
public Attendancesbw() {
|
||||
}
|
||||
|
||||
// 带参数的构造函数
|
||||
public Attendancesbw(String idsbw,String snosbw,String namesbw, String cnosbw, String datesbw, String statussbw) {
|
||||
this.idsbw=idsbw;
|
||||
this.snosbw=snosbw;
|
||||
this.namesbw=namesbw;
|
||||
this.cnosbw = cnosbw;
|
||||
this.datesbw = datesbw;
|
||||
this.statussbw=statussbw;
|
||||
}
|
||||
|
||||
// Getter 和 Setter 方法
|
||||
public String getId() {
|
||||
return idsbw;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.idsbw = idsbw;
|
||||
}
|
||||
|
||||
public String getStudentId() {
|
||||
return snosbw;
|
||||
}
|
||||
|
||||
public void setStudentId(String sno) {
|
||||
this.snosbw = snosbw;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return namesbw;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.namesbw=namesbw;
|
||||
}
|
||||
public String getCourseCno() {
|
||||
return cnosbw;
|
||||
}
|
||||
|
||||
public void setCourseCno(String cno) {
|
||||
this.cnosbw = cnosbw;
|
||||
}
|
||||
|
||||
public String getDate() {
|
||||
return datesbw;
|
||||
}
|
||||
|
||||
public void setDate(String date) {
|
||||
this.datesbw = datesbw;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return statussbw;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.statussbw = statussbw;
|
||||
}
|
||||
|
||||
// 重写 toString 方法
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Attendancesbw{" +"id=" + idsbw + ", sno=" + snosbw + ",sname="+ namesbw +", cno=" + cnosbw +", date=" + datesbw +", status=" + statussbw + '}';
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,100 @@
|
||||
package com.system.utils;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
|
||||
public class DB {
|
||||
|
||||
// 数据库地址
|
||||
private String Driversbw = "jdbc:mysql://localhost:3306/student_a?serverTimezone=Asia/Shanghai&useSSL=false";
|
||||
// 数据库用户名
|
||||
private String usersbw = "root"; // 这里需要修改为自己的用户名和密码
|
||||
// 数据库密码
|
||||
private String passsbw = "sbw20040420";
|
||||
// 数据库连接
|
||||
public static Connection consbw;
|
||||
|
||||
// 构造方法
|
||||
public DB() {
|
||||
try {
|
||||
// 加载驱动
|
||||
Class.forName("com.mysql.cj.jdbc.Driver"); // 这个驱动是mysql8版本的
|
||||
// 获取连接
|
||||
consbw = DriverManager.getConnection(Driversbw, usersbw, passsbw);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
// 获取连接
|
||||
public static Connection getConnection() {
|
||||
if (consbw == null) {
|
||||
new DB();
|
||||
}
|
||||
return consbw;
|
||||
}
|
||||
|
||||
// 释放连接
|
||||
public static void close(ResultSet resultSetsbw, Statement statementsbw, Connection connectionsbw) {
|
||||
|
||||
if (resultSetsbw != null) {
|
||||
try {
|
||||
resultSetsbw.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (statementsbw != null) {
|
||||
try {
|
||||
statementsbw.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (connectionsbw != null) {
|
||||
try {
|
||||
connectionsbw.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 释放连接
|
||||
public static void close(Statement statementsbw, Connection connectionsbw) {
|
||||
|
||||
if (statementsbw != null) {
|
||||
try {
|
||||
statementsbw.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (connectionsbw != null) {
|
||||
try {
|
||||
connectionsbw.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 释放连接
|
||||
public static void close(Connection connectionsbw) {
|
||||
|
||||
if (connectionsbw != null) {
|
||||
try {
|
||||
connectionsbw.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,167 @@
|
||||
package com.system.view;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import com.system.dao.AttendancesbwDao;
|
||||
import com.system.impl.Attendancesbwimpl;
|
||||
import com.system.javaBean.Attendancesbw;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
public class AttendancesbwAdd extends JFrame {
|
||||
|
||||
private AttendancesbwDao attendancesbwDao; // 声明为成员变量
|
||||
private JTextField idFieldsbw;
|
||||
private JTextField snoFieldsbw;
|
||||
private JTextField nameFieldsbw;
|
||||
private JTextField cnoFieldsbw;
|
||||
private JTextField dateFieldsbw;
|
||||
private JComboBox<String> statusComboBoxsbw;
|
||||
private JButton markButtonsbw;
|
||||
|
||||
|
||||
|
||||
public AttendancesbwAdd() {
|
||||
setTitle("考勤添加界面");
|
||||
setSize(500, 350); // 调整窗口大小
|
||||
setLocationRelativeTo(null);
|
||||
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
|
||||
initUI();
|
||||
attendancesbwDao = new Attendancesbwimpl();
|
||||
}
|
||||
|
||||
private void initUI() {
|
||||
JPanel panelsbw = new JPanel(new GridBagLayout());
|
||||
panelsbw.setBackground(Color.WHITE);
|
||||
getContentPane().add(panelsbw);
|
||||
|
||||
GridBagConstraints gbc = new GridBagConstraints();
|
||||
gbc.anchor = GridBagConstraints.NORTHWEST;
|
||||
gbc.insets = new Insets(10, 10, 10, 10);
|
||||
|
||||
// 序号字段可编辑
|
||||
JLabel lblSequencesbw = new JLabel("序号:");
|
||||
panelsbw.add(lblSequencesbw, gbc);
|
||||
|
||||
gbc.gridx = 1;
|
||||
idFieldsbw = new JTextField(20);
|
||||
panelsbw.add(idFieldsbw, gbc);
|
||||
gbc.gridx = 0;
|
||||
gbc.gridy = 1;
|
||||
JLabel lblStudentId = new JLabel("学号:");
|
||||
panelsbw.add(lblStudentId, gbc);
|
||||
|
||||
gbc.gridx = 1;
|
||||
snoFieldsbw = new JTextField(20);
|
||||
panelsbw.add(snoFieldsbw, gbc);
|
||||
|
||||
gbc.gridx = 0;
|
||||
gbc.gridy = 2;
|
||||
JLabel lblStudentName = new JLabel("姓名:");
|
||||
panelsbw.add(lblStudentName, gbc);
|
||||
|
||||
gbc.gridx = 1;
|
||||
nameFieldsbw = new JTextField(20);
|
||||
panelsbw.add(nameFieldsbw, gbc);
|
||||
|
||||
gbc.gridx = 0;
|
||||
gbc.gridy = 3;
|
||||
JLabel lblCourseNumber = new JLabel("课程号:");
|
||||
panelsbw.add(lblCourseNumber, gbc);
|
||||
|
||||
gbc.gridx = 1;
|
||||
cnoFieldsbw = new JTextField(20);
|
||||
panelsbw.add(cnoFieldsbw, gbc);
|
||||
|
||||
gbc.gridx = 0;
|
||||
gbc.gridy = 4;
|
||||
JLabel lblCheckInTime = new JLabel("签到时间:");
|
||||
panelsbw.add(lblCheckInTime, gbc);
|
||||
|
||||
gbc.gridx = 1;
|
||||
dateFieldsbw = new JTextField(20);
|
||||
dateFieldsbw.setEnabled(false); // 签到时间自动生成
|
||||
panelsbw.add(dateFieldsbw, gbc);
|
||||
|
||||
gbc.gridx = 0;
|
||||
gbc.gridy = 5;
|
||||
JLabel lblStatus = new JLabel("考勤状态:");
|
||||
panelsbw.add(lblStatus, gbc);
|
||||
|
||||
gbc.gridx = 1;
|
||||
String[] statusOptions = {"出勤", "缺勤"};
|
||||
statusComboBoxsbw = new JComboBox<>(statusOptions);
|
||||
panelsbw.add(statusComboBoxsbw, gbc);
|
||||
|
||||
gbc.gridx = 0;
|
||||
gbc.gridy = 6;
|
||||
gbc.gridwidth = 2;
|
||||
markButtonsbw = new JButton("记录考勤");
|
||||
markButtonsbw.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
markAttendance();
|
||||
}
|
||||
});
|
||||
panelsbw.add(markButtonsbw, gbc);
|
||||
}
|
||||
|
||||
private void markAttendance() {
|
||||
String idTextsbw = idFieldsbw.getText(); // 假设id对应序号字段
|
||||
String snosbw = snoFieldsbw.getText();
|
||||
String namesbw = nameFieldsbw.getText();
|
||||
String cnosbw = cnoFieldsbw.getText();
|
||||
String statussbw = (String) statusComboBoxsbw.getSelectedItem();
|
||||
|
||||
// 验证输入是否完整
|
||||
if (snosbw.isEmpty() || namesbw.isEmpty() || cnosbw.isEmpty() || idTextsbw.isEmpty()) {
|
||||
JOptionPane.showMessageDialog(this, "请输入所有必填信息!");
|
||||
return;
|
||||
}
|
||||
|
||||
String datesbw = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
|
||||
dateFieldsbw.setText(datesbw); // 设置签到时间到字段
|
||||
|
||||
Attendancesbw attendancesbw = new Attendancesbw();
|
||||
attendancesbw.setId(idTextsbw);
|
||||
attendancesbw.setStudentId(snosbw);
|
||||
attendancesbw.setName(namesbw);
|
||||
attendancesbw.setCourseCno(cnosbw);
|
||||
attendancesbw.setDate(datesbw); // 通过setter方法设置签到时间
|
||||
attendancesbw.setStatus(statussbw);
|
||||
|
||||
try {
|
||||
// 使用AttendanceDao的实现类来添加考勤记录
|
||||
boolean isAddedsbw = attendancesbwDao.addAttendance(attendancesbw);
|
||||
if (isAddedsbw) {
|
||||
JOptionPane.showMessageDialog(this, "考勤信息已成功保存到数据库!");
|
||||
} else {
|
||||
JOptionPane.showMessageDialog(this, "保存考勤信息失败!");
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
JOptionPane.showMessageDialog(this, "数据库访问出错:" + e.getMessage());
|
||||
}
|
||||
|
||||
// 清空文本字段,准备下一次输入
|
||||
idFieldsbw.setText(""); // 清空id字段
|
||||
snoFieldsbw.setText("");
|
||||
nameFieldsbw.setText("");
|
||||
cnoFieldsbw.setText("");
|
||||
statusComboBoxsbw.setSelectedIndex(0);
|
||||
}
|
||||
|
||||
public static void main(String[] argssbw) {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
new AttendancesbwAdd().setVisible(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,78 @@
|
||||
package com.system.view;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.SwingConstants;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
|
||||
import com.system.impl.Attendancesbwimpl;
|
||||
|
||||
public class AttendancesbwDelete extends Bg {
|
||||
|
||||
private JPanel contentPanesbw;
|
||||
private JTextField keyFieldsbw; // 假设使用学号作为关键字来删除考勤记录
|
||||
public AttendancesbwDelete(String a) {
|
||||
|
||||
super(a);
|
||||
|
||||
JPanel panelsbw = new JPanel();
|
||||
panelsbw.setBackground(Color.WHITE);
|
||||
panelsbw.setBounds(165, 54, 752, 493);
|
||||
getContentPane().add(panelsbw);
|
||||
panelsbw.setLayout(null);
|
||||
|
||||
JLabel lblNewLabelsbw = new JLabel("删除考勤记录");
|
||||
lblNewLabelsbw.setFont(new Font("微软雅黑", Font.BOLD, 18));
|
||||
lblNewLabelsbw.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
lblNewLabelsbw.setBounds(275, 55, 189, 33);
|
||||
panelsbw.add(lblNewLabelsbw);
|
||||
|
||||
JLabel lblNewLabel_1sbw = new JLabel("序号:");
|
||||
lblNewLabel_1sbw.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
lblNewLabel_1sbw.setFont(new Font("微软雅黑", Font.BOLD, 16));
|
||||
lblNewLabel_1sbw.setBounds(202, 120, 100, 33);
|
||||
panelsbw.add(lblNewLabel_1sbw);
|
||||
|
||||
keyFieldsbw = new JTextField();
|
||||
keyFieldsbw.setBounds(303, 120, 204, 33);
|
||||
panelsbw.add(keyFieldsbw);
|
||||
keyFieldsbw.setColumns(10);
|
||||
|
||||
JButton btnNewButtonsbw = new JButton("删除");
|
||||
btnNewButtonsbw.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
String keysbw = keyFieldsbw.getText();
|
||||
if (keysbw.equals("")) {
|
||||
JOptionPane.showMessageDialog(null, "请输入序号!");
|
||||
} else {
|
||||
Attendancesbwimpl attendancesbw = new Attendancesbwimpl();
|
||||
boolean flagsbw = false;
|
||||
try {
|
||||
flagsbw = attendancesbw.deleteAttendance(keysbw);
|
||||
} catch (SQLException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
if (flagsbw) {
|
||||
JOptionPane.showMessageDialog(null, "考勤记录删除成功!");
|
||||
} else {
|
||||
JOptionPane.showMessageDialog(null, "考勤记录删除失败,请检查学号是否正确!");
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
btnNewButtonsbw.setFont(new Font("微软雅黑", Font.BOLD, 14));
|
||||
btnNewButtonsbw.setBounds(525, 120, 102, 33);
|
||||
panelsbw.add(btnNewButtonsbw);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,91 @@
|
||||
package com.system.view;
|
||||
|
||||
import java.awt.Font;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.SwingConstants;
|
||||
|
||||
|
||||
public class AttendancesbwOperation extends Bg {
|
||||
|
||||
/**
|
||||
* Create the frame for attendance operation.
|
||||
*/
|
||||
public AttendancesbwOperation(String a) {
|
||||
super(a);
|
||||
|
||||
JLabel lblNewLabelsbw = new JLabel("考勤相关操作");
|
||||
lblNewLabelsbw.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
lblNewLabelsbw.setFont(new Font("微软雅黑", Font.BOLD, 18));
|
||||
lblNewLabelsbw.setBounds(370, 94, 352, 43);
|
||||
getContentPane().add(lblNewLabelsbw);
|
||||
|
||||
JButton btnNewButtonsbw = new JButton("录入考勤");
|
||||
btnNewButtonsbw.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (a.equals("学生")) {
|
||||
JOptionPane.showMessageDialog(null, "没有权限!");
|
||||
} else {
|
||||
setVisible(false);
|
||||
new AttendancesbwAdd().setVisible(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
btnNewButtonsbw.setFont(new Font("微软雅黑", Font.BOLD, 16));
|
||||
btnNewButtonsbw.setBounds(622, 174, 148, 37);
|
||||
getContentPane().add(btnNewButtonsbw);
|
||||
|
||||
JButton btnNewButton_1sbw = new JButton("查询考勤");
|
||||
btnNewButtonsbw.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (a.equals("学生")) {
|
||||
JOptionPane.showMessageDialog(null, "没有权限!");
|
||||
} else {
|
||||
setVisible(false);
|
||||
new AttendancesbwSelect().setVisible(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
btnNewButtonsbw.setFont(new Font("微软雅黑", Font.BOLD, 16));
|
||||
btnNewButtonsbw.setBounds(353, 174, 148, 37);
|
||||
getContentPane().add(btnNewButtonsbw);
|
||||
|
||||
JButton btnUpdateAttendancesbw = new JButton("修改考勤");
|
||||
btnUpdateAttendancesbw.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (a.equals("学生")) {
|
||||
JOptionPane.showMessageDialog(null, "没有权限!");
|
||||
} else {
|
||||
setVisible(false);
|
||||
new AttendancesbwUpdate(a).setVisible(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
btnUpdateAttendancesbw.setFont(new Font("微软雅黑", Font.BOLD, 16));
|
||||
btnUpdateAttendancesbw.setBounds(353, 257, 148, 37);
|
||||
getContentPane().add(btnUpdateAttendancesbw);
|
||||
|
||||
// 添加“删除考勤”按钮
|
||||
JButton btnDeleteAttendancesbw = new JButton("删除考勤");
|
||||
btnDeleteAttendancesbw.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (a.equals("学生")) {
|
||||
JOptionPane.showMessageDialog(null, "没有权限!");
|
||||
} else {
|
||||
setVisible(false);
|
||||
new AttendancesbwDelete(a).setVisible(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
btnDeleteAttendancesbw.setFont(new Font("微软雅黑", Font.BOLD, 16));
|
||||
btnDeleteAttendancesbw.setBounds(622, 257, 148, 37);
|
||||
getContentPane().add(btnDeleteAttendancesbw);
|
||||
// 根据需要添加更多考勤相关按钮和操作
|
||||
}
|
||||
|
||||
// 其他方法和类定义,如 AttendanceRecord 和 AttendanceQuery 等
|
||||
}
|
||||
@ -0,0 +1,138 @@
|
||||
package com.system.view;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import java.awt.SystemColor;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.SwingConstants;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
|
||||
import com.system.impl.Attendancesbwimpl;
|
||||
import com.system.javaBean.Attendancesbw;
|
||||
|
||||
|
||||
|
||||
public class AttendancesbwSelect extends JFrame {
|
||||
|
||||
private JPanel contentPanesbw;
|
||||
private JTextField studentIdFieldsbw;
|
||||
private JTable tablesbw;
|
||||
private JScrollPane scrollPanesbw;
|
||||
|
||||
public AttendancesbwSelect() {
|
||||
|
||||
setTitle("学生考勤查询");
|
||||
setBounds(100, 100, 600, 400);
|
||||
contentPanesbw = new JPanel();
|
||||
contentPanesbw.setBackground(Color.WHITE);
|
||||
contentPanesbw.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
setContentPane(contentPanesbw);
|
||||
contentPanesbw.setLayout(null);
|
||||
|
||||
final Vector<String> columnNamessbw = new Vector<>();
|
||||
columnNamessbw.add("序号");
|
||||
columnNamessbw.add("学生编号");
|
||||
columnNamessbw.add("姓名");
|
||||
columnNamessbw.add("课程号");
|
||||
columnNamessbw.add("签到时间");
|
||||
columnNamessbw.add("考勤状态");
|
||||
|
||||
Vector<Vector<String>> datasbw = new Vector<>();
|
||||
|
||||
JPanel panelsbw = new JPanel();
|
||||
panelsbw.setBackground(SystemColor.activeCaption);
|
||||
panelsbw.setBounds(0, 0, 584, 45);
|
||||
contentPanesbw.add(panelsbw);
|
||||
panelsbw.setLayout(null);
|
||||
|
||||
JLabel lblNewLabelsbw = new JLabel("学生考勤查询系统");
|
||||
lblNewLabelsbw.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
lblNewLabelsbw.setFont(new Font("微软雅黑", Font.BOLD, 16));
|
||||
lblNewLabelsbw.setBounds(155, 10, 280, 25);
|
||||
panelsbw.add(lblNewLabelsbw);
|
||||
|
||||
JPanel panel_1sbw = new JPanel();
|
||||
panel_1sbw.setBackground(Color.WHITE);
|
||||
panel_1sbw.setBounds(0, 44, 584, 51);
|
||||
contentPanesbw.add(panel_1sbw);
|
||||
panel_1sbw.setLayout(null);
|
||||
|
||||
JLabel lblNewLabel_1sbw = new JLabel("学生编号:");
|
||||
lblNewLabel_1sbw.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
lblNewLabel_1sbw.setFont(new Font("微软雅黑", Font.BOLD, 14));
|
||||
lblNewLabel_1sbw.setBounds(100, 10, 91, 31);
|
||||
panel_1sbw.add(lblNewLabel_1sbw);
|
||||
|
||||
studentIdFieldsbw = new JTextField();
|
||||
studentIdFieldsbw.setBounds(191, 10, 194, 31);
|
||||
panel_1sbw.add(studentIdFieldsbw);
|
||||
studentIdFieldsbw.setColumns(10);
|
||||
|
||||
JButton btnNewButtonsbw = new JButton("查询");
|
||||
btnNewButtonsbw.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
String snosbw = studentIdFieldsbw.getText();
|
||||
if (snosbw.isEmpty()) {
|
||||
JOptionPane.showMessageDialog(null, "学生编号不能为空!");
|
||||
} else {
|
||||
// 这里添加查询考勤的逻辑
|
||||
datasbw.clear();
|
||||
Attendancesbwimpl attendancesbw = new Attendancesbwimpl();
|
||||
List<Attendancesbw> attendanceListsbw = attendancesbw.selectBySno(snosbw);
|
||||
for (Attendancesbw attendance1sbw : attendanceListsbw) {
|
||||
Vector<String> rowsbw = new Vector<>();
|
||||
rowsbw.add(String.valueOf(attendance1sbw.getId())); // 假设Attendance有一个id字段
|
||||
rowsbw.add(attendance1sbw.getStudentId());
|
||||
rowsbw.add(attendance1sbw.getName());
|
||||
rowsbw.add(attendance1sbw.getCourseCno());
|
||||
rowsbw.add(attendance1sbw.getDate());
|
||||
rowsbw.add(attendance1sbw.getStatus());
|
||||
datasbw.add(rowsbw);
|
||||
}
|
||||
tablesbw = new JTable(datasbw, columnNamessbw);
|
||||
scrollPanesbw.setViewportView(tablesbw);
|
||||
}
|
||||
}
|
||||
});
|
||||
btnNewButtonsbw.setFont(new Font("微软雅黑", Font.BOLD, 14));
|
||||
btnNewButtonsbw.setBounds(395, 11, 79, 28);
|
||||
panel_1sbw.add(btnNewButtonsbw);
|
||||
|
||||
scrollPanesbw = new JScrollPane();
|
||||
scrollPanesbw.setBounds(0, 94, 584, 287);
|
||||
contentPanesbw.add(scrollPanesbw);
|
||||
|
||||
// 初始化表格数据,这里可以添加加载所有考勤记录的逻辑
|
||||
// 例如加载所有学生的考勤记录
|
||||
|
||||
tablesbw = new JTable(datasbw, columnNamessbw);
|
||||
scrollPanesbw.setViewportView(tablesbw);
|
||||
}
|
||||
|
||||
public static void main(String[] argssbw) {
|
||||
// 启动应用程序
|
||||
java.awt.EventQueue.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
AttendancesbwSelect frame = new AttendancesbwSelect();
|
||||
frame.setVisible(true);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,176 @@
|
||||
package com.system.view;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.SwingConstants;
|
||||
|
||||
import com.system.impl.Attendancesbwimpl;
|
||||
import com.system.javaBean.Attendancesbw;
|
||||
|
||||
|
||||
public class AttendancesbwUpdate extends Bg {
|
||||
|
||||
private JPanel contentPanesbw;
|
||||
private JTextField idkeyFieldsbw;
|
||||
|
||||
private JTextField snoFieldsbw;
|
||||
private JTextField nameFieldsbw;
|
||||
private JTextField cnoFieldsbw;
|
||||
private JTextField dateFieldsbw;
|
||||
private JTextField statusFieldsbw;
|
||||
private JTextField idFieldsbw = new JTextField();
|
||||
|
||||
|
||||
public AttendancesbwUpdate(String a) {
|
||||
// setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
// setBounds(100, 100, 450, 300);
|
||||
// contentPane = new JPanel();
|
||||
// contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
// contentPane.setLayout(new BorderLayout(0, 0));
|
||||
// setContentPane(contentPane);
|
||||
super(a);
|
||||
|
||||
|
||||
JPanel panelsbw = new JPanel();
|
||||
panelsbw.setBackground(Color.WHITE);
|
||||
panelsbw.setBounds(166, 32, 751, 495);
|
||||
getContentPane().add(panelsbw);
|
||||
panelsbw.setLayout(null);
|
||||
|
||||
|
||||
|
||||
JLabel lblNewLabelsbw = new JLabel("修改考勤信息");
|
||||
lblNewLabelsbw.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
lblNewLabelsbw.setFont(new Font("微软雅黑", Font.BOLD, 18));
|
||||
lblNewLabelsbw.setBounds(256, 28, 233, 38);
|
||||
panelsbw.add(lblNewLabelsbw);
|
||||
|
||||
//JLabel lblNewLabel_2 = new JLabel("考勤基本信息");
|
||||
//lblNewLabel_2.setFont(new Font("微软雅黑", Font.BOLD, 16));
|
||||
//lblNewLabel_2.setBounds(155, 136, 170, 28);
|
||||
//panel.add(lblNewLabel_2);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// 考勤序号标签
|
||||
JLabel lblNewLabel_3sbw = new JLabel("考勤序号:");
|
||||
lblNewLabel_3sbw.setFont(new Font("微软雅黑", Font.BOLD, 16));
|
||||
lblNewLabel_3sbw.setBounds(155, 131, 90, 28);
|
||||
panelsbw.add(lblNewLabel_3sbw);
|
||||
|
||||
// 学生学号标签
|
||||
JLabel lblNewLabel_3_1sbw = new JLabel("学生学号:");
|
||||
lblNewLabel_3_1sbw.setFont(new Font("微软雅黑", Font.BOLD, 16));
|
||||
lblNewLabel_3_1sbw.setBounds(155, 171, 90, 28);
|
||||
panelsbw.add(lblNewLabel_3_1sbw);
|
||||
|
||||
// 学生姓名标签
|
||||
JLabel lblNewLabel_3_2sbw = new JLabel("学生姓名:");
|
||||
lblNewLabel_3_2sbw.setFont(new Font("微软雅黑", Font.BOLD, 16));
|
||||
lblNewLabel_3_2sbw.setBounds(155, 212, 90, 28);
|
||||
panelsbw.add(lblNewLabel_3_2sbw);
|
||||
|
||||
// 课程号标签
|
||||
JLabel lblNewLabel_3_3sbw = new JLabel("课程号:");
|
||||
lblNewLabel_3_3sbw.setFont(new Font("微软雅黑", Font.BOLD, 16));
|
||||
lblNewLabel_3_3sbw.setBounds(171, 259, 73, 28);
|
||||
panelsbw.add(lblNewLabel_3_3sbw);
|
||||
|
||||
// 考勤日期标签
|
||||
JLabel lblNewLabel_3_4sbw = new JLabel("考勤日期:");
|
||||
lblNewLabel_3_4sbw.setFont(new Font("微软雅黑", Font.BOLD, 16));
|
||||
lblNewLabel_3_4sbw.setBounds(155, 306, 90, 28);
|
||||
panelsbw.add(lblNewLabel_3_4sbw);
|
||||
|
||||
// 考勤状态标签
|
||||
JLabel lblNewLabel_3_5sbw = new JLabel("考勤状态:");
|
||||
lblNewLabel_3_5sbw.setFont(new Font("微软雅黑", Font.BOLD, 16));
|
||||
lblNewLabel_3_5sbw.setBounds(155, 348, 90, 28);
|
||||
panelsbw.add(lblNewLabel_3_5sbw);
|
||||
|
||||
// 考勤序号文本框
|
||||
JTextField idFieldsbw = new JTextField();
|
||||
idFieldsbw.setBounds(238, 135, 240, 30);
|
||||
panelsbw.add(idFieldsbw);
|
||||
idFieldsbw.setColumns(8);
|
||||
|
||||
// 学生学号文本框
|
||||
JTextField snoFieldsbw = new JTextField();
|
||||
snoFieldsbw.setBounds(238, 175, 240, 30);
|
||||
panelsbw.add(snoFieldsbw);
|
||||
snoFieldsbw.setColumns(8);
|
||||
|
||||
// 学生姓名文本框
|
||||
JTextField nameFieldsbw = new JTextField();
|
||||
nameFieldsbw.setBounds(238, 217, 240, 30);
|
||||
panelsbw.add(nameFieldsbw);
|
||||
nameFieldsbw.setColumns(8);
|
||||
|
||||
// 课程号文本框
|
||||
JTextField cnoFieldsbw = new JTextField();
|
||||
cnoFieldsbw.setBounds(238, 264, 240, 30);
|
||||
panelsbw.add(cnoFieldsbw);
|
||||
cnoFieldsbw.setColumns(8);
|
||||
|
||||
// 考勤日期文本框
|
||||
JTextField dateFieldsbw = new JTextField();
|
||||
dateFieldsbw.setBounds(238, 311, 240, 30);
|
||||
panelsbw.add(dateFieldsbw);
|
||||
dateFieldsbw.setColumns(8);
|
||||
|
||||
// 考勤状态文本框
|
||||
JTextField statusFieldsbw = new JTextField();
|
||||
statusFieldsbw.setBounds(238, 352, 240, 30);
|
||||
panelsbw.add(statusFieldsbw);
|
||||
statusFieldsbw.setColumns(8);
|
||||
|
||||
JButton btnNewButton_1sbw = new JButton("修改");
|
||||
btnNewButton_1sbw.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
String idsbw = idFieldsbw.getText(); // 考勤序号
|
||||
String snosbw = snoFieldsbw.getText(); // 学生学号
|
||||
String namesbw = nameFieldsbw.getText(); // 学生姓名
|
||||
String cnosbw = cnoFieldsbw.getText(); // 课程号
|
||||
String datesbw = dateFieldsbw.getText(); // 考勤日期
|
||||
String statussbw = statusFieldsbw.getText(); // 考勤状态
|
||||
|
||||
if (idsbw.equals("") || snosbw.equals("") ||namesbw.equals("") ||cnosbw.equals("") ||datesbw.equals("") || statussbw.equals("") ) {
|
||||
JOptionPane.showMessageDialog(null, "请输入完整的信息!");
|
||||
} else {
|
||||
|
||||
Attendancesbwimpl attendancesbwDao = new Attendancesbwimpl();
|
||||
boolean istrue = false;
|
||||
try{
|
||||
istrue = attendancesbwDao.updateById(idsbw, snosbw, namesbw, cnosbw, datesbw, statussbw);
|
||||
}catch (SQLException e1) {
|
||||
// TODO Auto-generated catch block
|
||||
e1.printStackTrace();
|
||||
}
|
||||
if (istrue) {
|
||||
JOptionPane.showMessageDialog(null, "修改成功!");
|
||||
} else {
|
||||
JOptionPane.showMessageDialog(null, "修改失败,请检查输入信息是否正确!");
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
btnNewButton_1sbw.setBackground(Color.RED);
|
||||
btnNewButton_1sbw.setFont(new Font("微软雅黑", Font.BOLD, 14));
|
||||
btnNewButton_1sbw.setBounds(280, 447, 136, 38);
|
||||
panelsbw.add(btnNewButton_1sbw);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,58 @@
|
||||
package com.system.view;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import java.awt.SystemColor;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.SwingConstants;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
|
||||
public class Bg extends JFrame {
|
||||
|
||||
private JPanel contentPane;
|
||||
|
||||
|
||||
public Bg(String flag) {
|
||||
|
||||
JPanel panel_1 = new JPanel();
|
||||
panel_1.setBackground(SystemColor.activeCaptionBorder);
|
||||
panel_1.setBounds(0, 52, 166, 495);
|
||||
contentPane.add(panel_1);
|
||||
panel_1.setLayout(null);
|
||||
|
||||
JLabel lblNewLabel_4 = new JLabel("考勤模块");
|
||||
lblNewLabel_4.addMouseListener(new MouseAdapter() {
|
||||
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
setVisible(false);
|
||||
new AttendancesbwOperation(flag).setVisible(true);
|
||||
}
|
||||
});
|
||||
lblNewLabel_4.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
lblNewLabel_4.setFont(new Font("微软雅黑", Font.BOLD, 16));
|
||||
lblNewLabel_4.setBounds(0, 199, 166, 58);
|
||||
panel_1.add(lblNewLabel_4);
|
||||
|
||||
JLabel lblNewLabel_3 = new JLabel("退出系统");
|
||||
lblNewLabel_3.addMouseListener(new MouseAdapter() {
|
||||
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent arg0) {
|
||||
System.exit(0);
|
||||
}
|
||||
});
|
||||
lblNewLabel_3.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
lblNewLabel_3.setFont(new Font("微软雅黑", Font.BOLD, 16));
|
||||
lblNewLabel_3.setBounds(0, 262, 166, 58);
|
||||
panel_1.add(lblNewLabel_3);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,4 @@
|
||||
module studentguanli {
|
||||
requires java.sql;
|
||||
requires java.desktop;
|
||||
}
|
||||
Loading…
Reference in new issue