Compare commits
1 Commits
attendance
...
score
| Author | SHA1 | Date |
|---|---|---|
|
|
5498194af3 | 2 years ago |
@ -1,15 +1,10 @@
|
||||
<?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">
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
||||
<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>
|
||||
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>studentguanli</name>
|
||||
<name>bqhproject</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
@ -1,14 +1,12 @@
|
||||
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.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=17
|
||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
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
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
||||
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,80 @@
|
||||
package com.bqh.entity;
|
||||
|
||||
public class Scorebqh {
|
||||
|
||||
private String Sno;
|
||||
private String Sname;
|
||||
private String Cno;
|
||||
private String Cname;
|
||||
private String Sscore;
|
||||
private String Rescore;
|
||||
|
||||
public Scorebqh() {
|
||||
super();
|
||||
}
|
||||
|
||||
public Scorebqh(String sno, String sname, String cno, String cname, String sscore, String rescore) {
|
||||
super();
|
||||
Sno = sno;
|
||||
Sname = sname;
|
||||
Cno = cno;
|
||||
Cname = cname;
|
||||
Sscore = sscore;
|
||||
Rescore = rescore;
|
||||
}
|
||||
|
||||
public String getSno() {
|
||||
return Sno;
|
||||
}
|
||||
|
||||
public void setSno(String sno) {
|
||||
Sno = sno;
|
||||
}
|
||||
|
||||
public String getSname() {
|
||||
return Sname;
|
||||
}
|
||||
|
||||
public void setSname(String sname) {
|
||||
Sname = sname;
|
||||
}
|
||||
|
||||
public String getCno() {
|
||||
return Cno;
|
||||
}
|
||||
|
||||
public void setCno(String cno) {
|
||||
Cno = cno;
|
||||
}
|
||||
|
||||
public String getCname() {
|
||||
return Cname;
|
||||
}
|
||||
|
||||
public void setCname(String cname) {
|
||||
Cname = cname;
|
||||
}
|
||||
|
||||
public String getSscore() {
|
||||
return Sscore;
|
||||
}
|
||||
|
||||
public void setSscore(String sscore) {
|
||||
Sscore = sscore;
|
||||
}
|
||||
|
||||
public String getRescore() {
|
||||
return Rescore;
|
||||
}
|
||||
|
||||
public void setRescore(String rescore) {
|
||||
Rescore = rescore;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Score [Sno=" + Sno + ", Sname=" + Sname + ", Cno=" + Cno + ", Cname=" + Cname + ", Sscore=" + Sscore
|
||||
+ ", Rescore=" + Rescore + "]";
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,173 @@
|
||||
package com.bqh.impl;
|
||||
import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.bqh.entity.Scorebqh;
|
||||
import com.bqh.untils.DB;
|
||||
|
||||
public class Scoreimpl {
|
||||
Connection conn = null;
|
||||
DB dataBase = new DB();
|
||||
|
||||
//成绩信息
|
||||
public List<Scoreimpl> scoreRes(String key) throws Exception {
|
||||
List<Scoreimpl> scores = new ArrayList<>();
|
||||
int k = 0;
|
||||
if (!key.equals("")) {
|
||||
k = Integer.parseInt(key);
|
||||
}
|
||||
|
||||
Scorebqh score;
|
||||
conn = dataBase.getConnection();
|
||||
Statement stat = null;
|
||||
ResultSet rs = null;
|
||||
stat = conn.createStatement();
|
||||
String sql = "SELECT * FROM score";
|
||||
if (!key.equals("")) {
|
||||
sql = sql + " where Sno = " + k;
|
||||
|
||||
}
|
||||
rs = stat.executeQuery(sql);
|
||||
while (true) {
|
||||
if ( rs.next() ) {
|
||||
score = new Scorebqh();
|
||||
score.setSno( rs.getString("Sno") );
|
||||
score.setSname( rs.getString("Sname") );
|
||||
score.setCno( rs.getString("Cno") );
|
||||
score.setCname( rs.getString("Cname") );
|
||||
score.setSscore( rs.getString("Sscore") );
|
||||
score.setRescore( rs.getString("Rescore") );
|
||||
scores.add(score)
|
||||
}else
|
||||
break;
|
||||
}
|
||||
conn.close();
|
||||
return scores;
|
||||
}
|
||||
|
||||
//某个学生的所有成绩
|
||||
public List<Scorebqh> scoreOwnRes(String id) throws Exception {
|
||||
List<Scorebqh> scores = new ArrayList<>();
|
||||
Scorebqh score;
|
||||
conn = dataBase.getConnection();
|
||||
Statement stat = null;
|
||||
ResultSet rs = null;
|
||||
stat = conn.createStatement();
|
||||
String sql = "SELECT * FROM score WHERE sno = '"+id+"'";
|
||||
rs = stat.executeQuery(sql);
|
||||
while (true) {
|
||||
if ( rs.next() ) {
|
||||
score = new Scorebqh();
|
||||
score.setSno( rs.getString("Sno") );
|
||||
score.setSname( rs.getString("Sname") );
|
||||
score.setCno( rs.getString("Cno") );
|
||||
score.setCname( rs.getString("Cname") );
|
||||
score.setSscore( rs.getString("Sscore") );
|
||||
score.setRescore( rs.getString("Rescore") );
|
||||
scores.add(score);
|
||||
}else
|
||||
break;
|
||||
}
|
||||
conn.close();
|
||||
return scores;
|
||||
}
|
||||
|
||||
//录入成绩
|
||||
public boolean insert(String sno, String cno, String sscore) throws SQLException {
|
||||
try {
|
||||
conn = dataBase.getConnection();
|
||||
Statement stat = null;
|
||||
stat = conn.createStatement();
|
||||
String sql = "SELECT Sname FROM student WHERE sno = '"+sno+"' ";
|
||||
String sql_2 = "SELECT cname FROM course WHERE cno = '"+cno+"' ";
|
||||
ResultSet rs = null;
|
||||
ResultSet rs_2 = null;
|
||||
String sname =null;
|
||||
String cname = null;
|
||||
rs = stat.executeQuery(sql);
|
||||
if(rs.next())
|
||||
sname = rs.getString("Sname");
|
||||
rs_2 = stat.executeQuery(sql_2);
|
||||
if ( rs_2.next() )
|
||||
cname = rs_2.getString("Cname");
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
String sql_3 = "INSERT INTO score (sno,sname,cno,cname,sscore) VALUES ( '"+sno+"', '"+sname+"','"+cno+"', '"+cname+"','"+sscore+"' )";
|
||||
if ( stat.executeUpdate(sql_3)==1 ){
|
||||
return true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
conn.close();
|
||||
return false;
|
||||
}
|
||||
|
||||
//删除成绩
|
||||
public boolean delete(String sno, String cno) throws SQLException {
|
||||
try {
|
||||
conn = dataBase.getConnection();
|
||||
Statement stat = null;
|
||||
stat = conn.createStatement();
|
||||
String sql = "DELETE FROM score WHERE sno = '"+sno+"' AND cno = '"+cno+"' ";
|
||||
if ( stat.executeUpdate(sql)==1 ){
|
||||
return true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
conn.close();
|
||||
return false;
|
||||
}
|
||||
|
||||
//查询成绩
|
||||
public Scorebqh select(String sno, String cno) throws SQLException {
|
||||
try {
|
||||
conn = dataBase.getConnection();
|
||||
Statement stat = null;
|
||||
stat = conn.createStatement();
|
||||
ResultSet rs = null;
|
||||
Scorebqh sc = null;
|
||||
String sql = "SELECT * FROM score WHERE sno = '"+sno+"' AND cno = '"+cno+"'";
|
||||
rs = stat.executeQuery(sql);
|
||||
if ( rs.next() ){
|
||||
sc = new Scorebqh();
|
||||
sc.setSno( rs.getString("Sno") );
|
||||
sc.setSname( rs.getString("Sname") );
|
||||
sc.setCno( rs.getString("Cno") );
|
||||
sc.setCname( rs.getString("Cname") );
|
||||
sc.setSscore( rs.getString("Sscore") );
|
||||
sc.setRescore(rs.getString("Rescore"));
|
||||
return sc;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
conn.close();
|
||||
return null;
|
||||
}
|
||||
|
||||
//删除某门课程的成绩
|
||||
public boolean update(String sno, String cno, String sscore, String rescore) throws SQLException {
|
||||
try {
|
||||
conn = dataBase.getConnection();
|
||||
Statement stat = null;
|
||||
stat = conn.createStatement();
|
||||
String sql = "UPDATE score SET Sscore = '"+sscore+"', Rescore = '"+rescore+"' WHERE sno = '"+sno+"' AND cno ='"+cno+"' ";
|
||||
if ( stat.executeUpdate(sql)==1 ){
|
||||
return true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
conn.close();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,133 @@
|
||||
package com.bqh.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 javax.swing.border.EmptyBorder;
|
||||
|
||||
import com.bqh.impl.Scoreimpl;
|
||||
|
||||
public class ScorebqhADD extends JFrame {
|
||||
|
||||
private JPanel contentPane;
|
||||
private JTextField snoField;
|
||||
private JTextField cnoField;
|
||||
private JTextField sscoreField;
|
||||
|
||||
public ScorebqhADD(String a) {
|
||||
setBounds(100, 100, 695, 435);
|
||||
contentPane = new JPanel();
|
||||
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
setContentPane(contentPane);
|
||||
contentPane.setLayout(null);
|
||||
|
||||
JPanel panel = new JPanel();
|
||||
panel.setBackground(Color.WHITE);
|
||||
panel.setBounds(0, 0, 679, 396);
|
||||
contentPane.add(panel);
|
||||
panel.setLayout(null);
|
||||
|
||||
JLabel lblNewLabel = new JLabel("添加学生成绩");
|
||||
lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
lblNewLabel.setFont(new Font("微软雅黑", Font.BOLD, 18));
|
||||
lblNewLabel.setBounds(193, 55, 252, 45);
|
||||
panel.add(lblNewLabel);
|
||||
|
||||
JLabel lblNewLabel_1 = new JLabel("学号:");
|
||||
lblNewLabel_1.setFont(new Font("微软雅黑", Font.BOLD, 16));
|
||||
lblNewLabel_1.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
lblNewLabel_1.setBounds(141, 110, 72, 31);
|
||||
panel.add(lblNewLabel_1);
|
||||
|
||||
JLabel lblNewLabel_1_1 = new JLabel("课程号:");
|
||||
lblNewLabel_1_1.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
lblNewLabel_1_1.setFont(new Font("微软雅黑", Font.BOLD, 16));
|
||||
lblNewLabel_1_1.setBounds(141, 174, 72, 31);
|
||||
panel.add(lblNewLabel_1_1);
|
||||
|
||||
JLabel lblNewLabel_1_2 = new JLabel("成绩:");
|
||||
lblNewLabel_1_2.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
lblNewLabel_1_2.setFont(new Font("微软雅黑", Font.BOLD, 16));
|
||||
lblNewLabel_1_2.setBounds(141, 229, 72, 31);
|
||||
panel.add(lblNewLabel_1_2);
|
||||
|
||||
snoField = new JTextField();
|
||||
snoField.setBounds(203, 110, 276, 31);
|
||||
panel.add(snoField);
|
||||
snoField.setColumns(10);
|
||||
|
||||
cnoField = new JTextField();
|
||||
cnoField.setColumns(10);
|
||||
cnoField.setBounds(203, 175, 276, 31);
|
||||
panel.add(cnoField);
|
||||
|
||||
sscoreField = new JTextField();
|
||||
sscoreField.setColumns(10);
|
||||
sscoreField.setBounds(203, 230, 276, 31);
|
||||
panel.add(sscoreField);
|
||||
|
||||
JButton btnNewButton = new JButton("添加");
|
||||
btnNewButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
String sno = snoField.getText();
|
||||
String cno = cnoField.getText();
|
||||
String sscore = sscoreField.getText();
|
||||
|
||||
// 判断操作
|
||||
if (sno.equals("") || cno.equals("") || sscore.equals("")) {
|
||||
JOptionPane.showMessageDialog(null, "请将信息填写完整!");
|
||||
} else {
|
||||
|
||||
Scoreimpl scoreDao = new Scoreimpl();
|
||||
boolean istrue = false;
|
||||
try {
|
||||
istrue = scoreDao.insert(sno, cno, sscore);
|
||||
} catch (SQLException e1) {
|
||||
// TODO Auto-generated catch block
|
||||
e1.printStackTrace();
|
||||
}
|
||||
if (istrue) {
|
||||
JOptionPane.showMessageDialog(null, "成绩录入成功!");
|
||||
|
||||
} else {
|
||||
JOptionPane.showMessageDialog(null, "成绩录入失败,请检查学号与课程号是否正确!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
btnNewButton.setFont(new Font("微软雅黑", Font.BOLD, 14));
|
||||
btnNewButton.setBounds(141, 302, 108, 39);
|
||||
panel.add(btnNewButton);
|
||||
|
||||
JButton btnNewButton_1 = new JButton("重置");
|
||||
btnNewButton_1.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
snoField.setText("");
|
||||
cnoField.setText("");
|
||||
sscoreField.setText("");
|
||||
}
|
||||
});
|
||||
btnNewButton_1.setFont(new Font("微软雅黑", Font.BOLD, 14));
|
||||
btnNewButton_1.setBounds(412, 302, 108, 39);
|
||||
panel.add(btnNewButton_1);
|
||||
|
||||
JLabel lblNewLabel_2 = new JLabel("请勿重复添加成绩!");
|
||||
lblNewLabel_2.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
lblNewLabel_2.setForeground(Color.RED);
|
||||
lblNewLabel_2.setFont(new Font("微软雅黑", Font.BOLD, 12));
|
||||
lblNewLabel_2.setBounds(203, 259, 276, 22);
|
||||
panel.add(lblNewLabel_2);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,89 @@
|
||||
package com.bqh.view;
|
||||
|
||||
import java.awt.Color;
|
||||
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.JPanel;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.SwingConstants;
|
||||
|
||||
import com.bqh.impl.Scoreimpl;
|
||||
|
||||
public class ScorebqhDelete extends Bg {
|
||||
|
||||
private JPanel contentPane;
|
||||
private JTextField snoField;
|
||||
private JTextField cnoField;
|
||||
|
||||
public ScorebqhDelete(String a) {
|
||||
super(a);
|
||||
|
||||
JPanel panel = new JPanel();
|
||||
panel.setBackground(Color.WHITE);
|
||||
panel.setBounds(166, 52, 751, 495);
|
||||
getContentPane().add(panel);
|
||||
panel.setLayout(null);
|
||||
|
||||
JLabel lblNewLabel = new JLabel("删除成绩");
|
||||
lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
lblNewLabel.setFont(new Font("微软雅黑", Font.BOLD, 18));
|
||||
lblNewLabel.setBounds(234, 54, 214, 42);
|
||||
panel.add(lblNewLabel);
|
||||
|
||||
JLabel lblNewLabel_1 = new JLabel("学号:");
|
||||
lblNewLabel_1.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
lblNewLabel_1.setFont(new Font("微软雅黑", Font.BOLD, 16));
|
||||
lblNewLabel_1.setBounds(153, 110, 107, 30);
|
||||
panel.add(lblNewLabel_1);
|
||||
|
||||
JLabel lblNewLabel_1_1 = new JLabel("课程号:");
|
||||
lblNewLabel_1_1.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
lblNewLabel_1_1.setFont(new Font("微软雅黑", Font.BOLD, 16));
|
||||
lblNewLabel_1_1.setBounds(153, 170, 107, 30);
|
||||
panel.add(lblNewLabel_1_1);
|
||||
|
||||
snoField = new JTextField();
|
||||
snoField.setBounds(244, 112, 285, 30);
|
||||
panel.add(snoField);
|
||||
snoField.setColumns(10);
|
||||
|
||||
cnoField = new JTextField();
|
||||
cnoField.setColumns(10);
|
||||
cnoField.setBounds(244, 172, 285, 30);
|
||||
panel.add(cnoField);
|
||||
|
||||
JButton btnNewButton = new JButton("删除");
|
||||
btnNewButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
String sno = snoField.getText();
|
||||
String cno = cnoField.getText();
|
||||
|
||||
if (sno.equals("") || cno.equals("")) {
|
||||
JOptionPane.showMessageDialog(null, "请输入完整的信息!");
|
||||
} else {
|
||||
Scoreimpl score = new Scoreimpl();
|
||||
try {
|
||||
if (score.delete(sno, cno)) {
|
||||
JOptionPane.showMessageDialog(null, "成绩删除成功!");
|
||||
} else {
|
||||
JOptionPane.showMessageDialog(null, "请检查学号与课程号是否正确,或已被删除!");
|
||||
}
|
||||
} catch (Exception e1) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
btnNewButton.setFont(new Font("微软雅黑", Font.BOLD, 14));
|
||||
btnNewButton.setBackground(Color.RED);
|
||||
btnNewButton.setBounds(289, 252, 124, 36);
|
||||
panel.add(btnNewButton);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,102 @@
|
||||
package com.bqh.view;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import java.awt.SystemColor;
|
||||
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.JPanel;
|
||||
import javax.swing.SwingConstants;
|
||||
|
||||
public class ScorebqhOperation extends Bg {
|
||||
|
||||
private JPanel contentPane;
|
||||
|
||||
public ScorebqhOperation(String a) {
|
||||
super(a);
|
||||
|
||||
JPanel panel = new JPanel();
|
||||
panel.setBackground(Color.WHITE);
|
||||
panel.setBounds(166, 53, 751, 494);
|
||||
getContentPane().add(panel);
|
||||
panel.setLayout(null);
|
||||
|
||||
JLabel lblNewLabel = new JLabel("成绩模块基本操作");
|
||||
lblNewLabel.setFont(new Font("微软雅黑", Font.BOLD, 18));
|
||||
lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
lblNewLabel.setBounds(254, 33, 239, 39);
|
||||
panel.add(lblNewLabel);
|
||||
|
||||
JButton btnNewButton = new JButton("查询成绩");
|
||||
btnNewButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
setVisible(true);
|
||||
new ScoreSelect(a).setVisible(true);
|
||||
}
|
||||
});
|
||||
btnNewButton.setBackground(SystemColor.activeCaption);
|
||||
btnNewButton.setForeground(Color.BLACK);
|
||||
btnNewButton.setFont(new Font("微软雅黑", Font.BOLD, 14));
|
||||
btnNewButton.setBounds(187, 101, 110, 39);
|
||||
panel.add(btnNewButton);
|
||||
|
||||
JButton btnNewButton_1 = new JButton("添加成绩");
|
||||
btnNewButton_1.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
if (a.equals("学生")) {
|
||||
JOptionPane.showMessageDialog(null, "没有权限!");
|
||||
} else {
|
||||
setVisible(true);
|
||||
new ScorebqhADD(a).setVisible(true);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
btnNewButton_1.setForeground(Color.BLACK);
|
||||
btnNewButton_1.setFont(new Font("微软雅黑", Font.BOLD, 14));
|
||||
btnNewButton_1.setBackground(SystemColor.activeCaption);
|
||||
btnNewButton_1.setBounds(439, 101, 110, 39);
|
||||
panel.add(btnNewButton_1);
|
||||
|
||||
JButton btnNewButton_2 = new JButton("修改成绩");
|
||||
btnNewButton_2.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (a.equals("学生")) {
|
||||
JOptionPane.showMessageDialog(null, "没有权限!");
|
||||
} else {
|
||||
setVisible(false);
|
||||
new ScoreUpdate(a).setVisible(true);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
btnNewButton_2.setForeground(Color.BLACK);
|
||||
btnNewButton_2.setFont(new Font("微软雅黑", Font.BOLD, 14));
|
||||
btnNewButton_2.setBackground(SystemColor.activeCaption);
|
||||
btnNewButton_2.setBounds(187, 210, 110, 39);
|
||||
panel.add(btnNewButton_2);
|
||||
|
||||
JButton btnNewButton_3 = new JButton("删除成绩");
|
||||
btnNewButton_3.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (a.equals("学生")) {
|
||||
JOptionPane.showMessageDialog(null, "没有权限!");
|
||||
} else {
|
||||
setVisible(false);
|
||||
new ScoreDelect(a).setVisible(true);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
btnNewButton_3.setForeground(Color.BLACK);
|
||||
btnNewButton_3.setFont(new Font("微软雅黑", Font.BOLD, 14));
|
||||
btnNewButton_3.setBackground(SystemColor.activeCaption);
|
||||
btnNewButton_3.setBounds(439, 210, 110, 39);
|
||||
panel.add(btnNewButton_3);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,142 @@
|
||||
package com.bqh.view;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
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.bqh.entity.Scorebqh;
|
||||
import com.bqh.impl.Scoreimpl;
|
||||
|
||||
public class ScorebqhSelect extends JFrame {
|
||||
|
||||
private JPanel contentPane;
|
||||
private JTextField keyField;
|
||||
private JTable table;
|
||||
|
||||
public ScorebqhSelect(String a) {
|
||||
setBounds(100, 100, 808, 529);
|
||||
contentPane = new JPanel();
|
||||
contentPane.setBackground(Color.WHITE);
|
||||
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
setContentPane(contentPane);
|
||||
contentPane.setLayout(null);
|
||||
|
||||
final Vector vector = new Vector();
|
||||
Vector tData = new Vector();
|
||||
vector.add("学号");
|
||||
vector.add("姓名");
|
||||
vector.add("课程号");
|
||||
vector.add("课程名");
|
||||
vector.add("成绩");
|
||||
vector.add("补考成绩");
|
||||
|
||||
JPanel panel = new JPanel();
|
||||
panel.setBackground(Color.LIGHT_GRAY);
|
||||
panel.setBounds(0, 0, 792, 47);
|
||||
contentPane.add(panel);
|
||||
panel.setLayout(null);
|
||||
|
||||
JLabel lblNewLabel = new JLabel("学生成绩");
|
||||
lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
lblNewLabel.setFont(new Font("微软雅黑", Font.BOLD, 18));
|
||||
lblNewLabel.setBounds(305, 10, 134, 27);
|
||||
panel.add(lblNewLabel);
|
||||
|
||||
JScrollPane scrollPane = new JScrollPane();
|
||||
scrollPane.setBounds(0, 90, 792, 400);
|
||||
contentPane.add(scrollPane);
|
||||
|
||||
|
||||
|
||||
Scoreimpl score = new Scoreimpl();
|
||||
try {
|
||||
tData.clear();
|
||||
List<Score> list = score.scoreRes("");
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
Vector v = new Vector();
|
||||
v.add(list.get(i).getSno());
|
||||
v.add(list.get(i).getSname());
|
||||
v.add(list.get(i).getCno());
|
||||
v.add(list.get(i).getCname());
|
||||
v.add(list.get(i).getSscore());
|
||||
v.add(list.get(i).getRescore());
|
||||
tData.add(v);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
table = new JTable(tData, vector);
|
||||
scrollPane.setViewportView(table);
|
||||
|
||||
JPanel panel_1 = new JPanel();
|
||||
panel_1.setBackground(Color.WHITE);
|
||||
panel_1.setBounds(0, 46, 792, 47);
|
||||
contentPane.add(panel_1);
|
||||
panel_1.setLayout(null);
|
||||
|
||||
JLabel lblNewLabel_1 = new JLabel("学号:");
|
||||
lblNewLabel_1.setFont(new Font("微软雅黑", Font.BOLD, 14));
|
||||
lblNewLabel_1.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
lblNewLabel_1.setBounds(214, 10, 59, 27);
|
||||
panel_1.add(lblNewLabel_1);
|
||||
|
||||
keyField = new JTextField();
|
||||
keyField.setBounds(267, 14, 170, 23);
|
||||
panel_1.add(keyField);
|
||||
keyField.setColumns(10);
|
||||
|
||||
JButton btnNewButton = new JButton("查询");
|
||||
btnNewButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
String key = keyField.getText();
|
||||
if (key.equals("")) {
|
||||
JOptionPane.showMessageDialog(null, "学号不能为空!");
|
||||
} else {
|
||||
tData.clear();
|
||||
Scoreimpl score = new Scoreimpl();
|
||||
try {
|
||||
List<Score> list = score.scoreRes(key);
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
Vector v = new Vector();
|
||||
v.add(list.get(i).getSno());
|
||||
v.add(list.get(i).getSname());
|
||||
v.add(list.get(i).getCno());
|
||||
v.add(list.get(i).getCname());
|
||||
v.add(list.get(i).getSscore());
|
||||
v.add(list.get(i).getRescore());
|
||||
tData.add(v);
|
||||
}
|
||||
} catch (Exception a) {
|
||||
// TODO Auto-generated catch block
|
||||
a.printStackTrace();
|
||||
}
|
||||
|
||||
table = new JTable(tData, vector);
|
||||
scrollPane.setViewportView(table);
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
btnNewButton.setFont(new Font("微软雅黑", Font.BOLD, 14));
|
||||
btnNewButton.setBounds(458, 10, 76, 27);
|
||||
panel_1.add(btnNewButton);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,198 @@
|
||||
package com.bqh.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.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.SwingConstants;
|
||||
|
||||
import com.system.entity.Score;
|
||||
import com.system.impl.Scoreimpl;
|
||||
|
||||
public class ScorebqhUpdate extends Bg {
|
||||
|
||||
private JPanel contentPane;
|
||||
private JTextField snoKeyField;
|
||||
private JTextField cnameKeyField;
|
||||
private JLabel snoLabel;
|
||||
private JLabel snameLabel;
|
||||
private JLabel cnameLabel;
|
||||
private JTextField sscoreField;
|
||||
private JTextField rescoreField;
|
||||
private String cno;
|
||||
|
||||
public ScorebqhUpdate(String a) {
|
||||
super(a);
|
||||
|
||||
JPanel panel_1 = new JPanel();
|
||||
panel_1.setBounds(165, 53, 752, 494);
|
||||
getContentPane().add(panel_1);
|
||||
panel_1.setLayout(null);
|
||||
panel_1.setBackground(Color.WHITE);
|
||||
|
||||
JLabel lblNewLabel_2 = new JLabel("修改成绩");
|
||||
lblNewLabel_2.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
lblNewLabel_2.setFont(new Font("微软雅黑", Font.BOLD, 18));
|
||||
lblNewLabel_2.setBounds(252, 28, 238, 30);
|
||||
panel_1.add(lblNewLabel_2);
|
||||
|
||||
JLabel lblNewLabel_1_4 = new JLabel("学号:");
|
||||
lblNewLabel_1_4.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
lblNewLabel_1_4.setFont(new Font("微软雅黑", Font.BOLD, 15));
|
||||
lblNewLabel_1_4.setBounds(92, 67, 61, 30);
|
||||
panel_1.add(lblNewLabel_1_4);
|
||||
|
||||
snoKeyField = new JTextField();
|
||||
snoKeyField.setColumns(10);
|
||||
snoKeyField.setBounds(145, 68, 163, 29);
|
||||
panel_1.add(snoKeyField);
|
||||
|
||||
JLabel lblNewLabel_1_1_1 = new JLabel("课程号:");
|
||||
lblNewLabel_1_1_1.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
lblNewLabel_1_1_1.setFont(new Font("微软雅黑", Font.BOLD, 15));
|
||||
lblNewLabel_1_1_1.setBounds(327, 68, 61, 30);
|
||||
panel_1.add(lblNewLabel_1_1_1);
|
||||
|
||||
cnameKeyField = new JTextField();
|
||||
cnameKeyField.setColumns(10);
|
||||
cnameKeyField.setBounds(388, 68, 163, 29);
|
||||
panel_1.add(cnameKeyField);
|
||||
|
||||
JButton btnNewButton_1 = new JButton("查询");
|
||||
btnNewButton_1.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
String snoKey = snoKeyField.getText();
|
||||
String cnameKey = cnameKeyField.getText();
|
||||
if (snoKey.equals("") || cnameKey.equals("")) {
|
||||
JOptionPane.showMessageDialog(null, "请输入完整的信息进行查询!");
|
||||
} else {
|
||||
Scoreimpl scoreDao = new Scoreimpl();
|
||||
Score score = new Score();
|
||||
|
||||
try {
|
||||
score = scoreDao.select(snoKey, cnameKey);
|
||||
} catch (SQLException e1) {
|
||||
// TODO Auto-generated catch block
|
||||
e1.printStackTrace();
|
||||
}
|
||||
if (score != null) {
|
||||
|
||||
snoLabel.setText(score.getSno());
|
||||
snameLabel.setText(score.getSname());
|
||||
cnameLabel.setText(score.getCname());
|
||||
sscoreField.setText(score.getSscore());
|
||||
rescoreField.setText(score.getRescore());
|
||||
cno = score.getCno();
|
||||
} else {
|
||||
JOptionPane.showMessageDialog(null, "查无此课程成绩信息!");
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
btnNewButton_1.setFont(new Font("微软雅黑", Font.BOLD, 14));
|
||||
btnNewButton_1.setBounds(579, 67, 76, 30);
|
||||
panel_1.add(btnNewButton_1);
|
||||
|
||||
JLabel lblNewLabel_1_2_1 = new JLabel("学生成绩信息如下:");
|
||||
lblNewLabel_1_2_1.setHorizontalAlignment(SwingConstants.LEFT);
|
||||
lblNewLabel_1_2_1.setFont(new Font("微软雅黑", Font.BOLD, 15));
|
||||
lblNewLabel_1_2_1.setBounds(92, 129, 163, 30);
|
||||
panel_1.add(lblNewLabel_1_2_1);
|
||||
|
||||
JLabel lblNewLabel_1_3_2 = new JLabel("学号:");
|
||||
lblNewLabel_1_3_2.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
lblNewLabel_1_3_2.setFont(new Font("微软雅黑", Font.BOLD, 15));
|
||||
lblNewLabel_1_3_2.setBounds(92, 169, 61, 30);
|
||||
panel_1.add(lblNewLabel_1_3_2);
|
||||
|
||||
JLabel lblNewLabel_1_3_1_1 = new JLabel("姓名:");
|
||||
lblNewLabel_1_3_1_1.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
lblNewLabel_1_3_1_1.setFont(new Font("微软雅黑", Font.BOLD, 15));
|
||||
lblNewLabel_1_3_1_1.setBounds(92, 209, 61, 30);
|
||||
panel_1.add(lblNewLabel_1_3_1_1);
|
||||
|
||||
JLabel lblNewLabel_1_3_1_2 = new JLabel("课程名:");
|
||||
lblNewLabel_1_3_1_2.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
lblNewLabel_1_3_1_2.setFont(new Font("微软雅黑", Font.BOLD, 15));
|
||||
lblNewLabel_1_3_1_2.setBounds(92, 259, 61, 30);
|
||||
panel_1.add(lblNewLabel_1_3_1_2);
|
||||
|
||||
JLabel lblNewLabel_1_3_1_3 = new JLabel("成绩:");
|
||||
lblNewLabel_1_3_1_3.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
lblNewLabel_1_3_1_3.setFont(new Font("微软雅黑", Font.BOLD, 15));
|
||||
lblNewLabel_1_3_1_3.setBounds(92, 309, 61, 30);
|
||||
panel_1.add(lblNewLabel_1_3_1_3);
|
||||
|
||||
JLabel lblNewLabel_1_3_1_4 = new JLabel("补考成绩:");
|
||||
lblNewLabel_1_3_1_4.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
lblNewLabel_1_3_1_4.setFont(new Font("微软雅黑", Font.BOLD, 15));
|
||||
lblNewLabel_1_3_1_4.setBounds(80, 357, 101, 30);
|
||||
panel_1.add(lblNewLabel_1_3_1_4);
|
||||
|
||||
snoLabel = new JLabel("");
|
||||
snoLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
snoLabel.setFont(new Font("微软雅黑", Font.BOLD, 15));
|
||||
snoLabel.setBounds(163, 169, 163, 30);
|
||||
panel_1.add(snoLabel);
|
||||
|
||||
snameLabel = new JLabel("");
|
||||
snameLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
snameLabel.setFont(new Font("微软雅黑", Font.BOLD, 15));
|
||||
snameLabel.setBounds(163, 209, 163, 30);
|
||||
panel_1.add(snameLabel);
|
||||
|
||||
cnameLabel = new JLabel("");
|
||||
cnameLabel.setHorizontalAlignment(SwingConstants.LEFT);
|
||||
cnameLabel.setFont(new Font("微软雅黑", Font.BOLD, 15));
|
||||
cnameLabel.setBounds(163, 259, 204, 30);
|
||||
panel_1.add(cnameLabel);
|
||||
|
||||
sscoreField = new JTextField();
|
||||
sscoreField.setBounds(163, 315, 204, 30);
|
||||
panel_1.add(sscoreField);
|
||||
sscoreField.setColumns(10);
|
||||
|
||||
rescoreField = new JTextField();
|
||||
rescoreField.setColumns(10);
|
||||
rescoreField.setBounds(163, 363, 204, 30);
|
||||
panel_1.add(rescoreField);
|
||||
|
||||
JButton btnNewButton_2 = new JButton("修改");
|
||||
btnNewButton_2.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
||||
String sno = snoLabel.getText();
|
||||
String sscore = sscoreField.getText();
|
||||
String rescore = rescoreField.getText();
|
||||
|
||||
Scoreimpl scoreDao = new Scoreimpl();
|
||||
boolean istrue = false;
|
||||
try {
|
||||
istrue = scoreDao.update(sno, cno, sscore, rescore);
|
||||
} catch (SQLException e1) {
|
||||
// TODO Auto-generated catch block
|
||||
e1.printStackTrace();
|
||||
}
|
||||
if (istrue) {
|
||||
JOptionPane.showMessageDialog(null, "更新成绩成功!");
|
||||
} else {
|
||||
JOptionPane.showMessageDialog(null, "更新成绩失败!");
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
btnNewButton_2.setBackground(Color.RED);
|
||||
btnNewButton_2.setForeground(Color.BLACK);
|
||||
btnNewButton_2.setFont(new Font("微软雅黑", Font.BOLD, 14));
|
||||
btnNewButton_2.setBounds(194, 418, 93, 39);
|
||||
panel_1.add(btnNewButton_2);
|
||||
}
|
||||
|
||||
}
|
||||
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.
@ -1,15 +0,0 @@
|
||||
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;
|
||||
}
|
||||
@ -1,83 +0,0 @@
|
||||
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 + '}';
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -1,167 +0,0 @@
|
||||
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);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -1,78 +0,0 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
@ -1,91 +0,0 @@
|
||||
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 等
|
||||
}
|
||||
@ -1,138 +0,0 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -1,176 +0,0 @@
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,58 +0,0 @@
|
||||
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);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,4 +0,0 @@
|
||||
module studentguanli {
|
||||
requires java.sql;
|
||||
requires java.desktop;
|
||||
}
|
||||
Loading…
Reference in new issue