Compare commits
1 Commits
attendance
...
score
| Author | SHA1 | Date |
|---|---|---|
|
|
5498194af3 | 2 years ago |
@ -0,0 +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-1.8">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>bqhproject</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,12 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
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.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.release=enabled
|
||||
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,100 @@
|
||||
package com.bqh.untils;
|
||||
|
||||
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 Driver_name = "jdbc:mysql://localhost:3306/student_a?serverTimezone=Asia/Shanghai&useSSL=false";
|
||||
// 数据库用户名
|
||||
private String USER = "root"; // 这里需要修改为自己的用户名和密码
|
||||
// 数据库密码
|
||||
private String PASS = "123456";
|
||||
// 数据库连接
|
||||
public static Connection con;
|
||||
|
||||
// 构造方法
|
||||
public DB() {
|
||||
try {
|
||||
// 加载驱动
|
||||
Class.forName("com.mysql.cj.jdbc.Driver"); // 这个驱动是mysql8版本的
|
||||
// 获取连接
|
||||
con = DriverManager.getConnection(Driver_name, USER, PASS);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
// 获取连接
|
||||
public static Connection getConnection() {
|
||||
if (con == null) {
|
||||
new DB();
|
||||
}
|
||||
return con;
|
||||
}
|
||||
|
||||
// 释放连接
|
||||
public static void close(ResultSet resultSet, Statement statement, Connection connection) {
|
||||
|
||||
if (resultSet != null) {
|
||||
try {
|
||||
resultSet.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (statement != null) {
|
||||
try {
|
||||
statement.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (connection != null) {
|
||||
try {
|
||||
connection.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 释放连接
|
||||
public static void close(Statement statement, Connection connection) {
|
||||
|
||||
if (statement != null) {
|
||||
try {
|
||||
statement.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (connection != null) {
|
||||
try {
|
||||
connection.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 释放连接
|
||||
public static void close(Connection connection) {
|
||||
|
||||
if (connection != null) {
|
||||
try {
|
||||
connection.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in new issue