Eclipse+Java+Swing实现学校教务管理系统

} catch (Exception e) {

throw e;

} finally {

try {

if (pstmt != null) {

pstmt.close();

}

} catch (Exception e) {

}

}

return all;

}

// @Override

public UserInfo findById(String id) throws Exception {

// 查找用户信息-ID查找

UserInfo user = null;

PreparedStatement pstmt = null;

String sql = “SELECT * FROM UserInfo_tab WHERE UserName=?”;

try {

pstmt = this.conn.prepareStatement(sql);

pstmt.setString(1, id);

ResultSet rs = pstmt.executeQuery();

while (rs.next()) {

user = new UserInfo();

user.setID(rs.getInt(1));

user.setUserName(rs.getString(2));

user.setNickName(rs.getString(3));

user.setUserPass(rs.getString(4));

user.setGrade(rs.getInt(5));

}

rs.close();

} catch (Exception e) {

throw e;

} finally {

try {

if (pstmt != null) {

pstmt.close();

}

} catch (Exception e) {

}

}

return user;

}

}

UserInfo.java


package com.sjsq.entity;

/**

  • @author HZBIN1993

  • @author shuijianshiqing

  • @date 2021-01-09

*/

public class UserInfo {

private int ID;

private String nickName;

private String UserName;

private String UserPass;

private int Grade;

public UserInfo() {

super();

}

public UserInfo(int iD, String userName) {

super();

ID = iD;

UserName = userName;

}

public String getNickName() {

return nickName;

}

public void setNickName(String nickName) {

this.nickName = nickName;

}

public int getID() {

return ID;

}

public void setID(int iD) {

ID = iD;

}

public String getUserName() {

return UserName;

}

public void setUserName(String userName) {

UserName = userName;

}

public String getUserPass() {

return UserPass;

}

public void setUserPass(String userPass) {

UserPass = userPass;

}

public int getGrade() {

return Grade;

}

public void setGrade(int grade) {

Grade = grade;

}

@Override

public String toString() {

// Auto-generated method stub

String grade = “学生”;

if (Grade == 0) {

grade = “教务人员”;

} else if (Grade == 1) {

grade = “教师”;

}

return "ID: " + ID + ",用户名为: " + UserName + "权限为: " + grade;

}

}

DAOFactory.java


package com.sjsq.factory;

import com.sjsq.dao.IArrangeInfoDao;

import com.sjsq.dao.IClassInfoDao;

import com.sjsq.dao.ICourseInfoDao;

import com.sjsq.dao.IScoreInfoDao;

import com.sjsq.dao.IStudentInfoDao;

import com.sjsq.dao.ITeacherInfoDao;

import com.sjsq.dao.IUserInfoDAO;

import com.sjsq.proxy.ArrangeInfoDaoImpIPoxy;

import com.sjsq.proxy.ClassInfoDaoImpIPoxy;

import com.sjsq.proxy.CourseInfoDaoImpIProxy;

import com.sjsq.proxy.ScoreInfoDaoImpIProxy;

import com.sjsq.proxy.StudentInfoDaoImpIProxy;

import com.sjsq.proxy.TeacherInfoDaoImpIProxy;

import com.sjsq.proxy.UserInfoDaoImpIProxy;

/**

  • 创建工厂类

  • @author Administrator

*/

public class DAOFactory {

public static IUserInfoDAO getIUserDAOInstance() {

// 用户信息操作工厂

return new UserInfoDaoImpIProxy();

}

public static IScoreInfoDao getScoreDAOInstance() {

// 成绩操作工厂

return new ScoreInfoDaoImpIProxy();

}

public static ICourseInfoDao getCourseDAOInstance() {

// 课程操作工厂

return new CourseInfoDaoImpIProxy();

}

public static IStudentInfoDao getStudentDAOInstance() {

// 学生操作工厂

return new StudentInfoDaoImpIProxy();

}

public static IClassInfoDao getClassDAOInstance() {

// 班级操作工厂

return new ClassInfoDaoImpIPoxy();

}

public static ITeacherInfoDao getTeacherDAOInstance() {

// 老师操作工厂

return new TeacherInfoDaoImpIProxy();

}

public static IArrangeInfoDao getArrangeDaoInstance() {

// 选课信息操作工厂

return new ArrangeInfoDaoImpIPoxy();

}

}

UserInfoDaoImpIProxy.java


package com.sjsq.proxy;

import java.util.List;

import com.sjsq.dao.IUserInfoDAO;

import com.sjsq.dao.ImpI.UserInfoDaoImpI;

import com.sjsq.dbConnect.DataBaseConn;

import com.sjsq.entity.UserInfo;

/**

  • 用户信息代理类

  • @author shuijianshiqing

*/

public class UserInfoDaoImpIProxy implements IUserInfoDAO {

private DataBaseConn dbc = null;

private IUserInfoDAO dao = null;

public UserInfoDaoImpIProxy() {

dbc = new DataBaseConn();

dao = new UserInfoDaoImpI(dbc.getConnection());

}

@Override

public boolean doCreate(UserInfo user) throws Exception {

// 增加用户信息(代理实现)

boolean flag = true;

try {

flag = this.dao.doCreate(user);

} catch (Exception e) {

throw e;

} finally {

this.dbc.close();

}

return flag;

}

@Override

public boolean doUpdate(UserInfo user) throws Exception {

// 更新用户信息(代理实现)

boolean flag = true;

try {

flag = this.dao.doUpdate(user);

} catch (Exception e) {

throw e;

} finally {

this.dbc.close();

}

return flag;

}

@Override

public boolean doDelete(String username) throws Exception {

// 删除用户信息(代理实现)

boolean flag = true;

try {

flag = this.dao.doDelete(username);

} catch (Exception e) {

throw e;

} finally {

this.dbc.close();

}

return flag;

}

@Override

public List findAll(String keyword) throws Exception {

/

必看视频!获取2024年最新Java开发全套学习资料 备注Java

/ 查找用户信息-关键字查找(代理实现)

List all = null;

try {

all = this.dao.findAll(keyword);

} catch (Exception e) {

throw e;

} finally {

this.dbc.close();

}

return all;

}

@Override

public UserInfo findById(String id) throws Exception {

// 查找用户信息-ID查找(代理实现)

UserInfo user = null;

try {

user = this.dao.findById(id);

} catch (Exception e) {

throw e;

} finally {

this.dbc.close();

}

return user;

}

}

DateUtil.java


package com.sjsq.util;

import java.text.ParseException;

import java.text.SimpleDateFormat;

import java.util.Calendar;

import java.util.Date;

import java.util.Locale;

public class DateUtil {

public static String getAfterDay(String date, int num) {

SimpleDateFormat parser = new SimpleDateFormat(“yyyy-MM-dd”);

Date dt = null;

try {

dt = parser.parse(date);

} catch (ParseException e) {

e.printStackTrace();

}

Calendar calendar = Calendar.getInstance();

calendar.setTime(dt);

calendar.add(Calendar.DATE, num);

SimpleDateFormat simpledateformat = new SimpleDateFormat(“yyyy-MM-dd”, Locale.ENGLISH);

return simpledateformat.format(calendar.getTime());

}

public static String getBeforeDate(int num) {

Calendar calendar = Calendar.getInstance();

calendar.setTime(new Date());

calendar.add(Calendar.DATE, -num);

SimpleDateFormat simpledateformat = new SimpleDateFormat(“yyyy-MM-dd”, Locale.ENGLISH);

return simpledateformat.format(calendar.getTime());

}

public static String getDate() {

Date dt = new Date();

long tmLong = dt.getTime();

return (new java.sql.Date(tmLong)).toString();

}

public static String getDateTime() {

Date dt = new Date();

Long tmLong = dt.getTime();

return (new java.sql.Date(tmLong) + " " + (new java.sql.Time(tmLong))).toString();

}

public static java.sql.Date getStringToDate(String day) {

SimpleDateFormat parser = new SimpleDateFormat(“yyyy-MM-dd”);

Date dt = new Date();

try {

dt = parser.parse(day);

} catch (ParseException e) {

e.printStackTrace();

}

return (new java.sql.Date(dt.getTime()));

}

}

Login.java


package com.sjsq.window;

import java.awt.AWTException;

import java.awt.Dimension;

import java.awt.Font;

import java.awt.Image;

import java.awt.MenuItem;

import java.awt.PopupMenu;

import java.awt.SystemColor;

import java.awt.SystemTray;

import java.awt.Toolkit;

import java.awt.TrayIcon;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import java.awt.event.KeyEvent;

import java.awt.event.MouseAdapter;

import java.awt.event.MouseEvent;

import java.awt.event.MouseListener;

import java.net.URL;

import javax.swing.AbstractAction;

import javax.swing.Action;

import javax.swing.ButtonGroup;

import javax.swing.GroupLayout;

import javax.swing.GroupLayout.Alignment;

import javax.swing.ImageIcon;

import javax.swing.JButton;

import javax.swing.JFrame;

import javax.swing.JLabel;

import javax.swing.JMenu;

import javax.swing.JMenuBar;

import javax.swing.JMenuItem;

import javax.swing.JOptionPane;

import javax.swing.JPasswordField;

import javax.swing.JRadioButton;

import javax.swing.JTextField;

import javax.swing.KeyStroke;

import javax.swing.LayoutStyle.ComponentPlacement;

import com.sjsq.entity.UserInfo;

import com.sjsq.factory.DAOFactory;

import com.sjsq.util.GlobalUser;

/**

  • 登录

  • @author shuijianshiqing

  • @date 2021-01-09 20:42

*/

public class Login extends JFrame {

private final Action action = new SwingAction();

private JTextField textField;

private final ButtonGroup buttonGroup = new ButtonGroup();

private JPasswordField passwordField;

private JRadioButton rdbtnNewRadioButton = null;

private JRadioButton rdbtnNewRadioButton_1 = null;

private JRadioButton rdbtnNewRadioButton_2 = null;

public Login() {

setResizable(false);

getContentPane().setBackground(SystemColor.menu);

setSize(new Dimension(341, 410));

setTitle(“教务管理系统”);

setLocationRelativeTo(null);

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

JMenuBar menuBar = new JMenuBar();

setJMenuBar(menuBar);

JMenu mnFile = new JMenu(“菜单”);

mnFile.setFont(new Font(“微软雅黑”, Font.PLAIN, 16));

menuBar.add(mnFile);

JMenuItem mntmNewMenuItem = new JMenuItem(“退出”);

mntmNewMenuItem.setFont(new Font(“微软雅黑”, Font.PLAIN, 16));

mntmNewMenuItem.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

System.exit(0);

}

});

mntmNewMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_STOP, 0));

mnFile.add(mntmNewMenuItem);

JMenu mnHelp = new JMenu(“帮助”);

mnHelp.setFont(new Font(“微软雅黑”, Font.PLAIN, 16));

menuBar.add(mnHelp);

JMenuItem mntmNewMenuItem_1 = new JMenuItem(“关于”);

mntmNewMenuItem_1.setFont(new Font(“微软雅黑”, Font.PLAIN, 16));

mntmNewMenuItem_1.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

mntmNewMenuItem_1actionPerformed(e);

}

});

mnHelp.add(mntmNewMenuItem_1);

JLabel lblNewLabel = new JLabel(“New label”);

lblNewLabel.setIcon(new ImageIcon(Login.class.getResource(“/images/login.jpg”)));

JLabel lblNewLabel_1 = new JLabel(“账号”);

JLabel lblNewLabel_2 = new JLabel(“密码”);

textField = new JTextField();

textField.setColumns(0);

rdbtnNewRadioButton = new JRadioButton(“学生”);

rdbtnNewRadioButton.setSelected(true);

buttonGroup.add(rdbtnNewRadioButton);

rdbtnNewRadioButton_1 = new JRadioButton(“教师”);

buttonGroup.add(rdbtnNewRadioButton_1);

rdbtnNewRadioButton_2 = new JRadioButton(“教务人员”);

buttonGroup.add(rdbtnNewRadioButton_2);

JButton btnNewButton = new JButton(“登录”);

btnNewButton.setDoubleBuffered(true);

btnNewButton.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent event) {

btnNewButtonactionPerformed(event);

}

});

JButton btnNewButton_1 = new JButton(“取消”);

btnNewButton_1.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

System.exit(0);

}

});

passwordField = new JPasswordField();

GroupLayout groupLayout = new GroupLayout(getContentPane());

groupLayout.setHorizontalGroup(groupLayout.createParallelGroup(Alignment.LEADING).addGroup(groupLayout

.createSequentialGroup().addGap(70)

.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)

.addGroup(groupLayout.createSequentialGroup()

.addComponent(lblNewLabel_2, GroupLayout.PREFERRED_SIZE, 36, GroupLayout.PREFERRED_SIZE)

.addGap(8).addComponent(passwordField, 166, 166, 166))

.addGroup(groupLayout.createSequentialGroup().addComponent(rdbtnNewRadioButton).addGap(18)

.addComponent(rdbtnNewRadioButton_1).addPreferredGap(ComponentPlacement.UNRELATED)

.addComponent(rdbtnNewRadioButton_2))

.addGroup(groupLayout.createSequentialGroup().addComponent(lblNewLabel_1).addGap(18)

.addComponent(textField, GroupLayout.PREFERRED_SIZE, 166, GroupLayout.PREFERRED_SIZE)))

.addContainerGap(18, Short.MAX_VALUE))

.addComponent(lblNewLabel, GroupLayout.PREFERRED_SIZE, 341, Short.MAX_VALUE)

.addGroup(Alignment.TRAILING, groupLayout.createSequentialGroup().addContainerGap(82, Short.MAX_VALUE)

.addComponent(btnNewButton).addGap(27).addComponent(btnNewButton_1).addGap(118)));

groupLayout.setVerticalGroup(groupLayout.createParallelGroup(Alignment.LEADING).addGroup(groupLayout

.createSequentialGroup()

.addComponent(lblNewLabel, GroupLayout.PREFERRED_SIZE, 170, GroupLayout.PREFERRED_SIZE).addGap(18)

.addGroup(groupLayout.createParallelGroup(Alignment.LEADING).addComponent(lblNewLabel_1).addComponent(

textField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))

.addPreferredGap(ComponentPlacement.RELATED)

.addGroup(groupLayout

.createParallelGroup(Alignment.BASELINE).addComponent(lblNewLabel_2).addComponent(passwordField,

GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))

.addGap(18)

.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE).addComponent(rdbtnNewRadioButton_2)

.addComponent(rdbtnNewRadioButton_1).addComponent(rdbtnNewRadioButton))

.addGap(18).addGroup(groupLayout.createParallelGroup(Alignment.BASELINE).addComponent(btnNewButton_1)

.addComponent(btnNewButton))

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

getContentPane().setLayout(groupLayout);

addTrayIcon();

}

// 给心痛托盘区添加图标

private void addTrayIcon() {

// Auto-generated method stub

SystemTray st = SystemTray.getSystemTray();

if (SystemTray.isSupported()) {

URL imgurl = this.getClass().getClassLoader().getResource(“images/login_main.jpg”);

Image img = Toolkit.getDefaultToolkit().createImage(imgurl);

// Image

// img=Toolkit.getDefaultToolkit().createImage(“images/aboutme.jpg”);

PopupMenu popup = new PopupMenu();

MenuItem item = new MenuItem(“退出程序”);

item.addActionListener(new ActionListener() {

@Override

public void actionPerformed(ActionEvent e) {

// Auto-generated method stub

System.exit(0);

}

});

popup.add(item);

TrayIcon icon = new TrayIcon(img, “教务管理系统”, popup);

icon.addMouseListener(new MouseAdapter() {

@Override

public void mouseClicked(MouseEvent e) {

if (e.getClickCount() == 2) {

UserInfo u = GlobalUser.LOGIN_USER;

if (u == null) {

Login.start();

} else if (u.getGrade() == 0) {

AdminFrame.start();

} else if (u.getGrade() == 1) {

TeacherFrame.start();

} else if (u.getGrade() == 2) {

StudentFrame.start();

}

}

}

});

icon.setImageAutoSize(true);

try {

st.add(icon);

} catch (AWTException e1) {

e1.printStackTrace();

}

}

}

protected void mntmNewMenuItem_1actionPerformed(ActionEvent e) {

About.start();

}

protected void btnNewButtonactionPerformed(ActionEvent event) {

String name = textField.getText();// 获得用户名

String pass = String.valueOf(passwordField.getPassword());

UserInfo user = null;

// 未输入用户名

if (name.equals(“”)) {

JOptionPane.showMessageDialog(this, “用户名不允许为空!”, “提示”, 2);

return;

}

try {

user = DAOFactory.getIUserDAOInstance().findById(name);

// System.out.println(user);

if (user != null) {

if (user.getUserPass() != null && user.getUserPass().equals(pass)) {

GlobalUser.LOGIN_USER = user; // 记录当前用户

// 进入主界面

if (rdbtnNewRadioButton.isSelected()) {

if (user.getGrade() != 2) {

JOptionPane.showMessageDialog(this, “该用户不是学生!”, “消息”, 2);

return;

}

// 学生界面

StudentFrame.start();

} else if (rdbtnNewRadioButton_1.isSelected()) {

if (user.getGrade() != 1) {

JOptionPane.showMessageDialog(this, “该用户不是老师!”, “消息”, 2);

return;

}

// 教师界面

TeacherFrame.start();

} else if (rdbtnNewRadioButton_2.isSelected()) {

if (user.getGrade() != 0) {

JOptionPane.showMessageDialog(this, “该用户不是教务人员!”, “消息”, 2);

return;

}

// 教务人员界面

AdminFrame.start();

} else {

JOptionPane.showMessageDialog(this, “别急!权限没选呢”);

return;

}

this.dispose();

} else {

JOptionPane.showMessageDialog(this, “用户名或密码错误!”, “消息”, 2);

return;

}

}

} catch (Exception e) {

e.printStackTrace();

}

if (user == null) {

JOptionPane.showMessageDialog(this, “用户名或密码错误!”, “消息”, 0);

return;

}

}

private class SwingAction extends AbstractAction {

public SwingAction() {

putValue(NAME, “SwingAction”);

putValue(SHORT_DESCRIPTION, “Some short description”);

}

public void actionPerformed(ActionEvent e) {

}

}

public static void start() {

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

public void run() {

new Login().setVisible(true);

}

});

}

public static void main(String[] args) {

new Login().setVisible(true);

}

}

AdminFrame.java


package com.sjsq.window;

import java.awt.Dimension;

import javax.swing.JFrame;

import javax.swing.JMenu;

import javax.swing.JMenuBar;

import javax.swing.JMenuItem;

import java.awt.event.ActionListener;

import java.awt.event.ActionEvent;

import java.io.IOException;

import javax.swing.GroupLayout;

import javax.swing.GroupLayout.Alignment;

import javax.swing.JLabel;

import javax.swing.LayoutStyle.ComponentPlacement;

import javax.swing.SwingConstants;

import com.sjsq.util.DateUtil;

import com.sjsq.util.GlobalUser;

import com.sjsq.util.imageUtils;

import com.sjsq.util.msgUtils;

import java.awt.Color;

import java.awt.Font;

public class AdminFrame extends JFrame {

private JLabel lblNewLabel_3;

private JLabel lblNewLabel_1;

private JLabel lblNewLabel_2;

private JLabel lblNewLabel;

/**

*/

private static final long serialVersionUID = 1L;

public AdminFrame() {

setResizable(false);

setTitle(“教务管理系统—教务人员”);

setSize(new Dimension(800, 500));

setLocationRelativeTo(null);

JMenuBar menuBar = new JMenuBar();

setJMenuBar(menuBar);

JMenu mnNewMenu = new JMenu(“工具”);

menuBar.add(mnNewMenu);

JMenu menu_1 = new JMenu(“系统工具”);

mnNewMenu.add(menu_1);

JMenuItem mntmNewMenuItem_24 = new JMenuItem(“cmd”);

mntmNewMenuItem_24.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent event) {

mntmNewMenuItem_24actionPerformed(event);

}

});

menu_1.add(mntmNewMenuItem_24);

JMenuItem mntmNewMenuItem_25 = new JMenuItem(“截图”);

mntmNewMenuItem_25.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent event) {

mntmNewMenuItem_25actionPerformed(event);

}

});

menu_1.add(mntmNewMenuItem_25);

JMenuItem mntmNewMenuItem_26 = new JMenuItem(“画图”);

mntmNewMenuItem_26.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent event) {

mntmNewMenuItem_26actionPerformed(event);

}

});

menu_1.add(mntmNewMenuItem_26);

JMenuItem mntmNewMenuItem_27 = new JMenuItem(“键盘”);

mntmNewMenuItem_27.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent event) {

mntmNewMenuItem_27actionPerformed(event);

}

});

menu_1.add(mntmNewMenuItem_27);

JMenuItem mntmNewMenuItem_28 = new JMenuItem(“记事本”);

mntmNewMenuItem_28.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent event) {

mntmNewMenuItem_28actionPerformed(event);

}

});

menu_1.add(mntmNewMenuItem_28);

JMenuItem mntmNewMenuItem_29 = new JMenuItem(“计算器”);

mntmNewMenuItem_29.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent event) {

mntmNewMenuItem_29actionPerformed(event);

}

});

menu_1.add(mntmNewMenuItem_29);

JMenuItem mntmNewMenuItem_2 = new JMenuItem(“系统信息”);

mntmNewMenuItem_2.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

mntmNewMenuItem_2actionPerformed(e);

}

});

mnNewMenu.add(mntmNewMenuItem_2);

JMenuItem mntmNewMenuItem_3 = new JMenuItem(“系统版本”);

mntmNewMenuItem_3.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

mntmNewMenuItem_3actionPerformed(e);

}

});

mnNewMenu.add(mntmNewMenuItem_3);

JMenuItem mntmNewMenuItem_4 = new JMenuItem(“退出”);

mntmNewMenuItem_4.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent event) {

mntmNewMenuItem_4actionPerformed(event);

}

});

mnNewMenu.add(mntmNewMenuItem_4);

JMenu mnNewMenu_1 = new JMenu(“通知”);

menuBar.add(mnNewMenu_1);

JMenuItem menuItem_1 = new JMenuItem(“管理通知”);

menuItem_1.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

menuItem_1actionPerformed(e);

}

});

mnNewMenu_1.add(menuItem_1);

JMenu mnNewMenu_2 = new JMenu(“成绩管理”);

menuBar.add(mnNewMenu_2);

JMenuItem mntmNewMenuItem_6 = new JMenuItem(“成绩管理”);

mntmNewMenuItem_6.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

mntmNewMenuItem_6actionPerformed(e);

}

});

mnNewMenu_2.add(mntmNewMenuItem_6);

JMenu mnNewMenu_3 = new JMenu(“用户管理”);

menuBar.add(mnNewMenu_3);

JMenuItem menuItem_2 = new JMenuItem(“退出”);

menuItem_2.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

menuItem_2addActionListener(e);

}

});

JMenuItem menuItem_3 = new JMenuItem(“学生管理”);

menuItem_3.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

menuItem_3actionPerformed(e);

}

});

mnNewMenu_3.add(menuItem_3);

JMenuItem mntmNewMenuItem_8 = new JMenuItem(“教师管理”);

mntmNewMenuItem_8.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

mntmNewMenuItem_8actionPerformed(e);

}

});

mnNewMenu_3.add(mntmNewMenuItem_8);

JMenuItem mntmNewMenuItem_7 = new JMenuItem(“教务人员”);

mntmNewMenuItem_7.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

mntmNewMenuItem_7actionPerformed(e);

}

});

mnNewMenu_3.add(mntmNewMenuItem_7);

mnNewMenu_3.add(menuItem_2);

JMenu mnNewMenu_4 = new JMenu(“课程管理”);

menuBar.add(mnNewMenu_4);

JMenuItem mntmNewMenuItem_11 = new JMenuItem(“安排课程”);

mntmNewMenuItem_11.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

mntmNewMenuItem_11actionPerformed(e);

}

});

mnNewMenu_4.add(mntmNewMenuItem_11);

JMenuItem mntmNewMenuItem_12 = new JMenuItem(“课程管理”);

mntmNewMenuItem_12.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

mntmNewMenuItem_12actionPerformed(e);

}

});

mnNewMenu_4.add(mntmNewMenuItem_12);

JMenu menu_2 = new JMenu(“班级管理”);

menuBar.add(menu_2);

JMenuItem mntmNewMenuItem_9 = new JMenuItem(“班级管理”);

mntmNewMenuItem_9.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

mntmNewMenuItem_9actionPerformed(e);

}

});

menu_2.add(mntmNewMenuItem_9);

JMenu menu = new JMenu(“帮助”);

menuBar.add(menu);

JMenuItem mntmNewMenuItem = new JMenuItem(“关于”);

mntmNewMenuItem.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

About.start();

}

});

menu.add(mntmNewMenuItem);

JMenuItem mntmNewMenuItem_1 = new JMenuItem(“帮助”);

mntmNewMenuItem_1.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

mntmNewMenuItem_1actionPerformed(e);

}

});

menu.add(mntmNewMenuItem_1);

lblNewLabel = new JLabel(“”);

// 设置变换图片

imageUtils changeimg = new imageUtils(lblNewLabel);

changeimg.start();

lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER);

lblNewLabel_1 = new JLabel(“”);

lblNewLabel_1.setHorizontalAlignment(SwingConstants.LEFT);

// 设置当前用户

lblNewLabel_1.setText(GlobalUser.LOGIN_USER.getNickName() + “(” + GlobalUser.LOGIN_USER.getUserName() + “)”);

lblNewLabel_2 = new JLabel(“”);

lblNewLabel_2.setHorizontalAlignment(SwingConstants.LEFT);

lblNewLabel_3 = new JLabel(“”);

lblNewLabel_3.setFont(new Font(“宋体”, Font.PLAIN, 14));

lblNewLabel_3.setForeground(Color.RED);

// 设置提示信息

msgUtils msg = new msgUtils(lblNewLabel_3);

msg.start();

// 设置时间

new Thread() {

public void run() {

while (true) {

lblNewLabel_2.setText(DateUtil.getDateTime());

try {

Thread.sleep(1000);

} catch (InterruptedException e) {

e.printStackTrace();

}

}

};

}.start();

lblNewLabel_3.setHorizontalAlignment(SwingConstants.CENTER);

JLabel label = new JLabel(“当前用户:”);

GroupLayout groupLayout = new GroupLayout(getContentPane());

groupLayout.setHorizontalGroup(groupLayout.createParallelGroup(Alignment.LEADING)

.addGroup(groupLayout.createSequentialGroup().addContainerGap()

.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)

.addGroup(groupLayout.createSequentialGroup().addGap(10).addComponent(lblNewLabel_3,

GroupLayout.DEFAULT_SIZE, 764, Short.MAX_VALUE))

.addComponent(lblNewLabel, GroupLayout.PREFERRED_SIZE, 766, GroupLayout.PREFERRED_SIZE)

.addGroup(groupLayout.createSequentialGroup().addGap(176).addComponent(label)

.addPreferredGap(ComponentPlacement.RELATED)

.addComponent(lblNewLabel_1, GroupLayout.PREFERRED_SIZE, 213,

GroupLayout.PREFERRED_SIZE)

.addPreferredGap(ComponentPlacement.RELATED)

.addComponent(lblNewLabel_2, GroupLayout.DEFAULT_SIZE, 325, Short.MAX_VALUE)))

.addContainerGap()));

groupLayout.setVerticalGroup(groupLayout.createParallelGroup(Alignment.LEADING).addGroup(groupLayout

.createSequentialGroup().addContainerGap()

.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)

.addComponent(lblNewLabel_2, GroupLayout.PREFERRED_SIZE, 34, GroupLayout.PREFERRED_SIZE)

.addComponent(label)

.addComponent(lblNewLabel_1, GroupLayout.PREFERRED_SIZE, 33, GroupLayout.PREFERRED_SIZE))

.addPreferredGap(ComponentPlacement.RELATED)

.addComponent(lblNewLabel, GroupLayout.PREFERRED_SIZE, 345, GroupLayout.PREFERRED_SIZE)

.addPreferredGap(ComponentPlacement.UNRELATED)

.addComponent(lblNewLabel_3, GroupLayout.DEFAULT_SIZE, 46, Short.MAX_VALUE)));

getContentPane().setLayout(groupLayout);

}

protected void menuItem_1actionPerformed(ActionEvent e) {

// TODO 通知管理

}

protected void mntmNewMenuItem_7actionPerformed(ActionEvent e) {

// 教务人员

ManagerAdmin.start();

}

protected void mntmNewMenuItem_8actionPerformed(ActionEvent e) {

// 教师管理

ManagerTeach.start();

}

protected void menuItem_3actionPerformed(ActionEvent e) {

// 学生管理

ManagerStu.start();

}

protected void mntmNewMenuItem_12actionPerformed(ActionEvent e) {

// 课程管理

ManagerCourse.start();

}

protected void mntmNewMenuItem_11actionPerformed(ActionEvent e) {

// 排课

ArrangeCourse.start();

}

protected void mntmNewMenuItem_1actionPerformed(ActionEvent e) {

// TODO 帮助

}

protected void mntmNewMenuItem_9actionPerformed(ActionEvent e) {

// 班级管理

ManagerClass.start();

}

protected void mntmNewMenuItem_6actionPerformed(ActionEvent e) {

// 成绩管理

ManagerScore.start();

}

protected void mntmNewMenuItem_29actionPerformed(ActionEvent event) {

// 打开计算器

try {

Runtime.getRuntime().exec(“cmd /c start CALC”);

} catch (IOException e) {

e.printStackTrace();

}

}

protected void mntmNewMenuItem_28actionPerformed(ActionEvent event) {

// 打开记事本

try {

Runtime.getRuntime().exec(“cmd /c start notepad”);

} catch (IOException e) {

e.printStackTrace();

}

}

protected void mntmNewMenuItem_27actionPerformed(ActionEvent event) {

// 打开屏幕键盘

try {

Runtime.getRuntime().exec(“cmd /c start osk”);

} catch (IOException e) {

e.printStackTrace();

}

}

protected void mntmNewMenuItem_26actionPerformed(ActionEvent event) {

// 打开画图板

try {

Runtime.getRuntime().exec(“cmd /c start mspaint”);

} catch (IOException exc) {

exc.printStackTrace();

}

}

protected void mntmNewMenuItem_25actionPerformed(ActionEvent event) {

最后

码字不易,觉得有帮助的可以帮忙点个赞,让更多有需要的人看到

又是一年求职季,在这里,我为各位准备了一套Java程序员精选高频面试笔试真题,来帮助大家攻下BAT的offer,题目范围从初级的Java基础到高级的分布式架构等等一系列的面试题和答案,用于给大家作为参考

以下是部分内容截图
架构面试专题及架构学习笔记导图.png
entPane().setLayout(groupLayout);

}

protected void menuItem_1actionPerformed(ActionEvent e) {

// TODO 通知管理

}

protected void mntmNewMenuItem_7actionPerformed(ActionEvent e) {

// 教务人员

ManagerAdmin.start();

}

protected void mntmNewMenuItem_8actionPerformed(ActionEvent e) {

// 教师管理

ManagerTeach.start();

}

protected void menuItem_3actionPerformed(ActionEvent e) {

// 学生管理

ManagerStu.start();

}

protected void mntmNewMenuItem_12actionPerformed(ActionEvent e) {

// 课程管理

ManagerCourse.start();

}

protected void mntmNewMenuItem_11actionPerformed(ActionEvent e) {

// 排课

ArrangeCourse.start();

}

protected void mntmNewMenuItem_1actionPerformed(ActionEvent e) {

// TODO 帮助

}

protected void mntmNewMenuItem_9actionPerformed(ActionEvent e) {

// 班级管理

ManagerClass.start();

}

protected void mntmNewMenuItem_6actionPerformed(ActionEvent e) {

// 成绩管理

ManagerScore.start();

}

protected void mntmNewMenuItem_29actionPerformed(ActionEvent event) {

// 打开计算器

try {

Runtime.getRuntime().exec(“cmd /c start CALC”);

} catch (IOException e) {

e.printStackTrace();

}

}

protected void mntmNewMenuItem_28actionPerformed(ActionEvent event) {

// 打开记事本

try {

Runtime.getRuntime().exec(“cmd /c start notepad”);

} catch (IOException e) {

e.printStackTrace();

}

}

protected void mntmNewMenuItem_27actionPerformed(ActionEvent event) {

// 打开屏幕键盘

try {

Runtime.getRuntime().exec(“cmd /c start osk”);

} catch (IOException e) {

e.printStackTrace();

}

}

protected void mntmNewMenuItem_26actionPerformed(ActionEvent event) {

// 打开画图板

try {

Runtime.getRuntime().exec(“cmd /c start mspaint”);

} catch (IOException exc) {

exc.printStackTrace();

}

}

protected void mntmNewMenuItem_25actionPerformed(ActionEvent event) {

最后

码字不易,觉得有帮助的可以帮忙点个赞,让更多有需要的人看到

又是一年求职季,在这里,我为各位准备了一套Java程序员精选高频面试笔试真题,来帮助大家攻下BAT的offer,题目范围从初级的Java基础到高级的分布式架构等等一系列的面试题和答案,用于给大家作为参考

以下是部分内容截图
[外链图片转存中…(img-BTsCPWQ0-1716408999630)]

  • 9
    点赞
  • 18
    收藏
    觉得还不错? 一键收藏
  • 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、付费专栏及课程。

余额充值