基于Java+MySQL+Swing的学生管理系统

1.系统简介和开发背景

        该同学工作积极主动、高效,学习认真,待人诚恳,能够做到服从指挥、认真听取老同志的指导,不怕苦、不怕累,表现有较强的求知欲,积极观察、体验、思考,并能够灵活运用自己的知识解决工作中遇到的实际问题。   

本项目使用:jdk1.8、java、mysql、eclipse/idea

2.功能分析

学生管理模块:

(1)增删改查学生信息,当学生还有学习的学员时,不能删除学生信息;

(2)按学生查询选择课程信息,支持名称模糊查询;

学员管理模块:

(1)增删改查学员信息;

(2)按学员名查询学员信息,支持学员名模糊查询和分页显示;

3.功能模块图及说明

        管理员新增学生信息时填写对应的信息,如姓名、课程号等。后台代码将在页面创建的信息提交到控制层进行数据验证,如果信息填写符合规则且数据唯一,则该数据将存储到本地数据库中,否则添加失败。管理员进行登录时首先点击跳转到管理员登录界面按钮,输入相应的信息点击登录。登录界面流程图如图4-1所示,添加学生功能流程图如图4-2所示。

 

4-1 登录界面流程图

                                               

4-2 添加学生功能流程图

        管理员修改学生职位信息时可以从快速搜索区,输入学生名称进行查询。按要求填写信息后保存,第一条数据为新添加的数据;管理员修改部门信息时,依次填写好对应的信息,后台代码将信息提交到控制层进行数据验证,验证通过则修改成功,数据存储到本地数据库里,否则失败。职位修改功能流程图如图4-3所示,添加部门功能流程图如图4-4所示。

   4-3 学生信息修改流程图

4-4 添加学生功能流程图

学生信息管理系统的主要模块包括增加、删除、修改和查询等操作,以下是这些操作的简单描述:

增加模块:该模块允许管理员将新的学生信息添加到系统中。这通常涉及到填写一个包含各种字段(例如姓名、性别、出生日期、学号、班级等)的表单。系统将检查输入的数据是否有效,例如,学号是否唯一,然后将其添加到数据库中。

删除模块:在此模块中,管理员可以选择并删除系统中的学生信息。例如,当一个学生转学或退学时,管理员可能需要从系统中删除他们的记录。

修改模块:此模块允许管理员更新系统中已有的学生信息。例如,如果学生的家庭地址发生变化,管理员可以通过此模块更新学生的家庭地址信息。在修改数据时,管理员需要确保数据的完整性和准确性。

查询模块:此模块允许管理员和学生查询系统中的学生信息。管理员可以查看学生的全部信息,而学生通常只能查看与他们自己相关的信息,例如他们的成绩、等。

4.部分代码展示

4.1数据库表设计

CREATE TABLE `admin` (`Aid` int(11) NOT NULL,`Aname` varchar(30) NOT NULL,`Apwd` varchar(10) NOT NULL,PRIMARY KEY (`Aid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8 COLLATE = CREATE TABLE `course` (`Cnum` int(11) NOT NULL AUTO_INCREMENT,`Cno` int(11) NOT NULL,`Cname` varchar(20) NOT NULL,`Ctime` int(11) NOT NULL,`Ccredit` int(11) NOT NULL,PRIMARY KEY (`Cnum`,`Cno`),KEY `Cname` (`Cname`),KEY `Cno` (`Cno`)
CREATE TABLE `score` (`Sno` int(11) NOT NULL,`Sname` varchar(20) NOT NULL,`Cno` int(11) NOT NULL,`Cname` varchar(20) DEFAULT NULL,`Sscore` decimal(10,0) DEFAULT '0',`Rescore` decimal(10,0) DEFAULT '0',PRIMARY KEY (`Sno`,`Cno`),KEY `Cname` (`Cname`),KEY `Cno` (`Cno`),KEY `Sname` (`Sname`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;-- ----------------------------
-- Table structure for user_train_re   //学生,用户联系表
-- ----------------------------
CREATE TABLE `student` (`Sno` int(11) NOT NULL,`Sname` varchar(30) NOT NULL,`Sgender` char(2) NOT NULL,`Sage` int(11) NOT NULL,`Sbirthday` datetime DEFAULT '1999-01-01 00:00:00' ON UPDATE CURRENT_TIMESTAMP,`Sclass` varchar(10) NOT NULL,`Smajor` varchar(20) NOT NULL,`Sdept` varchar(20) NOT NULL,`Spwd` varchar(10) NOT NULL DEFAULT '123',PRIMARY KEY (`Sno`),KEY `Sname` (`Sname`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

4.2后台管理界面设计

登录

package com.system.view;import java.awt.EventQueue;
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.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.border.EmptyBorder;import com.system.dao.StudentDao;
import com.system.dao.UserDao;public class Login extends JFrame {private JPanel contentPane;private JTextField usernameField;private JPasswordField passwordField;private JComboBox comboBox;/*** Launch the application. */public static void main(String[] args) {EventQueue.invokeLater(new Runnable() {public void run() {try {Login frame = new Login();frame.setVisible(true);} catch (Exception e) {e.printStackTrace();}}});}/*** Create the frame.*/public Login() {setTitle("学生信息管理系统");setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);setBounds(100, 100, 689, 428);contentPane = new JPanel();contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));setContentPane(contentPane);contentPane.setLayout(null);JPanel panel = new JPanel();panel.setBounds(0, 0, 673, 389);contentPane.add(panel);panel.setLayout(null);JLabel lblNewLabel = new JLabel("学生信息管理系统");lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER);lblNewLabel.setFont(new Font("微软雅黑", Font.BOLD, 18));lblNewLabel.setBounds(114, 36, 393, 55);panel.add(lblNewLabel);JLabel lblNewLabel_1 = new JLabel("用户名:");lblNewLabel_1.setHorizontalAlignment(SwingConstants.CENTER);lblNewLabel_1.setFont(new Font("微软雅黑", Font.BOLD, 16));lblNewLabel_1.setBounds(106, 112, 145, 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(106, 173, 145, 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(106, 242, 145, 31);panel.add(lblNewLabel_1_2);usernameField = new JTextField();usernameField.setBounds(227, 112, 249, 37);panel.add(usernameField);usernameField.setColumns(10);passwordField = new JPasswordField();passwordField.setBounds(227, 170, 249, 37);panel.add(passwordField);String[] a = new String[] { "管理员", "学生" };comboBox = new JComboBox(a);comboBox.setBounds(227, 237, 249, 42);panel.add(comboBox);JButton btnNewButton = new JButton("登录");btnNewButton.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent arg0) {// 获取文本框数据String username = usernameField.getText();String password = passwordField.getText();String type = (String) comboBox.getSelectedItem();// 判断是否为空if (username.equals("") || password.equals("")) {JOptionPane.showMessageDialog(null, "用户名或密码不能为空!");} else {if ("管理员".equals(type)) {// 管理员登录try {UserDao log = new UserDao();boolean istrue = log.LoginCheck(username, password);if (istrue) {JOptionPane.showMessageDialog(null, "登录成功!");String a = "admin";setVisible(false);new Bg(a).setVisible(true);} else {JOptionPane.showMessageDialog(null, "用户名或密码错误!");}} catch (SQLException e1) {e1.printStackTrace();}} else {// 学生登录try {StudentDao log = new StudentDao();boolean istrue = log.LoginCheck(username, password);if (istrue) {JOptionPane.showMessageDialog(null, "登录成功!");String a = "学生"; // 不可修改,控制权限!setVisible(false);new Bg(a).setVisible(true);} else {JOptionPane.showMessageDialog(null, "用户名或密码错误!");}} catch (SQLException e1) {e1.printStackTrace();}}}}});btnNewButton.setFont(new Font("微软雅黑", Font.BOLD, 14));btnNewButton.setBounds(132, 308, 108, 37);panel.add(btnNewButton);JButton btnNewButton_1 = new JButton("重置");btnNewButton_1.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent arg0) {usernameField.setText("");passwordField.setText("");}});btnNewButton_1.setFont(new Font("微软雅黑", Font.BOLD, 14));btnNewButton_1.setBounds(399, 308, 108, 37);panel.add(btnNewButton_1);}
}

查询操作

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.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.UserDao;
import com.system.entity.Student;public class StudentSelect 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 {// StudentSelect frame = new StudentSelect();// frame.setVisible(true);// } catch (Exception e) {// e.printStackTrace();// }// }// });// }/*** Create the frame.*/public StudentSelect(String flag) {setTitle("学生信息管理系统");setBounds(100, 100, 845, 558);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, 848, 51);contentPane.add(panel);panel.setLayout(null);JLabel lblNewLabel = new JLabel("学生基本信息");lblNewLabel.setFont(new Font("微软雅黑", Font.BOLD, 16));lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER);lblNewLabel.setBounds(325, 10, 222, 31);panel.add(lblNewLabel);JPanel panel_1 = new JPanel();panel_1.setBackground(Color.WHITE);panel_1.setBounds(0, 49, 829, 51);contentPane.add(panel_1);panel_1.setLayout(null);JLabel lblNewLabel_1 = new JLabel("学号:");lblNewLabel_1.setFont(new Font("微软雅黑", Font.BOLD, 14));lblNewLabel_1.setBounds(225, 10, 54, 31);panel_1.add(lblNewLabel_1);// 表头final Vector vector = new Vector();vector.add("学号");vector.add("姓名");vector.add("性别");vector.add("年龄");vector.add("班级");vector.add("专业");vector.add("系别");// 表里面的数据Vector tData = new Vector();keyField = new JTextField();keyField.setBounds(273, 10, 190, 31);panel_1.add(keyField);keyField.setColumns(10);JButton btnNewButton = new JButton("查询");btnNewButton.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent arg0) {// 根据学号查询学生String key = keyField.getText();if (key.equals("")) {JOptionPane.showMessageDialog(null, "学号不能为空!");} else {try {UserDao user = new UserDao();List<Student> list = user.Select(key, null);tData.clear();for (int i = 0; i < list.size(); i++) {Vector v = new Vector();v.add(list.get(i).getSno());v.add(list.get(i).getName());v.add(list.get(i).getGender());v.add(list.get(i).getAge());v.add(list.get(i).getClas());v.add(list.get(i).getMajor());v.add(list.get(i).getDept());tData.add(v);}table = new JTable(tData, vector);scrollPane.setViewportView(table);// table = new JTable(tData, vector);} catch (Exception e) {// TODO Auto-generated catch blocke.printStackTrace();}}}});btnNewButton.setFont(new Font("微软雅黑", Font.BOLD, 14));btnNewButton.setBounds(483, 10, 67, 31);panel_1.add(btnNewButton);scrollPane = new JScrollPane();scrollPane.setBounds(0, 98, 829, 421);contentPane.add(scrollPane);try {UserDao user = new UserDao();List<Student> list = user.res();tData.clear();for (int i = 0; i < list.size(); i++) {Vector v = new Vector();v.add(list.get(i).getSno());v.add(list.get(i).getName());v.add(list.get(i).getGender());v.add(list.get(i).getAge());v.add(list.get(i).getClas());v.add(list.get(i).getMajor());v.add(list.get(i).getDept());tData.add(v);}} catch (Exception e) {// TODO Auto-generated catch blocke.printStackTrace();}table = new JTable(tData, vector);scrollPane.setViewportView(table);}
}

添加操作

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.JComboBox;
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.dao.UserDao;public class StudentAdd extends JFrame {private JPanel contentPane;private JTextField snoField;private JTextField snameField;private JTextField sageField;private JTextField sclassField;private JTextField smajorField;private JTextField sdeptField;private JComboBox comboBox;/*** Launch the application.*/// public static void main(String[] args) {// EventQueue.invokeLater(new Runnable() {// public void run() {// try {// StudentAdd frame = new StudentAdd();// frame.setVisible(true);// } catch (Exception e) {// e.printStackTrace();// }// }// });// }/*** Create the frame.*/public StudentAdd(String admin) {setBounds(100, 100, 723, 506);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, 707, 467);contentPane.add(panel);panel.setLayout(null);JLabel lblNewLabel = new JLabel("添加学生");lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER);lblNewLabel.setFont(new Font("微软雅黑", Font.BOLD, 16));lblNewLabel.setBounds(237, 28, 172, 36);panel.add(lblNewLabel);JLabel lblNewLabel_1 = new JLabel("学号:");lblNewLabel_1.setFont(new Font("微软雅黑", Font.BOLD, 15));lblNewLabel_1.setHorizontalAlignment(SwingConstants.CENTER);lblNewLabel_1.setBounds(201, 81, 53, 30);panel.add(lblNewLabel_1);snoField = new JTextField();snoField.setBounds(267, 80, 194, 36);panel.add(snoField);snoField.setColumns(10);JLabel lblNewLabel_1_1 = new JLabel("姓名:");lblNewLabel_1_1.setHorizontalAlignment(SwingConstants.CENTER);lblNewLabel_1_1.setFont(new Font("微软雅黑", Font.BOLD, 15));lblNewLabel_1_1.setBounds(201, 129, 53, 30);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, 15));lblNewLabel_1_2.setBounds(201, 178, 53, 30);panel.add(lblNewLabel_1_2);JLabel lblNewLabel_1_3 = new JLabel("班级:");lblNewLabel_1_3.setHorizontalAlignment(SwingConstants.CENTER);lblNewLabel_1_3.setFont(new Font("微软雅黑", Font.BOLD, 15));lblNewLabel_1_3.setBounds(201, 231, 53, 30);panel.add(lblNewLabel_1_3);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(201, 277, 53, 30);panel.add(lblNewLabel_1_4);JLabel lblNewLabel_1_5 = new JLabel("系别:");lblNewLabel_1_5.setHorizontalAlignment(SwingConstants.CENTER);lblNewLabel_1_5.setFont(new Font("微软雅黑", Font.BOLD, 15));lblNewLabel_1_5.setBounds(201, 330, 53, 30);panel.add(lblNewLabel_1_5);JLabel lblNewLabel_1_6 = new JLabel("性别:");lblNewLabel_1_6.setHorizontalAlignment(SwingConstants.CENTER);lblNewLabel_1_6.setFont(new Font("微软雅黑", Font.BOLD, 15));lblNewLabel_1_6.setBounds(201, 381, 53, 30);panel.add(lblNewLabel_1_6);snameField = new JTextField();snameField.setColumns(10);snameField.setBounds(267, 126, 194, 36);panel.add(snameField);sageField = new JTextField();sageField.setColumns(10);sageField.setBounds(267, 177, 194, 36);panel.add(sageField);sclassField = new JTextField();sclassField.setColumns(10);sclassField.setBounds(267, 230, 194, 36);panel.add(sclassField);smajorField = new JTextField();smajorField.setColumns(10);smajorField.setBounds(267, 276, 194, 36);panel.add(smajorField);sdeptField = new JTextField();sdeptField.setColumns(10);sdeptField.setBounds(267, 329, 194, 36);panel.add(sdeptField);JButton btnNewButton = new JButton("添加");btnNewButton.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {String sno = snoField.getText();String sname = snameField.getText();String sage = sageField.getText();String sclass = sclassField.getText();String smajor = smajorField.getText();String sdept = sdeptField.getText();String sex = (String) comboBox.getSelectedItem();if (sno.equals("") || sname.equals("") || sage.equals("") || sclass.equals("") || smajor.equals("")|| sdept.equals("") || sex.equals("")) {JOptionPane.showMessageDialog(null, "信息不完整,请填写完整!");} else {UserDao userDao = new UserDao();try {boolean istrue = userDao.insert(sno, sname, sex, sage, sclass, smajor, sdept);if (istrue) {JOptionPane.showMessageDialog(null, "学生信息录入成功!");} else{JOptionPane.showMessageDialog(null, "学生录入失败,此学号已存在!");}} catch (SQLException e1) {// TODO Auto-generated catch blocke1.printStackTrace();}}}});btnNewButton.setFont(new Font("微软雅黑", Font.BOLD, 14));btnNewButton.setBounds(201, 427, 93, 30);panel.add(btnNewButton);JButton btnNewButton_1 = new JButton("重置");btnNewButton_1.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {snoField.setText("");snameField.setText("");sageField.setText("");sclassField.setText("");smajorField.setText("");sdeptField.setText("");}});btnNewButton_1.setFont(new Font("微软雅黑", Font.BOLD, 14));btnNewButton_1.setBounds(390, 427, 93, 30);panel.add(btnNewButton_1);String[] a = new String[] { "男", "女" };comboBox = new JComboBox(a);comboBox.setBounds(267, 381, 194, 27);panel.add(comboBox);}
}

修改操作

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.JComboBox;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.SwingConstants;import com.system.dao.UserDao;
import com.system.entity.Student;public class StudentUpdate extends Bg {private JPanel contentPane;private JTextField keyField;private JTextField snoField;private JTextField snameField;private JTextField sageField;private JTextField sclassField;private JTextField smajorField;private JTextField sdeptField;private JComboBox comboBox;/*** Launch the application.*/// public static void main(String[] args) {// EventQueue.invokeLater(new Runnable() {// public void run() {// try {// StudentUpdate frame = new StudentUpdate();// frame.setVisible(true);// } catch (Exception e) {// e.printStackTrace();// }// }// });// }/*** Create the frame.*/public StudentUpdate(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, 54, 751, 493);getContentPane().add(panel);panel.setLayout(null);JLabel lblNewLabel = new JLabel("修改学生信息");lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER);lblNewLabel.setFont(new Font("微软雅黑", Font.BOLD, 16));lblNewLabel.setBounds(270, 32, 214, 32);panel.add(lblNewLabel);JLabel lblNewLabel_1 = new JLabel("输入学号:");lblNewLabel_1.setFont(new Font("微软雅黑", Font.BOLD, 14));lblNewLabel_1.setBounds(140, 81, 81, 19);panel.add(lblNewLabel_1);keyField = new JTextField();keyField.setBounds(214, 81, 182, 21);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 {UserDao user = new UserDao();Student stu = new Student();try {stu = user.select(key);} catch (SQLException e1) {// TODO Auto-generated catch blocke1.printStackTrace();}if (stu != null) {snoField.setText(String.valueOf(stu.getSno()));snameField.setText(stu.getName());sageField.setText(String.valueOf(stu.getAge()));sclassField.setText(stu.getClas());smajorField.setText(stu.getMajor());sdeptField.setText(stu.getDept());comboBox.setSelectedItem(stu.getGender());} else {JOptionPane.showMessageDialog(null, "查无此生!");}}}});btnNewButton.setFont(new Font("微软雅黑", Font.BOLD, 14));btnNewButton.setBounds(429, 77, 75, 26);panel.add(btnNewButton);JLabel lblNewLabel_2 = new JLabel("查询学生是否存在!");lblNewLabel_2.setHorizontalAlignment(SwingConstants.CENTER);lblNewLabel_2.setForeground(Color.RED);lblNewLabel_2.setFont(new Font("微软雅黑", Font.BOLD, 13));lblNewLabel_2.setBounds(224, 110, 172, 19);panel.add(lblNewLabel_2);JLabel lblNewLabel_3 = new JLabel("学生基本信息:");lblNewLabel_3.setFont(new Font("微软雅黑", Font.BOLD, 16));lblNewLabel_3.setBounds(140, 151, 182, 19);panel.add(lblNewLabel_3);JLabel lblNewLabel_4 = new JLabel("学号:");lblNewLabel_4.setFont(new Font("微软雅黑", Font.BOLD, 14));lblNewLabel_4.setBounds(140, 193, 53, 21);panel.add(lblNewLabel_4);snoField = new JTextField();snoField.setBounds(190, 188, 227, 32);panel.add(snoField);snoField.setColumns(10);JLabel lblNewLabel_4_1 = new JLabel("姓名:");lblNewLabel_4_1.setFont(new Font("微软雅黑", Font.BOLD, 14));lblNewLabel_4_1.setBounds(140, 239, 53, 21);panel.add(lblNewLabel_4_1);snameField = new JTextField();snameField.setColumns(10);snameField.setBounds(190, 235, 227, 32);panel.add(snameField);JLabel lblNewLabel_4_1_1 = new JLabel("年龄:");lblNewLabel_4_1_1.setFont(new Font("微软雅黑", Font.BOLD, 14));lblNewLabel_4_1_1.setBounds(140, 284, 53, 21);panel.add(lblNewLabel_4_1_1);sageField = new JTextField();sageField.setColumns(10);sageField.setBounds(190, 277, 227, 32);panel.add(sageField);sclassField = new JTextField();sclassField.setColumns(10);sclassField.setBounds(190, 319, 227, 32);panel.add(sclassField);JLabel lblNewLabel_4_1_1_1 = new JLabel("班级:");lblNewLabel_4_1_1_1.setFont(new Font("微软雅黑", Font.BOLD, 14));lblNewLabel_4_1_1_1.setBounds(140, 327, 53, 21);panel.add(lblNewLabel_4_1_1_1);JLabel lblNewLabel_4_1_1_1_1 = new JLabel("班级:");lblNewLabel_4_1_1_1_1.setFont(new Font("微软雅黑", Font.BOLD, 14));lblNewLabel_4_1_1_1_1.setBounds(140, 327, 53, 21);panel.add(lblNewLabel_4_1_1_1_1);JLabel lblNewLabel_4_1_1_1_2 = new JLabel("专业:");lblNewLabel_4_1_1_1_2.setFont(new Font("微软雅黑", Font.BOLD, 14));lblNewLabel_4_1_1_1_2.setBounds(140, 373, 53, 21);panel.add(lblNewLabel_4_1_1_1_2);smajorField = new JTextField();smajorField.setColumns(10);smajorField.setBounds(190, 369, 227, 32);panel.add(smajorField);JLabel lblNewLabel_4_1_1_1_2_1 = new JLabel("系别:");lblNewLabel_4_1_1_1_2_1.setFont(new Font("微软雅黑", Font.BOLD, 14));lblNewLabel_4_1_1_1_2_1.setBounds(140, 416, 53, 21);panel.add(lblNewLabel_4_1_1_1_2_1);sdeptField = new JTextField();sdeptField.setColumns(10);sdeptField.setBounds(190, 411, 227, 32);panel.add(sdeptField);JLabel lblNewLabel_4_1_1_1_2_1_1 = new JLabel("性别:");lblNewLabel_4_1_1_1_2_1_1.setFont(new Font("微软雅黑", Font.BOLD, 14));lblNewLabel_4_1_1_1_2_1_1.setBounds(140, 462, 53, 21);panel.add(lblNewLabel_4_1_1_1_2_1_1);String[] b = new String[] { "男", "女" };comboBox = new JComboBox(b);comboBox.setBounds(190, 453, 227, 30);panel.add(comboBox);JButton btnNewButton_1 = new JButton("保存");btnNewButton_1.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {String sno = snoField.getText();String sname = snameField.getText();String sage = sageField.getText();String sclass = sclassField.getText();String smajor = smajorField.getText();String sdept = sdeptField.getText();String sex = (String) comboBox.getSelectedItem();UserDao userDao = new UserDao();try {boolean flag = userDao.update(sno, sname, sex, sage, sclass, smajor, sdept);if (flag) {JOptionPane.showMessageDialog(null, "修改成功!");} else {JOptionPane.showMessageDialog(null, "修改失败!");}} catch (SQLException e1) {// TODO Auto-generated catch blocke1.printStackTrace();}}});btnNewButton_1.setFont(new Font("微软雅黑", Font.BOLD, 14));btnNewButton_1.setBounds(474, 453, 93, 30);panel.add(btnNewButton_1);}}

删除操作

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.JTextField;
import javax.swing.SwingConstants;import com.system.dao.UserDao;public class StudentDelete 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 {// StudentDelete frame = new StudentDelete();// frame.setVisible(true);// } catch (Exception e) {// e.printStackTrace();// }// }// });// }/*** Create the frame.*/public StudentDelete(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(442, 113, 227, 37);getContentPane().add(lblNewLabel);JLabel lblNewLabel_1 = new JLabel("输入学号:");lblNewLabel_1.setHorizontalAlignment(SwingConstants.CENTER);lblNewLabel_1.setFont(new Font("微软雅黑", Font.BOLD, 16));lblNewLabel_1.setBounds(402, 197, 81, 27);getContentPane().add(lblNewLabel_1);keyField = new JTextField();keyField.setBounds(485, 193, 184, 37);getContentPane().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 {UserDao user = new UserDao();try {if (user.delete(key)) {JOptionPane.showMessageDialog(null, "删除学生成功!");} else {JOptionPane.showMessageDialog(null, "删除学生失败,请检查该学号是否正确!");}} catch (Exception e1) {}}}});btnNewButton.setFont(new Font("微软雅黑", Font.BOLD, 14));btnNewButton.setBounds(696, 193, 102, 37);getContentPane().add(btnNewButton);}}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/pingmian/16596.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

自养号测评是什么?亚马逊、沃尔玛、Target卖家如何建立自己的护城河?

近期有跨境卖家咨询我自养买家账号测评的事情&#xff0c;他们还是有不了解自养号测评的&#xff0c;所以珑哥觉得有必要再讲一下卖家测评的一些事情&#xff0c;之前文章也说过。这可能是跨境卖家运营的一个趋势。今天珑哥着重来介绍一下自养号测评 一、什么叫做自养号测评&a…

OrangePi AIpro初体验之图片视频检测案例真实测评

OrangePi AIpro简介 OrangePi AIpro官网 Orange Pi AI Pro 开发板是香橙派联合华为精心打造的高性能AI 开发板&#xff0c;其搭载了昇腾AI 处理器&#xff0c;可提供8TOPS INT8 的计算能力&#xff0c;内存提供了8GB 和16GB两种版本。可以实现图像、视频等多种数据分析与推理…

全球点赞最高的人颜廷利:真正的人生目标是什么

在那个充满生机的2024年春天&#xff0c;记者有幸对中国第一起名大师的老师颜廷利教授进行了深入的访谈。带着对其人生哲学的强烈好奇&#xff0c;记者紧张而期待地提出了问题&#xff1a;“颜教授&#xff0c;您在漫长的人生旅途中最追求的是什么&#xff1f;” 宁夏银川、山东…

PMP考试没有考过应该如何再考?

一、接受失败&#xff0c;理性分析 其实&#xff0c;PMP考试可以在PMI一年有效期内提交补考申请&#xff0c;若已经过了一年有效期&#xff0c;考生则需要重新进行完整的PMP考试报名流程。PMP考试补考费用&#xff1a;2500元/次。 1.接受失败&#xff1a;接受并处理情绪。面对…

【Python数据分析】基于自回归积分滑动平均模型的疫情分析报告 附完整python代码

资源地址&#xff1a;Python数据分析大作业 2000字 图文分析文档 疫情分析完整python代码 数据分析 数据来自法国疫情数据 资源地址&#xff1a;Python数据分析大作业 2000字 图文分析文档 疫情分析完整python代码 代码详解 完整代码文件 主要是对时间序列数据进行分析和预…

技术面‍:前端代码是如何与服务器交互的

前言&#xff1a; 本篇文章主要是想讲解 .html 文件和 .CSS 文件在实际开发中和后端服务器交互最后上线的基础原理。 面向的人群&#x1f195;&#xff1a;是刚入行不久&#xff0c;且目前只会写前端业务代码而不清楚整个工作流的前端新人。我会从 0 开始一步一步带你理解整个…

大规模敏捷SA(Leading SAFe)证书是什么意思?如何报名,含金量高吗?

大规模敏捷SA(Leading SAFe)证书是什么意思&#xff1f; 常规的敏捷框架适用于中小型项目团队&#xff0c;而且不具有扩展性。基于常规的敏捷框架&#xff0c;SAFe定义了一个可扩展的敏捷框架模型&#xff0c;它适用于大型团队的合作开发&#xff0c;可以提高团队之间的协作性…

【再探】设计模式—职责链模式、命令模式及迭代器模式

行为型设计模式研究系统在运行时对象之间的交互&#xff0c;进一步明确对象的职责。有职责链模式、命令模式、解释器模式、迭代器模式、中介者模式、备忘录模式、观察者模式、状态模式、策略模式、模板方法模式及访问模式共11种。 1 职责链模式 需求&#xff1a;1) 请求能被多…

如何使用golang自带工具对代码进行覆盖率测试

在 Go 语言中&#xff0c;测试代码覆盖率通常使用 go test 命令结合 -cover 和 -coverprofile 1. 基本代码覆盖率报告 在项目目录下运行以下命令 go test -cover这将在控制台输出一个代码覆盖率的百分比。但是&#xff0c;这种方式不会保存覆盖率数据&#xff08;可以指定目…

反对加征关税,特斯拉上海厂传减产20% | 百能云芯

特斯拉公司首席执行官马斯克近日在公开场合表达了对美国计划对中国电动车加征关税的反对立场&#xff0c;强调特斯拉不支持任何扭曲市场的举措。据知情人士透露&#xff0c;特斯拉上海工厂正计划在今年第二季度至少削减Model Y车型的产量20%&#xff0c;以应对市场需求的变化。…

C#读取.sql文件并执行文件中的sql脚本

有些时候我们需要在程序中编写读取sql脚本文件并执行这些sql语句&#xff0c;但是我们在有些时候会遇到读出来的sql语句不能执行&#xff0c;其实不能执行并不是你的sql脚本文件有错误&#xff0c;而是去执行sql语句的时候&#xff0c;C#代码里面执行sql语句的代码对sql里面的一…

低代码与人工智能:改变软件开发的未来

引言 在当今快速发展的科技时代&#xff0c;软件开发行业也在不断地创新和演进。其中&#xff0c;低代码开发和人工智能技术是两个备受关注的领域&#xff0c;低代码开发通过简化开发流程和降低编码难度&#xff0c;使得软件开发变得更加高效和便捷&#xff0c;而人工智能技术…

正宇软件:引领数字人大新纪元,开启甘肃人大代表履职新篇章

在数字化强国的主旋律之下&#xff0c;政府工作的数字化、智能化转型已成为提升治理效能、增强人民满意度的关键一环。在这个大背景下&#xff0c;正宇软件技术开发有限公司以其卓越的技术实力和丰富的行业经验&#xff0c;成为了政府信息化建设的杰出代表。甘肃省人大代表履职…

基于 Wireshark 分析 TCP 协议

一、TCP 协议 TCP&#xff08;Transmission Control Protocol&#xff09;是一种面向连接的、可靠的传输层协议。它在网络通信中扮演着重要的角色&#xff0c;用于保证数据的可靠传输。 TCP协议的特点如下&#xff1a; 1. 面向连接&#xff1a;在通信前需要先建立连接&#x…

Hunyuan-DiT环境搭建推理测试

引子 最近鹅厂竟然开源了一个多模态的大模型&#xff0c;之前分享福报厂的多模态视觉大模型&#xff08;Qwen-VL环境搭建&推理测试-CSDN博客&#xff09;感兴趣的可以移步。鹅厂开源的&#xff0c;我还是头一回部署。好的&#xff0c;那就让我们看看这个多模态视觉大模型有…

强化学习,第 3 部分:蒙特卡罗方法

文章目录 一、介绍二、关于此文章三、无模型方法与基于模型的方法四、V函数估计4.1 基本概念4.2 V-功能 五、Q 函数估计5.1 V函数概念5.2 优势5.3 Q函数 六、勘探与勘探的权衡七、结论 一、介绍 从赌场到人工智能&#xff1a;揭示蒙特卡罗方法在复杂环境中的强大功能    强化…

zstd库数据压缩与解压缩

在 Visual Studio 2019 中使用 C 的 zstd 库进行数据压缩与解压缩 在今天的博客中&#xff0c;我们将探讨如何在 Visual Studio 2019 中使用 zstd 库进行高效的数据压缩和解压缩。zstd&#xff08;也称为 Zstandard 或 zstd&#xff09;是由 Facebook 开发的开源压缩库&#x…

动手学深度学习22 池化层

动手学深度学习22 池化层 1. 池化层2. 实现3. QA 课本&#xff1a; https://zh-v2.d2l.ai/chapter_convolutional-neural-networks/pooling.html 视频&#xff1a; https://www.bilibili.com/video/BV1EV411j7nX/?spm_id_fromautoNext&vd_sourceeb04c9a33e87ceba9c9a2e5f0…

关于单元测试

关于单元测试的一些总结&#xff1a;

【408真题】2009-17

“接”是针对题目进行必要的分析&#xff0c;比较简略&#xff1b; “化”是对题目中所涉及到的知识点进行详细解释&#xff1b; “发”是对此题型的解题套路总结&#xff0c;并结合历年真题或者典型例题进行运用。 涉及到的知识全部来源于王道各科教材&#xff08;2025版&…