欢迎来到天天文库
浏览记录
ID:39812138
大小:16.55 KB
页数:8页
时间:2019-07-11
《简单的JAVA员工信息管理系统源码》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、//项目目标:建立员工管理系统第一个版本。//实现图形用户界面的员工信息查询、增、删、改;与数据库建立,并将修改结果时时保存到数据库。//模块:1.GUI界面2.数据库连接3.查询4.增、5删6改(操作数据库)importjava.sql.*;importjava.awt.*;importjava.awt.event.*;importjavax.swing.*;publicclassEmpManageSysimplementsActionListener{Connectioncon;Statementstmt;Stringsql;ResultSetrs;StringBuffersb=ne
2、wStringBuffer();JTextFieldjtf2=newJTextField("张飞",10);JTextFieldjtf3=newJTextField(10);JTextFieldjtf4=newJTextField(10);JTextFieldjtf7=newJTextField(10);JTextFieldjtf5=newJTextField(10);JTextFieldjtf6=newJTextField(10);JTextFieldjtf8=newJTextField(10);JTextFieldjtf9=newJTextField(10);JTextAreajta
3、10=newJTextArea(50,40);publicvoidactionPerformed(ActionEvente){Stringstr=e.getActionCommand();if("查询".equals(str)){//ifcheckthebuttonof查询,thengotomethodofsearchEmp()searchEmp();}elseif("增加".equals(str)){//ifcheckthebuttonof增加,thengotomethodofaddEmp()addEmp();}elseif("修改".equals(str)){//ifcheckthe
4、buttonof修改,thengotomethodofalterEmp()alterEmp();}elseif("撤除".equals(str)){//ifcheckthebuttonof撤除,thengotomethodofdeleteEmp()deleteEmp();}}//thisistheconstructor.EmpManageSys(){createGUI();connectToDataBase();//searchEmp();//addEmp();//deleteEmp();alterEmp();}//connecttothedatabasebyusingthemethod
5、getConnectionfromtheclassofJdbcUtil.//YoucanfindtheclassofJdbcUtilatthebuttonofthispage.publicConnectionconnectToDataBase(){con=JdbcUtil.getConnection();System.out.println(con);returncon;}publicvoidsearchEmp(){jta10.setText("");try{stmt=con.createStatement();//sql="select*fromMstarwhereid="+jtf3.
6、getText();//sql1="select*fromsd100343where="+jtf3.getText();sql="select*fromMstarwherechineseName="+jtf2.getText().toLowerCase().trim()+"orid="+jtf3.getText().toLowerCase().trim()+"orengName="+jtf4.getText().toLowerCase().trim()+"orUNIT="+jtf5.getText().toLowerCase().trim()+"orTEAM="+jtf6.getText
7、().toLowerCase().trim()+"orPhone="+jtf7.getText().toLowerCase().trim()+"orregion="+jtf8.getText().toLowerCase().trim()+"orbusStation="+jtf9.getText().toLowerCase().trim();stmt.executeQuery(sql);rs=stmt.getResultSet();R
此文档下载收益归作者所有