2022年2022年简单的JAVA员工信息管理系统源码 .pdf





《2022年2022年简单的JAVA员工信息管理系统源码 .pdf》由会员分享,可在线阅读,更多相关《2022年2022年简单的JAVA员工信息管理系统源码 .pdf(8页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、/ 项目目标:建立员工管理系统第一个版本。/ 实现图形用户界面的员工信息查询、增、删、改;与数据库建立,并将修改结果时时保存到数据库。/ 模块: 1.GUI 界面 2. 数据库连接 3. 查询 4. 增、5 删 6 改( 操作数据库)import java.sql.*; import java.awt.*; import java.awt.event.*; import javax.swing.*; public class EmpManageSys implements ActionListener Connection con; Statement stmt; String sql; Re
2、sultSet rs; StringBuffer sb = new StringBuffer(); JTextField jtf2 = new JTextField(张飞,10); JTextField jtf3 = new JTextField(10); JTextField jtf4 = new JTextField(10); JTextField jtf7 = new JTextField(10); JTextField jtf5 = new JTextField(10); JTextField jtf6 = new JTextField(10); JTextField jtf8 = n
3、ew JTextField(10); JTextField jtf9 = new JTextField(10); JTextArea jta10 = new JTextArea(50, 40); public void actionPerformed(ActionEvent e) String str = e.getActionCommand(); if (查询.equals(str) /if check the button of 查询, then go to method of searchEmp() searchEmp(); else if (增加.equals(str) 名师资料总结
4、- - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 1 页,共 8 页 - - - - - - - - - /if check the button of 增加, then go to method of addEmp() addEmp(); else if (修改.equals(str) /if check the button of 修改, then go to method of alterEmp() alterEmp(); else if (撤除.equals(str) /if check t
5、he button of 撤除, then go to method of deleteEmp() deleteEmp(); /this is the constructor. EmpManageSys() createGUI(); connectToDataBase(); / searchEmp(); / addEmp(); / deleteEmp(); alterEmp(); /connect to the database by using the method getConnection from the class of JdbcUtil. /You can find the cla
6、ss of JdbcUtil at the button of this page. public Connection connectToDataBase() con = JdbcUtil.getConnection(); System.out.println(con); return con; public void searchEmp() jta10.setText(); try stmt = con.createStatement(); / sql = select * from Mstar where id= + jtf3.getText(); / sql1=select * fro
7、m sd100343 where =+jtf3.getText(); sql = select * from Mstar where chineseName= + jtf2.getText().toLowerCase().trim() + or id= + jtf3.getText().toLowerCase().trim() + or engName= 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 2 页,共 8 页 - - - - - - - - - + jtf4.getTex
8、t().toLowerCase().trim() + or UNIT= + jtf5.getText().toLowerCase().trim() + or TEAM= + jtf6.getText().toLowerCase().trim() + or Phone= + jtf7.getText().toLowerCase().trim() + or region= + jtf8.getText().toLowerCase().trim() + or busStation= + jtf9.getText().toLowerCase().trim(); stmt.executeQuery(sq
9、l); rs = stmt.getResultSet(); ResultSetMetaData meta = rs.getMetaData(); int cols = meta.getColumnCount(); while (rs.next() for (int i = 1; i = cols; i+) sb.append( + meta.getColumnName(i) + =); sb.append(rs.getString(i); sb.append(n); jta10.setText(sb.toString(); catch (SQLException e11) e11.printS
10、tackTrace(); public void addEmp() try stmt = con.createStatement(); sql = update Mstar values( + jtf2.getText() + jtf3.getText() + jtf4.getText() + jtf5.getText() + jtf6.getText() + jtf7.getText() + jtf8.getText() + jtf9.getText() + ); int i = stmt.getUpdateCount(); if (jtf2.getText() != null) & (jt
11、f4.getText() != null) & (jtf6.getText() != null) & (jtf7.getText() != null) stmt.executeUpdate(sql); jta10.setText(添加记录成功 + i + 条); else jta10.setText(带*号项为添加记录时不能为空); catch (SQLException e1) e1.printStackTrace(); public void deleteEmp() searchEmp(); 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - -
12、- - - - 名师精心整理 - - - - - - - 第 3 页,共 8 页 - - - - - - - - - try stmt = con.createStatement(); sql = delete from Mstar where chineseName= + jtf2.getText().toLowerCase().trim() + or id= + jtf3.getText().toLowerCase().trim() + or engName= + jtf4.getText().toLowerCase().trim() + or UNIT= + jtf5.getText()
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 2022年2022年简单的JAVA员工信息管理系统源码 2022 简单 JAVA 员工 信息管理 系统 源码

限制150内