下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、川心整理训以编级的word文档综合实验三员工管理系统、实验目的掌握编写数据库应用程序的方法,包括菜单、布局管理器、弹出提示信息对话框、输入对话框、 数据库读写、事件处理。二、实验环境PC 系列微机,Windows XPOEclipse. JDK150或更高版本。三、实验内容package ch4;import serial)public class Employer extends JFrame JMenuBar cd;JMenuItem addygzdeleteyg,updateyg,selectyg,addgzzupdategz,selectgz,sumgzzhelp;JMenu cdl,
2、cd2,cd3;JTextArea textarea;public Employer() supers员工管理系统“);cd=new JMenuBar();cd 1=new JMenu(员工管理”);addyg=new JMenuItem(添加新员工”);deleteyg=new JMenuItem(删除员工”);updateyg=new JMenuItem(修改员工信息”);selectyg=new JMenuItem(查询员工”); cd2=new JMenu(”工资管理”); addgz=new JMenuItem(录入员工工资); updategz=new JMenuItem(修改员工
3、I资”); selectgz=new JMenuItem(n查询员工工资); sumgz=new JMenuItem(统计工资总额”); cd 3=new JMenu(关于); help=new JMenuItem(帮助”); textarea=new JTextArea();(cd,;(textarea,;(cdl);(addyg);(deleteyg);(updateyg);(selectyg); (cd2);(addgz);(updategz);(selectgz);(selectgz); (cd3);(help);(new ActionListener() /添加新员工Override
4、public void actio nPerformed(Acti on Eve nt e) / TODO Auto-generated method stub insertEmployee add=new insertEmployee(););(new ActionListener() /删除员工Overridepublic void actio n Performed (Acti on Eve nt e) a川心整理川以编樹的word文档public void action Performed (Acti on Eve nt e) / TODO Auto-generated method
5、stub updateWage update=new updateWage(););(new ActionListener() /查询员工工资Overridepublic void action Performed (Acti on Eve nt e) / TODO Auto-generated method stub selectWage selectwage=new selectWage(););(new ActionListener() /统计工资总额Overridepublic void action Performed (Acti on Eve nt e) / TODO Auto-g
6、enerated method stub sumWage sum=new sumWage(););(new ActionListener() /帮助Overridepublic void action Performed (Acti on Eve nt e) / TODO Auto-generated method stub(textarea, ”本实验由邹杰所写,2015520”帮助文档”);public static void main(String args) Employer em=new Employer();(true);(500,500);(false);package ch4;
7、import class DBConnection private Connection conn=null;public Connection getConnection()return ;public DBConnection()try r);String url=jdbc:;String user=,zoujien;String password=888518;conn=(url,user,password); catch (ClassNotFoundException e) / TODO Auto-generated catch block0; catch (SQLException
8、e) / TODO Auto-generated catch block0;a川心整理川以编级的uwd文档public void close()if(conn!=null)try 0; catch (SQLException e) / TODO Auto-generated catch block0;Package ch4;import class EmployeeDAL public int insert(Employee e) throws SQLExceptionString sql=insert into employee(employeeID,employeeName/sex,wor
9、kagezgangwei)values。?,?,?,?) “;DBConnection dbConn二new DBConnection();Connection cn=();PreparedStatement pst=(sql);(lz 0);(2, 0);(3, 0);(4, 0);(5, 0);int ret=();0;return ret; public int deleteByEmployeeID(String id) throws SQLExceptionString sql=delete from employee where employeeID=?H;DBConnection
10、dbConn二new DBConnection();Connection cn=();PreparedStatement pst=(sql);(1, id);int ret=();0;return ret;public int updateEmployeeID(Employee e)throws SQLExceptionString sql=Update employee set employeeName=?,sex=?,workage=?zgangwei二? where employeeID=?;DBConnection dbConn二new DBConnection();Connectio
11、n cn=();PreparedStatement pst=(sql);添加数据(5, 0);(lz 0);(2, 0);(3, 0);(4, 0);int ret=();0;return ret;public String selectByEmployeeID(String id) throws SQLExceptionString sql=select * from employee where employeeID=?H;DBConnection dbConn二new DBConnection();Connection cn=();PreparedStatement pst=(sql);
12、(1/ id);ResultSet rs=null;String abc = null;trya川心整理川以樹的word文档rs=();while()String employeeID=(employeeId);String employeeName=(employeeName);String workAge=(workage);String sex=(sex);String gangWei=(gangwei);abc=员工 ID : +employeeID+n+,姓名:,+employeeName+,n,+,tt!l : +sex+n+”工龄:”+workAge+”n“+“岗位:+gangW
13、ei;0;catch (SQLException e) abc二喳询错误,请核对后再次查询:return abc;向数据库插入数据public int insert2(int tl, int t2, int t3, int t4,int t5z int t6, int t7) throws SQLException String sql=insert into Wage values(?,DBConnection dbConn=new DBConnection();Connection cn=();PreparedStatement pst=(sql);(1/ ;(2, t2);(3, t3)
14、;(4, t4);(5, t5);(6, t6); t7);(8, t4+t5);(9, t4+t5-t6-t7);int ret=(); 返回更新了几条记录0;return ret;修改数据以适应新表public int UpdateEmployeeID2(int tlz int t2, int t3, int t4,int t5z int t6, int t7) throws SQLExceptionString sql=Update Wage setyear=?,month=?zgangweiwage=?/Salary二?,baoxian二?,gongjijin二?“ingfa=?,sh
15、ifa=? where employeeID=?;DBConnection dbConn二new DBConnection();Connection cn=();PreparedStatement pst=(sql);修改数据(9/tl);(1,;(2,t3);(3,t4);(4,;(5,;(6,t7);(7,t4+;但 zt4+t5-t6-t7);int ret=();0;return ret;a川心整理川以蝙樹的uwd文档a根据ID查询数据(2)public String selectByEmployeeID2(int id) throws SQLExceptionString sql=s
16、elect * from Wage where employeeID=?;DBConnection dbConn二new DBConnection();Connection cn=();PreparedStatement pst=(sql);(1, id);ResultSet rs=null;String abc = null;tryrs=();while()String employeeID=(employeeID)+;String year=(year)+;String month=(month)+;String gangweigongzi=(gangweiwage)+”;String s
17、alary=(”salary”)+“;String baoxian=(baoxian)+;String gongjijin=(gongjijinString yingfa=(“yingfa”)+“,;String shifa=(shifa)+;月份:,+month+,n,+奖金:”+salary+”rT+“保险:”+发:,+yingfa+,n+ :”abc=”员工 ID : “+纟口戸切此+“”+”年份:,+year+,n+岗位工资:+gangweigongzi+n+baoxian+”n“+“公积金:,+gongjijin+n+,+shifa;0;catch (SQLException e)
18、abc二喳询错误f请核对后再次查询“;return abc;查询员工统计工资public String chaxun(int tl,int t2) throws SQLExceptionString sql=select * from Wage where year=? and year0)(bt_delete,“删除成功”);else(bt_delete,“未删除但可数据”); catch (NumberFormatException el) / TODO Auto-generated catch block (bt.delete;删除失败,请检查后删除“); catch (SQLExcep
19、tion el) / TODO Auto-generated catch block (bt.delete;删除失败,请检查后删除“););(new ActionListene()Overridepublic void action Performed (Acti on Eve nt e) g川心整理训以编级的word文档/ TODO Auto-generated method stub dispose(););SuppressWar nin gs( unu secT)public static void main(String args)deleteEmployee yg二new delet
20、eEmployee();package ch4;import serial)public class updateEmployee extends JFrame final JDialog jd=new JDialog();JPanel jp=new JPanel();JLabel ictnamezworkage,sexzgangwei; final JTextField id_;final JTextField name_;final JTextField sex_;final JTextField workage_;final JTextField gangwei_;public upda
21、teEmployee()supers修改信息”);id=new JLabel(员工 ID); name=new JLabel(姓名”); sex=new JLabel(H 性别J;workage=new JLabel(,f 工龄l!);gangwei=new JLabel( 岗位,J;final JButton button 1=new JButton(”确定”);JButton button2=new JButton(取消);id_=new JTextField(lO);name_=new JTextField(lO);sex_=new JTextField(lO); workage_=ne
22、w JTextField(lO); gangwei_= new JTextField(lO);(id);(id_);(name);(name_);(sex); (sex_); (workage) ;(workage_);(ga ngwei);(ga ngwei_);(buttonl);(button2);(jP);(550,240,200,220);(true);(new ActionListener() Overridepublic void actio n Performed (Acti on Eve nt argO) String id_0=(); 读取信息String name_0=(
23、);String sex_0=();String workage_0=();String gangwei_0=();try EmployeeDAL edal=new EmployeeDAL();Employee e二new Employee(id_0,nameqsexqworkageqgangwei_0);int t=(e); if(t=O)a川心整理训以编驸的word文档(button”未修改俗可信息”);else(buttonl;修改成功”); catch (SQLException el) (button lz改失败,请检查后修改”););(new ActionListener()Ove
24、rridepublic void action Performed (Acti on Eve nt argO) (false);public static void main(String args)updateEmployee xiugai=new updateEmployee();package ch4;import class selectEmployee public selectEmployee()final JDialog jdl=new JDialog();final JPanel jpl=new JPanel();JLabel jll=new JLabel(请输入员工 ID :
25、);final JTextField jft=new JTextField(lO);JButton button 1=new JButton(确定);JButton button2=new JButton(取消“);final TextArea ta=new TextArea();布局设置(jll); (jft); (buttonl);(button2);(ta);0P1);(550,240,450,250);(true);(new Actio nListe ner()Overridepublic void action Performed (Acti on Eve nt e) Employe
26、eDAL edal=new EmployeeDAL();try String s=();; catch (NumberFormatException el) / TODO Auto-generated catch block catch (SQLException el) );(new ActionListener() Override g川心整理训以轴樹的uwd文档public void action Performed(Acti on Eve nt e) / TODO Auto-generated method stub (false);public static void main(St
27、ring args)selectEmployee select=new selectEmployee();package ch4;import class insertWage final JDialog jd=new JDialog();JPa nel jp;JLabel id,year,monthgongzi,jiangjin,baoxlan,gongjijin,yfgz,sfgz;final JTextField idyeaomonth_,gongzijiangjin_,baoxian_,gongjijin_; public insertWage()jp二new JPa nel();id
28、=new JLabel(员工 ID);year=new JLabel(年份);month=new JLabel(月份);gongzi=new JLabel(岗位工资”);jiangjin=new JLabel(”奖金);baoxian=new JLabel(保险);gongjijin=new JLabel(公积金);JButton button 1=new JButton(确定);JButton button2=new JButton(取消”);id_=new JTextField(lO);year_=new JTextField(lO);month_=new JTextField(lO);g
29、ongzi_=new JTextField(lO);jiangjin_=new JTextField(lO);baoxian_=new JTextField(lO);gongjijin_=new JTextField(lO);(id);(id_);(year);(year_);(month);(m on th_);(go ngzi);(go ngzi_);(jiangjin);(jiangjin _);(baoxia n) ;(baoxia n_);(gongjiji n);(gongjijin_);(buttonl);(button2);(jP);(550,240,210,290) ;(tr
30、ue);(new ActionListener() Overridepublic void action Performed(Acti on Eve nt argO) int id_0=(); 读取信息int year_0=();int month_0=();int gongzi_0=();int jiangjin_O=();int baoxian_0=();int gongjijin_0=();a川心整理训以编轨的uwd文档try EmployeeDAL edal=new EmployeeDAL();int t=(id_Ozyear_O/m on th_O,g on gzi_O,jia ng
31、jin _Ozbaoxia n_0,gongjiji n_0);if(t=O)(null/没有添力);else(null,”已添力); catch (SQLException el) (null,已存在,请确认后添加”););(new Action Liste ner()public void action Performed (Acti on Eve nt argO) (false););public static void main(String args)insertWage insert= new insertWage();package ch4;import class update
32、Wage final JDialog jd=new JDialog();JPanel jp=new JPanel();JLabel id,year,monthgongzi,jiangjin,baoxian,gongjijin,yfgz,sfgz;final JTextField idyeaomonth_,gongzi_jiangjin_,baoxian_,gongjijin_; public updateWage()id=new JLabel(员工 ID);year=new JLabel(年份);month=new JLabel(月份);gongzi=new JLabel(岗位工资”);jia
33、ngjin=new JLabel(”奖金);baoxian=new JLabel(保险);gongjijin=new JLabel(公积金”);JButton button 1=new JButton(确定);JButton button2=new JButton(取消);id_=new JTextField(lO);year_=new JTextField(lO);month_=new JTextField(lO);gongzi_=new JTextField(lO);jiangjin_=new JTextField(lO);baoxian_=new JTextField(lO);gongj
34、ijin_=new JTextField(lO);(id);(id_);(year);(year_);(month);(m on th_);(g on gzi);(g on gzi_);(jiangjin);(jiangjin _);(baoxia n) ;(baoxia n_);(gongjiji n);(gongjijin_);(buttonl);(button2);(jp);(550,240,210,290) ;(true);(new ActionListener() Overridepublic void actio nPerformed(Acti on Eve nt argO) in
35、t id_0=(); 读取信息int year_0=();int month_0=();int gongzi_0=();int jia ngjin_O=();int baoxian_0=();int gongjijin_0=();try EmployeeDAL edal=new EmployeeDAL();int t=(id_0zyear_0,m on th_O,g on gzi_O,jia ngjin _0zbaoxia n_0, gongjiji n_0);if(t!=O)(null,”已经修改”);else(null,”未修改成功”); catch (SQLException el) (
36、null/请确认之后再修改”););a川心整理川以編级的uwd文档(new ActionListener()public void action Performed (Acti on Eve nt argO) (false););public static void main(String args)updateWage update=new updateWage();package ch4;import class selectWage final JDialog jdl=new JDialog();final JPanel jpl=new JPanel();public selectWage()JLabel jll=new JLabel(请输入员工 ID :);final JTextField jft=new JTextField(lO);JButton button 1=new JButton(确定”);JButton button2=new JButton(取消”);final TextArea ta=new TextArea();布局设置(jll); (jft); (buttonl
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 福建省南平市太平镇中学高二语文月考试卷含解析
- 27《我的伯父鲁迅先生》说课稿-2024-2025学年统编版语文六年级上册
- 秋分营销全攻略
- 2024年香港居民内地离婚手续办理与法律援助合同3篇
- 多媒体内容制作服务合同(2篇)
- U盘年度供应与分销协议样本版
- 2024年跨境电子商务平台运营与推广协议
- 10 我们当地的风俗 第二课时 说课稿-2023-2024学年道德与法治四年级下册统编版
- 11-2《五代史·伶官传序》(说课稿)高二语文同步高效课堂(统编版 选择性必修中册)
- 专业化清洗系统采购协议2024年版版A版
- 2024年意识形态风险隐患点及应对措施
- 2025版新能源充电桩加盟代理合作协议范本3篇
- 2025年广东省揭阳市揭西县招聘事业单位人员11人历年高频重点提升(共500题)附带答案详解
- 2025年云南昆明经济技术开发区投资开发(集团)有限公司招聘笔试参考题库附带答案详解
- 社会单位消防安全知识考试题库(浓缩500题)
- 企业地震应急预案样本(三篇)
- 2023-2024学年广东省广州市花都区九年级(上)期末物理试卷(含答案)
- GB/T 5483-2024天然石膏
- 空调年度巡检报告范文
- 线上推广授权合同范例
- 保定学院《大学英语》2023-2024学年第一学期期末试卷
评论
0/150
提交评论