




版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
....word教育資料word教育資料word教育資料課程設(shè)計(jì)報(bào)告企業(yè)工資管理系統(tǒng)..得分: XXX 班級(jí) XXXXX 學(xué)號(hào) XXXXXX 課程名稱 數(shù)據(jù)庫(kù)原理及應(yīng)用 指導(dǎo)教師 201X年X月X日目錄一.工資管理系統(tǒng)需求分析…………………1.1功能需求…………………1.1.1功能劃分………1.1.2功能描述……………1.2性能需求…………………1.3數(shù)據(jù)流圖………………二.總體設(shè)計(jì)…………………2.1數(shù)據(jù)庫(kù)概念設(shè)計(jì)…………2.2功能模塊…………………三.系統(tǒng)詳細(xì)設(shè)計(jì)……………3.1數(shù)據(jù)庫(kù)邏輯設(shè)計(jì)…………3.2各模塊功能………………3.2.1職工信息管理系統(tǒng)…………………3.2.2職工工資管理系統(tǒng)…………………3.2.3職工津貼管理系統(tǒng)…………………四.系統(tǒng)實(shí)現(xiàn)…………………4.1界面截圖…………………4.1.1主界面及工資基本信息界面……4.1.2登錄界面…………4.1.3系統(tǒng)主界面………4.1.4信息錄入,修改,刪除,查詢界面…………4.2設(shè)計(jì)代碼…………………五.實(shí)驗(yàn)總結(jié)…………………
需求分析功能需求1.1.1功能劃分(1)、員工信息表;及時(shí)反映員工的基本信息(2)、員工津貼表,反映員工津貼(3)、員工基本工資表1.1.2功能描述(1)、基本工資的設(shè)定(2)、津貼的設(shè)定(3)、計(jì)算出月工資(4)、錄入員工工資信息(5)、添加員工工資信息(6)、更改員工工資信息1.2性能需求此工資管理系統(tǒng)對(duì)工資數(shù)據(jù)精度的計(jì)算能在默認(rèn)情況之下精確到小數(shù)點(diǎn)后3位小數(shù),即是精確到分的計(jì)算。但在用戶使用過(guò)程中,能自行根據(jù)實(shí)際情況進(jìn)行小數(shù)計(jì)算精度的設(shè)定,最大能允許保留小數(shù)點(diǎn)后5位的精度。在時(shí)間特性上,當(dāng)用戶發(fā)出命令請(qǐng)求時(shí)的服務(wù)器的響應(yīng)時(shí)間、對(duì)數(shù)據(jù)更新處理、工資數(shù)據(jù)的查詢檢索等上,同樣要求系統(tǒng)響應(yīng)時(shí)間不會(huì)超過(guò)0.5秒時(shí)間。系統(tǒng)支持多種操作系統(tǒng)的運(yùn)行環(huán)境,多不同操作系統(tǒng),不同文件格式的磁盤上的數(shù)據(jù)均能實(shí)現(xiàn)信息的互通,及共享。當(dāng)服務(wù)器移植到其他的系統(tǒng)平臺(tái),如:Linux平臺(tái)下時(shí),同樣能和其他的系統(tǒng)進(jìn)行數(shù)據(jù)存取同步,不會(huì)出現(xiàn)系統(tǒng)之間互不兼容的情況,系統(tǒng)支持多系統(tǒng)之間的互連互通,系統(tǒng)有巨大的強(qiáng)健性。本課程設(shè)計(jì)是用Java語(yǔ)言編寫(xiě),mysql數(shù)據(jù)庫(kù)。1.3數(shù)據(jù)流圖根據(jù)工資管理要求及用戶需求調(diào)查分析,得到以下數(shù)據(jù)流圖圖1.1第一層數(shù)據(jù)流圖修改職工信息修改職工信息刪除職工記錄輸入職工基本信息工資表添加操作修改操作刪除操作用戶查詢操作職工號(hào)圖1.2職工信息的載入津貼表添加操作修改操作刪除操作查詢操作用戶圖1.4考勤的信息載入2.總體設(shè)計(jì)2.1數(shù)據(jù)庫(kù)概念設(shè)計(jì)有了數(shù)據(jù)流圖,用E-R圖來(lái)說(shuō)明工資信息管理系統(tǒng)的數(shù)據(jù)庫(kù)概念模式,如圖11nm員工領(lǐng)取工資領(lǐng)取津貼影響職工號(hào)姓名職工號(hào)基本工資職工號(hào)津貼姓名密碼姓名圖2.1實(shí)體之間關(guān)系E-R圖2.2功能模塊工資管理系統(tǒng)系統(tǒng)模塊工資管理模塊職工登陸模塊員工管理模塊3.系統(tǒng)詳細(xì)設(shè)計(jì)3.1數(shù)據(jù)庫(kù)邏輯設(shè)計(jì)將以上E-R轉(zhuǎn)換成如下關(guān)系模式員工(職工號(hào),,密碼)工資(職工號(hào),,基本工資,)津貼(職工號(hào),,獎(jiǎng)金)其中,標(biāo)有下劃線的字段表示為該數(shù)據(jù)表的主碼,即主關(guān)鍵字。在上面的實(shí)體以及實(shí)體之間關(guān)系的基礎(chǔ)上,形成數(shù)據(jù)庫(kù)中的表格以及各個(gè)表格之間的關(guān)系。工資信息管理系統(tǒng)數(shù)據(jù)庫(kù)中各個(gè)表格的設(shè)計(jì)結(jié)果如下面的幾個(gè)表格所示。每個(gè)表格表示在數(shù)據(jù)庫(kù)中的一個(gè)表。表一:?jiǎn)T工信息表:列名列名數(shù)據(jù)類型可否取空備注說(shuō)明noChar(8)NOTNULL職工號(hào)(主鍵)nameChar(10)NOTNULL職工miSmallintNOTNULL登錄密碼表二:基本工資表:列名列名數(shù)據(jù)類型可否取空備注說(shuō)明noChar(8)NOTNULL職工號(hào)(主鍵)nameChar(10)NOTNULL職工JbmoneyNOTNULL基本工資表四:津貼信息表....word教育資料word教育資料..word教育資料列名列名數(shù)據(jù)類型可否為空備注說(shuō)明noChar(8)NOTNULL職工號(hào)(主鍵)nameChar(10)NOTNULL職工JtmoneyNOTNULL津貼3.2各模塊功能3.2.1職工信息管理系統(tǒng)功能為:財(cái)務(wù)部門相關(guān)人員錄入、修改、刪除、查詢員工個(gè)人信息3.2.2職工工資管理系統(tǒng)功能為:根據(jù)工資生成公式,按照員工的考勤情況及各種表現(xiàn)按月生成相應(yīng)的工資;財(cái)務(wù)部門相關(guān)人員能錄入、修改、刪除、查詢每個(gè)月每個(gè)員工的工資信息以及工資匯總;員工本人能查詢自己的工資信息以及工資匯總;2.3職工登陸查詢系統(tǒng)功能為:?jiǎn)T工本人能通過(guò)用戶名和密碼查詢自己的信息以及修改自己的密碼;4.系統(tǒng)實(shí)現(xiàn)4.1界面截圖1.1主界面4.1.2登錄界面4.1.3管理員管理工資界面4.1.4信息錄入,修改,刪除,查詢界面4.1.5職工信息查詢界面4.1.6職工密碼修改界面4.2設(shè)計(jì)代碼DB.javapackagewage_management;importjava.awt.*;importjava.awt.event.*;importjavax.swing.*;classDBextendsJFrameimplementsActionListener{JFrameframe=newJFrame("歡迎進(jìn)入企業(yè)工資管理系統(tǒng)");JLabellabel=newJLabel("",JLabel.CENTER);JButtonbutton1=newJButton("進(jìn)入系統(tǒng)");JButtonbutton2=newJButton("退出系統(tǒng)");ImageIconim=newImageIcon("1.jpg");....word教育資料word教育資料..word教育資料JLabela1=newJLabel(im);voidCreate(){JPanelpcontentPane=(JPanel)frame.getContentPane();pcontentPane.add(a1);pcontentPane.add(label);pcontentPane.setLayout(newFlowLayout());pcontentPane.add(button1);pcontentPane.add(button2);pcontentPane.setVisible(true);button1.addActionListener(this);button2.addActionListener(this);frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);frame.pack();frame.setBounds(200,100,550,180);frame.setVisible(true);}publicstaticvoidmain(String[]args){DBdome=newDB();dome.Create();}publicvoidactionPerformed(ActionEvente){if(button1.equals(e.getSource())){DLdl=newDL();dl.create();frame.dispose();}if(button2.equals(e.getSource())){//退出System.exit(0);}}}登陸DL.javapackagewage_management;importjava.awt.Color;importjava.awt.FlowLayout;importjava.awt.event.ActionEvent;importjava.awt.event.ActionListener;importjava.sql.Connection;importjava.sql.DriverManager;importjava.sql.ResultSet;importjava.sql.Statement;importjavax.swing.ImageIcon;importjavax.swing.JButton;importjavax.swing.JFrame;importjavax.swing.JLabel;importjavax.swing.JOptionPane;importjavax.swing.JPanel;importjavax.swing.JPasswordField;importjavax.swing.JTextField;import.mysql.jdbc.PreparedStatement;importQuery.Querypad;classDLextendsJFrameimplementsActionListener{ImageIconim=newImageIcon("2.jpg");JLabela2=newJLabel(im);JFrameframe=newJFrame("職工/管理員登陸");JLabellabel1=newJLabel("用戶名");JLabellabel2=newJLabel("密碼");JButtonlogonButton1=newJButton("管理員登錄");JButtonlogonButton2=newJButton("職工登錄");JButtoncancelButton=newJButton("退出");JTextFieldusername=newJTextField(9);JPasswordFieldpassword=newJPasswordField(9);staticStringt1;staticStringt2;voidcreate(){JPanelp=(JPanel)frame.getContentPane();JPanelp1=newJPanel();p.setLayout(newFlowLayout());p.add(a2);p.add(label1);p.setSize(5,5);p.setLocation(4,8);p.add(username);p.setSize(100,200);p.setLocation(800,800);p.add(label2);p.setSize(50,20);p.setLocation(40,80);p.add(password);p.setSize(100,20);p.setLocation(80,120);p.add(logonButton1);p.add(logonButton2);p.add(cancelButton);p.setBackground(Color.cyan);p.setVisible(true);logonButton1.addActionListener(this);logonButton2.addActionListener(this);cancelButton.addActionListener(this);frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);frame.pack();frame.setBounds(200,100,500,220);frame.setVisible(true);}publicvoidactionPerformed(ActionEvente){t1=username.getText();t2=password.getText();if(e.getSource()==logonButton1){if(username.getText().equals("admin")==true&&(password.getText().equals("admin")==true)){JOptionPane.showMessageDialog(this,"登錄成功!");GZGLZJMgz=newGZGLZJM();gz.create();frame.dispose();}else{JOptionPane.showMessageDialog(null,"輸入用戶名或密碼錯(cuò)誤!");}}if(e.getSource()==logonButton2){try{Connectioncon;Statementps;ResultSetrs;Stringsql=null;Class.forName("org.gjt.mm.mysql.Driver");Class.forName("org.gjt.mm.mysql.Driver").newInstance();con=DriverManager.getConnection("jdbc:mysql://localhost:3306/wagemanagement","root","jxb");sql="select*fromworkerinfowherename='"+t1+"'andmi='"+t2+"'";ps=(PreparedStatement)con.prepareStatement(sql);rs=ps.executeQuery(sql);if(rs.next()){if(rs.getString("name").equals(t1) &&rs.getString("mi").equals(t2)){YGDLJMyg=newYGDLJM();yg.create();frame.dispose();JOptionPane.showMessageDialog(this,"登錄成功!");this.dispose();}}else{JOptionPane.showMessageDialog(this,"輸入用戶名或密碼錯(cuò)誤!");}}catch(Exceptione1){//TODOAuto-generatedcatchblocke1.printStackTrace();}}if(cancelButton.equals(e.getSource()))//退出{System.exit(0);}}}GZGLZJM.java//工資管理主界面packagewage_management;importjava.awt.Color;importjava.awt.FlowLayout;importjava.awt.event.ActionEvent;importjava.awt.event.ActionListener;importjavax.swing.ImageIcon;importjavax.swing.JButton;importjavax.swing.JFrame;importjavax.swing.JLabel;importjavax.swing.JPanel;classGZGLZJMextendsJFrameimplementsActionListener{JFramef=newJFrame("工資管理系統(tǒng)");JButtonb1=newJButton("工資管理");JButtonb2=newJButton("員工信息管理");JButtonb3=newJButton("返回");ImageIconim=newImageIcon("3.jpg");JLabela1=newJLabel(im);voidcreate(){JPanelp=(JPanel)f.getContentPane();p.setLayout(newFlowLayout());p.add(a1);p.add(b1);p.add(b2);p.add(b3);p.setBackground(Color.cyan);p.setVisible(true);b1.addActionListener(this);b2.addActionListener(this);b3.addActionListener(this);f.setBounds(200,100,500,200);f.setVisible(true);}publicvoidactionPerformed(ActionEvente){if(b3.equals(e.getSource())){//返回DLd=newDL();d.create();f.dispose();}if(b2.equals(e.getSource())){//員工信息管理YGGLyg=newYGGL();yg.create();f.dispose();}if(b1.equals(e.getSource())){//工資管理GZGLgz=newGZGL();gz.create();f.dispose();}}}//////工資管理GZGL.javapackagewage_management;importjava.awt.Color;importjava.awt.FlowLayout;importjava.awt.event.ActionEvent;importjava.awt.event.ActionListener;importjava.sql.Connection;importjava.sql.DriverManager;importjava.sql.ResultSet;importjava.sql.SQLException;importjava.sql.Statement;importjavax.swing.JButton;importjavax.swing.JFrame;importjavax.swing.JLabel;importjavax.swing.JOptionPane;importjavax.swing.JPanel;importjavax.swing.JScrollPane;importjavax.swing.JSplitPane;importjavax.swing.JTable;importjavax.swing.JTextField;publicclassGZGLextendsJFrameimplementsActionListener{JFramef=newJFrame("工資管理");JButtonb1=newJButton("錄入");JButtonb2=newJButton("修改");JButtonb3=newJButton("刪除");JButtonb4=newJButton("查詢所有");JButtonb5=newJButton("返回");JTextFieldtf1=newJTextField(4);JTextFieldtf2=newJTextField(4);JTextFieldtf3=newJTextField(4);JTextFieldtf4=newJTextField(4);JTextFieldtf5=newJTextField(6);JTextFieldtf6=newJTextField(7);String[]cloum={"職工號(hào)","","津貼","月基本工資","月薪"};Object[][]row=newObject[50][5];JTabletable=newJTable(row,cloum);JScrollPanescrollpane=newJScrollPane(table);JSplitPane splitpane = newJSplitPane(JSplitPane.VERTICAL_SPLIT);voidcreate(){JPanelp=(JPanel)f.getContentPane();p.setLayout(newFlowLayout());p.add(scrollpane);p.add(splitpane);JPanelp1=newJPanel();p1.add(b1);p1.add(b2);p1.add(b3);p1.add(b4);p1.add(b5);JPanelp2=newJPanel();p2.setBackground(Color.cyan);p2.add(scrollpane);JPanelp3=newJPanel();p.setLayout(newFlowLayout());p.add(newJLabel(""));p.add(newJLabel("職工號(hào)"));p.add(tf1);p.add(newJLabel(""));p.add(tf2);p.add(newJLabel("津貼"));p.add(tf3);p.add(newJLabel("月基本工資"));p.add(tf4);p.add(newJLabel("月薪"));p.add(tf5);p.add(newJLabel("在此處輸入職工號(hào)點(diǎn)擊查詢刪除"));p.add(tf6);splitpane.add(p1,splitpane.TOP);splitpane.add(p2,splitpane.BOTTOM);splitpane.setDividerLocation(50);p.setBackground(Color.CYAN);b1.addActionListener(this);b2.addActionListener(this);b3.addActionListener(this);b4.addActionListener(this);b5.addActionListener(this);f.setBounds(200,100,500,600);f.setResizable(true);//可以調(diào)整界面大小f.setVisible(true);}publicvoidactionPerformed(ActionEvente){if(b1.equals(e.getSource())){//錄入Connectioncon;Statementsql;try{Class.forName("org.gjt.mm.mysql.Driver");}catch(ClassNotFoundExceptione1){System.out.println(""+e1);}try{con=DriverManager.getConnection("jdbc:mysql://localhost:3306/wagemanagement","root","jxb");sql=con.createStatement();StringinsertStr="INSERTINTOwelfare(no,name,jt)VALUES('"+tf1.getText()+"','"+tf2.getText()+"','"+tf3.getText()+"');";sql.executeUpdate(insertStr);StringinsertStr1="INSERTINTOwageinfo(no,name,jb)VALUES('"+tf1.getText()+"','"+tf2.getText()+"','"+tf4.getText()+"');";sql.executeUpdate(insertStr1);con.close();");JOptionPane.showMessageDialog(this,"入錄成功!}catch(SQLExceptione1){");JOptionPane.showMessageDialog(this,"入錄失敗!}}if(b2.equals(e.getSource())){//修改Connectioncon;Statementsql;try{Class.forName("org.gjt.mm.mysql.Driver");}catch(ClassNotFoundExceptione1){System.out.println(""+e1);}try{con =DriverManager.getConnection("jdbc:mysql://localhost:3306/wagemanagement","root","jxb");sql=con.createStatement();StringupdateStr="UPDATEwelfareSETjt='"+tf3.getText()+"',name='"+tf2.getText()+"'whereno='"+tf1.getText()+"';";sql.executeUpdate(updateStr);StringupdateStr1="UPDATEwageinfoSETjb='"+tf4.getText()+"',name='"+tf2.getText()+"'whereno='"+tf1.getText()+"';";sql.executeUpdate(updateStr1);JOptionPane.showMessageDialog(this,"修改成功!");con.close();}catch(SQLExceptione1){JOptionPane.showMessageDialog(this,"信息不存在!");}}if(b3.equals(e.getSource())){//刪除Connectioncon;Statementsql;ResultSetrs;try{Class.forName("org.gjt.mm.mysql.Driver");}catch(ClassNotFoundExceptione1){System.out.println(""+e1);}try{con =DriverManager.getConnection("jdbc:mysql://localhost:3306/wagemanagement","root","jxb");sql =con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);sql.executeUpdate("DELETEFROMwageinfowhereno='"+tf6.getText()+"';");sql.executeUpdate("DELETEFROMwelfarewhereno='"+tf6.getText()+"';");");JOptionPane.showMessageDialog(this,"刪除成功!con.close();}catch(SQLExceptione1){");JOptionPane.showMessageDialog(this,"刪除失敗!}}if(b4.equals(e.getSource())){//查詢?nèi)緾onnectioncon;Statementsql;ResultSetrs;//Vectorvector=newVector();try{Class.forName("org.gjt.mm.mysql.Driver");}catch(ClassNotFoundExceptione1){JOptionPane.showMessageDialog(this,"連接數(shù)據(jù)庫(kù)失??!");}try{con =DriverManager.getConnection("jdbc:mysql://localhost:3306/wagemanagement","root","jxb");sql =con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);if(b4.equals(e.getSource())){for(inti=0;i<50;i++)for(intj=0;j<4;j++)table.setValueAt("",i,j);rs=sql.executeQuery("selectdistinct*fromwageinfo,=");intk=-1;while(rs.next()){++k;Stringno=rs.getString(1);Stringname=rs.getString(2);Stringjb=rs.getString(3);Stringjt=rs.getString(6);intsum=rs.getInt(3)+rs.getInt(6);table.setValueAt(no,k,0);table.setValueAt(name,k,1);table.setValueAt(jb,k,3);table.setValueAt(jt,k,2);table.setValueAt(sum,k,4);}}}catch(SQLExceptione1){JOptionPane.showMessageDialog(this,"查詢失??!");}}if(b5.equals(e.getSource())){//返回GZGLZJMgl=newGZGLZJM();gl.create();f.dispose();}}}////////修改管理主界面YGGLZJM.javapackagewage_management;importjava.awt.Color;importjava.awt.FlowLayout;importjava.awt.event.ActionEvent;importjava.awt.event.ActionListener;importjava.sql.Connection;importjava.sql.DriverManager;importjava.sql.ResultSet;importjava.sql.SQLException;importjava.sql.Statement;importjavax.swing.JButton;importjavax.swing.JFrame;importjavax.swing.JOptionPane;importjavax.swing.JPanel;importjavax.swing.JScrollPane;importjavax.swing.JSplitPane;importjavax.swing.JTable;publicclassYGDLJMextendsDLimplementsActionListener{JFramef=newJFrame("工資管理");JButtonb1=newJButton("查詢個(gè)人工資");JButtonb2=newJButton("修改密碼");JButtonb3=newJButton("返回");String[]cloum={"職工號(hào)","","津貼","月基本工資","月薪"};Object[][]row=newObject[50][5];JTabletable=newJTable(row,cloum);JScrollPanescrollpane=newJScrollPane(table);JSplitPane splitpane = newJSplitPane(JSplitPane.VERTICAL_SPLIT);voidcreate(){JPanelp=(JPanel)f.getContentPane();p.setLayout(newFlowLayout());p.add(scrollpane);p.add(splitpane);JPanelp1=newJPanel();p1.add(b1);p1.add(b2);p1.add(b3);JPanelp2=newJPanel();p2.setBackground(Color.cyan);p2.add(scrollpane);JPanelp3=newJPanel();p.setLayout(newFlowLayout());splitpane.add(p1,splitpane.TOP);splitpane.add(p2,splitpane.BOTTOM);splitpane.setDividerLocation(50);p.setBackground(Color.CYAN);b1.addActionListener(this);b2.addActionListener(this);b3.addActionListener(this);f.setBounds(200,100,500,550);f.setResizable(true);//可以調(diào)整界面大小f.setVisible(true);}publicvoidactionPerformed(ActionEvente){if(b1.equals(e.getSource())){//查詢個(gè)人工資Connectioncon;Statementsql;ResultSetrs;try{Class.forName("org.gjt.mm.mysql.Driver");}catch(ClassNotFoundExceptione1){System.out.println(""+e1);}try{con =DriverManager.getConnection("jdbc:mysql://localhost:3306/wagemanagement","root","jxb");sql =con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);if(b1.equals(e.getSource())){for(inti=0;i<50;i++)for(intj=0;j<4;j++)table.setValueAt("",i,j);//System.out.println(t1);rs=sql.executeQuery("selectdistinct*fromwageinfo ,welfare,workerinfo wherewageinfo.no=welfare.noandwageinfo.no=='"+t1+"'andworkerinfo.mi='"+t2+"'");intk=-1;while(rs.next()){++k;Stringno=rs.getString(1);Stringname=rs.getString(2);Stringjb=rs.getString(3);Stringjt=rs.getString(6);intsum=rs.getInt(3)+rs.getInt(6);table.setValueAt(no,k,0);table.setValueAt(name,k,1);table.setValueAt(jb,k,3);table.setValueAt(jt,k,2);table.setValueAt(sum,k,4);}}}catch(SQLExceptione1){JOptionPane.showMessageDialog(this,"查詢失??!");}}if(b2.equals(e.getSource())){//修改密碼XGMMxgmm=newXGMM();xgmm.create();}if(b3.equals(e.getSource())){//返回DLdl=newDL();dl.create();f.dispose();}}}///修改管理YGGL.javapackagewage_management;importjava.awt.Color;importjava.awt.FlowLayout;importjava.awt.event.ActionEvent;importjava.awt.event.ActionListener;importjava.sql.Connection;importjava.sql.DriverManager;importjava.sql.ResultSet;importjava.sql.SQLException;importjava.sql.Statement;importjavax.swing.JButton;importjavax.swing.JFrame;importjavax.swing.JLabel;importjavax.swing.JOptionPane;importjavax.swing.JPanel;importjavax.swing.JScrollPane;importjavax.swing.JSplitPane;importjavax.swing.JTable;importjavax.swing.JTextField;publicclassYGGLextendsJFrameimplementsActionListener{JFramef=newJFrame("員工信息管理");JButtonb1=newJButton("添加新員工信息");JButtonb2=newJButton("修改員工信息");JButtonb3=newJButton("刪除員工信息");JButtonb4=newJButton("查詢所有員工信息");JButtonb5=newJButton("返回");JTextFieldtf1=newJTextField(4);JTextFieldtf2=newJTextField(4);JTextFieldtf3=newJTextField(4);JTextFieldtf4=newJTextField(4);JTextFieldtf5=newJTextField(6);JTextFieldtf6=newJTextField(7);String[]cloum={"職工號(hào)","","津貼","月基本工資","月薪","登陸密碼"};Object[][]row=newObject[50][6];JTabletable=newJTable(row,cloum);JScrollPanescrollpane=newJScrollPane(table);JSplitPane splitpane = newJSplitPane(JSplitPane.VERTICAL_SPLIT);voidcreate(){JPanelp=(JPanel)f.getContentPane();p.setLayout(newFlowLayout());p.add(scrollpane);p.add(splitpane);JPanelp1=newJPanel();p1.add(b1);p1.add(b2);p1.add(b3);p1.add(b4);p1.add(b5);JPanelp2=newJPanel();p2.setBackground(Color.cyan);p2.add(scrollpane);p.setLayout(newFlowLayout());p.add(newJLabel(""));p.add(newJLabel("職工號(hào)"));p.add(tf1);p.add(newJLabel(""));p.add(tf2);p.add(newJLabel("津貼"));p.add(tf3);p.add(newJLabel("月基本工資"));p.add(tf4);p.add(newJLabel("登陸密碼"));p.add(tf5);p.add(newJLabel("在此處輸入職工號(hào)點(diǎn)擊查詢刪除"));p.add(tf6);splitpane.add(p1,splitpane.TOP);splitpane.add(p2,splitpane.BOTTOM);splitpane.setDividerLocation(50);p.setBackground(Color.CYAN);b1.addActionListener(this);b2.addActionListener(this);b3.addActionListener(this);b4.addActionListener(this);b5.addActionListener(this);f.setBounds(200,100,600,600);f.setResizable(true);//可以調(diào)整界面大小f.setVisible(true);}publicvoidactionPerformed(ActionEvente){if(b1.equals(e.getSource())){//添加新員工信息Connectioncon;Statementsql;try{Class.forName("org.gjt.mm.mysql.Driver");}catch(ClassNotFoundExceptione1){JOptionPane.showMessageDialog(this,"連接數(shù)據(jù)庫(kù)失敗!");}try{con =DriverManager.getConnection("jdbc:mysql://localhost:3306/wagemanagement","root","jxb");sql=con.createStatement();StringinsertStr="INSERTINTOwelfare(no,name,jt)VALUES('"+tf1.getText()+"','"+tf2.getText()+"','"+tf3.getText()+"');";sql.executeUpdate(insertStr);StringinsertStr1="INSERTINTOwageinfo(no,name,jb)VALUES('"+tf1.getText()+"','"+tf2.getText()+"','"+tf4.getText()+"');";sql.executeUpdate(insertStr1);StringinsertStr2="INSERTINTOworkerinfo(no,name,mi)VALUES('"+tf1.getText()+"','"+tf2.getText()+"','"+tf5.getText()+"');";sql.executeUpdate(insertStr2);");JOptionPane.showMessageDialog(this,"添加成功!con.close();}catch(SQLExceptione1){");JOptionPane.showMessageDialog(this,"添加失??!}}if(b2.equals(e.getSource())){//修改員工信息Connectioncon;Statementsql;try{Class.forName("org.gjt.mm.mysql.Driver");}catch(ClassNotFoundExceptione1){JOptionPane.showMessageDialog(this,"連接數(shù)據(jù)庫(kù)失敗!");}try{con =DriverManager.getConnection("jdbc:mysql://localhost:3306/wagemanagement","root","jxb");sql=con.createStatement();con =DriverManager.getConnection("jdbc:mysql://localhost:3306/wagemanagement","root","jxb");sql=con.createStatement();StringupdateStr="UPDATEwelfareSETjt='"+tf3.getText()+"',name='"+tf2.getText()+"'whereno='"+tf1.getText()+"';";sql.executeUpdate(updateStr);StringupdateStr1="UPDATEwageinfoSETjb='"+tf4.getText()+"',name='"+tf2.getText()+"'whereno='"+tf1.getText()+"';";sql.executeUpdate(updateStr1);sql.executeUpdate(updateStr1);StringupdateStr2="UPDATEworkerinfoSETname='"+tf2.getText()+"',mi='"+tf5.getText()+"'whereno='"+tf1.getText()+"';";sql.executeUpdate(updateStr2);");JOptionPane.showMessageDialog(this,"修改成功!con.close();}catch(SQLExceptione1){");JOptionPane.showMessageDialog(this,"修改失??!}}if(b3.equals(e.getSource())){//刪除員工信息Connectioncon;Statementsql;try{Class.forName("org.gjt.mm.mysql.Driver");}catch(ClassNotFoundExceptione1){JOptionPane.showMessageDialog(this,"連接數(shù)據(jù)庫(kù)失??!");}try{ con =DriverManager.getConnection("jdbc:mysql://localhost:3306/wagemanagement","root","jxb");sql =con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);sql.executeUpdate("DELETEFROMwageinfowhereno='"+tf6.getText()+"';");sql.executeUpdate("DELETEFROMwelfarewhereno='"+tf6.getText()+"';");sql.executeUpdate("DELETE FROM workerinfowhereno='"+tf6.getText()+"';");");JOptionPane.showMessageDialog(this,"刪除成功!con.close();}catch(SQLExceptione1){");JOptionPane.showMessageDialog(this,"刪除失??!}}if(b4.equals(e.getSource())){//查詢?nèi)繂T工信息Connectioncon;Statementsql;ResultSetrs;try{Class.forName("org.gjt.mm.mysql.Driver");}catch(ClassNotFoundExceptione1){JOptionPane.showMessageDialog(this,"連接數(shù)據(jù)庫(kù)失??!");}try{con =DriverManager.getConnection("jdbc:mysql://localhost:3306/wagemanagement","root","jxb");sql =con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);if(b4.equals(e.getSource())){for(inti=0;i<50;i++)for(intj=0;j<4;j++)table.setValueAt("",i,j);rs=sql.executeQuery("selectdistinct*fromwageinfo ,welfare,workerinfo wherewageinfo.no=welfare.noandwageinfo.no=workerinfo.no;");intk=-1;while(rs.next()){++k;Stringno=rs.getString(1);Stringname=rs.getString(2);Stringjb=rs.getString(3);Stringjt=rs.getString(6);intsum=rs.getInt(3)+rs.getInt(6);Stringmi=rs.getString(9);table.setValueAt(no,k,0);table.setValueAt(name,k,1);table.setValueAt(jb,k,3);table.setValueAt(jt,k,2);table.setValueAt(sum,k,4);
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝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ù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 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ì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 小學(xué)人口教育
- 班級(jí)慶?;顒?dòng)組織方案計(jì)劃
- 提升團(tuán)隊(duì)溝通技巧的策略計(jì)劃
- 住院醫(yī)師培訓(xùn)項(xiàng)目總結(jié)與下步計(jì)劃
- 《猜猜我是誰(shuí)》(教學(xué)設(shè)計(jì))-2024-2025學(xué)年人美版(2012)美術(shù)四年級(jí)上冊(cè)
- 學(xué)校與社區(qū)聯(lián)動(dòng)的實(shí)例計(jì)劃
- 藝術(shù)教育在幼兒園的應(yīng)用計(jì)劃
- 林業(yè)工作者的新年個(gè)人工作計(jì)劃
- 投資回報(bào)分析報(bào)告計(jì)劃
- 加強(qiáng)網(wǎng)絡(luò)營(yíng)銷的實(shí)施方案計(jì)劃
- T-CSCP 0019-2024 電網(wǎng)金屬設(shè)備防腐蝕運(yùn)維診斷策略技術(shù)導(dǎo)則
- 2025中考道德與法治核心知識(shí)點(diǎn)+易錯(cuò)易混改錯(cuò)
- 授權(quán)獨(dú)家代理商合作協(xié)議2025年
- 《技術(shù)分析之均線》課件
- 小兒高熱驚厥護(hù)理查房
- 2025年度全款文化演出門票購(gòu)買合同4篇
- 臨床基于高級(jí)健康評(píng)估的高血壓Ⅲ級(jí)合并腦梗死患者康復(fù)個(gè)案護(hù)理
- 2025年廈門建發(fā)股份有限公司招聘筆試參考題庫(kù)含答案解析
- 2025年中國(guó)EAM系統(tǒng)行業(yè)發(fā)展前景預(yù)測(cè)及投資戰(zhàn)略研究報(bào)告
- 《基于三維熒光技術(shù)的水環(huán)境污染源深度溯源技術(shù)規(guī)范》
- 《反洗錢知識(shí)培訓(xùn)》課件
評(píng)論
0/150
提交評(píng)論