java考勤管理系统数据库实现.docx

上传人:小飞机 文档编号:3159804 上传时间:2023-03-11 格式:DOCX 页数:15 大小:39.58KB
返回 下载 相关 举报
java考勤管理系统数据库实现.docx_第1页
第1页 / 共15页
java考勤管理系统数据库实现.docx_第2页
第2页 / 共15页
java考勤管理系统数据库实现.docx_第3页
第3页 / 共15页
java考勤管理系统数据库实现.docx_第4页
第4页 / 共15页
java考勤管理系统数据库实现.docx_第5页
第5页 / 共15页
亲,该文档总共15页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述

《java考勤管理系统数据库实现.docx》由会员分享,可在线阅读,更多相关《java考勤管理系统数据库实现.docx(15页珍藏版)》请在三一办公上搜索。

1、java考勤管理系统数据库实现4.2设计代码Java源程序: import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.awt.*; import java.sql.*; import java.lang.*; import java.util.*; import javax.swing.table.*; import java.math.*; class DB_LS implements ActionListener JFrame frame=new JFrame(欢迎进入LS工资管理系统);

2、JLabel label=new JLabel(09网络2_54_李胜,JLabel.CENTER); JButton button1=new JButton(进入系统); JButton button2=new JButton(退出系统); ImageIcon im=new ImageIcon(1.jpg); JLabel a1=new JLabel(im); void Create JPanel pcontentPane=(JPanel)frame.getContentPane; JPanel pcontentPane1=new JPanel; pcontentPane.add(label

3、); pcontentPane.setLayout(new FlowLayout); pcontentPane.add(button1); pcontentPane.add(button2); pcontentPane.add(new Label( ); pcontentPane.add(a1); pcontentPane.setBackground(Color.green); pcontentPane.setVisible(true); button1.addActionListener(this); button2.addActionListener(this); public stati

4、c void main(String args) DB_LS dome=new DB_LS; dome.Create; frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack; frame.setBounds(200,100,550,600); frame.setVisible(true); public void actionPerformed(ActionEvent e) 1 if(button1.equals(e.getSource) DL dl=new DL; dl.create; if(button2.equa

5、ls(e.getSource)/退出 System.exit(0); class DL implements ActionListener JFrame frame=new JFrame(职工/管理员登陆); JLabel label1=new JLabel(用户名); JLabel label2=new JLabel(密码); JButton logonButton1=new JButton(管理员登录); JButton logonButton2=new JButton(职工登录); JButton cancelButton=new JButton(退出); JTextField t1=n

6、ew JTextField(0); JTextField t2=new JTextField(0); ImageIcon im=new ImageIcon(2.jpg); JLabel a2=new JLabel(im); JTextField username=new JTextField(9); JPasswordField password=new JPasswordField(9); void create JPanel p=(JPanel)frame.getContentPane; JPanel p1=new JPanel; p.setLayout(new FlowLayout);

7、p.add(label1); p.setSize(5,5); p.setLocation(4,8); p.add(username); p.setSize(100,200); p.setLocation(800,800); p.add(label2); p.setSize(50,20); p.setLocation(40,80); p.add(password); p.setSize(100,20); p.setLocation(80,120); p.add(logonButton1); p.add(new JLabel( ); 2 p.add(logonButton2); p.add(new

8、 JLabel( ); p.add(cancelButton); p.add(new JLabel( ); p.add(a2); p.add(t1); p.add(t2); p.setBackground(Color.blue); p.setVisible(true); logonButton1.addActionListener(this); logonButton2.addActionListener(this); cancelButton.addActionListener(this); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOS

9、E); frame.pack; frame.setBounds(200,100,750,550); frame.setVisible(true); public void actionPerformed(ActionEvent e) if(logonButton1.equals(e.getSource)&(username.getText.equals(123)=true)&(password.getText.equals(123)=true) if(logonButton2.equals(e.getSource)&(username.getText.equals(t1.getText)= G

10、ZGLZJM gz=new GZGLZJM; gz.create; elseJOptionPane.showMessageDialog(null,对不起,你输入的密码错误!); ; true)&(password.getText.equals(t2.getText)=true) Connection con; Statement sql; ResultSet rs; Vector vector=new Vector; try Class.forName(sun.jdbc.odbc.JdbcOdbcDriver); XK xk=new XK; xk.create; catch (ClassNot

11、FoundException e1) System.out.println( + e1); try con = DriverManager.getConnection(jdbc:odbc:123, , ); 3 sql = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY); sql.executeQuery(SELECT Gno,mm FROM Y WHERE Gno=+t1.getText +AND mm=+t2.getText); catch (SQLException e1) S

12、ystem.out.println(e1); if(cancelButton.equals(e.getSource) System.exit(0); class GZGLZJM extends JFrame implements ActionListener JFrame f=new JFrame(工资管理系统); JButton b1=new JButton(津贴管理); JButton b2=new JButton(总查询); JButton b3=new JButton(工资管理); JButton b4=new JButton(后勤管理); JButton b6=new JButton

13、(员工个人信息管理); JButton b5=new JButton(返回); ImageIcon im=new ImageIcon(3.jpg); JLabel a3=new JLabel(im); void create JPanel p=(JPanel)f.getContentPane; JPanel p1=new JPanel; p.setLayout(new FlowLayout); p.add(b1); p.add(new JLabel( ); p.add(b6); p.add(new JLabel( ); p.add(b3); p.add(new JLabel( ); p.add

14、(b4); p.add(new JLabel( ); p.add(b2); p.add(new JLabel( ); p.add(b5); p.add(a3); p.setBackground(Color.red); p.setVisible(true); b1.addActionListener(this); 4 b2.addActionListener(this); b3.addActionListener(this); b4.addActionListener(this); b5.addActionListener(this); b6.addActionListener(this); f

15、.setBounds(200,100,800,600); f.setVisible(true); public void actionPerformed(ActionEvent e) if(b5.equals(e.getSource)/返回 if(b1.equals(e.getSource)/津贴管理 if(b6.equals(e.getSource)/员工个人信息管理 if(b2.equals(e.getSource)/查询 if(b4.equals(e.getSource)/后勤管理 if(b3.equals(e.getSource)/工资管理 GZGL gz=new GZGL; clas

16、s KQGL implements ActionListener JFrame f=new JFrame(录入修改删除考勤信息); JButton b1=new JButton(录入); JButton b2=new JButton(修改); JButton b3=new JButton(删除); JButton b4=new JButton(查询所有); gz.create; KQGL kq=new KQGL; kq.create; XK xk=new XK; xk.create; YGGL yg=new YGGL; yg.create; JTGL jt=new JTGL; jt.creat

17、e; DL d=new DL; f.dispose; 5 JButton b5=new JButton(返回); JTextField tf1=new JTextField(4); JTextField tf2=new JTextField(4); JTextField tf3=new JTextField(4); JTextField tf4=new JTextField(4); JTextField tf5=new JTextField(6); JButton b6=new JButton(查询单人考勤); String cloum=职工号,缺勤天数,缺勤类别,缺勤时间; Object r

18、ow=new Object504; JTable table=new JTable(row,cloum); JScrollPane scrollpane=new JScrollPane(table); JSplitPane splitpane=new JSplitPane(JSplitPane.VERTICAL_SPLIT); void create JPanel p=(JPanel)f.getContentPane; p.setLayout(new FlowLayout); /p.add(scrollpane); p.add(splitpane); JPanel p1=new JPanel;

19、 p1.add(b1); p1.add(b2); p1.add(b3); p1.add(b4); p1.add(b6); p1.add(b5); JPanel p2=new JPanel; p2.setBackground(Color.red); p2.add(scrollpane); JPanel p3=new JPanel; p.setLayout(new FlowLayout); p.add(new JLabel(); p.add(new JLabel(职工号); p.add(tf1); p.add(new JLabel(缺勤天数); p.add(tf2); p.add(new JLab

20、el(缺勤类别); p.add(tf3); 6 p.add(new JLabel(); p.add(new JLabel(缺勤时间); p.add(tf4); p.add(new JLabel( 在此处输入职工号点击查询删除); p.add(tf5); splitpane.add(p1,splitpane.TOP); splitpane.add(p2,splitpane.BOTTOM); splitpane.setDividerLocation(50); p.setBackground(Color.CYAN); b1.addActionListener(this); b2.addActionL

21、istener(this); b3.addActionListener(this); b4.addActionListener(this); b5.addActionListener(this); b6.addActionListener(this); f.setBounds(200,100,500,600); f.setResizable(true);/可以调整界面大小 f.setVisible(true); public void actionPerformed(ActionEvent e) if(b1.equals(e.getSource) /添加 Connection con; Sta

22、tement sql; ResultSet rs; try Class.forName(sun.jdbc.odbc.JdbcOdbcDriver); catch (ClassNotFoundException e1) System.out.println( + e1); try con = DriverManager.getConnection(jdbc:odbc:123, , ); sql = con.createStatement; 7 String insertStr = INSERT INTO K VALUES + ( + + tf1.getText + + , + tf2.getTe

23、xt+, + +tf3.getText+ + ,+tf4.getText+); sql.executeUpdate(insertStr); con.close; catch (SQLException e1) System.out.println(e1); if(b2.equals(e.getSource)/修改 Connection con; Statement sql; ResultSet rs; try Class.forName(sun.jdbc.odbc.JdbcOdbcDriver); catch (ClassNotFoundException e1) System.out.pri

24、ntln( + e1); try con = DriverManager.getConnection(jdbc:odbc:123, , ); sql = con.createStatement; sql.executeUpdate(UPDATE K SET ts=+tf2.getText+WHERE Kno=+tf1.getText+); sql.executeUpdate(UPDATE K SET lb=+tf3.getText+WHERE Kno=+tf1.getText+); sql.executeUpdate(UPDATE K SET sj=+tf4.getText+WHERE Kno

25、=+tf1.getText+); con.close; catch (SQLException e1) System.out.println(e1); if(b3.equals(e.getSource)/删除 Connection con; Statement sql; ResultSet rs; try Class.forName(sun.jdbc.odbc.JdbcOdbcDriver); catch (ClassNotFoundException e1) System.out.println( + e1); try con = DriverManager.getConnection(jd

26、bc:odbc:123, , ); 8 sql = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY); sql.executeUpdate(DELETE FROM K WHERE Kno=+tf5.getText); con.close; catch (SQLException e1) System.out.println(e1); if(b4.equals(e.getSource)/查询全部 Connection con; Statement sql; ResultSet rs; V

27、ector vector=new Vector; try Class.forName(sun.jdbc.odbc.JdbcOdbcDriver); catch (ClassNotFoundException e1) try con = DriverManager.getConnection(jdbc:odbc:123, sa, ); sql = System.out.println( + e1); con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY); if(b4.equals(e.get

28、Source) for(int i=0;i50;i+) for(int j=0;j4;j+) table.setValueAt(,i,j) ; rs = sql.executeQuery(SELECT * FROM K ORDER BY Kno DESC); int k=-1; while(rs.next) +k; String Kno = rs.getString(1); String ts = rs.getString(2); String lb = rs.getString(3); String sj = rs.getString(4); table.setValueAt(Kno,k,0

29、); table.setValueAt(ts,k,1); table.setValueAt(lb,k,2); 9 table.setValueAt(sj,k,3); catch (SQLException e1) System.out.println(e1); if(b6.equals(e.getSource) /查询关键字 Connection con; Statement sql; ResultSet rs; Vector vector=new Vector; try Class.forName(sun.jdbc.odbc.JdbcOdbcDriver); catch (ClassNotF

30、oundException e1) try con = DriverManager.getConnection(jdbc:odbc:123, sa, ); sql = System.out.println( + e1); con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY); if(b6.equals(e.getSource) for(int i=0;i50;i+) for(int j=0;j4;j+) table.setValueAt(, i, j); rs = sql.executeQ

31、uery(SELECT * FROM K WHERE Kno=+tf5.getText); int k=-1; while (rs.next) +k; String Kno = rs.getString(1); String ts = rs.getString(2); String lb = rs.getString(3); String sj = rs.getString(4); table.setValueAt(Kno,k,0); table.setValueAt(ts,k,1); table.setValueAt(lb,k,2); table.setValueAt(sj,k,3); 10 catch (SQLException e1) System.out.println(e1); if(b5.equals(e.getSource)/返回 DL dl=new DL; f.dispose; 11

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 生活休闲 > 在线阅读


备案号:宁ICP备20000045号-2

经营许可证:宁B2-20210002

宁公网安备 64010402000987号