企业⼈事管理系统java源代码
import java.awt.* ;
import java.awt.event.*;
import java.sql.*;
import java.util.*;
import javax.swing.*;
import javax.swing.border.*;
public class A extends JFrame
{
protected JPanel p = new JPanel();
protected JPanel p1 = new JPanel();
protected JPanel p2 = new JPanel();
protected JPanel p3= new JPanel();
JMenuBar M =new JMenuBar();
JMenu m1 = new JMenu("基本信息模块");
JMenu m2 = new JMenu("考勤考评信息模块");
JMenu m3 = new JMenu("系统维护信息模块");
JMenuItem mm1 = new JMenuItem("员⼯基本信息"); JMenuItem mm2 = new JMenuItem("员⼯家庭成员基本信息"); JMenuItem mm3 = new JMenuItem("员⼯培训信息"); JMenuItem mm4 = new JMenuItem("员⼯考勤信息"); JMenuItem mm5 = new JMenuItem("员⼯考评信息"); JMenuItem mm6 = new JMenuItem("普通管理员"); JMenuItem mm7 = new JMenuItem("⾼级管理员"); JMenuItem mm8 = new JMenuItem("退出");
protected JLabel l1 = new JLabel("员⼯编号:");
protected JLabel l2 = new JLabel("姓名:");
protected JLabel l3 = new JLabel("性别:");
protected JLabel l4 = new JLabel("年龄:");
protected JLabel l5 = new JLabel("部门:");
protected JTextField t1 = new JTextField(10);
protected JTextField t2 = new JTextField(10);
protected JTextField t3 = new JTextField(10);
protected JTextField t4 = new JTextField(10);
protected JTextField t5 = new JTextField(10);
private JButton b1 = new JButton("查询");
private JButton b2 = new JButton("插⼊");
private JButton b3 = new JButton("修改");
private JButton b4 = new JButton("删除");
private JButton b5 = new JButton("清除");
private JButton b6 = new JButton("下⼀条");
private Connection c; // @jve:decl-index=0:
private Statement s; // @jve:decl-index=0:
private ResultSet r; // @jve:decl-index=0:
{
super("⼈事管理系统");
公司介绍源码getContentPane().add(p);
setJMenuBar(M);M.add(m1);M.add(m2);M.add(m3);m1.add(mm1);
m1.add(mm2);m1.add(mm3);m1.addSeparator();m1.add(mm8);m2.add(mm4);
m2.add(mm5);m3.add(mm6);m3.add(mm7);
p.add(p1,BorderLayout.NORTH);
p.add(p2,BorderLayout.CENTER);
p.add(p3,BorderLayout.SOUTH);
p1.setLayout(new GridLayout(5,2,1,3));
p1.add(l1);p1.add(t1);
p1.add(l2);p1.add(t2);
p1.add(l3);p1.add(t3);
p1.add(l4);p1.add(t4);
p1.add(l5);p1.add(t5);
p2.add(b1);p1.add(b2);
p2.add(b3);p1.add(b4);
p2.add(b5);p3.add(b6);
t1.setText("");t2.setText("");t3.setText("");t4.setText("");t5.setText("");
setSize(350,300);setVisible(true);
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDrive");
Connection("jdbc:odbc:sd","sa",null);
ateStatement();
uteQuery("select * from 员⼯基本信息表");
}
catch (SQLException e){
JOptionPane.showMessageDialog(null ,e.getMessage(),"操作错误!",JOptionPane.ERROR_MESSAGE); it(1);
}
catch(ClassNotFoundException e)
JOptionPane.showMessageDialog(null ,e.getMessage(),"驱动程序不到!",JOptionPane.ERROR_MESSAGE); it(1);
}
addWindowListener( new WindowAdapter(){
public void windowClosing(WindowEvent event)
{
try {
s.close();c.close();
catch(SQLException e)
{
JOptionPane.showMessageDialog(Message(),"不能关闭!",JOptionPane.ERROR_MESSAGE); it(1);
}
}
});
b1.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent event)
{
try{
uteQuery("select * from 员⼯基本信息表" + "where 员⼯编号='"+t1.getText()+"'");
())
{
t1.String(1));
t2.String(2));
t3.String(3));
t4.String(4));
t5.String(5));
JOptionPane.showMessageDialog(null,"查询成功!","查询操作",JOptionPane.ERROR_MESSAGE);
}
else{
t2.setText("");t3.setText("");t4.setText("");t5.setText("");
JOptionPane.showMessageDialog(null,"查询失败!","查询操作",JOptionPane.ERROR_MESSAGE);
}
catch(NumberFormatException e){
System.out.println(e);
}
catch(SQLException e){
System.out.println(e);
}
}
);
b2.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent event)
{
String v1,v2,v3,v4,v5;
Text();Text();Text();Text();Text();
if((!v1.equals( "" ))&&(!v2.equals(""))&&(!v3.equals(""))&&(!v4.equals(""))&&(!v5.equals ("")))
{
try{
int n1 = Integer.parseInt(v4);
int r1 = s.executeUpdate("INSERT INTO 员⼯基本信息表"+ "values('"+v1+"','"+v2+"','"+v3+"',"+n1+",'"+v5+"')"); if(r1!=0){
t1.setText("");t2.setText("");t3.setText("");t4.setText("");t5.setText("");
JOptionPane.showMessageDialog(null,"插⼊成功!","插⼊操作",JOptionPane.ERROR_MESSAGE);
}
}
catch (NumberFormatException e ){System.out.println(e);}
catch (SQLException e){System.out.println(e);}}
else{JOptionPane.showMessageDialog(null,"插⼊失败!","插⼊操作",JOptionPane.ERROR_MESSAGE);
}
}
}
);
b3.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent event)
try {
int uteUpdate("update 员⼯基本信息表set 姓名='"+t2.getText()+"'," +
"性别='"+t3.getText()+"'," +
"年龄="+Integer.Text())+"," +
"部门='"+t5.getText()+"'"+
"where 员⼯编号='"+t1.getText()+"'");
if(r1!=0){
JOptionPane.showMessageDialog(null,"修改成功!","修改操作",JOptionPane.ERROR_MESSAGE);
}
else{JOptionPane.showMessageDialog(null,"修改失败!","修改操作",JOptionPane.ERROR_MESSAGE);}} catch (NumberFormatException e ){System.out.println(e);}
catch (SQLException e){System.out.println(e);}}});
b4.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent event)
{
try{
int uteUpdate("delete from 员⼯基本信息表"+"where 员⼯编号='"+t1.getText()+"'");
if(r1!=0){
t1.setText("");t2.setText("");t3.setText("");t4.setText("");t5.setText("");
JOptionPane.showMessageDialog(null,"删除成功!","删除操作",JOptionPane.ERROR_MESSAGE);
}
else{JOptionPane.showMessageDialog(null,"删除失败!","删除操作",JOptionPane.ERROR_MESSAGE);}} catch (NumberFormatException e ){System.out.println(e);}
catch (SQLException e){System.out.println(e);}
}
}
);
b5.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent event)
{
t1.setText("");t2.setText("");t3.setText("");t4.setText("");t5.setText("");
}
}
);
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论