《课程设计考勤管理系统源代码.pdf》由会员分享,可在线阅读,更多相关《课程设计考勤管理系统源代码.pdf(103页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、package kaoqin;import javax.swing.*;import java.awt.*;import java.awt.event.*;import java.sql.Connection;import java.sql.DriverManager;import java.sql.ResultSet;import java.sql.SQLException;import java.sql.Statement;import java.sql.*;class AttendFrame extends JFrame/工作制类型public AttendFrame()private
2、void create()this.setTitle(工作制类型);this.setVisible(true);this.setContentPane(new JPanel();this.setSize(300,200);create();JButton b1,b2,b3;Box box1,box2,box;b1=new JButton(非弹性工作制);b2=new JButton(弹性工作制);b3=new JButton(返回);box1=Box.createHorizontalBox();box2=Box.createHorizontalBox();box=Box.createVerti
3、calBox();box1.add(b1);box1.add(Box.createHorizontalStrut(20);box1.add(b2);box2.add(b3);box.add(box1);box.add(Box.createVerticalStrut(30);box.add(box2);this.add(box);b1.addActionListener(new ActionListener()/Override public void actionPerformed(ActionEvent e)/TODO自动生成的方法存根 UBoundFrame frame=new UBoun
4、dFrame();dispose(););b2.addActionListener(new ActionListener()/Override public void actionPerformed(ActionEvent e)/TODO自动生成的方法存根BoundFrame frame=new BoundFrame();dispose(););b3.addActionListener(new ActionListener()/Override public void actionPerformed(ActionEvent e)/TODO自动生成的方法存根 MFrame frame=new M
5、Frame();dispose(););package kaoqin;import javax.swing.*;import java.awt.*;import java.awt.event.*;import java.sql.Connection;import java.sql.DriverManager;import java.sql.ResultSet;import java.sql.SQLException;import java.sql.Statement;import java.sql.*;class BoundFrame extends JFramepublic BoundFra
6、me()JLabel k1,k2,k3,k4,k5,k6;JTextField f1,f2,f3,f4,f5,f6;Box box1,box2,box3,box4,box5,box;JButton b1;private void create()k1=new JLabel(工号:);k2=new JLabel(姓名:);k3=new JLabel(当月工时:);this.setTitle(弹性工作制);this.setVisible(true);this.setContentPane(new JPanel();this.setSize(400,400);create();k4=new JLab
7、el(:);k5=new JLabel(当月工作天数);k6=new JLabel(当月富余:);b1=new JButton(返回);f1=new JTextField(5);f2=new JTextField(5);f3=new JTextField(5);f4=new JTextField(5);f5=new JTextField(5);f6=new JTextField(5);box1=Box.createHorizontalBox();box2=Box.createHorizontalBox();box3=Box.createHorizontalBox();box4=Box.crea
8、teHorizontalBox();box5=Box.createHorizontalBox();box=Box.createVerticalBox();box1.add(k1);box1.add(f1);box1.add(Box.createHorizontalStrut(20);box1.add(k2);box1.add(f2);box2.add(k3);box2.add(f3);box2.add(k4);box2.add(f4);box3.add(k5);box3.add(f5);box4.add(k6);box4.add(f6);box5.add(b1);box.add(box1);b
9、ox.add(Box.createVerticalStrut(20);box.add(box2);box.add(Box.createVerticalStrut(20);box.add(box3);box.add(Box.createVerticalStrut(20);box.add(box4);box.add(Box.createVerticalStrut(20);box.add(box5);this.add(box);b1.addActionListener(new ActionListener()/Override public void actionPerformed(ActionEv
10、ent e)/TODO自动生成的方法存根 AttendFrame frame=new AttendFrame();dispose(););package kaoqin;import java.sql.Connection;拟定import java.sql.DriverManager;import java.sql.ResultSet;import java.sql.SQLException;import java.sql.Statement;public class ConnectionDB private String JDriver=sun.jdbc.odbc.JdbcOdbcDrive
11、r;private String sqlURL=jdbc:odbc:bobo;/private String JDriver=com.microsoft.sqlserver.jdbc.SQLServerDriver;/privateStringsqlURL=jdbc:sqlserver:/localhost:1433;DatabaseName=MyTest;integratedSecurity=TRUE;private Connection connection;private Statement statement;private static Connection conn=null;pr
12、ivate String tableSQL=new String4;public ConnectionDB()try Class.forName(JDriver);connection=DriverManager.getConnection(sqlURL);statement=connection.createStatement();catch(ClassNotFoundException e)e.printStackTrace();catch(SQLException e)e.printStackTrace();public Connection getConnection()public
13、Statement getStatement()public void breakDB()try statement.close();connection.close();return statement;return connection;catch(SQLException e)e.printStackTrace();public void createTable()tableSQL0=create table staff_info(+Sno char(9)primary key,+Sname char(10)not null,+Sage smallint,+enter_time char
14、(10)not null,+position char(10)not null,+sex char(1),+password char(6);tableSQL1=create table pz_info(+arrive_hour char(2),+arrive_minute char(2),+leave_hour char(2),+leave_minute char(2),+everyday_time char(2);tableSQL2=create table everymonth_statistics(+Sno char(9)not null,+Sname char(10)not null
15、,+remain_time char(4),+late_times smallint,+early_leave smallint,+work_day smallint,+primary key(Sno),+foreign key(Sno)+references staff_info(Sno)on delete cascade);tableSQL3=create table everyday_statistics(+Sno char(9)not null,+Sname char(10)not null,+hour char(2),+minute char(2),+action char(6),+
16、time char(4),+primary key(Sno),+foreign key(Sno)+references staff_info(Sno)on delete cascade);try for(int i=0;i4;i+)statement.executeUpdate(tableSQLi);catch(SQLException e)e.printStackTrace();private static ResultSet executeQuery(String sql)try if(conn=null)new ConnectionDB();returnconn.createStatem
17、ent(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDA TABLE).executeQuery(sql);catch(SQLException e)e.printStackTrace();return null;finally package kaoqin;import javax.swing.*;import java.awt.*;import java.awt.event.*;import java.sql.Connection;import java.sql.DriverManager;import java.sql.Resul
18、tSet;import java.sql.SQLException;import java.sql.Statement;import java.sql.*;class Equ_Frame extends JFrame/配置信息public Equ_Frame()this.setTitle(配置信息);this.setSize(400,400);this.setContentPane(new JPanel();this.setVisible(true);this.create();JLabel k1,k2,k3,k4,k5,k6,k7,k8,k9,k10;JLabel f1,f2,f3,f4,f
19、5,f6,f7,f8,f9,f10;Box box1,box2,box3,box4,box5,box6,box7,box;JButton b1,b2;private void create()k1=new JLabel(上班时间:);k2=new JLabel(:);k3=new JLabel(下班时间:);k4=new JLabel(:);k5=new JLabel(每月工作总时间:);k6=new JLabel(每月工作天数:);k7=new JLabel(每月工作日期:);k8=new JLabel();k9=new JLabel(每月放假日期:);k10=new JLabel();b1
20、=new JButton(修改);b2=new JButton(返回);f1=new JLabel(08);f2=new JLabel(30);f3=new JLabel(17);f4=new JLabel(30);f5=new JLabel(200);f6=new JLabel(22);f7=new JLabel(星期一);f8=new JLabel(星期五);f9=new JLabel(星期六);f10=new JLabel(星期日);box1=Box.createHorizontalBox();box2=Box.createHorizontalBox();box3=Box.createH
21、orizontalBox();box4=Box.createHorizontalBox();box5=Box.createHorizontalBox();box6=Box.createHorizontalBox();box7=Box.createHorizontalBox();box=Box.createVerticalBox();box1.add(k1);box1.add(f1);box1.add(k2);box1.add(f2);box2.add(k3);box2.add(f3);box2.add(k4);box2.add(f4);box3.add(k5);box3.add(f5);box
22、4.add(k6);box4.add(f6);box5.add(k7);box5.add(f7);box5.add(k8);box5.add(f8);box6.add(k9);box6.add(f9);box6.add(k10);box6.add(f10);box7.add(b1);box7.add(Box.createHorizontalStrut(20);box7.add(b2);box.add(box1);box.add(Box.createVerticalStrut(20);box.add(box2);box.add(Box.createVerticalStrut(20);box.ad
23、d(box3);box.add(Box.createVerticalStrut(20);box.add(box4);box.add(Box.createVerticalStrut(20);box.add(box5);box.add(Box.createVerticalStrut(20);box.add(box6);box.add(Box.createVerticalStrut(20);box.add(box7);this.add(box);b1.addActionListener(new ActionListener()/拟定 Override public void actionPerfor
24、med(ActionEvent e)/TODO自动生成的方法存根 EquAltFrame frame=new EquAltFrame();dispose(););b2.addActionListener(new ActionListener()/Override public void actionPerformed(ActionEvent e)/TODO自动生成的方法存根 MFrame frame=new MFrame();dispose();拟定 );package kaoqin;import javax.swing.*;import java.awt.*;import java.awt.
25、event.*;import java.sql.Connection;import java.sql.DriverManager;import java.sql.ResultSet;import java.sql.SQLException;import java.sql.Statement;import java.sql.*;class EquAltFrame extends JFrame /修改配置信息public EquAltFrame()this.setTitle(修改配置信息);this.setSize(400,400);this.setContentPane(new JPanel()
26、;this.setVisible(true);this.create();JLabel k1,k2,k3,k4,k5,k6,k7,k8,k9,k10;JTextField f1,f2,f3,f4,f5,f6,f7,f8,f9,f10;Box box1,box2,box3,box4,box5,box6,box7,box;JButton b1,b2;private void create()k1=new JLabel(上班时间:);k2=new JLabel(:);k3=new JLabel(下班时间:);k4=new JLabel(:);k5=new JLabel(每月工作总时间:);k6=ne
27、w JLabel(每月工作天数:);k7=new JLabel(每月工作日期:);k8=new JLabel();k9=new JLabel(每月放假日期:);k10=new JLabel();b1=new JButton(保存);b2=new JButton(取消);f1=new JTextField(5);f2=new JTextField(5);f3=new JTextField(5);f4=new JTextField(5);f5=new JTextField(5);f6=new JTextField(5);f7=new JTextField(5);f8=new JTextField(
28、5);f9=new JTextField(5);f10=new JTextField(5);box1=Box.createHorizontalBox();box2=Box.createHorizontalBox();box3=Box.createHorizontalBox();box4=Box.createHorizontalBox();box5=Box.createHorizontalBox();box6=Box.createHorizontalBox();box7=Box.createHorizontalBox();box=Box.createVerticalBox();box1.add(
29、k1);box1.add(f1);box1.add(k2);box1.add(f2);box2.add(k3);box2.add(f3);box2.add(k4);box2.add(f4);box3.add(k5);box3.add(f5);box4.add(k6);box4.add(f6);box5.add(k7);box5.add(f7);box5.add(k8);box5.add(f8);box6.add(k9);box6.add(f9);box6.add(k10);box6.add(f10);box7.add(b1);box7.add(Box.createHorizontalStrut
30、(20);box7.add(b2);box.add(box1);box.add(Box.createVerticalStrut(20);box.add(box2);box.add(Box.createVerticalStrut(20);box.add(box3);box.add(Box.createVerticalStrut(20);box.add(box4);box.add(Box.createVerticalStrut(20);box.add(box5);box.add(Box.createVerticalStrut(20);box.add(box6);box.add(Box.create
31、VerticalStrut(20);box.add(box7);this.add(box);b1.addActionListener(new ActionListener()/自动生成的方法存根拟定 Override public void actionPerformed(ActionEvent e)/TODO Equ_Frame in=new Equ_Frame();EquAltFrame on=new EquAltFrame();in.f1.setText(on.f1.getText();in.f2.setText(on.f2.getText();in.f3.setText(on.f3.g
32、etText();in.f4.setText(on.f4.getText();in.f5.setText(on.f5.getText();in.f6.setText(on.f6.getText();in.f7.setText(on.f7.getText();in.f8.setText(on.f8.getText();in.f9.setText(on.f9.getText();in.f10.setText(on.f10.getText(););b2.addActionListener(new ActionListener()/拟定 Override public void actionPerfo
33、rmed(ActionEvent e)/TODO自动生成的方法存根 Equ_Frame frame=new Equ_Frame();dispose(););package kaoqin;import javax.swing.*;import java.awt.*;import java.awt.event.*;import java.sql.Connection;import java.sql.DriverManager;import java.sql.ResultSet;import java.sql.SQLException;import java.sql.Statement;import
34、 java.sql.*;class login extends JFrame/管理员登陆界面 public login()this.setTitle(管理员登陆界面);this.setSize(300,300);this.setContentPane(new JPanel();this.setVisible(true);init();JTextField jTextField1;JPasswordField jPasswordField1;private void init()JLabel jLabel1=new JLabel(管理员登陆);JLabel jLabel2=new JLabel(
35、用户名);JLabel jLabel3=new JLabel(密码);jTextField1=new JTextField(10);jPasswordField1=new JPasswordField(10);JButton button1=new JButton(拟定);JButton button2=new JButton(取消);JButton button3=new JButton(修改密码);Box box,box1,box2,box3,box4,box5;box1=Box.createHorizontalBox();box1.add(jLabel1);box1.add(Box.cr
36、eateHorizontalStrut(10);box2=Box.createHorizontalBox();box2.add(jLabel2);box2.add(Box.createHorizontalStrut(20);box2.add(jTextField1);box3=Box.createHorizontalBox();box3.add(jLabel3);box3.add(Box.createHorizontalStrut(20);box3.add(jPasswordField1);box4=Box.createHorizontalBox();box4.add(button1);box
37、4.add(Box.createHorizontalStrut(20);box4.add(button2);box5=Box.createHorizontalBox();box5.add(button3);box=Box.createVerticalBox();box.add(box1);box.add(Box.createVerticalStrut(20);box.add(box2);box.add(Box.createVerticalStrut(20);box.add(box3);box.add(Box.createVerticalStrut(20);box.add(box4);box.a
38、dd(Box.createVerticalStrut(20);box.add(box5);this.add(box);button1.addActionListener(new ActionListener()Override public void actionPerformed(ActionEvent e)/TODO自动生成的方法存根/login im=new login();String name=jTextField1.getText(),password=jPasswordField1.getText();if(name.equals(admin)&password.equals(1
39、23456)else JOptionPane.showMessageDialog(new JFrame(WARNING),用户名 MFrame mi=new MFrame();dispose();或密码错误););Override public void actionPerformed(ActionEvent e)/TODO自动生成的方法存根 Main_login frame=new Main_login();button2.addActionListener(new ActionListener()dispose(););Override public void actionPerforme
40、d(ActionEvent e)/TODO自动生成的方法存根 MPwd f1=new MPwd();dispose();button3.addActionListener(new ActionListener();package kaoqin;import javax.swing.*;import java.awt.*;import java.awt.event.*;import java.sql.Connection;import java.sql.DriverManager;import java.sql.ResultSet;import java.sql.SQLException;imp
41、ort java.sql.Statement;import java.sql.*;class login1 extends JFrame/普通用户登陆界面public login1()this.setTitle(普通用户登陆界面);this.setSize(300,300);this.setContentPane(new JPanel();this.setVisible(true);init();JTextField jTextField1;JPasswordField jPasswordField1;private void init()JLabel jLabel1=new JLabel(员
42、工登陆);JLabel jLabel2=new JLabel(用户名);JLabel jLabel3=new JLabel(密码);jTextField1=new JTextField(10);jPasswordField1=new JPasswordField(10);JButton button1=new JButton(拟定);JButton button2=new JButton(取消);JButton button3=new JButton(修改密码);Box box,box1,box2,box3,box4,box5;box1=Box.createHorizontalBox();bo
43、x1.add(jLabel1);box1.add(Box.createHorizontalStrut(10);box2=Box.createHorizontalBox();box2.add(jLabel2);box2.add(Box.createHorizontalStrut(20);box2.add(jTextField1);box3=Box.createHorizontalBox();box3.add(jLabel3);box3.add(Box.createHorizontalStrut(20);box3.add(jPasswordField1);box4=Box.createHorizo
44、ntalBox();box4.add(button1);box4.add(Box.createHorizontalStrut(20);box4.add(button2);box5=Box.createHorizontalBox();box5.add(button3);box=Box.createVerticalBox();box.add(box1);box.add(Box.createVerticalStrut(20);box.add(box2);box.add(Box.createVerticalStrut(20);box.add(box3);box.add(Box.createVertic
45、alStrut(20);box.add(box4);box.add(Box.createVerticalStrut(20);box.add(box5);this.add(box);button1.addActionListener(new ActionListener()Override public void actionPerformed(ActionEvent e)/TODO自动生成的方法存根 String name=jTextField1.getText(),password=jPasswordField1.getText();if(name.equals(user)&password
46、.equals(123456)else WoSerFrame2 mi=new WoSerFrame2();dispose();JOptionPane.showMessageDialog(new JFrame(WARNING),用户名或密码错误););Override public void actionPerformed(ActionEvent e)/TODO自动生成的方法存根 Main_login frame=new Main_login();dispose(););button2.addActionListener(new ActionListener()button3.addAction
47、Listener(new ActionListener()Override public void actionPerformed(ActionEvent e)/TODO自动生成的方法存根 MPwd f1=new MPwd();dispose(););package kaoqin;import javax.swing.*;import java.awt.*;import java.awt.event.*;import java.io.*;import java.sql.*;public class Main_login extends JFrame implements ActionListe
48、nerpublic Main_login()private void create()JButton b1,b2,b3;Box box1,box2,box3,box;b1=new JButton(系统管理员);b2=new JButton(普通用户);b3=new JButton(退出登陆);b1.addActionListener(this);b2.addActionListener(this);b3.addActionListener(this);box1=Box.createHorizontalBox();box2=Box.createHorizontalBox();box3=Box.c
49、reateHorizontalBox();box1.add(b1);super(选择用户类型);this.setSize(300,300);this.setContentPane(new JPanel();create();box2.add(b2);box3.add(b3);box=Box.createVerticalBox();box.add(box1);box.add(Box.createVerticalStrut(20);box.add(box2);box.add(Box.createVerticalStrut(40);box.add(box3);this.add(box);public
50、 void actionPerformed(ActionEvent e)if(e.getActionCommand()=系统管理员)else if(e.getActionCommand()=普通用户)login1 frame=new login1();dispose();login frame=new login();dispose();else if(e.getActionCommand()=退出登陆)System.exit(0);public static void main(String args)int flag=0;/判断是否创建过数据库的标志File file=new File(S