java課程設(shè)計(jì)(人事管理系統(tǒng))_第1頁(yè)
java課程設(shè)計(jì)(人事管理系統(tǒng))_第2頁(yè)
java課程設(shè)計(jì)(人事管理系統(tǒng))_第3頁(yè)
java課程設(shè)計(jì)(人事管理系統(tǒng))_第4頁(yè)
java課程設(shè)計(jì)(人事管理系統(tǒng))_第5頁(yè)
已閱讀5頁(yè),還剩19頁(yè)未讀 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶(hù)提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

人事管理系統(tǒng)一.系統(tǒng)需求分析:2〔1〕系統(tǒng)的功能設(shè)計(jì)2〔2〕系統(tǒng)功能結(jié)構(gòu)2〔3〕數(shù)據(jù)庫(kù)設(shè)計(jì)2二.功能模塊開(kāi)發(fā)3〔1〕查詢(xún)?nèi)藛T信息界面3〔2〕添加員工界面3〔3〕修改員工信息界面4〔4〕刪除員工界面5〔5〕員工考核界面5〔6〕員工考核歷史記錄界面6三.各個(gè)類(lèi)說(shuō)明6四.程序代碼9〔1〕Manager9〔2〕CardEmploy11〔3〕SelEmploy12〔4〕AddEmploy14〔5〕ReviseEmploy16iUpdDialog18〔6〕DelEmploy21〔7〕AllEmploy22〔8〕Examine23〔9〕History27〔10〕EmployModel28〔11〕AppraisalModel30〔12〕SqlHelper33一.系統(tǒng)需求分析:系統(tǒng)的功能設(shè)計(jì)員工信息管理:?jiǎn)T工信息管理包括對(duì)員工根本信息和情況進(jìn)行查詢(xún)、添加、刪除和修改及部門(mén)管理員工考核管理:包括對(duì)員工的考核情況進(jìn)行操作,還可以對(duì)歷史考核情況進(jìn)行瀏覽系統(tǒng)功能結(jié)構(gòu)人事管理的系統(tǒng)結(jié)構(gòu)功能結(jié)構(gòu)如下圖:數(shù)據(jù)庫(kù)設(shè)計(jì)員工根本表〔Employinfo〕名稱(chēng)字段名稱(chēng)數(shù)據(jù)類(lèi)型主鍵非空工號(hào)Empnovarchar(10)YesYes姓名Enamevarchar(10)Noyes性別Sexvarchar(4)Noyes出生年月BirthdayDatetimeNoYes部門(mén)DeptNoChar(10)NoYes職務(wù)EjobChar(20)NoYes工資SalfloatNoYes員工考核表〔Appraisal〕名稱(chēng)字段名稱(chēng)數(shù)據(jù)類(lèi)型主鍵非空工號(hào)Empnovarchar(10)yesyes考核Consequencevarchar(10)noyes變更日期RegDatedatetimeNoYes考核歷史記錄〔History〕名稱(chēng)字段名稱(chēng)數(shù)據(jù)類(lèi)型主鍵非空流水號(hào)JourNoIntYesyes工號(hào)Empnovarchar(10)noyes姓名Enamevarchar(10)NoYes上次考核OldInfovarchar(10)NoYes本次考核NewInfovarchar(10)NoYes變更日期RegDatedatetimeNoYes功能模塊開(kāi)發(fā)查詢(xún)?nèi)藛T信息界面實(shí)例一個(gè)SelEmploy類(lèi),當(dāng)點(diǎn)擊“查詢(xún)〞時(shí)調(diào)用EmployModel類(lèi)的queryEmploy方法實(shí)現(xiàn)查詢(xún)添加員工界面實(shí)例一個(gè)AddEmploy類(lèi)當(dāng)點(diǎn)擊“添加〞時(shí)調(diào)用EmployModel類(lèi)的updEmploy方法實(shí)現(xiàn)添加功能修改員工信息界面實(shí)例一個(gè)ReviseEmploy類(lèi)當(dāng)點(diǎn)擊“修改〞時(shí),先調(diào)用UpdDialo彈跳出一個(gè)修改信息對(duì)話框,信息修改完畢后,調(diào)用EmployModel類(lèi)的updEmploy方法實(shí)現(xiàn)修改功能刪除員工界面實(shí)例一個(gè)DelEmploy類(lèi)當(dāng)點(diǎn)擊“刪除〞時(shí)調(diào)用EmployModel類(lèi)的updEmploy方法實(shí)現(xiàn)刪除功能員工考核界面實(shí)例一個(gè)Examine類(lèi)當(dāng)點(diǎn)擊“確認(rèn)〞時(shí)調(diào)用AppraisalModel類(lèi)的updAppraisal方法來(lái)完成考核功能員工考核歷史記錄界面實(shí)例一個(gè)History類(lèi)當(dāng)點(diǎn)擊時(shí)調(diào)用AppraisalModel類(lèi)的updAppraisal方法來(lái)完成考核功能各個(gè)類(lèi)說(shuō)明類(lèi)之間的關(guān)系圖:Manager類(lèi)Manager類(lèi)的一個(gè)實(shí)例,從而生成了人事管理系統(tǒng)的界面,用JSplitPane類(lèi)將整個(gè)界面分為左右兩個(gè)局部。其中左側(cè)實(shí)現(xiàn)了人事管理系統(tǒng)的功能樹(shù),采用JTree類(lèi)構(gòu)建,同時(shí)實(shí)現(xiàn)了TreeSelectionListener接口,定義了該接口所必須實(shí)現(xiàn)的valueChanged(TreeSelectionEvente)方法,JSplitPane右邊參加CardEmploy類(lèi)。當(dāng)JTree的TreeSelectionEvent事件發(fā)生時(shí),調(diào)用CardEmploy的c.show方法切換不同卡片,實(shí)現(xiàn)不同的管理界面。CardEmploy為卡片布局類(lèi)的面板,主要功能是添加各個(gè)界面的卡片,當(dāng)JTree的TreeSelectionEvent事件發(fā)生時(shí)。切換不同的卡片這兩個(gè)類(lèi)繼承了AbstractTableModel,主要實(shí)現(xiàn)的功能是,存放調(diào)用sqlhelper類(lèi)得到的數(shù)據(jù)。可以通過(guò)調(diào)用sqlhelper實(shí)現(xiàn)增刪查改功能r類(lèi)主要就是連接數(shù)據(jù)庫(kù)的一些根底操作是,方便代碼修改,重復(fù)使用y這個(gè)類(lèi)繼承Panel,為“查詢(xún)員工〞的界面。實(shí)現(xiàn)了Actionlistener接口,當(dāng)ActionEvent事件發(fā)生時(shí),調(diào)用EmployModel類(lèi)的queryEmploy方法實(shí)現(xiàn)查詢(xún)這些類(lèi)繼承Pane,分別為“添加員工信息〞“修改員工信息〞“刪除員工信息〞的界面,這些類(lèi)實(shí)現(xiàn)了Actionlistener接口,當(dāng)ActionEvent事件發(fā)生時(shí),調(diào)用EmployModel類(lèi)的updEmploy方法實(shí)現(xiàn)添加、查詢(xún)、刪除、功能這個(gè)類(lèi)繼承Panel,為“考核員工〞界面。這個(gè)類(lèi)實(shí)現(xiàn)了Actionlistener接口,當(dāng)ActionEvent事件發(fā)生時(shí),(1)先通過(guò)調(diào)用AppraisalModel的queryAppraisal獲取上次考核成績(jī),(2)修改Appraisal表的考核成績(jī)〔3〕再把上次考核成績(jī)跟本次考核成績(jī)加到History表中這個(gè)類(lèi)主要是把History表中的信息顯示到界面上。程序代碼Managerpackagecom.Manager;importjava.awt.*;importjavax.swing.*;importjavax.swing.event.TreeSelectionEvent;import;importjavax.swing.tree.*;import.*;publicclassManagerextendsJFrameimplementsTreeSelectionListener{ JPaneljp; JSplitPanejs; JScrollPanejsp;JTreetree; DefaultMutableTreeNoderoot,t1,t2,t1_1,t1_2,t1_3,t1_4,t1_5,t2_1,t2_2; CardEmployae; EmployModelem;publicstaticvoidmain(String[]args){ Managermanager=newManager(); }publicManager(){//給樹(shù)的各個(gè)結(jié)點(diǎn)賦值root=newDefaultMutableTreeNode("人事管理系統(tǒng)");t1=newDefaultMutableTreeNode("根本信息管理");t1_1=newDefaultMutableTreeNode("查詢(xún)員工");t1_2=newDefaultMutableTreeNode("添加員工");t1_3=newDefaultMutableTreeNode("修改員工信息");t1_4=newDefaultMutableTreeNode("刪除員工資料");t1_5=newDefaultMutableTreeNode("查詢(xún)?nèi)w員工");t2=newDefaultMutableTreeNode("人員考核管理");t2_1=newDefaultMutableTreeNode("人員考核");t2_2=newDefaultMutableTreeNode("考核歷史查詢(xún)");t1.add(t1_1);t1.add(t1_2);t1.add(t1_3);t1.add(t1_4);t1.add(t1_5);t2.add(t2_1);t2.add(t2_2);root.add(t1);root.add(t2);tree=newJTree(root);//對(duì)樹(shù)進(jìn)行監(jiān)聽(tīng)tree.addTreeSelectionListener(this);//實(shí)例化CardEmploy面板并加到j(luò)splitpane的邊ae=newCardEmploy();js=newJSplitPane();js.setLeftComponent(tree);js.setRightComponent(ae);this.getContentPane().add(js);this.setTitle("人事管理系統(tǒng)");this.setVisible(true);this.setSize(600,500);this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); }publicvoidvalueChanged(TreeSelectionEvente){//獲取點(diǎn)擊結(jié)點(diǎn)名稱(chēng) DefaultMutableTreeNodedpath=(DefaultMutableTreeNode)tree .getLastSelectedPathComponent();//通過(guò)點(diǎn)擊不同結(jié)點(diǎn)切換不同界面if(dpath.equals(t1_1)){ae.c.show(ae,"1"); }elseif(dpath.equals(t1_2)){ae.c.show(ae,"2"); }elseif(dpath.equals(t1_3)){ae.c.show(ae,"3"); }elseif(dpath.equals(t1_4)){ae.c.show(ae,"4"); }elseif(dpath.equals(t1_5)){ae.c.show(ae,"5"); }elseif(dpath.equals(t2_1)){ae.c.show(ae,"6"); }elseif(dpath.equals(t2_2)){ae.c.show(ae,"7"); } }}CardEmploy/***用卡片布局設(shè)置各個(gè)界面*/packagecom.Manager;importjavax.swing.*;importjava.awt.*;publicclassCardEmployextendsPanel{ CardLayoutc;//查詢(xún)表 SelEmployselE;//添加表 AddEmployaddE;//修改員工信息表ReviseEmployrevE;//刪除員工表格DelEmploydelE;//所有員工信息AllEmployallE;//員工考核表ExamineexaE;//歷史記錄界面HistoryHis;publicCardEmploy(){//查詢(xún)員工表selE=newSelEmploy();//添加員工表addE=newAddEmploy();//修改員工信息revE=newReviseEmploy();//刪除員工表格delE=newDelEmploy();//所有員工信息allE=newAllEmploy();//員工考核表exaE=newExamine();//歷史記錄界面His=newHistory();JPaneljp=newJPanel();//定義cardemploy面板為卡片布局//把各個(gè)面板參加到C的卡片布局中c=newCardLayout();this.setLayout(c);this.add(selE,"1");this.add(addE,"2");this.add(revE,"3");this.add(delE,"4");this.add(allE,"5");this.add(exaE,"6");this.add(His,"7");}}SelEmploy/***SelEmploy類(lèi)設(shè)置查詢(xún)員工界面*/packagecom.Manager;importjava.awt.*;importjavax.swing.*;importjava.awt.event.*;publicclassSelEmployextendsPanelimplementsActionListener{ EmployModelem; JLabeljl; JTextFieldjtf; JButtonjb; JTablejt; JScrollPanejsp; JPaneljp1;publicSelEmploy(){//北部jp1=newJPanel();jl=newJLabel("輸入員工號(hào):");jtf=newJTextField(20);jb=newJButton("查詢(xún)");//對(duì)查詢(xún)按鈕監(jiān)聽(tīng)jb.addActionListener(this);jp1.add(jl);jp1.add(jtf);jp1.add(jb);//中部em=newEmployModel(); String[]paras={"1"};em.queryEmploy("select*fromEmployinfowhere1=?",paras);jt=newJTable(em);jsp=newJScrollPane(jt);this.setLayout(newBorderLayout());this.add(jp1,BorderLayout.NORTH);this.add(jsp,BorderLayout.CENTER); }publicvoidactionPerformed(ActionEvente){if(e.getSource()==jb){ Stringname=this.jtf.getText().trim(); Stringsql="select*fromEmployinfowhereEmpno=?"; String[]paras={name};em=newEmployModel();em.queryEmploy(sql,paras);//查找成功更新表jt.setModel(em); } }}AddEmploypackagecom.Manager;importjava.awt.*;importjavax.swing.*;importjava.awt.event.*;publicclassAddEmployextendsPanelimplementsActionListener{ JLabeljl,jl1,jl2,jl3,jl4,jl5,jl6,jl7; JButtonjb1,jb2; JTextFieldjtf1,jtf2,jtf3,jtf4,jtf5,jtf6,jtf7; JPaneljp1,jp2,jp3,jp4; EmployModelem;publicAddEmploy(){jl1=newJLabel("工號(hào):");jl2=newJLabel("姓名:");jl3=newJLabel("性別:");jl4=newJLabel("出生年月:");jl5=newJLabel("部門(mén):");jl6=newJLabel("職位:");jl7=newJLabel("工資:");jtf1=newJTextField(20);jtf2=newJTextField(20);jtf3=newJTextField(20);jtf4=newJTextField(20);jtf5=newJTextField(20);jtf6=newJTextField(20);jtf7=newJTextField(20);jb1=newJButton("添加");jb2=newJButton("取消");//監(jiān)聽(tīng)‘添加’‘取消’按鈕jb1.addActionListener(this);jb2.addActionListener(this);jp1=newJPanel(newGridLayout(7,1));jp2=newJPanel(newGridLayout(7,1));jp3=newJPanel();jp1.add(jl1);jp1.add(jl2);jp1.add(jl3);jp1.add(jl4);jp1.add(jl5);jp1.add(jl6);jp1.add(jl7);jp2.add(jtf1);jp2.add(jtf2);jp2.add(jtf3);jp2.add(jtf4);jp2.add(jtf5);jp2.add(jtf6);jp2.add(jtf7);jp3.add(jb1);jp3.add(jb2);jp4=newJPanel(newBorderLayout());jp4.add(jp1,BorderLayout.WEST);jp4.add(jp2,BorderLayout.EAST);jp4.setSize(300,300);this.setLayout(newFlowLayout());this.add(jp4);this.add(jp3); }publicvoidactionPerformed(ActionEvente){if(e.getSource()==jb1){//調(diào)用EmployModel里的updEmploy方法,實(shí)現(xiàn)對(duì)表格的添加 Stringsql="insertintoEmployinfovalues(?,?,?,?,?,?,?)"; String[]paras={jtf1.getText(),jtf2.getText(),jtf3.getText(),jtf4.getText(),jtf5.getText(),jtf6.getText(),jtf7.getText()};em=newEmployModel();if(em.updEmploy(sql,paras)){//當(dāng)添加新員工成功時(shí),那么彈出〞添加成功“的對(duì)話框 JOptionPane.showMessageDialog(this,"添加成功"); }elseif(!em.updEmploy(sql,paras)){ JOptionPane.showMessageDialog(this,"添加失敗"); }//當(dāng)新員工參加成功后,要把新參加員工的工號(hào)加到考核表 AppraisalModeltemp=newAppraisalModel(); Stringsql1="insertintoAppraisal(Empno)values(?)"; String[]paras1={jtf1.getText()}; temp.updAppraisal(sql1,paras1); }elseif(e.getSource()==jb2){jtf1.setText("");jtf2.setText("");jtf3.setText("");jtf4.setText("");jtf5.setText("");jtf6.setText("");jtf7.setText(""); } }}ReviseEmploypackagecom.Manager;/***修改員工界面*/importjava.awt.*;importjava.awt.event.*;importjavax.swing.*;publicclassReviseEmployextendsPanelimplementsActionListener{ JTablejt; JScrollPanejsp; JButtonjb1,jb2;JPaneljp1,jp2; EmployModelem;JLabeljl1;publicReviseEmploy(){jl1=newJLabel("修改員工信息",JLabel.CENTER);jl1.setFont(newFont("宋體",Font.BOLD,28));jp2=newJPanel();jp2.add(jl1);em=newEmployModel(); String[]paras={"1"};em.queryEmploy("select*fromEmployinfowhere1=?",paras);jt=newJTable(em);jsp=newJScrollPane(jt);jb1=newJButton("修改");jb2=newJButton("刷新");//對(duì)兩個(gè)按鈕進(jìn)行監(jiān)聽(tīng)jb1.addActionListener(this);jb2.addActionListener(this);this.setLayout(newBorderLayout());jp1=newJPanel();jp1.add(jb1);jp1.add(jb2);this.add(jp2,BorderLayout.NORTH);this.add(jsp,BorderLayout.CENTER);this.add(jp1,BorderLayout.SOUTH); }publicvoidactionPerformed(ActionEvente){if(e.getSource()==jb1){introwNum=this.jt.getSelectedRow();if(rowNum==-1){ JOptionPane.showMessageDialog(this,"請(qǐng)選擇一行");return; }//彈出修改對(duì)話框newUpdDialog(em,rowNum); }elseif(e.getSource()==jb2){//刷新修改界面中的表格em=newEmployModel(); String[]paras1={"1"};em.queryEmploy("select*fromEmployinfowhere1=?",paras1);jt.setModel(em); } }}UpdDialogpackagecom.Manager;/***彈出修改界面*/importjavax.swing.*;importjava.awt.*;importjava.awt.event.*;publicclassUpdDialogextendsJDialogimplementsActionListener{ JLabeljl1,jl2,jl3,jl4,jl5,jl6,jl7; JButtonjb1,jb2; JTextFieldjtf1,jtf2,jtf3,jtf4,jtf5,jtf6,jtf7; JPaneljp1,jp2,jp3;publicUpdDialog(EmployModelem,introwNums){jl1=newJLabel("工號(hào):");jl2=newJLabel("姓名:");jl3=newJLabel("性別:");jl4=newJLabel("出生年月:");jl5=newJLabel("部門(mén):");jl6=newJLabel("職位:");jl7=newJLabel("工資:");jtf1=newJTextField(20);jtf2=newJTextField(30);jtf3=newJTextField(30);jtf4=newJTextField(30);jtf5=newJTextField(30);jtf6=newJTextField(30);jtf7=newJTextField(30);//初始化jtextfield數(shù)據(jù)jtf1.setText((String)em.getValueAt(rowNums,0));jtf1.setEditable(false);jtf2.setText((String)em.getValueAt(rowNums,1));jtf3.setText((String)em.getValueAt(rowNums,2));jtf4.setText((String)em.getValueAt(rowNums,3));jtf5.setText((String)em.getValueAt(rowNums,4));jtf6.setText((String)em.getValueAt(rowNums,5));jtf7.setText((String)em.getValueAt(rowNums,6));jb1=newJButton("修改");jb2=newJButton("取消");//對(duì)兩個(gè)按鈕監(jiān)聽(tīng)jb1.addActionListener(this);jb2.addActionListener(this);jp1=newJPanel();jp2=newJPanel();jp3=newJPanel();//設(shè)置布局jp1.setLayout(newGridLayout(7,1));jp2.setLayout(newGridLayout(7,1));//添加組件jp1.add(jl1);jp1.add(jl2);jp1.add(jl3);jp1.add(jl4);jp1.add(jl5);jp1.add(jl6);jp1.add(jl7);jp2.add(jtf1);jp2.add(jtf2);jp2.add(jtf3);jp2.add(jtf4);jp2.add(jtf5);jp2.add(jtf6);jp2.add(jtf7);jp3.add(jb1);jp3.add(jb2);this.add(jp1,BorderLayout.WEST);this.add(jp2,BorderLayout.CENTER);this.add(jp3,BorderLayout.SOUTH);this.setSize(300,250);this.setVisible(true);this.setLocation(200,200);this.addWindowListener(newWindowAdapter(){publicvoidwindowClosing(WindowEvente){ dispose(); } }); }publicvoidactionPerformed(ActionEvente){if(e.getSource()==jb1){//修改員工信息的sql語(yǔ)句,paras為待注入的值 Stringsql="updateEmployinfoset" +"Ename=?,Sex=?,Birthday=?,DeptNo=?,Ejob=?,Sal=?whereEmpno=?"; String[]paras={jtf2.getText(),jtf3.getText(),jtf4.getText(),jtf5.getText(),jtf6.getText(),jtf7.getText(),jtf1.getText()}; EmployModeltemp=newEmployModel();//如果修改語(yǔ)句運(yùn)行成功那么彈出“修改成功〞對(duì)話框if(temp.updEmploy(sql,paras)){ JOptionPane.showMessageDialog(this,"修改成功"); }this.dispose(); }elseif(e.getSource()==jb2){//關(guān)閉對(duì)話框this.dispose(); } }}DelEmploy/***刪除員工*/packagecom.Manager;importjavax.swing.*;importjava.awt.*;importjava.awt.event.*;publicclassDelEmployextendsPanelimplementsActionListener{ JTablejt; JScrollPanejsp; JButtonjb1,jb2;JPaneljp1,jp2; JLabeljl1; EmployModelem;publicDelEmploy(){//北部jl1=newJLabel("刪除員工",JLabel.CENTER);jl1.setFont(newFont("黑體",Font.BOLD,30));jp2=newJPanel();jp2.add(jl1);//中部em=newEmployModel(); String[]paras={"1"};em.queryEmploy("select*fromEmployinfowhere1=?",paras);jt=newJTable(em);jsp=newJScrollPane(jt);//南部jp1=newJPanel();jb1=newJButton("刪除");jb2=newJButton("取消");jb1.addActionListener(this);jp1.add(jb1);jp1.add(jb2);this.setLayout(newBorderLayout());this.add(jp2,BorderLayout.NORTH);this.add(jsp,BorderLayout.CENTER);this.add(jp1,BorderLayout.SOUTH); }publicvoidactionPerformed(ActionEvente){if(e.getSource()==jb1){//返回用戶(hù)點(diǎn)中的行introwNum=this.jt.getSelectedRow();if(rowNum==-1){ JOptionPane.showMessageDialog(this,"請(qǐng)選擇一行");return; }//得到學(xué)生編號(hào) StringEmpno=(String)em.getValueAt(rowNum,0);//刪除記錄的sql語(yǔ)句 Stringsql="deletefromEmployinfowhereEmpno=?"; String[]paras={Empno}; EmployModeltemp=newEmployModel(); temp.updEmploy(sql,paras);//刪除員工成功后,更新員工表em=newEmployModel(); String[]paras1={"1"};em.queryEmploy("select*fromEmployinfowhere1=?",paras1);jt.setModel(em); } }}AllEmploy/***遍歷所有員工*/packagecom.Manager;importjava.awt.*;importjavax.swing.*;publicclassAllEmployextendsPanel{ EmployModelem; JTablejt; JScrollPanejsp;JLabeljl1;JPaneljp;publicAllEmploy() {//北部jp=newJPanel();jl1=newJLabel("全體員工",JLabel.CENTER);jl1.setFont(newFont("黑體",Font.BOLD,30));jp.add(jl1);//中部em=newEmployModel(); String[]paras={"1"};em.queryEmploy("select*fromEmployinfowhere1=?",paras); jt=newJTable(em); jsp=newJScrollPane(jt); this.setLayout(newBorderLayout());this.add(jp,BorderLayout.NORTH);this.add(jsp,BorderLayout.CENTER); }}Examine/***員工考核界面*/packagecom.Manager;importjava.awt.*;importjava.awt.event.*;importjava.sql.ResultSet;import;importjava.sql.*;importjavax.swing.*;publicclassExamineextendsPanelimplementsActionListener{ JLabeljl1,jl2,jl3,jl4; JTablejt; JScrollPanejsp; JTextFieldjtf1,jtf2; Choicech; JButtonjb1,jb2; JPaneljp1,jp2,jp3,jp4; AppraisalModelam; SqlHelpersqh;publicExamine(){//北部為標(biāo)題文字jp4=newJPanel();jl1=newJLabel("員工考核",JLabel.CENTER);jl1.setFont(newFont("黑體",Font.BOLD,30));jp4.add(jl1);//中部am=newAppraisalModel();am.queryAppraisal("selectE.Empno,E.Ename,A.Consequence,A.RegDatefrom" +"EmployinfoasE,AppraisalasAwhereE.Empno=A.Empno");jt=newJTable(am);jsp=newJScrollPane(jt);//監(jiān)聽(tīng)jtable點(diǎn)擊表格時(shí)獲取點(diǎn)擊的行數(shù)并通過(guò)鼠標(biāo)點(diǎn)擊事件給jtf1,jtf2賦值jt.addMouseListener(newMouseAdapter(){publicvoidmouseClicked(MouseEvente){introwNum=jt.getSelectedRow();jtf1.setText((String)am.getValueAt(rowNum,0));jtf2.setText((String)am.getValueAt(rowNum,1)); } });jl2=newJLabel("工號(hào):");jl3=newJLabel("姓名:");jl4=newJLabel("考核");jtf1=newJTextField(10);jtf2=newJTextField(10);jtf1.setEditable(false);jtf2.setEditable(false);//實(shí)例單項(xiàng)選擇框組件,并賦值ch=newChoice();ch.add("未考核");ch.add("不合格");ch.add("合格");ch.add("優(yōu)秀");jp1=newJPanel();jp1.add(jl2);jp1.add(jtf1);jp1.add(jl3);jp1.add(jtf2);jp1.add(jl4);jp1.add(ch);jp2=newJPanel(newBorderLayout());jp2.add(jsp,BorderLayout.CENTER);jp2.add(jp1,BorderLayout.SOUTH);//南部jb1=newJButton("確認(rèn)");jb2=newJButton("刷新");jp3=newJPanel();jb1.addActionListener(this);jb2.addActionListener(this);jp3.add(jb1);jp3.add(jb2);this.setLayout(newBorderLayout());this.add(jp4,BorderLayout.NORTH);this.add(jp2,BorderLayout.CENTER);this.add(jp3,BorderLayout.SOUTH); }publicvoidactionPerformed(ActionEvente){if(e.getSource()==jb1){ StringEmpno=jtf1.getText(); StringEname=jtf2.getText(); StringConsequence=ch.getSelectedItem();//先獲取上次考核記錄 Stringsql="selectConsequencefromAppraisalwhereEmpno=?"; String[]paras={Empno}; StringOldInfo="";try{sqh=newSqlHelper(); ResultSetrs=sqh.queryExecute(sql,paras); rs.next(); OldInfo=rs.getString(1); }catch(Exceptione1){ e1.printStackTrace(); }finally{sqh.close(); }//對(duì)考核表進(jìn)行修改修改考核記錄的sql語(yǔ)句 Stringsql1="updateAppraisalsetConsequence=?whereEmpno=?"; String[]paras1={Consequence,Empno}; AppraisalModeltemp=newAppraisalModel();if(temp.updAppraisal(sql1,paras1)){ JOptionPane.showMessageDialog(this,"考核成功"); }//再把"上次考核記錄"以及"本次操作記錄"插入到history表中 Stringsql2="insertintoHistory(Empno,Ename,OldInfo,NewInfo)values(?,?,?,?)"; String[]paras2={Empno,Ename,OldInfo,Consequence}; AppraisalModeltemp1=newAppraisalModel(); temp1.updAppraisal(sql2,paras2); }elseif(e.getSource()==jb2){//刷新員工考核表am=newAppraisalModel(); String[]paras3={"1"};am.queryAppraisal("selectE.Empno,E.Ename,A.Consequence,A.RegDatefrom" +"EmployinfoasE,AppraisalasAwhereE.Empno=A.Empno");this.jt.setModel(am); } }}History/***歷史記錄界面*/packagecom.Manager;importjava.awt.*;importjava.awt.event.*;importjavax.swing.*;publicclassHistoryextendsPanelimplementsActionListener{ AppraisalModelam; JTablejt; JScrollPanejsp; JLabeljl1; JPaneljp,jp1,jp2; JButtonjb1,jb2;publicHistory(){//北部jp=newJPanel();jl1=newJLabel("員工考核歷史記錄",JLabel.CENTER);jl1.setFont(newFont("黑體",Font.BOLD,30));jp.add(jl1);//中部am=newAppraisalModel(); String[]paras={"1"};am.queryHistory("select*fromHistorywhere1=?",paras);jt=newJTable(am);jsp=newJScrollPane(jt);//南部jp2=newJPanel();jb1=newJButton("清空");jb2=newJButton("刷新");jb1.addActionListener(this);jb2.addActionListener(this);jp2.add(jb1);jp2.add(jb2);this.setLayout(newBorderLayout());this.add(jp,BorderLayout.NORTH);this.add(jsp,BorderLayout.CENTER);this.add(jp2,BorderLayout.SOUTH); }publicvoidactionPerformed(ActionEvente){if(e.getSource()==jb1){//刪除歷史記錄并更新表am=newAppraisalModel(); String[]paras={"1"};am.updAppraisal("deleteHistorywhere1=?",paras);am.queryHistory("select*fromHistorywhere1=?",paras);this.jt.setModel(am); }elseif(e.getSource()==jb2){//刷新表格am=newAppraisalModel(); String[]paras={"1"};am.queryHistory("select*fromHistorywhere1=?",paras);this.jt.setModel(am); } }}EmployModel/***重寫(xiě)TableModel*/packagecom.Manager;importjavax.swing.table.*;importjava.sql.*;importjava.util.*;publicclassEmployModelextendsAbstractTableModel{VectorrowData,columnNames;//實(shí)現(xiàn)查詢(xún)publicvoidqueryEmploy(Stringsql,String[]paras){ SqlHelpersqh=null;//用columnNames存放表的列名columnNames=newVector();columnNames.add("工號(hào)");columnNames.add("姓名");columnNames.add("性別");columnNames.add("出生年月");columnNames.add("部門(mén)");columnNames.add("職位");columnNames.add("工資");//rowData存放表格的各行數(shù)據(jù)rowData=newVector();try{ sqh=newSqlHelper(); ResultSetrs=sqh.queryExecute(sql,paras);while(rs.next()) {Vectorhang=newVector();hang.add(rs.getString(1));hang.add(rs.getString(2));hang.add(rs.getString(3));hang.add(rs.getString(4));hang.add(rs.getString(5));hang.add(rs.getString(6));hang.add(rs.getString(7));rowData.add(hang); } }catch(Exceptione){ e.printStackTrace(); }finally{ sqh.close(); }}//實(shí)現(xiàn)表格增修改功能publicbooleanupdEmploy(Stringsql,String[]paras) { SqlHelpersqh=newSqlHelper();returnsqh.updExecute(sql,paras); }publicintgetRowCount(){returnthis.rowData.size(); }publicStringgetColumnName(intcolumn){return(String)this.columnNames.get(column); }publicintgetColumnCount(){ returnthis.columnNames.size(); }publicObjectgetValueAt(introw,intcolumn){//獲得某一個(gè)單元格的數(shù)值return((Vector)this.rowData.get(row)).get(column); }}AppraisalModel/***重寫(xiě)TableModel為考核類(lèi)的table模板*/packagecom.Manager;importjavax.swing.table.*;importjava.sql.*;importjava.util.*;publicclassAppraisalModelextendsAbstractTableModel{VectorrowData,columnNames;//實(shí)現(xiàn)查詢(xún)publicvoidqueryAppraisal(Stringsql){SqlHelpersqh=null;//用columnNames存放表的列名columnNames=newVector();columnNames.add("工號(hào)");columnNames.add("姓名");columnNames.add("上次考核");columnNames.add("考核時(shí)間");//rowData存放表格的各行數(shù)據(jù)rowData=newVector();try{ sqh=newSqlHelper(); ResultSetrs=sqh.queryExecute(sql);while(rs.next()){Vectorhang=newVector();hang.add(rs.getString(1));hang.add(rs.getString(2));hang.add(rs.getString(3));hang.add(rs.getString(4));rowData.add(hang); } }catch(Exceptione){ e.printStackTrace(); }finally{ sqh.close(); } }//查詢(xún)員工考核歷史記錄方法publicvoidqueryHistory(Stringsql,String[]paras){SqlHelpersqh=null;//用columnNames存放表的列名columnNames=newVector();columnNames.add("流水號(hào)");columnNames.add("工號(hào)");columnNames.add("姓名");columnNames.add("上次考核");columnNames.add("本次考核");columnNa

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶(hù)所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶(hù)上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶(hù)上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶(hù)因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論