企业员工考勤管理系统 32页

  • 520.42 KB
  • 2022-05-17 13:25:06 发布

企业员工考勤管理系统

  • 32页
  • 当前文档由用户上传发布,收益归属用户
  1. 1、本文档共5页,可阅读全部内容。
  2. 2、本文档内容版权归属内容提供方,所产生的收益全部归内容提供方所有。如果您对本文有版权争议,可选择认领,认领后既往收益都归您。
  3. 3、本文档由用户上传,本站不保证质量和数量令人满意,可能有诸多瑕疵,付费之前,请仔细先通过免费阅读内容等途径辨别内容交易风险。如存在严重挂羊头卖狗肉之情形,可联系本站下载客服投诉处理。
  4. 文档侵权举报电话:19940600175。
(一)、登录代码packageZGKQ;importjava.awt.*;importjava.awt.event.*;importjavax.swing.*;importjava.sql.*;publicclassLoginextendsJFrameimplementsActionListener{JFramejf;Containercon=getContentPane();JTextFieldtfName;JPasswordFieldps;JLabellabel;JLabellbName;JLabellbps;JLabelshenfen;JButtonbt1;JButtonbt2;privateStringpsword;JComboBoxbox;JPaneljp1;publicLogin(){jf=this;setTitle("用户登录界面");con.setBackground(Color.black);Fontf=newFont("新宋体",Font.PLAIN,22);/////////////////////////////////////////////////((JPanel)this.getContentPane()).setOpaque(false);ImageIconimg=newImageIcon("4.jpg");//添加图片 JLabelbackground=newJLabel(img);this.getLayeredPane().add(background,newInteger(Integer.MIN_VALUE));background.setBounds(0,0,img.getIconWidth(),img.getIconHeight());jp1=newJPanel();////////////////////////////////////////////////tfName=newJTextField();ps=newJPasswordField();label=newJLabel("职工考勤管理系统");lbName=newJLabel("用户名:");lbps=newJLabel("密码:");bt1=newJButton("登录");bt2=newJButton("清空");///////////////////////////////////////////////con.setLayout(null);jp1=newJPanel();con.add(jp1);con.add(label);label.setFont(f);label.setBounds(220,100,300,40);con.add(lbName);con.add(tfName);lbName.setBounds(250,250,80,20);tfName.setBounds(330,250,100,20);shenfen=newJLabel("身份:");shenfen.setBounds(250,310,80,20);con.add(shenfen);box=newJComboBox();box.addItem("管理员"); box.addItem("员工");con.add(box);box.setBounds(330,310,80,20);con.add(lbps);con.add(ps);lbps.setBounds(250,280,80,20);ps.setBounds(330,280,100,20);con.add(bt1);con.add(bt2);bt1.setBounds(260,340,60,20);bt1.setBackground(Color.gray);bt2.setBounds(350,340,60,20);bt2.setBackground(Color.gray);bt1.addActionListener(this);bt2.addActionListener(this);setBounds(310,150,700,500);setVisible(true);}publicvoidactionPerformed(ActionEvente){Databasedb=newDatabase();db.OpenConn();Stringpass=newString(ps.getPassword()).trim();Stringname=tfName.getText().trim();Objectsource=e.getSource();if(box.getSelectedItem().equals("管理员")){ if(source==bt1){try{Stringsql="select*fromlogin_adminwhereadmin=""+name+""andpassword=""+pass+""";ResultSetres=db.executeQuery(sql);while(res.next()){psword=res.getString(2).trim();}if(name.equals("")){newJOptionPane().showMessageDialog(null,"用户名不能为空!");}elseif(pass.equals("")){newJOptionPane().showMessageDialog(null,"密码不能为空!");}elseif(pass.equals(psword)){this.dispose();newmain_1().setVisible(true);}else{newJOptionPane().showMessageDialog(null,"密码错误!");}}catch(SQLExceptione1){//TODOAuto-generatedcatchblocke1.printStackTrace();}}}if((box.getSelectedItem().equals("员工"))){if(source==bt1){try{ Stringsql="select*fromlogin_wwherew_id=""+name+""andpassword_w=""+pass+""";ResultSetres=db.executeQuery(sql);while(res.next()){psword=res.getString(2).trim();}Stringnum=tfName.getText().trim();if(name.equals("")){newJOptionPane().showMessageDialog(null,"用户名不能为空!");}elseif(pass.equals("")){newJOptionPane().showMessageDialog(null,"密码不能为空!");}elseif(pass.equals(psword)){this.dispose();newmain_2().setVisible(true);}else{newJOptionPane().showMessageDialog(null,"密码错误!");}}catch(SQLExceptione1){//TODOAuto-generatedcatchblocke1.printStackTrace();}}}if(e.getSource()==bt2){tfName.setText(""); ps.setText("");}}publicstaticvoidmain(Stringargs[]){newLogin();}}(二)、管理员主界面代码packageZGKQ;importjava.awt.*;importjava.awt.event.ActionEvent;importjava.awt.event.ActionListener;importjava.sql.Connection;importjava.sql.DriverManager;importjava.sql.PreparedStatement;importjava.sql.ResultSet;importjava.sql.SQLException;importjava.sql.Statement;importjavax.swing.*;importZGKQ_add.*;importZGKQ_query.*;importZGKQ_delete.*;importZGKQ_update.*;publicclassmain_1extendsJFrameimplementsActionListener{ Containercon;JTabletable1=newJTable(200,5);//JScrollPanescrollPane=newJScrollPane(table1);JPanelpn=newJPanel();//创建一个面板并实例化JPanelp1=newJPanel();JPanelp2=newJPanel();JPanelp3=newJPanel();//JPanelp4=newJPanel();Labellb1=newLabel("欢迎使用员工考勤管理系统!有不明白请看帮助!");JLabellb2=newJLabel(newImageIcon("2.jpg"));//实例化菜单栏JMenuBarmb=newJMenuBar();//实例化菜单开始JMenusystemM;JMenujibenM; JMenuguanliM;JMenuhelpM;JMenuaboutM;//文件的菜单项JMenuItempsUpdate;JMenuItemlogin;//JMenuItemaddDelete;JMenuItemexit;//基本信息的菜单项JMenuItemworker;JMenuItemwork_note;JMenuItemout_note;JMenuItemoff_note;JMenuItemover_note;//信息管理JMenukqquery; JMenuItemjibenquery;JMenuItemdakaquery;JMenuItemjiabanquery;JMenuItemchuchaiquery;JMenuItemqingjiaquery;JMenukqadd;JMenuItemjibenadd;JMenuItemdakaadd;JMenuItemjiabanadd;JMenuItemchuchaiadd;JMenuItemqingjiaadd;JMenukqupdate;JMenuItemjibenupdate;JMenuItemdakaupdate;JMenuItemjiabanupdate; JMenuItemchuchaiupdate;JMenuItemqingjiaupdate;JMenukqdelete;JMenuItemjibendelete;JMenuItemdakadelete;JMenuItemjiabandelete;JMenuItemchuchaidelete;JMenuItemqingjiadelete;JMenuItemhelpcon;JMenuItemaboutcon;JButtonb1,b2,b3,b4,b5,b6,b7,b8,b9;Fontf=newFont("宋体",Font.PLAIN,20);//设置一种字体main_1(){setTitle("员工考勤管理系统");//设置窗体标题con=getContentPane();con.setLayout(newBorderLayout());//创建一个布局 con.add(pn,BorderLayout.CENTER);//实例虚拟桌面的布局//////////////////////////////////////////////////////////////////////////////((JPanel)this.getContentPane()).setOpaque(false);ImageIconimg=newImageIcon("3.jpg");//添加图片JLabelbackground=newJLabel(img);this.getLayeredPane().add(background,newInteger(Integer.MIN_VALUE));background.setBounds(0,0,img.getIconWidth(),img.getIconHeight());/////////////////////////////////////////////////////////////////////////////////实例化菜单栏mb=newJMenuBar();//实例化菜单开始systemM=newJMenu("菜单");jibenM=newJMenu("基本信息");guanliM=newJMenu("信息管理");helpM=newJMenu("帮助");aboutM=newJMenu("关于");//文件的菜单项psUpdate=newJMenuItem("密码修改");login=newJMenuItem("重新登陆");login.setBackground(Color.pink);//addDelete=newJMenuItem("添加/删除用户"); exit=newJMenuItem("退出系统");psUpdate.addActionListener(this);login.addActionListener(this);//addDelete.addActionListener(this);exit.addActionListener(this);//添加菜单项systemM.add(psUpdate);systemM.add(login);//systemM.add(addDelete);systemM.add(exit);//基本信息的菜单项worker=newJMenuItem("职工信息");work_note=newJMenuItem("出勤信息");out_note=newJMenuItem("出差信息");off_note=newJMenuItem("请假信息");over_note=newJMenuItem("加班信息");//注册监听器worker.addActionListener(this);work_note.addActionListener(this);out_note.addActionListener(this);off_note.addActionListener(this);over_note.addActionListener(this);//添加jibenM.add(worker);jibenM.add(work_note);jibenM.add(out_note);jibenM.add(off_note); jibenM.add(over_note);//信息查询的菜单项kqquery=newJMenu("信息查询");jibenquery=newJMenuItem("基本信息查询");dakaquery=newJMenuItem("打卡信息查询");jiabanquery=newJMenuItem("加班信息查询");chuchaiquery=newJMenuItem("出差信息查询");qingjiaquery=newJMenuItem("请假信息查询");jibenquery.addActionListener(this);dakaquery.addActionListener(this);jiabanquery.addActionListener(this);chuchaiquery.addActionListener(this);qingjiaquery.addActionListener(this);kqquery.add(jibenquery);kqquery.add(dakaquery);kqquery.add(jiabanquery);kqquery.add(chuchaiquery);kqquery.add(qingjiaquery);kqadd=newJMenu("信息添加");jibenadd=newJMenuItem("基本信息添加");dakaadd=newJMenuItem("打卡信息添加");jiabanadd=newJMenuItem("加班信息添加"); chuchaiadd=newJMenuItem("出差信息添加");qingjiaadd=newJMenuItem("请假信息添加");jibenadd.addActionListener(this);dakaadd.addActionListener(this);jiabanadd.addActionListener(this);chuchaiadd.addActionListener(this);qingjiaadd.addActionListener(this);kqadd.add(jibenadd);kqadd.add(dakaadd);kqadd.add(jiabanadd);kqadd.add(chuchaiadd);kqadd.add(qingjiaadd);kqupdate=newJMenu("信息修改");jibenupdate=newJMenuItem("基本信息修改");dakaupdate=newJMenuItem("打卡信息修改");jiabanupdate=newJMenuItem("加班信息修改");chuchaiupdate=newJMenuItem("出差信息修改");qingjiaupdate=newJMenuItem("请假信息修改");jibenupdate.addActionListener(this);dakaupdate.addActionListener(this);jiabanupdate.addActionListener(this);chuchaiupdate.addActionListener(this);qingjiaupdate.addActionListener(this); kqupdate.add(jibenupdate);kqupdate.add(dakaupdate);kqupdate.add(jiabanupdate);kqupdate.add(chuchaiupdate);kqupdate.add(qingjiaupdate);kqdelete=newJMenu("信息删除");jibendelete=newJMenuItem("基本信息删除");dakadelete=newJMenuItem("打卡信息删除");jiabandelete=newJMenuItem("加班信息删除");chuchaidelete=newJMenuItem("出差信息删除");qingjiadelete=newJMenuItem("请假信息删除");jibendelete.addActionListener(this);dakadelete.addActionListener(this);jiabandelete.addActionListener(this);chuchaidelete.addActionListener(this);qingjiadelete.addActionListener(this);kqdelete.add(jibendelete);kqdelete.add(dakadelete);kqdelete.add(jiabandelete);kqdelete.add(chuchaidelete);kqdelete.add(qingjiadelete);guanliM.add(kqquery);guanliM.add(kqadd);guanliM.add(kqupdate); guanliM.add(kqdelete);helpcon=newJMenuItem("帮助内容");helpcon.addActionListener(this);helpM.add(helpcon);aboutcon=newJMenuItem("关于内容");aboutcon.addActionListener(this);aboutM.add(aboutcon);//添加菜单mb.add(systemM);mb.add(jibenM);mb.add(guanliM);mb.add(helpM);mb.add(aboutM);this.setJMenuBar(mb);//Iconi1=newImageIcon("image/1.jpg");//Iconi2=newImageIcon("image/2.jpg");//Iconi3=newImageIcon("image/3.jpg");//Iconi4=newImageIcon("image/4.jpg");//Iconi5=newImageIcon("image/5.jpg");b1=newJButton("职工信息");b1.setBackground(Color.gray);b1.setFont(f);b2=newJButton("出勤信息");b2.setBackground(Color.gray);b2.setFont(f); b3=newJButton("出差信息");b3.setBackground(Color.gray);b3.setFont(f);b4=newJButton("请假信息");b4.setBackground(Color.gray);b4.setFont(f);b5=newJButton("加班信息");b5.setBackground(Color.gray);b5.setFont(f);b1.addActionListener(this);b2.addActionListener(this);b3.addActionListener(this);b4.addActionListener(this);b5.addActionListener(this);//b1.setBounds(0,0,40,100);p1.setBounds(0,0,100,50);p1.setLayout(newBoxLayout(p1,BoxLayout.Y_AXIS));p1.add(Box.createRigidArea(newDimension(10,100)));p1.add(b1);p1.add(Box.createRigidArea(newDimension(20,5)));p1.add(b2);p1.add(Box.createRigidArea(newDimension(20,5)));p1.add(b3);p1.add(Box.createRigidArea(newDimension(20,5)));p1.add(b4);p1.add(Box.createRigidArea(newDimension(20,5)));p1.add(b5); p1.add(Box.createRigidArea(newDimension(20,20)));con.add(p1,BorderLayout.WEST);p1.setOpaque(false);//Iconi6=newImageIcon("image/6.jpg");//Iconi7=newImageIcon("image/7.jpg");//Iconi8=newImageIcon("image/8.jpg");//Iconi9=newImageIcon("image/9.jpg");b6=newJButton("查询");//b6.setIcon(i6);b7=newJButton("添加");//b7.setIcon(i7);b8=newJButton("修改");//b8.setIcon(i8);b9=newJButton("删除");//b9.setIcon(i9);b6.setBackground(Color.white);b7.setBackground(Color.white);b8.setBackground(Color.white);b9.setBackground(Color.white);b6.addActionListener(this);b7.addActionListener(this);b8.addActionListener(this);b9.addActionListener(this);////////////////////////////////////////////////////////////////////////////////((JPanel)this.getContentPane()).setOpaque(false);//ImageIconimg=newImageIcon("1.jpg");//添加图片//JLabelbackground=newJLabel(img);//this.getLayeredPane().add(background,new//Integer(Integer.MIN_VALUE)); //background.setBounds(0,0,img.getIconWidth(),img.getIconHeight());//Containerc=this.getContentPane();//获取JFrame面板/////////////////////////////////////////////////////////////////////////////p3.setOpaque(false);p3.add(b6);p3.add(Box.createRigidArea(newDimension(20,0)));p3.add(b7);p3.add(Box.createRigidArea(newDimension(20,0)));p3.add(b8);p3.add(Box.createRigidArea(newDimension(20,0)));p3.add(b9);con.add(p3,BorderLayout.SOUTH);///////////////////////////////////////////////p2.setBackground(Color.pink);//JTabletable=newJTable(4,4);//p2.add(table);//con.add(p2);//con.add(scrollPane);lb2.setBounds(0,0,p2.getWidth(),p2.getHeight());p2.add(lb2);p2.add(lb1);con.add(p2);p1.setBackground(Color.red);p3.setBackground(Color.green);setBounds(310,150,700,500);//setBounds(0,0,1440,900); setVisible(true);//System.out.println(b1.getWidth());//System.out.println(b1.getHeight());}publicvoidactionPerformed(ActionEvente){if(e.getSource()==psUpdate){passUpdate1psup1=newpassUpdate1();psup1.setVisible(true);}if(e.getSource()==login){Loginlg=newLogin();lg.setVisible(true);}//if(e.getSource()==addDelete){//AddDeleteUseraduser=newAddDeleteUser();//aduser.setVisible(true);//}if(e.getSource()==exit){setVisible(false);}////////////////////////////////////////////////////if(e.getSource()==worker){workerswk=newworkers();}if(e.getSource()==work_note){work_notewknt=newwork_note();}if(e.getSource()==out_note){out_noteotnt=newout_note(); }if(e.getSource()==off_note){off_noteofnt=newoff_note();}if(e.getSource()==over_note){over_noteovnt=newover_note();}/////////////////////////////////////////////if(e.getSource()==jibenquery){jibenqueryjbqy=newjibenquery();jbqy.setBounds(1010,150,250,500);jbqy.setVisible(true);}if(e.getSource()==dakaquery){dakaquerydkqy=newdakaquery();dkqy.setBounds(1010,150,250,500);dkqy.setVisible(true);}if(e.getSource()==jiabanquery){jiabanqueryjbaqy=newjiabanquery();jbaqy.setBounds(1010,150,250,500);jbaqy.setVisible(true);}if(e.getSource()==chuchaiquery){chuchaiqueryccqy=newchuchaiquery();ccqy.setBounds(1010,150,250,500);ccqy.setVisible(true); }if(e.getSource()==qingjiaquery){qingjiaqueryqjqy=newqingjiaquery();qjqy.setBounds(1010,150,250,500);qjqy.setVisible(true);}/////////////////////////////////////////////if(e.getSource()==jibenadd){jibenaddjbadd=newjibenadd();jbadd.setBounds(1010,150,250,500);jbadd.setVisible(true);}if(e.getSource()==dakaadd){dakaadddkadd=newdakaadd();dkadd.setBounds(1010,150,250,500);dkadd.setVisible(true);}if(e.getSource()==jiabanadd){jiabanaddjbanadd=newjiabanadd();jbanadd.setBounds(1010,150,250,500);jbanadd.setVisible(true);}if(e.getSource()==chuchaiadd){chuchaiaddccadd=newchuchaiadd();ccadd.setBounds(1010,150,250,500);ccadd.setVisible(true);}if(e.getSource()==qingjiaadd){qingjiaaddqjadd=newqingjiaadd(); qjadd.setBounds(1010,150,250,500);qjadd.setVisible(true);}////////////////////////////////////////////if(e.getSource()==jibenupdate){jibenupdatejbut=newjibenupdate();jbut.setBounds(1010,150,250,500);jbut.setVisible(true);}if(e.getSource()==dakaupdate){dakaupdatedkup=newdakaupdate();dkup.setBounds(1010,150,250,500);dkup.setVisible(true);}if(e.getSource()==jiabanupdate){jiabanupdatejbaup=newjiabanupdate();jbaup.setBounds(1010,150,250,500);jbaup.setVisible(true);}if(e.getSource()==chuchaiupdate){chuchaiupdateccup=newchuchaiupdate();ccup.setBounds(1010,150,250,500);ccup.setVisible(true);}if(e.getSource()==qingjiaupdate){qingjiaupdateqjup=newqingjiaupdate();qjup.setBounds(1010,150,250,500);qjup.setVisible(true);}////////////////////////////////////////// if(e.getSource()==jibendelete){jibendeletejbdt=newjibendelete();jbdt.setBounds(1010,150,250,500);jbdt.setVisible(true);}if(e.getSource()==dakadelete){dakadeletedkat=newdakadelete();dkat.setBounds(1010,150,250,500);dkat.setVisible(true);}if(e.getSource()==jiabandelete){jiabandeletejbandt=newjiabandelete();jbandt.setBounds(1010,150,250,500);jbandt.setVisible(true);}if(e.getSource()==chuchaidelete){chuchaideleteccdt=newchuchaidelete();ccdt.setBounds(1010,150,250,500);ccdt.setVisible(true);}if(e.getSource()==qingjiadelete){qingjiadeleteqjdt=newqingjiadelete();qjdt.setBounds(1010,150,250,500);qjdt.setVisible(true);}////////////////////////////////////////////if(e.getSource()==helpcon){helpconhc=newhelpcon();hc.setBounds(1010,150,250,500);hc.setVisible(true); }///////////////////////////////////////////if(e.getSource()==aboutcon){aboutconac=newaboutcon();ac.setBounds(1010,150,250,500);ac.setVisible(true);}////////////////////////////////////////////if(e.getSource()==b1){newworkers();}if(e.getSource()==b2){work_notewknt=newwork_note();}if(e.getSource()==b3){out_noteotnt=newout_note();}if(e.getSource()==b4){off_noteofnt=newoff_note();}if(e.getSource()==b5){over_noteovnt=newover_note();}////////////////////////////////////////////////////if(e.getSource()==b6){QueryQ=newQuery();Q.setBounds(470,520,500,70);Q.setVisible(true);}if(e.getActionCommand()=="添加"){ AddA=newAdd();A.setBounds(470,520,500,70);A.setVisible(true);}if(e.getActionCommand()=="修改"){UpdateU=newUpdate();U.setBounds(470,520,500,70);U.setVisible(true);}if(e.getActionCommand()=="删除"){DeleteD=newDelete();D.setBounds(470,520,500,70);D.setVisible(true);}/**if(e.getSource()==password){}if(e.getSource()==land){}if*(e.getSource()==addDelete){}if(e.getSource()==exit){*setVisible(false);}*/}///////////////////////////////////////////////////publicstaticvoidmain(String[]args){//主函数newmain_1();}} 二、JAVA运行(一)、用户登录界面(二)、主界面 (三)、基本功能