目录
1.系统运行环境
运行环境:Java8 + MySQL8
开发工具:eclipse/idea
2.系统功能介绍
(下面介绍的功能肯定都有,没有介绍的功能肯定没有!)
系统采用模拟MVC三层进行开发,这样方便项目进行修改或者二次开发!
数据库:四张表
功能:两种角色管理员和员工
普通员工无需登录:查询某个月工资;
管理员可以管理员工、部门、工资等基本信息。
员工模块:增加、删除、修改、查看
部门模块:增加、删除、修改、查看
管理员模块:增加、删除、修改、查看
工资模块:录入工资,查询工资,发放工资,工资一览表
3.项目结构略讲
3.1乱码问题
系统开发时的编码为UTF-8,因此导入eclipse时,也需要eclipse工作空间的编码为UTF-8
修改编码:点击Window->Preference->General->workplace,然后选择默认编码方式 UTF-8。
错误做法:开始将系统导入,出现乱码的问题,然后去修改eclipse的编码,这样有的 时候并不能修乱码的问题!需要将项目删除掉,然后修改eclipse的工作空 间编码,再次导入系统才能修改掉乱码!
3.2 如何将UTF-8编码系统修改为GBK编码的系统?
需要靠我们勤劳的双手,嘿嘿嘿......
将系统文件复制一份,然后将eclipse的工作空间编码修改为GBK,导入系统;eclipse里面文件与原来文件进行一一比对,修改
Ctrl +c 和ctrl + v
除此之外,我目前还不知道如何一步修改,嘿嘿嘿......
3.3 项目结构
com.system.bean包:实体包,在有些情况下也写成entity或者pojo,相当于model持 久层
com.system.dao包:操作数据库的JDBC包,相当于model持久层
com.system.util包:工具包
com.system.view包:swing类包,相当于view视图层
com.system.service包:业务处理包,相当于model持久层
com.system.test包:测试包,和项目无关
mvc设计模式中:m是指业务模型,v是指用户界面,c则是控制器
你想问:这不是没有控制器层?
我:阿巴阿巴......确实没有
3.4 项目修改
在com.system.util包下面的DB类中,里面包含的一些数据库连接的基本信息,PASS变量需要修改成自己的数据库密码
3.5 项目运行
在com.system.view包下面的Login类,main函数就在这个类里面,然后点击右键就可以运行
3.6 代码片段
public class Login extends JFrame {
private JPanel contentPane;
private JPasswordField passwordField;
private JTextField usernameField;
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("员工工资管理系统");
setBounds(100, 100, 734, 548);
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(Color.BLACK);
panel.setBounds(0, 0, 361, 509);
contentPane.add(panel);
panel.setLayout(null);
JLabel lblNewLabel = new JLabel("");
lblNewLabel.setIcon(new ImageIcon(Login.class.getResource("/images/welcome.jpg")));
lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER);
lblNewLabel.setBounds(0, 0, 361, 426);
panel.add(lblNewLabel);
JLabel lblNewLabel_1 = new JLabel("员工工资管理系统");
lblNewLabel_1.setHorizontalAlignment(SwingConstants.CENTER);
lblNewLabel_1.setFont(new Font("微软雅黑", Font.BOLD, 18));
lblNewLabel_1.setForeground(Color.WHITE);
lblNewLabel_1.setBounds(67, 450, 212, 36);
panel.add(lblNewLabel_1);
JPanel panel_1 = new JPanel();
panel_1.setBackground(Color.WHITE);
panel_1.setBounds(361, 0, 357, 509);
contentPane.add(panel_1);
panel_1.setLayout(null);
JLabel lblNewLabel_2 = new JLabel("登 录");
lblNewLabel_2.setForeground(Color.BLUE);
lblNewLabel_2.setFont(new Font("微软雅黑", Font.BOLD, 18));
lblNewLabel_2.setHorizontalAlignment(SwingConstants.CENTER);
lblNewLabel_2.setBounds(97, 61, 155, 29);
panel_1.add(lblNewLabel_2);
JLabel lblNewLabel_3 = new JLabel("用户名:");
lblNewLabel_3.setFont(new Font("微软雅黑", Font.BOLD, 16));
lblNewLabel_3.setHorizontalAlignment(SwingConstants.RIGHT);
lblNewLabel_3.setBounds(41, 123, 72, 29);
panel_1.add(lblNewLabel_3);
JLabel lblNewLabel_3_1 = new JLabel("密 码:");
lblNewLabel_3_1.setHorizontalAlignment(SwingConstants.RIGHT);
lblNewLabel_3_1.setFont(new Font("微软雅黑", Font.BOLD, 16));
lblNewLabel_3_1.setBounds(41, 184, 72, 29);
panel_1.add(lblNewLabel_3_1);
JLabel lblNewLabel_3_1_1 = new JLabel("权 限:");
lblNewLabel_3_1_1.setHorizontalAlignment(SwingConstants.RIGHT);
lblNewLabel_3_1_1.setFont(new Font("微软雅黑", Font.BOLD, 16));
lblNewLabel_3_1_1.setBounds(41, 253, 72, 29);
panel_1.add(lblNewLabel_3_1_1);
passwordField = new JPasswordField();
passwordField.setBounds(116, 184, 167, 29);
panel_1.add(passwordField);
usernameField = new JTextField();
usernameField.setBounds(116, 123, 167, 29);
panel_1.add(usernameField);
usernameField.setColumns(10);
String[] menu = { "管理员", "普通用户" };
comboBox = new JComboBox(menu);
comboBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String a = (String) comboBox.getSelectedItem();
if ("普通用户".equals(a)) {
setVisible(false);
new EmployeeView().setVisible(true);
}
}
});
comboBox.setBounds(116, 253, 167, 29);
panel_1.add(comboBox);
JButton btnNewButton = new JButton("登录");
btnNewButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String username = usernameField.getText();
String password = passwordField.getText();
String status = (String) comboBox.getSelectedItem();
if ("".equals(username) || "".equals(password)) {
JOptionPane.showMessageDialog(null, "用户名或密码不能为空!");
} else {
UserService userService = new UserServiceImpl();
User user = userService.Login(username, password, status);
if (user != null) {
JOptionPane.showMessageDialog(null, "登录成功!");
setVisible(false);
new BG().setVisible(true);
} else {
JOptionPane.showMessageDialog(null, "登录失败!");
}
}
}
});
btnNewButton.setFont(new Font("微软雅黑", Font.BOLD, 14));
btnNewButton.setForeground(Color.BLACK);
btnNewButton.setBounds(41, 356, 93, 29);
panel_1.add(btnNewButton);
JButton btnNewButton_1 = new JButton("退出");
btnNewButton_1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
System.exit(1);
}
});
btnNewButton_1.setForeground(Color.BLACK);
btnNewButton_1.setFont(new Font("微软雅黑", Font.BOLD, 14));
btnNewButton_1.setBounds(231, 356, 93, 29);
panel_1.add(btnNewButton_1);
}
}