《数据库应用》课程设计人事管理系统(java源代码)

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

《数据库应用》课程设计——人事管理系统(java源代码)//用户登陆类packageclasssource;importjava.awt.*;importjava.awt.event.*;importjavax.swing.*;importjava.sql.*;publicclassLandextendsJFrame{JFramejf;JTextFieldtextName=newJTextField();JPasswordFieldtextage=newJPasswordField();JLabellabel=newJLabel(员工管理系统);JLabellabelName=newJLabel(用户名:);JLabellabelage=newJLabel(密码:);JButtonbuttonEnter=newJButton(登录);JButtonbuttoncancel=newJButton(清空);publicLand(){jf=this;setTitle(登录);Fontf=newFont(新宋体,Font.PLAIN,12);Containercon=getContentPane();con.setLayout(null);label.setBounds(95,10,110,20);label.setFont(newFont(新宋体,Font.PLAIN,14));con.add(label);labelName.setBounds(45,40,55,20);labelName.setFont(f);con.add(labelName);textName.setBounds(95,40,120,20);con.add(textName);labelage.setBounds(45,70,45,20);con.add(labelage);labelage.setFont(f);textage.setBounds(95,70,120,20);con.add(textage);buttonEnter.setBounds(90,110,60,20);buttonEnter.setFont(f);con.add(buttonEnter);//登陆的鼠标监听buttonEnter.addMouseListener(newMouseAdapter(){publicvoidmouseClicked(MouseEventme){if(textName.getText().equals()){newJOptionPane().showMessageDialog(null,用户名不能为空!);}elseif(textage.getText().equals()){newJOptionPane().showMessageDialog(null,密码不能为空!);}else{Stringsql=select*fromUserInformationwhereUser_Name='+textName.getText()+'andPassword='+textage.getText()+';System.out.println(sql);Judge(sql);}}});buttoncancel.setBounds(155,110,60,20);buttoncancel.setFont(f);con.add(buttoncancel);//清空按钮的鼠标监听方法buttoncancel.addMouseListener(newMouseAdapter(){publicvoidmouseClicked(MouseEventme){textName.setText();textage.setText();}});setResizable(false);Imageimg=Toolkit.getDefaultToolkit().getImage(image\\main.gif);setIconImage(img);Toolkitt=Toolkit.getDefaultToolkit();intw=t.getScreenSize().width;inth=t.getScreenSize().height;setBounds(w/2-150,h/2-90,300,180);setVisible(true);}privatevoidJudge(StringsqlString){if(Database.joinDB()){if(Database.query(sqlString))try{if(Database.rs.isBeforeFirst()){System.out.println(密码正确);jf.setVisible(false);Database.cn.close();newMain();}else{System.out.println(错误);newJOptionPane().showMessageDialog(null,用户名或密码错误!,,JOptionPane.ERROR_MESSAGE);}}catch(Exceptionex){System.out.println(ex.getMessage());}}else{System.out.println(连接数据库不成功!!!);}}publicstaticvoidmain(Stringargs[]){newLand();}}//主函数类,可以独立运行packageclasssource;importjava.awt.*;importjava.awt.event.*;importjavax.swing.*;importjava.sql.*;publicclassMainextendsJFrameimplementsRunnable{Threadt=newThread(this);JDesktopPanedeskpane=newJDesktopPane();JPanelp=newJPanel();Labellp1=newLabel(欢迎使用员工管理系统!);ImageIconicon1=newImageIcon(imagetjsc.gif);ImageIconicon2=newImageIcon(imagecxdl.gif);ImageIconicon3=newImageIcon(imagexgmm.gif);ImageIconicon4=newImageIcon(imagetcxt.gif);ImageIconicon5=newImageIcon(imagejj.gif);ImageIconicon6=newImageIcon(imagehelp.gif);ImageIconicon7=newImageIcon(imagecx.gif);ImageIconicon8=newImageIcon(imagegl.gif);ImageIconicon9=newImageIcon(imagext.gif);ImageIconicon10=newImageIcon(imagexxgl.gif);ImageIconicon11=newImageIcon(imagexxcx.gif);ImageIconicon12=newImageIcon(imagebz.gif);ImageIconicon13=newImageIcon(imagegy.gif);ImageIconicon14=newImageIcon(imageglxx.gif);ImageIconicon15=newImageIcon(imagecxxx.gif);//完--------------------------------------------------------------------------------publicMain(){setTitle(员工管理系统);Containercon=getContentPane();con.setLayout(newBorderLayout());con.add(deskpane,BorderLayout.CENTER);Fontf=newFont(新宋体,Font.PLAIN,12);JMenuBarmb=newJMenuBar();JMenusystemM=newJMenu(系统管理);systemM.setFont(f);JMenumanageM=newJMenu(信息管理);manageM.setFont(f);JMenuemployeeMM=newJMenu(员工信息管理);employeeMM.setFont(f);JMenuselectM=newJMenu(信息查询);selectM.setFont(f);JMenuemployeeSM=newJMenu(员工信息查询);employeeSM.setFont(f);JMenuhelpM=newJMenu(帮助);helpM.setFont(f);JMenuaboutM=newJMenu(关于);aboutM.setFont(f);JMenuItempassword=newJMenuItem(密码修改);password.setFont(f);JMenuItemland=newJMenuItem(重新登陆);land.setFont(f);JMenuItemaddDelete=newJMenuItem(添加/删除用户);addDelete.setFont(f);JMenuItemexit=newJMenuItem(退出系统);exit.setFont(f);systemM.add(password);systemM.add(land);systemM.add(addDelete);systemM.add(exit);//为系统管理菜单加事件password.addActionListener(newActionListener(){publicvoidactionPerformed(ActionEvente){System.out.println(AmendPassword);deskpane.add(newAmendPassword());}});land.addActionListener(newActionListener(){publicvoidactionPerformed(ActionEvente){System.out.println(Land);setVisible(false);newLand();}});addDelete.addActionListener(newActionListener(){publicvoidactionPerformed(ActionEvente){deskpane.add(newAddDeleteUser());}});exit.addActionListener(newActionListener(){publicvoidactionPerformed(ActionEvente){//newJOptionPane().showMessageDialog(setVisible(false);}});JMenuItemdepartmentM=newJMenuItem(部门信息管理);departmentM.setFont(f);JMenuItememployeeM=newJMenuItem(基本信息管理);employeeM.setFont(f);JMenuItemtrainM=newJMenuItem(培训信息管理);trainM.setFont(f);JMenuItemencouragementPunishM=newJMenuItem(奖罚信息管理);encouragementPunishM.setFont(f);JMenuItemwageM=newJMenuItem(薪资信息管理);wageM.setFont(f);employeeMM.add(trainM);e

1 / 90
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功