版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、川心整理訓(xùn)以編級(jí)的word文檔綜合實(shí)驗(yàn)三員工管理系統(tǒng)、實(shí)驗(yàn)?zāi)康恼莆站帉憯?shù)據(jù)庫(kù)應(yīng)用程序的方法,包括菜單、布局管理器、彈出提示信息對(duì)話框、輸入對(duì)話框、 數(shù)據(jù)庫(kù)讀寫、事件處理。二、實(shí)驗(yàn)環(huán)境PC 系列微機(jī),Windows XPOEclipse. JDK150或更高版本。三、實(shí)驗(yàn)內(nèi)容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員工管理系統(tǒng)“);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(統(tǒng)計(jì)工資總額”); cd 3=new JMenu(關(guān)于); 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() /統(tǒng)計(jì)工資總額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, ”本實(shí)驗(yàn)由鄒杰所寫,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川心整理川以編級(jí)的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);添加數(shù)據(jù)(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二喳詢錯(cuò)誤,請(qǐng)核對(duì)后再次查詢:return abc;向數(shù)據(jù)庫(kù)插入數(shù)據(jù)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;修改數(shù)據(jù)以適應(yīng)新表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);修改數(shù)據(jù)(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根據(jù)ID查詢數(shù)據(jù)(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,+獎(jiǎng)金:”+salary+”rT+“保險(xiǎn):”+發(fā):,+yingfa+,n+ :”abc=”員工 ID : “+纟口戸切此+“”+”年份:,+year+,n+崗位工資:+gangweigongzi+n+baoxian+”n“+“公積金:,+gongjijin+n+,+shifa;0;catch (SQLException e)
18、abc二喳詢錯(cuò)誤f請(qǐng)核對(duì)后再次查詢“;return abc;查詢員工統(tǒng)計(jì)工資public String chaxun(int tl,int t2) throws SQLExceptionString sql=select * from Wage where year=? and year0)(bt_delete,“刪除成功”);else(bt_delete,“未刪除但可數(shù)據(jù)”); catch (NumberFormatException el) / TODO Auto-generated catch block (bt.delete;刪除失敗,請(qǐng)檢查后刪除“); catch (SQLExcep
19、tion el) / TODO Auto-generated catch block (bt.delete;刪除失敗,請(qǐng)檢查后刪除“););(new ActionListene()Overridepublic void action Performed (Acti on Eve nt e) g川心整理訓(xùn)以編級(jí)的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川心整理訓(xùn)以編駙的word文檔(button”未修改俗可信息”);else(buttonl;修改成功”); catch (SQLException el) (button lz改失敗,請(qǐng)檢查后修改”););(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(請(qǐng)輸入員工 ID :
25、);final JTextField jft=new JTextField(lO);JButton button 1=new JButton(確定);JButton button2=new JButton(取消“);final TextArea ta=new TextArea();布局設(shè)置(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川心整理訓(xùn)以軸樹的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(”獎(jiǎng)金);baoxian=new JLabel(保險(xiǎn));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川心整理訓(xùn)以編軌的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,已存在,請(qǐng)確認(rèn)后添加”););(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(”獎(jiǎng)金);baoxian=new JLabel(保險(xiǎn));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,”已經(jīng)修改”);else(null,”未修改成功”); catch (SQLException el) (
36、null/請(qǐng)確認(rèn)之后再修改”););a川心整理川以編級(jí)的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(請(qǐng)輸入員工 ID :);final JTextField jft=new JTextField(lO);JButton button 1=new JButton(確定”);JButton button2=new JButton(取消”);final TextArea ta=new TextArea();布局設(shè)置(jll); (jft); (buttonl
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 二零二五版國(guó)際金融風(fēng)險(xiǎn)管理合同范本3篇
- 二零二五版建筑工地勞務(wù)用工及社會(huì)保障服務(wù)合同范本3篇
- 二零二五年酒店客房協(xié)議價(jià)優(yōu)惠合作合同3篇
- 2024政府采購(gòu)合同環(huán)境與安全監(jiān)督協(xié)議3篇
- 2025年新型城鎮(zhèn)化項(xiàng)目水電設(shè)施安裝施工合同3篇
- 二零二五版板房租賃與租賃期滿資產(chǎn)評(píng)估與轉(zhuǎn)讓合同3篇
- 二零二五年度出租車司機(jī)服務(wù)規(guī)范與客戶滿意度提升合同3篇
- 二零二五年透水混凝土工程驗(yàn)收與評(píng)估合同2篇
- 二零二五年智能交通管理系統(tǒng)采購(gòu)合同3篇
- 二零二五版房屋代理租賃資產(chǎn)評(píng)估合同3篇
- 蓋洛普Q12解讀和實(shí)施完整版
- 2023年Web前端技術(shù)試題
- GB/T 20840.8-2007互感器第8部分:電子式電流互感器
- GB/T 14864-2013實(shí)心聚乙烯絕緣柔軟射頻電纜
- 品牌策劃與推廣-項(xiàng)目5-品牌推廣課件
- 信息學(xué)奧賽-計(jì)算機(jī)基礎(chǔ)知識(shí)(完整版)資料
- 發(fā)煙硫酸(CAS:8014-95-7)理化性質(zhì)及危險(xiǎn)特性表
- 數(shù)字信號(hào)處理(課件)
- 公路自然災(zāi)害防治對(duì)策課件
- 耳鳴中醫(yī)臨床路徑
- 安徽身份證號(hào)碼前6位
評(píng)論
0/150
提交評(píng)論