Compare commits
No commits in common. 'course' and 'attendance' have entirely different histories.
course
...
attendance
@ -1,15 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="lib" path="D:/个人/下载/mysql-connector-java-8.0.16.jar">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
@ -1,17 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>kecheng</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>
|
||||
@ -1,14 +0,0 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=17
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=17
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
|
||||
org.eclipse.jdt.core.compiler.release=enabled
|
||||
org.eclipse.jdt.core.compiler.source=17
|
||||
@ -1,15 +0,0 @@
|
||||
package com.system.dao;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
import com.system.javaBean.Course;
|
||||
|
||||
public interface CourseDao {
|
||||
public Course selectByCno(int cno) throws SQLException;
|
||||
public List<Course> courseRes() throws Exception;
|
||||
public boolean insert(String cno, String cname, String ccredit, String ctime) throws SQLException;
|
||||
public boolean delete(String cno) throws SQLException;
|
||||
public Course select(String cno) throws SQLException;
|
||||
public boolean update(String cno, String cname, String ccredit, String ctime) throws SQLException;
|
||||
}
|
||||
@ -1,151 +0,0 @@
|
||||
package com.system.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.system.javaBean.Course;
|
||||
import com.system.utils.DB;
|
||||
|
||||
|
||||
public class Courseimpl {
|
||||
Connection conn = null;
|
||||
DB dataBase = new DB();
|
||||
|
||||
// 按照课程号进行查询
|
||||
public Course selectByCno(int cno) throws SQLException {
|
||||
conn = dataBase.getConnection();
|
||||
Statement stat = null;
|
||||
ResultSet rs = null;
|
||||
String sql = "SELECT * FROM course where Cno = " + cno;
|
||||
stat = conn.createStatement();
|
||||
rs = stat.executeQuery(sql);
|
||||
Course course = new Course();
|
||||
while (true) {
|
||||
if (rs.next()) {
|
||||
course.setCnum(rs.getString("Cnum"));
|
||||
course.setCno(rs.getString("Cno"));
|
||||
course.setCname(rs.getString("Cname"));
|
||||
course.setCcredit(rs.getString("Ccredit"));
|
||||
course.setCtime(rs.getString("Ctime"));
|
||||
} else
|
||||
break;
|
||||
}
|
||||
conn.close();
|
||||
return course;
|
||||
|
||||
}
|
||||
|
||||
//课程信息
|
||||
public List<Course> courseRes() throws Exception {
|
||||
List<Course> courses = new ArrayList<>();
|
||||
Course course;
|
||||
conn = dataBase.getConnection();
|
||||
Statement stat = null;
|
||||
ResultSet rs = null;
|
||||
stat = conn.createStatement();
|
||||
String sql = "SELECT * FROM course";
|
||||
rs = stat.executeQuery(sql);
|
||||
while (true) {
|
||||
if ( rs.next() ) {
|
||||
course = new Course();
|
||||
course.setCnum( rs.getString("Cnum") );
|
||||
course.setCno( rs.getString("Cno") );
|
||||
course.setCname( rs.getString("Cname") );
|
||||
course.setCcredit( rs.getString("Ccredit") );
|
||||
course.setCtime( rs.getString("Ctime") );
|
||||
courses.add(course);
|
||||
}else
|
||||
break;
|
||||
}
|
||||
conn.close();
|
||||
return courses;
|
||||
}
|
||||
|
||||
//增加课程
|
||||
public boolean insert(String cno, String cname, String ccredit, String ctime) throws SQLException {
|
||||
try {
|
||||
conn = dataBase.getConnection();
|
||||
Statement stat = null;
|
||||
stat = conn.createStatement();
|
||||
String sql = "SELECT * FROM course WHERE cno = '"+cno+"'";
|
||||
if ( stat.executeQuery(sql).next() ) {
|
||||
return false;
|
||||
}
|
||||
sql = "INSERT INTO course (cno,cname,ccredit,ctime)"
|
||||
+ " VALUES ( '"+cno+"','"+cname+"', '"+ccredit+"' ,'"+ctime+"')";
|
||||
if ( stat.executeUpdate(sql)==1 ){
|
||||
return true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
conn.close();
|
||||
return false;
|
||||
}
|
||||
|
||||
//删除课程
|
||||
public boolean delete(String cno) throws SQLException {
|
||||
try {
|
||||
conn = dataBase.getConnection();
|
||||
Statement stat = null;
|
||||
stat = conn.createStatement();
|
||||
String sql = "DELETE FROM course WHERE cno = '"+cno+"' ";
|
||||
if ( stat.executeUpdate(sql)==1 ){
|
||||
return true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
conn.close();
|
||||
return false;
|
||||
}
|
||||
|
||||
//查询课程
|
||||
public Course select(String cno) throws SQLException {
|
||||
try {
|
||||
conn = dataBase.getConnection();
|
||||
Statement stat = null;
|
||||
stat = conn.createStatement();
|
||||
ResultSet rs = null;
|
||||
Course course = null;
|
||||
String sql = "SELECT * FROM course WHERE cno = '"+cno+"' ";
|
||||
rs = stat.executeQuery(sql);
|
||||
if ( rs.next() ){
|
||||
course = new Course();
|
||||
course.setCno( rs.getString("Cno") );
|
||||
course.setCname( rs.getString("Cname") );
|
||||
course.setCcredit( rs.getString("Ccredit") );
|
||||
course.setCtime( rs.getString("Ctime") );
|
||||
return course;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
conn.close();
|
||||
return null;
|
||||
}
|
||||
|
||||
//更新课程
|
||||
public boolean update(String cno, String cname, String ccredit, String ctime) throws SQLException {
|
||||
try {
|
||||
conn = dataBase.getConnection();
|
||||
Statement stat = null;
|
||||
stat = conn.createStatement();
|
||||
String sql = "UPDATE course SET Cno = '"+cno+"', Cname = '"+cname+"', Ccredit = '"+ccredit+"', Ctime = '"+ctime+"' "
|
||||
+ "WHERE Cno = '"+cno+"' ";
|
||||
if ( stat.executeUpdate(sql)==1 ){
|
||||
return true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
conn.close();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -1,102 +0,0 @@
|
||||
package com.system.impl;
|
||||
|
||||
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 = "852456";
|
||||
// 数据库连接
|
||||
public static Connection con;
|
||||
|
||||
// 构造方法
|
||||
public DB() {
|
||||
try {
|
||||
// 加载驱动
|
||||
Class.forName("com.mysql.cj.jdbc.Driver");
|
||||
// 获取连接
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -1,70 +0,0 @@
|
||||
package com.system.javaBean;
|
||||
|
||||
public class Course {
|
||||
|
||||
private String cnum;
|
||||
private String cno;
|
||||
private String cname;
|
||||
private String ccredit;
|
||||
private String ctime;
|
||||
|
||||
public Course() {
|
||||
super();
|
||||
}
|
||||
|
||||
public Course(String cnum, String cno, String cname, String ccredit, String ctime) {
|
||||
super();
|
||||
this.cnum = cnum;
|
||||
this.cno = cno;
|
||||
this.cname = cname;
|
||||
this.ccredit = ccredit;
|
||||
this.ctime = ctime;
|
||||
}
|
||||
|
||||
public String getCnum() {
|
||||
return cnum;
|
||||
}
|
||||
|
||||
public void setCnum(String cnum) {
|
||||
this.cnum = cnum;
|
||||
}
|
||||
|
||||
public String getCno() {
|
||||
return cno;
|
||||
}
|
||||
|
||||
public void setCno(String cno) {
|
||||
this.cno = cno;
|
||||
}
|
||||
|
||||
public String getCname() {
|
||||
return cname;
|
||||
}
|
||||
|
||||
public void setCname(String cname) {
|
||||
this.cname = cname;
|
||||
}
|
||||
|
||||
public String getCcredit() {
|
||||
return ccredit;
|
||||
}
|
||||
|
||||
public void setCcredit(String ccredit) {
|
||||
this.ccredit = ccredit;
|
||||
}
|
||||
|
||||
public String getCtime() {
|
||||
return ctime;
|
||||
}
|
||||
|
||||
public void setCtime(String ctime) {
|
||||
this.ctime = ctime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Course [cnum=" + cnum + ", cno=" + cno + ", cname=" + cname + ", ccredit=" + ccredit + ", ctime="
|
||||
+ ctime + "]";
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,148 +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;
|
||||
private JPanel panel_2; // 学生模块
|
||||
private JPanel panel_3; // 成绩模块
|
||||
private JPanel panel_4; // 课程模块
|
||||
|
||||
/**
|
||||
* Launch the application.
|
||||
*/
|
||||
// public static void main(String[] args) {
|
||||
// EventQueue.invokeLater(new Runnable() {
|
||||
// public void run() {
|
||||
// try {
|
||||
// BgAdmin frame = new BgAdmin();
|
||||
// frame.setVisible(true);
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
/**
|
||||
* Create the frame.
|
||||
*/
|
||||
public Bg(String flag) {
|
||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
setBounds(100, 100, 933, 586);
|
||||
contentPane = new JPanel();
|
||||
contentPane.setBackground(Color.WHITE);
|
||||
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
setContentPane(contentPane);
|
||||
contentPane.setLayout(null);
|
||||
|
||||
JPanel panel = new JPanel();
|
||||
panel.setBackground(SystemColor.activeCaption);
|
||||
panel.setBounds(0, 0, 917, 53);
|
||||
contentPane.add(panel);
|
||||
panel.setLayout(null);
|
||||
|
||||
JLabel label = new JLabel("学生信息管理系统");
|
||||
label.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
label.setFont(new Font("微软雅黑", Font.BOLD, 16));
|
||||
label.setBounds(371, 10, 213, 33);
|
||||
panel.add(label);
|
||||
|
||||
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 = new JLabel("学生模块");
|
||||
lblNewLabel.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent arg0) {
|
||||
|
||||
if (flag.equals("admin")) {
|
||||
// 管理员端
|
||||
setVisible(false);
|
||||
new StudentOpetion("admin").setVisible(true);
|
||||
} else {
|
||||
// 学生端
|
||||
setVisible(false);
|
||||
new StudentOpetion("学生").setVisible(true);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
lblNewLabel.setFont(new Font("微软雅黑", Font.BOLD, 16));
|
||||
lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
lblNewLabel.setBounds(0, 0, 166, 58);
|
||||
panel_1.add(lblNewLabel);
|
||||
|
||||
JLabel lblNewLabel_1 = new JLabel("成绩模块");
|
||||
lblNewLabel_1.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
|
||||
if (flag.equals("admin")) {
|
||||
// 管理员端
|
||||
setVisible(false);
|
||||
new ScoreOperation("admin").setVisible(true);
|
||||
} else {
|
||||
// 学生端
|
||||
setVisible(false);
|
||||
new ScoreOperation("学生").setVisible(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
lblNewLabel_1.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
lblNewLabel_1.setFont(new Font("微软雅黑", Font.BOLD, 16));
|
||||
lblNewLabel_1.setBounds(0, 63, 166, 58);
|
||||
panel_1.add(lblNewLabel_1);
|
||||
|
||||
JLabel lblNewLabel_2 = new JLabel("课程模块");
|
||||
lblNewLabel_2.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
|
||||
if (flag.equals("admin")) {
|
||||
// 管理员端
|
||||
setVisible(false);
|
||||
new CourseOperation("admin").setVisible(true);
|
||||
} else {
|
||||
// 学生端
|
||||
setVisible(false);
|
||||
new CourseOperation("学生").setVisible(true);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
lblNewLabel_2.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
lblNewLabel_2.setFont(new Font("微软雅黑", Font.BOLD, 16));
|
||||
lblNewLabel_2.setBounds(0, 131, 166, 58);
|
||||
panel_1.add(lblNewLabel_2);
|
||||
|
||||
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, 199, 166, 58);
|
||||
panel_1.add(lblNewLabel_3);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,157 +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.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.SwingConstants;
|
||||
|
||||
import com.system.dao.CourseDao;
|
||||
|
||||
public class CourseAdd extends Bg {
|
||||
|
||||
private JPanel contentPane;
|
||||
private JTextField cnoField;
|
||||
private JTextField cnameField;
|
||||
private JTextField ccreditField;
|
||||
private JTextField ctimeField;
|
||||
|
||||
/**
|
||||
* Launch the application.
|
||||
*/
|
||||
// public static void main(String[] args) {
|
||||
// EventQueue.invokeLater(new Runnable() {
|
||||
// public void run() {
|
||||
// try {
|
||||
// CourseAdd frame = new CourseAdd();
|
||||
// frame.setVisible(true);
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
/**
|
||||
* Create the frame.
|
||||
*/
|
||||
public CourseAdd(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 panel = new JPanel();
|
||||
panel.setBackground(Color.WHITE);
|
||||
panel.setBounds(165, 52, 752, 495);
|
||||
getContentPane().add(panel);
|
||||
panel.setLayout(null);
|
||||
|
||||
JLabel lblNewLabel = new JLabel("添加课程");
|
||||
lblNewLabel.setFont(new Font("微软雅黑", Font.BOLD, 18));
|
||||
lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
lblNewLabel.setBounds(263, 47, 217, 37);
|
||||
panel.add(lblNewLabel);
|
||||
|
||||
JLabel lblNewLabel_1 = new JLabel("课程号:");
|
||||
lblNewLabel_1.setFont(new Font("微软雅黑", Font.BOLD, 16));
|
||||
lblNewLabel_1.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
lblNewLabel_1.setBounds(216, 94, 83, 37);
|
||||
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(216, 161, 83, 37);
|
||||
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(216, 229, 83, 37);
|
||||
panel.add(lblNewLabel_1_2);
|
||||
|
||||
JLabel lblNewLabel_1_2_1 = new JLabel("学时:");
|
||||
lblNewLabel_1_2_1.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
lblNewLabel_1_2_1.setFont(new Font("微软雅黑", Font.BOLD, 16));
|
||||
lblNewLabel_1_2_1.setBounds(216, 292, 83, 37);
|
||||
panel.add(lblNewLabel_1_2_1);
|
||||
|
||||
cnoField = new JTextField();
|
||||
cnoField.setBounds(297, 94, 271, 37);
|
||||
panel.add(cnoField);
|
||||
cnoField.setColumns(10);
|
||||
|
||||
cnameField = new JTextField();
|
||||
cnameField.setColumns(10);
|
||||
cnameField.setBounds(297, 161, 271, 37);
|
||||
panel.add(cnameField);
|
||||
|
||||
ccreditField = new JTextField();
|
||||
ccreditField.setColumns(10);
|
||||
ccreditField.setBounds(297, 229, 271, 37);
|
||||
panel.add(ccreditField);
|
||||
|
||||
ctimeField = new JTextField();
|
||||
ctimeField.setColumns(10);
|
||||
ctimeField.setBounds(297, 292, 271, 37);
|
||||
panel.add(ctimeField);
|
||||
|
||||
JButton btnNewButton = new JButton("添加");
|
||||
btnNewButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
||||
String cno = cnoField.getText();
|
||||
String cname = cnameField.getText();
|
||||
String ccredit = ccreditField.getText();
|
||||
String ctime = ctimeField.getText();
|
||||
|
||||
if (cno.equals("") || cname.equals("") || ccredit.equals("") || ctime.equals("")) {
|
||||
JOptionPane.showMessageDialog(null, "请输入完整的信息!");
|
||||
} else {
|
||||
|
||||
CourseDao courseDao = new CourseDao();
|
||||
boolean istrue = false;
|
||||
try {
|
||||
istrue = courseDao.insert(cno, cname, ccredit, ctime);
|
||||
} 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(216, 374, 93, 37);
|
||||
panel.add(btnNewButton);
|
||||
|
||||
JButton btnNewButton_1 = new JButton("重置");
|
||||
btnNewButton_1.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
cnoField.setText("");
|
||||
cnameField.setText("");
|
||||
ccreditField.setText("");
|
||||
ctimeField.setText("");
|
||||
}
|
||||
});
|
||||
btnNewButton_1.setFont(new Font("微软雅黑", Font.BOLD, 14));
|
||||
btnNewButton_1.setBounds(514, 374, 93, 37);
|
||||
panel.add(btnNewButton_1);
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,104 +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.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.SwingConstants;
|
||||
|
||||
import com.system.dao.CourseDao;
|
||||
|
||||
public class CourseDelect extends Bg {
|
||||
|
||||
private JPanel contentPane;
|
||||
private JTextField keyField;
|
||||
|
||||
/**
|
||||
* Launch the application.
|
||||
*/
|
||||
// public static void main(String[] args) {
|
||||
// EventQueue.invokeLater(new Runnable() {
|
||||
// public void run() {
|
||||
// try {
|
||||
// CourseDelect frame = new CourseDelect();
|
||||
// frame.setVisible(true);
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
/**
|
||||
* Create the frame.
|
||||
*/
|
||||
public CourseDelect(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 panel = new JPanel();
|
||||
panel.setBackground(Color.WHITE);
|
||||
panel.setBounds(165, 54, 752, 493);
|
||||
getContentPane().add(panel);
|
||||
panel.setLayout(null);
|
||||
|
||||
JLabel lblNewLabel = new JLabel("删除课程");
|
||||
lblNewLabel.setFont(new Font("微软雅黑", Font.BOLD, 18));
|
||||
lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
lblNewLabel.setBounds(275, 55, 189, 33);
|
||||
panel.add(lblNewLabel);
|
||||
|
||||
JLabel lblNewLabel_1 = new JLabel("课程号:");
|
||||
lblNewLabel_1.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
lblNewLabel_1.setFont(new Font("微软雅黑", Font.BOLD, 16));
|
||||
lblNewLabel_1.setBounds(202, 120, 126, 33);
|
||||
panel.add(lblNewLabel_1);
|
||||
|
||||
keyField = new JTextField();
|
||||
keyField.setBounds(303, 120, 204, 33);
|
||||
panel.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 {
|
||||
|
||||
CourseDao course = new CourseDao();
|
||||
boolean flag = false;
|
||||
try {
|
||||
flag = course.delete(key);
|
||||
} catch (SQLException e1) {
|
||||
// TODO Auto-generated catch block
|
||||
e1.printStackTrace();
|
||||
}
|
||||
if (flag) {
|
||||
JOptionPane.showMessageDialog(null, "课程删除成功!");
|
||||
} else
|
||||
JOptionPane.showMessageDialog(null, "课程删除失败,请检查课程号是否正确!");
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
btnNewButton.setFont(new Font("微软雅黑", Font.BOLD, 14));
|
||||
btnNewButton.setBounds(525, 120, 102, 33);
|
||||
panel.add(btnNewButton);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,113 +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.JPanel;
|
||||
import javax.swing.SwingConstants;
|
||||
|
||||
public class CourseOperation extends Bg {
|
||||
|
||||
private JPanel contentPane;
|
||||
|
||||
/**
|
||||
* Launch the application.
|
||||
*/
|
||||
// public static void main(String[] args) {
|
||||
// EventQueue.invokeLater(new Runnable() {
|
||||
// public void run() {
|
||||
// try {
|
||||
// CourseOperation frame = new CourseOperation();
|
||||
// frame.setVisible(true);
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
/**
|
||||
* Create the frame.
|
||||
*/
|
||||
public CourseOperation(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);
|
||||
|
||||
JLabel lblNewLabel = new JLabel("课程相关操作");
|
||||
lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
lblNewLabel.setFont(new Font("微软雅黑", Font.BOLD, 18));
|
||||
lblNewLabel.setBounds(370, 94, 352, 43);
|
||||
getContentPane().add(lblNewLabel);
|
||||
|
||||
JButton btnNewButton = new JButton("查询课程");
|
||||
btnNewButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
setVisible(true);
|
||||
new CourseSelect().setVisible(true);
|
||||
}
|
||||
});
|
||||
btnNewButton.setFont(new Font("微软雅黑", Font.BOLD, 16));
|
||||
btnNewButton.setBounds(353, 174, 148, 37);
|
||||
getContentPane().add(btnNewButton);
|
||||
|
||||
JButton btnNewButton_1 = new JButton("添加课程");
|
||||
btnNewButton_1.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
||||
if (a.equals("学生")) {
|
||||
JOptionPane.showMessageDialog(null, "没有权限!");
|
||||
} else {
|
||||
setVisible(false);
|
||||
new CourseAdd(a).setVisible(true);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
btnNewButton_1.setFont(new Font("微软雅黑", Font.BOLD, 16));
|
||||
btnNewButton_1.setBounds(622, 174, 148, 37);
|
||||
getContentPane().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 CourseUpdate(a).setVisible(true);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
btnNewButton_2.setFont(new Font("微软雅黑", Font.BOLD, 16));
|
||||
btnNewButton_2.setBounds(353, 274, 148, 37);
|
||||
getContentPane().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 CourseDelect(a).setVisible(true);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
btnNewButton_3.setFont(new Font("微软雅黑", Font.BOLD, 16));
|
||||
btnNewButton_3.setBounds(622, 274, 148, 37);
|
||||
getContentPane().add(btnNewButton_3);
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,163 +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.dao.CourseDao;
|
||||
import com.system.entity.Course;
|
||||
|
||||
public class CourseSelect extends JFrame {
|
||||
|
||||
private JPanel contentPane;
|
||||
private JTextField keyField;
|
||||
private JTable table;
|
||||
private JScrollPane scrollPane;
|
||||
|
||||
/**
|
||||
* Launch the application.
|
||||
*/
|
||||
// public static void main(String[] args) {
|
||||
// EventQueue.invokeLater(new Runnable() {
|
||||
// public void run() {
|
||||
// try {
|
||||
// CourseSelect frame = new CourseSelect();
|
||||
// frame.setVisible(true);
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
/**
|
||||
* Create the frame.
|
||||
*/
|
||||
public CourseSelect() {
|
||||
setBounds(100, 100, 780, 486);
|
||||
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.add("序号");
|
||||
vector.add("课程号");
|
||||
vector.add("课程名");
|
||||
vector.add("学分");
|
||||
vector.add("学时");
|
||||
|
||||
Vector tData = new Vector();
|
||||
|
||||
JPanel panel = new JPanel();
|
||||
panel.setBackground(SystemColor.activeCaption);
|
||||
panel.setBounds(0, 0, 764, 45);
|
||||
contentPane.add(panel);
|
||||
panel.setLayout(null);
|
||||
|
||||
JLabel lblNewLabel = new JLabel("课程基本上信息");
|
||||
lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
lblNewLabel.setFont(new Font("微软雅黑", Font.BOLD, 16));
|
||||
lblNewLabel.setBounds(263, 10, 191, 25);
|
||||
panel.add(lblNewLabel);
|
||||
|
||||
JPanel panel_1 = new JPanel();
|
||||
panel_1.setBackground(Color.WHITE);
|
||||
panel_1.setBounds(0, 44, 764, 51);
|
||||
contentPane.add(panel_1);
|
||||
panel_1.setLayout(null);
|
||||
|
||||
JLabel lblNewLabel_1 = new JLabel("课程号:");
|
||||
lblNewLabel_1.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
lblNewLabel_1.setFont(new Font("微软雅黑", Font.BOLD, 14));
|
||||
lblNewLabel_1.setBounds(177, 10, 79, 31);
|
||||
panel_1.add(lblNewLabel_1);
|
||||
|
||||
keyField = new JTextField();
|
||||
keyField.setBounds(247, 10, 194, 31);
|
||||
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();
|
||||
int a = Integer.parseInt(key);
|
||||
CourseDao user = new CourseDao();
|
||||
try {
|
||||
Course course = user.selectByCno(a);
|
||||
Vector v = new Vector();
|
||||
v.add(course.getCnum());
|
||||
v.add(course.getCno());
|
||||
v.add(course.getCname());
|
||||
v.add(course.getCcredit());
|
||||
v.add(course.getCtime());
|
||||
tData.add(v);
|
||||
table = new JTable(tData, vector);
|
||||
scrollPane.setViewportView(table);
|
||||
|
||||
} catch (SQLException e1) {
|
||||
// TODO Auto-generated catch block
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
btnNewButton.setFont(new Font("微软雅黑", Font.BOLD, 14));
|
||||
btnNewButton.setBounds(451, 11, 79, 28);
|
||||
panel_1.add(btnNewButton);
|
||||
|
||||
scrollPane = new JScrollPane();
|
||||
scrollPane.setBounds(0, 94, 764, 353);
|
||||
contentPane.add(scrollPane);
|
||||
|
||||
|
||||
|
||||
|
||||
tData.clear();
|
||||
CourseDao user = new CourseDao();
|
||||
try {
|
||||
List<Course> list = user.courseRes();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
Vector v = new Vector();
|
||||
v.add(list.get(i).getCnum());
|
||||
v.add(list.get(i).getCno());
|
||||
v.add(list.get(i).getCname());
|
||||
v.add(list.get(i).getCcredit());
|
||||
v.add(list.get(i).getCtime());
|
||||
tData.add(v);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
table = new JTable(tData, vector);
|
||||
scrollPane.setViewportView(table);
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@ -1,190 +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.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.SwingConstants;
|
||||
|
||||
import com.system.dao.CourseDao;
|
||||
import com.system.entity.Course;
|
||||
|
||||
public class CourseUpdate extends Bg {
|
||||
|
||||
private JPanel contentPane;
|
||||
private JTextField keyField;
|
||||
private JTextField cnoField;
|
||||
private JTextField cnameField;
|
||||
private JTextField ccreditField;
|
||||
private JTextField ctimeField;
|
||||
|
||||
/**
|
||||
* Launch the application.
|
||||
*/
|
||||
// public static void main(String[] args) {
|
||||
// EventQueue.invokeLater(new Runnable() {
|
||||
// public void run() {
|
||||
// try {
|
||||
// CourseUpdate frame = new CourseUpdate();
|
||||
// frame.setVisible(true);
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
/**
|
||||
* Create the frame.
|
||||
*/
|
||||
public CourseUpdate(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 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(256, 38, 233, 38);
|
||||
panel.add(lblNewLabel);
|
||||
|
||||
JLabel lblNewLabel_1 = new JLabel("课程号:");
|
||||
lblNewLabel_1.setFont(new Font("微软雅黑", Font.BOLD, 16));
|
||||
lblNewLabel_1.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
lblNewLabel_1.setBounds(162, 89, 94, 28);
|
||||
panel.add(lblNewLabel_1);
|
||||
|
||||
keyField = new JTextField();
|
||||
keyField.setBounds(254, 86, 224, 37);
|
||||
panel.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 {
|
||||
CourseDao course = new CourseDao();
|
||||
Course c = new Course();
|
||||
try {
|
||||
c = course.select(key);
|
||||
} catch (SQLException e1) {
|
||||
// TODO Auto-generated catch block
|
||||
e1.printStackTrace();
|
||||
}
|
||||
if (c != null) {
|
||||
cnoField.setText(String.valueOf(c.getCno()));
|
||||
cnameField.setText(c.getCname());
|
||||
ccreditField.setText(c.getCcredit());
|
||||
ctimeField.setText(c.getCtime());
|
||||
} else {
|
||||
JOptionPane.showMessageDialog(null, "课程表里没有此课程的信息,无法修改!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
btnNewButton.setFont(new Font("微软雅黑", Font.BOLD, 14));
|
||||
btnNewButton.setBounds(496, 89, 93, 34);
|
||||
panel.add(btnNewButton);
|
||||
|
||||
JLabel lblNewLabel_2 = new JLabel("课程基本信息");
|
||||
lblNewLabel_2.setFont(new Font("微软雅黑", Font.BOLD, 16));
|
||||
lblNewLabel_2.setBounds(162, 156, 170, 28);
|
||||
panel.add(lblNewLabel_2);
|
||||
|
||||
JLabel lblNewLabel_3 = new JLabel("课程号:");
|
||||
lblNewLabel_3.setFont(new Font("微软雅黑", Font.BOLD, 16));
|
||||
lblNewLabel_3.setBounds(162, 211, 73, 28);
|
||||
panel.add(lblNewLabel_3);
|
||||
|
||||
JLabel lblNewLabel_3_1 = new JLabel("课程名:");
|
||||
lblNewLabel_3_1.setFont(new Font("微软雅黑", Font.BOLD, 16));
|
||||
lblNewLabel_3_1.setBounds(162, 271, 73, 28);
|
||||
panel.add(lblNewLabel_3_1);
|
||||
|
||||
JLabel lblNewLabel_3_2 = new JLabel("学分:");
|
||||
lblNewLabel_3_2.setFont(new Font("微软雅黑", Font.BOLD, 16));
|
||||
lblNewLabel_3_2.setBounds(162, 332, 73, 28);
|
||||
panel.add(lblNewLabel_3_2);
|
||||
|
||||
JLabel lblNewLabel_3_3 = new JLabel("学时:");
|
||||
lblNewLabel_3_3.setFont(new Font("微软雅黑", Font.BOLD, 16));
|
||||
lblNewLabel_3_3.setBounds(162, 389, 73, 28);
|
||||
panel.add(lblNewLabel_3_3);
|
||||
|
||||
cnoField = new JTextField();
|
||||
cnoField.setBounds(238, 208, 240, 38);
|
||||
panel.add(cnoField);
|
||||
cnoField.setColumns(10);
|
||||
|
||||
cnameField = new JTextField();
|
||||
cnameField.setColumns(10);
|
||||
cnameField.setBounds(238, 268, 240, 38);
|
||||
panel.add(cnameField);
|
||||
|
||||
ccreditField = new JTextField();
|
||||
ccreditField.setColumns(10);
|
||||
ccreditField.setBounds(238, 329, 240, 38);
|
||||
panel.add(ccreditField);
|
||||
|
||||
ctimeField = new JTextField();
|
||||
ctimeField.setColumns(10);
|
||||
ctimeField.setBounds(238, 386, 240, 38);
|
||||
panel.add(ctimeField);
|
||||
|
||||
JButton btnNewButton_1 = new JButton("修改");
|
||||
btnNewButton_1.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
String cno = cnoField.getText();
|
||||
String cname = cnameField.getText();
|
||||
String ccredit = ccreditField.getText();
|
||||
String ctime = ctimeField.getText();
|
||||
|
||||
if (cno.equals("") || cname.equals("") || ccredit.equals("") || ctime.equals("")) {
|
||||
JOptionPane.showMessageDialog(null, "请输入完整的信息!");
|
||||
} else {
|
||||
|
||||
CourseDao courseDao = new CourseDao();
|
||||
boolean istrue = false;
|
||||
try {
|
||||
istrue = courseDao.update(cno, cname, ccredit, ctime);
|
||||
} catch (SQLException e1) {
|
||||
// TODO Auto-generated catch block
|
||||
e1.printStackTrace();
|
||||
}
|
||||
if (istrue) {
|
||||
JOptionPane.showMessageDialog(null, "修改成功!");
|
||||
} else {
|
||||
JOptionPane.showMessageDialog(null, "修改失败,请检查输入信息是否正确!");
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
btnNewButton_1.setBackground(Color.RED);
|
||||
btnNewButton_1.setFont(new Font("微软雅黑", Font.BOLD, 14));
|
||||
btnNewButton_1.setBounds(280, 447, 136, 38);
|
||||
panel.add(btnNewButton_1);
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,10 +0,0 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
/**
|
||||
*
|
||||
*/
|
||||
module kaoqin {
|
||||
requires java.sql;
|
||||
requires java.desktop;
|
||||
}
|
||||
Loading…
Reference in new issue