




下載本文檔
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
1、川心整理訓(xùn)以編級的word文檔綜合實驗三員工管理系統(tǒng)、實驗?zāi)康恼莆站帉憯?shù)據(jù)庫應(yīng)用程序的方法,包括菜單、布局管理器、彈出提示信息對話框、輸入對話框、 數(shù)據(jù)庫讀寫、事件處理。二、實驗環(huán)境PC 系列微機,Windows XPOEclipse. JDK150或更高版本。三、實驗內(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)計工資總額”); 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)計工資總額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);添加數(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二喳詢錯誤,請核對后再次查詢:return abc;向數(shù)據(jù)庫插入數(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,+獎金:”+salary+”rT+“保險:”+發(fā):,+yingfa+,n+ :”abc=”員工 ID : “+纟口戸切此+“”+”年份:,+year+,n+崗位工資:+gangweigongzi+n+baoxian+”n“+“公積金:,+gongjijin+n+,+shifa;0;catch (SQLException e)
18、abc二喳詢錯誤f請核對后再次查詢“;return abc;查詢員工統(tǒng)計工資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;刪除失敗,請檢查后刪除“); catch (SQLExcep
19、tion el) / TODO Auto-generated catch block (bt.delete;刪除失敗,請檢查后刪除“););(new ActionListene()Overridepublic void action Performed (Acti on Eve nt e) g川心整理訓(xùn)以編級的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改失敗,請檢查后修改”););(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();布局設(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(”獎金);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川心整理訓(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,已存在,請確認后添加”););(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,”已經(jīng)修改”);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();布局設(shè)置(jll); (jft); (buttonl
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年全球貿(mào)易合同履行面臨的挑戰(zhàn)及應(yīng)對策略
- 二手房產(chǎn)交易合同協(xié)議書
- 旅行社與景區(qū)合作協(xié)議合同模板
- 別墅二次裝修施工合同范本
- 2025年企業(yè)乘用車批量采購策劃合同
- 2025年公園照明維修服務(wù)合同
- 2025年茶葉品牌合作授權(quán)經(jīng)營合同模板
- 2025年倉庫保管員勞動合同范文標準
- 2025版本成都市物業(yè)管理服務(wù)合同8篇
- 與政府簽署的合同履約金條款
- 2025年不停電電源(UPS)項目合作計劃書
- 2025年國家林業(yè)和草原局直屬事業(yè)單位第一批招聘應(yīng)屆畢業(yè)生96人歷年高頻重點模擬試卷提升(共500題附帶答案詳解)
- 2025年春季開學典禮校長講話稿-少年無畏凌云志扶搖直上入云蒼
- 2025寒假開學第一課 課件【1】
- 山東省泰安市新泰市2024-2025學年(五四學制)九年級上學期1月期末道德與法治試題(含答案)
- 1《北京的春節(jié)》課后練習(含答案)
- (完整版)陸河客家請神書
- 2025年行業(yè)協(xié)會年度工作計劃
- DB3502T 160-2024 工業(yè)產(chǎn)品質(zhì)量技術(shù)幫扶和質(zhì)量安全監(jiān)管聯(lián)動工作規(guī)范
- 2025年學校教師政治理論學習計劃
- 集團專利管理制度內(nèi)容
評論
0/150
提交評論