Eclipse+Java+Swing实现学生宿舍管理系统(1),2024年最新京东面试流程要走几天

先自我介绍一下,小编浙江大学毕业,去过华为、字节跳动等大厂,目前阿里P7

深知大多数程序员,想要提升技能,往往是自己摸索成长,但自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!

因此收集整理了一份《2024年最新Java开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友。
img
img
img
img
img
img

既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上Java开发知识点,真正体系化!

由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新

如果你需要这些资料,可以添加V获取:vip1024b (备注Java)
img

正文

public void setId(String id) {

this.id = id;

}

public String getUserName() {

return userName;

}

public void setUserName(String userName) {

this.userName = userName;

}

public String getUserPassword() {

return userPassword;

}

public void setUserPassword(String userPassword) {

this.userPassword = userPassword;

}

@Override

public String toString() {

return this.getUserName();

}

}

DMUtil.java


package com.sjsq.util;

import java.sql.Connection;

import java.sql.DriverManager;

/**

  • 数据库工具连接类

  • @author shuijianshiqing

  • @date 2020-09-01 07:03

*/

public class DMUtil {

// URL链接

private String url = “jdbc:mysql://localhost:3306/dormitory_management_swing?serverTimezone=UTC”;

// 账号

private String userName = “root”;

// 密码

private String userPassword = “admin”;

// JDBC驱动

private String jdbcName = “com.mysql.cj.jdbc.Driver”;

// 链接

public Connection getCon() throws Exception {

Class.forName(jdbcName);

Connection con = DriverManager.getConnection(url, userName, userPassword);

return con;

}

// 关闭链接

public void closeCon(Connection con) throws Exception {

if (con != null) {

con.close();

}

}

// 测试

public static void main(String[] args) {

DMUtil dmutil = new DMUtil();

Connection con = null;

try {

con = dmutil.getCon();

System.out.println(“数据库连接成功!”);

} catch (Exception e) {

e.printStackTrace();

} finally {

try {

dmutil.closeCon(con);

} catch (Exception e) {

e.printStackTrace();

}

}

}

}

StringUtil.java


package com.sjsq.util;

/**

  • 字符串工具类

  • @author shuijianshiqing

  • @date 2020-09-01 07:03

*/

public class StringUtil {

// 判断字符串是否是""

public static boolean isEmpty(String type) {

if (type.equals(“”)) {

return true;

} else {

return false;

}

}

// 判断字符串不为空

public static boolean isNotEmpty(String type) {

if (type != null && !type.equals(“”)) {

return true;

} else {

return false;

}

}

}

RoomDao.java


package com.sjsq.dao;

import java.sql.Connection;

import java.sql.PreparedStatement;

import java.sql.ResultSet;

import com.sjsq.model.Room;

import com.sjsq.util.StringUtil;

/**

  • 操作宿舍信息

  • @author shuijianshiqing

  • @date 2020-09-01 07:07

*/

public class RoomDao {

// 添加宿舍信息

public int roomAdd(Connection con, Room room) throws Exception {

String sql = “insert into room_message values(null,?,?)”;

PreparedStatement pstmt = con.prepareStatement(sql);

pstmt.setString(1, room.getMember());

pstmt.setString(2, room.getLeader());

return pstmt.executeUpdate();

}

// 查询宿舍信息

public ResultSet roomList(Connection con, Room room) throws Exception {

StringBuffer sb = new StringBuffer(“select * from room_message”);

if (StringUtil.isNotEmpty(room.getMember())) {

String member = room.getMember();

sb.append(" and member like ‘%" + room.getMember() + "%’");

}

PreparedStatement pstmt = con.prepareStatement(sb.toString().replaceFirst(“and”, “where”));

return pstmt.executeQuery();

}

// 修改宿舍信息

public int roomModify(Connection con, Room room) throws Exception {

String sql = “update room_message set member=?,leader=? where id=?”;

PreparedStatement pstmt = con.prepareStatement(sql);

pstmt.setString(1, room.getMember());

pstmt.setString(2, room.getLeader());

pstmt.setString(3, room.getId());

return pstmt.executeUpdate();

}

// 删除宿舍信息

public int roomDelete(Connection con, Room room) throws Exception {

String sql = “delete from room_message where member=?”;

PreparedStatement pstmt = con.prepareStatement(sql);

pstmt.setString(1, room.getMember());

return pstmt.executeUpdate();

}

}

UserDao.java


package com.sjsq.dao;

import java.sql.Connection;

import java.sql.PreparedStatement;

import java.sql.ResultSet;

import com.sjsq.model.User;

/**

  • 返回学生信息

  • @author shuijianshiqing

  • @date 2020-09-01 07:07

*/

public class UserDao {

// 登录

public User Login(Connection con, User user) throws Exception {

User currentuser = null;

String sql = “select * from d_user where userName=? and userPassword=?”;

PreparedStatement pstmt = con.prepareStatement(sql);

pstmt.setString(1, user.getUserName());

pstmt.setString(2, user.getUserPassword());

ResultSet rs = pstmt.executeQuery();

while (rs.next()) {

currentuser = new User();

currentuser.setUserName(rs.getString(“userName”));

currentuser.setUserPassword(rs.getString(“userPassword”));

}

return currentuser;

}

}

LoginFrm.java


package com.sjsq.view;

import java.awt.Font;

import java.sql.Connection;

import javax.swing.JLabel;

import javax.swing.JButton;

import javax.swing.JComboBox;

import javax.swing.JTextField;

import javax.swing.JPasswordField;

import javax.swing.ImageIcon;

import javax.swing.JOptionPane;

import javax.swing.UIManager;

import com.sjsq.dao.UserDao;

import com.sjsq.model.User;

import com.sjsq.util.DMUtil;

import com.sjsq.util.StringUtil;

/**

  • 登录界面

  • @author 刁雨健 dyj

  • @author shuijianshiqing

  • @date 2020-09-01 07:41

*/

public class LoginFrm extends javax.swing.JFrame {

private JLabel jLabel1;

private JLabel jLabel2;

private JLabel jLabel3;

private JLabel jLabel4;

private JButton jb_login;

private JButton jb_reset;

private JComboBox jcb_choose;

private JTextField userNameTxt;

private JPasswordField userPasswordTxt;

DMUtil dmutil = new DMUtil();

UserDao userdao = new UserDao();

/**

  • 创建窗体

*/

public LoginFrm() {

Font font = new Font(“Dialog”, Font.PLAIN, 12);

java.util.Enumeration keys = UIManager.getDefaults().keys();

while (keys.hasMoreElements()) {

Object key = keys.nextElement();

Object value = UIManager.get(key);

if (value instanceof javax.swing.plaf.FontUIResource) {

UIManager.put(key, font);

}

}

// 初始化

initComponents();

// 居中

this.setLocationRelativeTo(null);

this.filltable();

}

// 填充表格

private void filltable() {

User user1 = new User();

User user2 = new User();

user1.setUserName(“学生”);

user2.setUserName(“管理员”);

user1.setId(1 + “”);

user2.setId(2 + “”);

jcb_choose.addItem(user1);

jcb_choose.addItem(user2);

}

// 初始化

private void initComponents() {

jLabel1 = new JLabel(“General”, JLabel.CENTER);

jLabel2 = new JLabel();

jLabel3 = new JLabel();

userNameTxt = new JTextField();

userPasswordTxt = new JPasswordField();

jb_login = new JButton();

jb_reset = new JButton();

jcb_choose = new JComboBox();

jLabel4 = new JLabel();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

setTitle(“学生宿舍管理系统登录界面”);

setResizable(false);

jLabel1.setFont(new Font(“宋体”, 0, 24));

jLabel1.setText(“学生宿舍管理系统”);

// 用户名

jLabel2.setIcon(new ImageIcon(LoginFrm.class.getResource(“/images/user.png”)));

jLabel2.setText(“账号:”);

// 密码

jLabel3.setIcon(new ImageIcon(LoginFrm.class.getResource(“/images/password.png”)));

jLabel3.setText(“密码:”);

userNameTxt.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

userNameTxtActionPerformed(evt);

}

});

// 登录

jb_login.setIcon(new ImageIcon(LoginFrm.class.getResource(“/images/login.png”)));

jb_login.setText(“登录”);

jb_login.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jb_loginActionPerformed(evt);

}

});

// 重置

jb_reset.setIcon(new ImageIcon(LoginFrm.class.getResource(“/images/reset.png”))); // NOI18N

jb_reset.setText(“重置”);

jb_reset.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jb_resetActionPerformed(evt);

}

});

jLabel4.setIcon(new ImageIcon(LoginFrm.class.getResource(“/images/type.png”))); // NOI18N

jLabel4.setText(“用户类型:”);

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());

getContentPane().setLayout(layout);

layout.setHorizontalGroup(

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(layout.createSequentialGroup().addGap(103, 103, 103).addComponent(jLabel1)

.addContainerGap(58, Short.MAX_VALUE))

.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout

.createSequentialGroup().addGroup(layout.createParallelGroup(

javax.swing.GroupLayout.Alignment.TRAILING).addGroup(

layout.createSequentialGroup().addContainerGap().addComponent(

jLabel4).addGap(42, 42, 42).addComponent(jcb_choose,

javax.swing.GroupLayout.PREFERRED_SIZE, 111,

javax.swing.GroupLayout.PREFERRED_SIZE))

.addGroup(layout.createSequentialGroup()

.addGroup(layout.createParallelGroup(

javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(layout.createSequentialGroup().addGap(103, 103, 103)

.addGroup(layout.createParallelGroup(

javax.swing.GroupLayout.Alignment.TRAILING)

.addComponent(jLabel3).addComponent(jLabel2)))

.addGroup(layout

.createSequentialGroup().addGap(104, 104, 104)

.addComponent(jb_login)))

.addGroup(layout

.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(layout.createSequentialGroup().addGap(42, 42, 42)

.addGroup(layout.createParallelGroup(

javax.swing.GroupLayout.Alignment.LEADING)

.addComponent(userNameTxt,

javax.swing.GroupLayout.DEFAULT_SIZE,

111, Short.MAX_VALUE)

.addComponent(userPasswordTxt,

javax.swing.GroupLayout.DEFAULT_SIZE,

111, Short.MAX_VALUE)))

.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,

layout.createSequentialGroup().addPreferredGap(

javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addComponent(jb_reset).addGap(25, 25, 25)))))

.addGap(100, 100, 100)));

layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout

.createSequentialGroup().addGap(60, 60, 60).addComponent(jLabel1)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(jLabel2)

.addComponent(userNameTxt, javax.swing.GroupLayout.PREFERRED_SIZE,

javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

.addGap(27, 27, 27)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(jLabel3)

.addComponent(userPasswordTxt, javax.swing.GroupLayout.PREFERRED_SIZE,

javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

.addGap(27, 27, 27)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(jLabel4)

.addComponent(jcb_choose, javax.swing.GroupLayout.PREFERRED_SIZE,

javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

.addGap(34, 34, 34).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jb_login).addComponent(jb_reset))

.addContainerGap(34, Short.MAX_VALUE)));

pack();

}

// 登录事件监控

private void jb_loginActionPerformed(java.awt.event.ActionEvent evt) {

String userName = userNameTxt.getText();

String userPassword = new String(userPasswordTxt.getPassword());

if (StringUtil.isEmpty(userName)) {

JOptionPane.showMessageDialog(null, “用户名不能为空!”);

return;

} else if (StringUtil.isEmpty(userPassword)) {

JOptionPane.showMessageDialog(null, “密码不能为空!”);

return;

}

User user = new User(userName, userPassword);

Connection con = null;

try {

con = dmutil.getCon();

User currentuser = userdao.Login(con, user);

if (currentuser != null) {

User user1 = (User) jcb_choose.getSelectedItem();

String userright = user1.getUserName();

if (userright.equals(“管理员”)) {

this.dispose();

MainFrm main = new MainFrm();

main.setVisible(true);

} else if (userright.equals(“学生”)) {

this.dispose();

MainFrm2 main2 = new MainFrm2();

main2.setVisible(true);

} else {

JOptionPane.showMessageDialog(null, “用户名密码错误!”);

}

}

} catch (Exception e) {

JOptionPane.showInternalMessageDialog(null, “登陆失败”);

e.printStackTrace();

}

}

// 重置事件监控

private void jb_resetActionPerformed(java.awt.event.ActionEvent evt) {

this.userNameTxt.setText(“”);

this.userPasswordTxt.setText(“”);

}

private void userNameTxtActionPerformed(java.awt.event.ActionEvent evt) {

}

// 主函数

public static void main(String args[]) {

java.awt.EventQueue.invokeLater(new Runnable() {

public void run() {

new LoginFrm().setVisible(true);

}

});

}

}

MainFrm2.java


package com.sjsq.view;

import javax.swing.JDesktopPane;

import javax.swing.JMenu;

import javax.swing.JMenuBar;

import javax.swing.JMenuItem;

import javax.swing.JOptionPane;

/**

  • 学生主页面

  • @author shuijianshiqing

  • @date 2020-09-01 07:52

*/

public class MainFrm2 extends javax.swing.JFrame {

private JMenu jMenu1;

private JMenu jMenu3;

private JMenu jMenu2;

private JMenuBar jMenuBar1;

private JMenuItem jMenuItem1;

private JMenuItem jMenuItem2;

private JMenuItem jMenuItem3;

private JMenuItem jMenuItem4;

private JMenuItem jMenuItem5;

private JMenuItem jMenuItem6;

private JDesktopPane table;

/**

  • 创建窗体

*/

public MainFrm2() {

initComponents();

// 设置位置

setBounds(100, 200, 1050, 650);

// 居中显示

this.setLocationRelativeTo(null);

}

/**

  • 初始化窗体

*/

private void initComponents() {

table = new JDesktopPane();

jMenuBar1 = new JMenuBar();

jMenu1 = new JMenu();

jMenuItem2 = new JMenuItem();

jMenuItem3 = new JMenuItem();

jMenu2 = new JMenu();

jMenuItem1 = new JMenuItem();

jMenuItem4 = new JMenuItem();

jMenu3 = new JMenu();

jMenuItem5 = new JMenuItem();

jMenuItem6 = new JMenuItem();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

setTitle(“学生信息管理学生页面”);

// 设置导航栏

jMenu1.setText(“学生入住”);

jMenuItem2.setText(“办理入住”);

jMenuItem2.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jMenuItem2ActionPerformed(evt);

}

});

jMenu1.add(jMenuItem2);

jMenuItem3.setText(“信息修改”);

jMenuItem3.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jMenuItem3ActionPerformed(evt);

}

});

jMenu1.add(jMenuItem3);

jMenuBar1.add(jMenu1);

jMenu2.setText(“信息查询”);

jMenuItem1.setText(“寝室查询”);

jMenuItem1.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jMenuItem1ActionPerformed(evt);

}

});

jMenu2.add(jMenuItem1);

jMenuItem4.setText(“人员查询”);

jMenuItem4.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jMenuItem4ActionPerformed(evt);

}

});

jMenu2.add(jMenuItem4);

jMenuBar1.add(jMenu2);

jMenu3.setText(“帮助服务”);

jMenuItem5.setText(“关于系统”);

jMenu3.add(jMenuItem5);

jMenuItem6.setText(“退出系统”);

jMenuItem6.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jMenuItem6ActionPerformed(evt);

}

});

jMenu3.add(jMenuItem6);

jMenuBar1.add(jMenu3);

setJMenuBar(jMenuBar1);

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());

getContentPane().setLayout(layout);

layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addComponent(table, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE));

layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addComponent(table, javax.swing.GroupLayout.DEFAULT_SIZE, 277, Short.MAX_VALUE));

pack();

}

// 事件监控

private void jMenuItem6ActionPerformed(java.awt.event.ActionEvent evt) {

int a = JOptionPane.showConfirmDialog(null, “确定要退出?”);

if (a == 0) {

this.dispose();

}

}

private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {

RoomSearchInterFrm roomSearch = new RoomSearchInterFrm();

roomSearch.setVisible(true);

this.table.add(roomSearch);

}

private void jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) {

StudentSearchInterFrm StudentSearch = new StudentSearchInterFrm();

StudentSearch.setVisible(true);

this.table.add(StudentSearch);

}

private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {

StudentModifyInterFrm StudentModify = new StudentModifyInterFrm();

StudentModify.setVisible(true);

this.table.add(StudentModify);

}

private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {

StudentAddInterFrm Student = new StudentAddInterFrm();

Student.setVisible(true);

this.table.add(Student);

}

// 主函数

public static void main(String args[]) {

java.awt.EventQueue.invokeLater(new Runnable() {

public void run() {

new MainFrm2().setVisible(true);

}

});

}

}

RoomAddInterFrm.java


package com.sjsq.view;

import java.sql.Connection;

import javax.swing.JOptionPane;

import javax.swing.JTextField;

import javax.swing.JLabel;

import javax.swing.JButton;

import com.sjsq.dao.RoomDao;

import com.sjsq.model.Room;

import com.sjsq.util.DMUtil;

/**

  • 房间信息添加

  • @author shuijianshiqing

  • @date 2020-09-01 20:51

*/

public class RoomAddInterFrm extends javax.swing.JInternalFrame {

private JTextField dm_leader;

private JTextField dm_number;

private JLabel jLabel1;

private JLabel jLabel2;

private JLabel jLabel3;

private JButton jb_add;

private JButton jb_reset;

DMUtil dmutil = new DMUtil();

RoomDao roomdao = new RoomDao();

public RoomAddInterFrm() {

initComponents();

this.setLocation(200, 50);

}

private void initComponents() {

jLabel1 = new JLabel();

dm_number = new JTextField();

jLabel2 = new JLabel();

dm_leader = new JTextField();

jb_add = new JButton();

jb_reset = new JButton();

jLabel3 = new JLabel();

setClosable(true);

setIconifiable(true);

setTitle(“宿舍添加”);

jLabel1.setText(“宿舍号:”);

jLabel2.setText(“寝室长:”);

jb_add.setText(“添加”);

jb_add.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jb_addActionPerformed(evt);

}

});

jb_reset.setText(“重置”);

jb_reset.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jb_resetActionPerformed(evt);

}

});

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());

getContentPane().setLayout(layout);

layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout

.createSequentialGroup().addGap(150, 150, 150)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(layout.createSequentialGroup().addComponent(jLabel2)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addComponent(dm_leader, javax.swing.GroupLayout.DEFAULT_SIZE, 121, Short.MAX_VALUE))

.addGroup(layout.createSequentialGroup().addComponent(jLabel1)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addComponent(dm_number, javax.swing.GroupLayout.DEFAULT_SIZE, 121, Short.MAX_VALUE)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))

.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,

layout.createSequentialGroup().addComponent(jb_add).addGap(18, 18, 18)

.addComponent(jb_reset)))

.addGap(4, 4, 4).addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 170,

javax.swing.GroupLayout.PREFERRED_SIZE)

.addGap(25, 25, 25)));

layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout

.createSequentialGroup()

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING).addGroup(layout

.createSequentialGroup().addGap(29, 29, 29)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabel1).addComponent(dm_number, javax.swing.GroupLayout.PREFERRED_SIZE,

javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

.addGap(70, 70, 70)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabel2).addComponent(dm_leader, javax.swing.GroupLayout.PREFERRED_SIZE,

javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 91, Short.MAX_VALUE)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jb_reset).addComponent(jb_add)))

.addGroup(javax.swing.GroupLayout.Alignment.LEADING,

layout.createSequentialGroup().addGap(27, 27, 27).addComponent(jLabel3,

javax.swing.GroupLayout.PREFERRED_SIZE, 222,

javax.swing.GroupLayout.PREFERRED_SIZE)))

.addContainerGap(40, Short.MAX_VALUE)));

pack();

}

private void jb_addActionPerformed(java.awt.event.ActionEvent evt) {

String name = dm_number.getText();

String leader = dm_leader.getText();

Room room = new Room(name, leader);

Connection con = null;

try {

con = dmutil.getCon();

int a = roomdao.roomAdd(con, room);

if (a == 1) {

JOptionPane.showMessageDialog(null, “添加成功!”);

this.resetValue();

} else {

JOptionPane.showMessageDialog(null, “添加失败!”);

}

} catch (Exception e) {

JOptionPane.showMessageDialog(null, “添加失败!”);

e.printStackTrace();

} finally {

try {

dmutil.closeCon(con);

} catch (Exception e) {

e.printStackTrace();

}

}

}

private void resetValue() {

this.dm_leader.setText(“”);

this.dm_number.setText(“”);

}

private void jb_resetActionPerformed(java.awt.event.ActionEvent evt) {

this.dm_number.setText(“”);

this.dm_leader.setText(“”);

}

}

RoomDeleteInterFrm.java


package com.sjsq.view;

import java.sql.Connection;

import java.sql.ResultSet;

import java.util.Vector;

import javax.swing.JLabel;

import javax.swing.JScrollPane;

import javax.swing.JButton;

import javax.swing.JTextField;

import javax.swing.JTable;

import javax.swing.JOptionPane;

import javax.swing.table.DefaultTableModel;

import com.sjsq.dao.RoomDao;

import com.sjsq.model.Room;

import com.sjsq.util.DMUtil;

import com.sjsq.util.StringUtil;

/**

  • 删除房间信息

  • @author shuijianshiqing

  • @date 2020-09-01 20:40

*/

public class RoomDeleteInterFrm extends javax.swing.JInternalFrame {

// 定义变量

private JLabel jLabel1;

private JScrollPane jScrollPane1;

private JButton jb_delete;

private JButton jb_exit;

private JButton jb_search;

private JTextField roomNum;

private JTable table;

DMUtil dmutil = new DMUtil();

RoomDao roomdao = new RoomDao();

// 构造函数

public RoomDeleteInterFrm() {

initComponents();

this.setLocation(200, 50);

this.fillTable(new Room());

}

// 填充表格

private void fillTable(Room room) {

DefaultTableModel dtm = (DefaultTableModel) table.getModel();

dtm.setRowCount(0);

Connection con = null;

try {

con = dmutil.getCon();

ResultSet rs = roomdao.roomList(con, room);

while (rs.next()) {

Vector v = new Vector();

v.add(rs.getString(“id”));

v.add(rs.getString(“member”));

v.add(rs.getString(“leader”));

dtm.addRow(v);

}

} catch (Exception e) {

e.printStackTrace();

} finally {

try {

dmutil.closeCon(con);

} catch (Exception e) {

e.printStackTrace();

}

}

}

// 初始化

private void initComponents() {

jLabel1 = new JLabel();

roomNum = new JTextField();

jb_search = new JButton();

jScrollPane1 = new JScrollPane();

table = new JTable();

jb_delete = new JButton();

jb_exit = new JButton();

setClosable(true);

setIconifiable(true);

setTitle(“房间删除”);

jLabel1.setText(“房间号:”);

jb_search.setText(“查询”);

jb_search.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jb_searchActionPerformed(evt);

}

});

table.setModel(new javax.swing.table.DefaultTableModel(new Object[][] {

}, new String[] { “编号”, "寝室号 ", “寝室长” }) {

boolean[] canEdit = new boolean[] { false, false, false };

public boolean isCellEditable(int rowIndex, int columnIndex) {

return canEdit[columnIndex];

}

});

jScrollPane1.setViewportView(table);

jb_delete.setText(“删除”);

jb_delete.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jb_deleteActionPerformed(evt);

}

});

jb_exit.setText(“退出”);

jb_exit.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jb_exitActionPerformed(evt);

}

});

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());

getContentPane().setLayout(layout);

layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(layout.createSequentialGroup().addGap(64, 64, 64).addComponent(jLabel1).addGap(18, 18, 18)

.addComponent(roomNum, javax.swing.GroupLayout.PREFERRED_SIZE, 142,

javax.swing.GroupLayout.PREFERRED_SIZE)

.addGap(29, 29, 29).addComponent(jb_search).addContainerGap(41, Short.MAX_VALUE))

.addGroup(layout.createSequentialGroup().addGap(76, 76, 76).addComponent(jb_delete)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 123, Short.MAX_VALUE)

.addComponent(jb_exit).addGap(86, 86, 86))

.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,

layout.createSequentialGroup()

.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 379,

javax.swing.GroupLayout.PREFERRED_SIZE)

.addContainerGap()));

layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout

.createSequentialGroup().addGap(28, 28, 28)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(jb_search)

.addComponent(jLabel1).addComponent(roomNum, javax.swing.GroupLayout.PREFERRED_SIZE,

javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

.addGap(18, 18, 18)

.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 216,

javax.swing.GroupLayout.PREFERRED_SIZE)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 20, Short.MAX_VALUE)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(jb_delete)

.addComponent(jb_exit))

.addGap(27, 27, 27)));

pack();

}

private void jb_deleteActionPerformed(java.awt.event.ActionEvent evt) {

int row = this.table.getSelectedRow();

String member = (String) this.table.getValueAt(row, 1);

if (StringUtil.isEmpty(member)) {

JOptionPane.showMessageDialog(null, “请选择要删除的记录!”);

return;

}

int n = JOptionPane.showConfirmDialog(null, “确定要删除这条记录么”);

if (n == 0) {

Connection con = null;

try {

con = dmutil.getCon();

Room room = new Room(member);

int deleteNum = roomdao.roomDelete(con, room);

if (deleteNum == 1) {

JOptionPane.showMessageDialog(null, “删除成功”);

this.roomNum.setText(“”);

this.fillTable(new Room());

} else {

JOptionPane.showMessageDialog(null, “删除失败”);

}

} catch (Exception e) {

JOptionPane.showMessageDialog(null, “删除失败”);

e.printStackTrace();

} finally {

try {

dmutil.closeCon(con);

} catch (Exception e) {

e.printStackTrace();

}

}

}

}

private void jb_exitActionPerformed(java.awt.event.ActionEvent evt) {

int a = JOptionPane.showConfirmDialog(null, “确认要退出?”);

if (a == 0) {

this.dispose();

}

}

private void jb_searchActionPerformed(java.awt.event.ActionEvent evt) {

String member = roomNum.getText();

Room room = new Room(member);

this.fillTable(room);

}

}

RoomManagerInterFrm.java


package com.sjsq.view;

import java.sql.Connection;

import java.sql.ResultSet;

import java.util.Vector;

import javax.swing.JOptionPane;

import javax.swing.table.DefaultTableModel;

import javax.swing.JTextField;

import javax.swing.JLabel;

import javax.swing.JPanel;

import javax.swing.JScrollPane;

import javax.swing.JTable;

import com.sjsq.dao.RoomDao;

import com.sjsq.model.Room;

import com.sjsq.util.DMUtil;

public class RoomManagerInterFrm extends javax.swing.JInternalFrame {

private JTextField idTxt;

private JLabel jLabel1;

private JLabel jLabel2;

private JLabel jLabel3;

private JLabel jLabel4;

private JPanel jPanel1;

private JScrollPane jScrollPane1;

private javax.swing.JButton jb_exit;

private javax.swing.JButton jb_modify;

private javax.swing.JButton jb_search;

private JTextField roomNum;

private JTextField roomleader;

private JTextField roomnumber;

private JTable table;

DMUtil dmutil = new DMUtil();

RoomDao roomdao = new RoomDao();

public RoomManagerInterFrm() {

initComponents();

this.setLocation(200, 50);

this.fillTable(new Room());

}

private void fillTable(Room room) {

DefaultTableModel dtm = (DefaultTableModel) table.getModel();

dtm.setRowCount(0);

Connection con = null;

try {

con = dmutil.getCon();

ResultSet rs = roomdao.roomList(con, room);

while (rs.next()) {

Vector v = new Vector();

v.add(rs.getString(“id”));

v.add(rs.getString(“member”));

v.add(rs.getString(“leader”));

dtm.addRow(v);

}

} catch (Exception e) {

e.printStackTrace();

} finally {

try {

dmutil.closeCon(con);

} catch (Exception e) {

e.printStackTrace();

}

}

}

private void initComponents() {

jLabel1 = new JLabel();

roomNum = new JTextField();

jb_search = new javax.swing.JButton();

jScrollPane1 = new JScrollPane();

table = new JTable();

jPanel1 = new JPanel();

jLabel2 = new JLabel();

idTxt = new JTextField();

jLabel3 = new JLabel();

roomnumber = new JTextField();

jb_modify = new javax.swing.JButton();

jb_exit = new javax.swing.JButton();

jLabel4 = new JLabel();

roomleader = new JTextField();

setClosable(true);

setIconifiable(true);

setTitle(“宿舍信息修改”);

jLabel1.setText(“寝室号:”);

最后

现在其实从大厂招聘需求可见,在招聘要求上有高并发经验优先,包括很多朋友之前都是做传统行业或者外包项目,一直在小公司,技术搞的比较简单,没有怎么搞过分布式系统,但是现在互联网公司一般都是做分布式系统。

所以说,如果你想进大厂,想脱离传统行业,这些技术知识都是你必备的,下面自己手打了一份Java并发体系思维导图,希望对你有所帮助。

网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。

需要这份系统化的资料的朋友,可以添加V获取:vip1024b (备注Java)
img

一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!
g.JInternalFrame {

private JTextField idTxt;

private JLabel jLabel1;

private JLabel jLabel2;

private JLabel jLabel3;

private JLabel jLabel4;

private JPanel jPanel1;

private JScrollPane jScrollPane1;

private javax.swing.JButton jb_exit;

private javax.swing.JButton jb_modify;

private javax.swing.JButton jb_search;

private JTextField roomNum;

private JTextField roomleader;

private JTextField roomnumber;

private JTable table;

DMUtil dmutil = new DMUtil();

RoomDao roomdao = new RoomDao();

public RoomManagerInterFrm() {

initComponents();

this.setLocation(200, 50);

this.fillTable(new Room());

}

private void fillTable(Room room) {

DefaultTableModel dtm = (DefaultTableModel) table.getModel();

dtm.setRowCount(0);

Connection con = null;

try {

con = dmutil.getCon();

ResultSet rs = roomdao.roomList(con, room);

while (rs.next()) {

Vector v = new Vector();

v.add(rs.getString(“id”));

v.add(rs.getString(“member”));

v.add(rs.getString(“leader”));

dtm.addRow(v);

}

} catch (Exception e) {

e.printStackTrace();

} finally {

try {

dmutil.closeCon(con);

} catch (Exception e) {

e.printStackTrace();

}

}

}

private void initComponents() {

jLabel1 = new JLabel();

roomNum = new JTextField();

jb_search = new javax.swing.JButton();

jScrollPane1 = new JScrollPane();

table = new JTable();

jPanel1 = new JPanel();

jLabel2 = new JLabel();

idTxt = new JTextField();

jLabel3 = new JLabel();

roomnumber = new JTextField();

jb_modify = new javax.swing.JButton();

jb_exit = new javax.swing.JButton();

jLabel4 = new JLabel();

roomleader = new JTextField();

setClosable(true);

setIconifiable(true);

setTitle(“宿舍信息修改”);

jLabel1.setText(“寝室号:”);

最后

现在其实从大厂招聘需求可见,在招聘要求上有高并发经验优先,包括很多朋友之前都是做传统行业或者外包项目,一直在小公司,技术搞的比较简单,没有怎么搞过分布式系统,但是现在互联网公司一般都是做分布式系统。

所以说,如果你想进大厂,想脱离传统行业,这些技术知识都是你必备的,下面自己手打了一份Java并发体系思维导图,希望对你有所帮助。

[外链图片转存中…(img-tr4ypFa6-1713471285205)]

网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。

需要这份系统化的资料的朋友,可以添加V获取:vip1024b (备注Java)
[外链图片转存中…(img-o9bG49iJ-1713471285205)]

一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!

  • 21
    点赞
  • 24
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
员工工资管理系统是一个常见的软件应用程序,可以帮助公司管理员工的基本信息、薪资、考勤、福利等方面的内容。本文将介绍如何使用 Eclipse+Java+Swing+Mysql 实现员工工资管理系统。 步骤1:创建数据库 首先,我们需要在 Mysql 中创建一个名为 salary 的数据库,并在其中创建三个表:employee、salary_record 和 department。 employee 表用于存储员工的基本信息,包括员工编号、姓名、性别、部门编号等字段。salary_record 表用于存储员工的薪资记录,包括员工编号、发放日期、基本工资、奖金、扣款等字段。department 表用于存储部门的基本信息,包括部门编号、部门名称等字段。 步骤2:创建 Java 项目 在 Eclipse 中创建一个新的 Java 项目,命名为 SalaryManagementSystem。在项目中创建三个包:entity、dao 和 view。 entity 包用于存储实体类,包括 Employee、SalaryRecord 和 Department 等类。dao 包用于存储数据访问对象,包括 EmployeeDao、SalaryRecordDao 和 DepartmentDao 等类。view 包用于存储界面类,包括 LoginFrame、MainFrame 和 AddEmployeeFrame 等类。 步骤3:编写实体类 在 entity 包中创建 Employee、SalaryRecord 和 Department 等类,并为每个类添加相应的属性和方法。例如,Employee 类包括员工编号、姓名、性别、所属部门等属性,以及获取和设置这些属性的方法。 步骤4:编写数据访问对象 在 dao 包中创建 EmployeeDao、SalaryRecordDao 和 DepartmentDao 等类,并实现相应的数据访问方法。例如,EmployeeDao 类包括添加员工、删除员工、更新员工信息、查询员工信息等方法。 步骤5:编写界面类 在 view 包中创建 LoginFrame、MainFrame 和 AddEmployeeFrame 等类,并实现相应的界面和事件处理方法。例如,LoginFrame 类用于显示登录界面,并处理用户登录事件;AddEmployeeFrame 类用于显示添加员工界面,并处理添加员工事件。 步骤6:连接数据库 使用 JDBC 连接 Mysql 数据库,为每个数据访问对象创建相应的连接和预编译语句,实现数据库的增删改查操作。 步骤7:测试程序 在 Eclipse 中运行程序,测试各个功能是否正常。例如,登录功能、员工信息查询功能、添加员工功能等。 总结 本文介绍了如何使用 Eclipse+Java+Swing+Mysql 实现员工工资管理系统。通过实现实体类、数据访问对象和界面类等模块,实现对员工信息、薪资、部门信息等数据的管理。这个项目可以作为 Java 开发入门的练手项目,帮助初学者熟悉 Java 开发、Swing 界面设计和 Mysql 数据库操作等技术。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值