人事工資管理系統(tǒng)源代碼 java_第1頁
人事工資管理系統(tǒng)源代碼 java_第2頁
人事工資管理系統(tǒng)源代碼 java_第3頁
人事工資管理系統(tǒng)源代碼 java_第4頁
人事工資管理系統(tǒng)源代碼 java_第5頁
已閱讀5頁,還剩29頁未讀, 繼續(xù)免費閱讀

下載本文檔

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

文檔簡介

bm.javaimportjava.awt.*;importjava.awt.event.*;importjava.sql.*;importjavax.swing.*;classbmextendsFrameimplementsActionListener,ItemListener{privatecondbconx=null;privateResultSetrs=null;privateStringsql=null;privateLabelnum=newLabel("職工號");privateLabeljb=newLabel("稅收");privateLabelfj=newLabel("醫(yī)療保險");privateLabelin=newLabel("退休保險");privateTextFieldnumtx=newTextField();privateTextFieldjbtx=newTextField();privateTextFieldfjtx=newTextField();privateTextFieldintx=newTextField();privateChoicenumcho=newChoice();privateButtonadd=newButton("增加");privateButtonexit=newButton("退出");publicbm(){setTitle("扣除工資");setSize(400,300);setBackground(Color.LIGHT_GRAY);this.setLocationRelativeTo(this.getParent());this.setResizable(false);setLayout(null);num.setBounds(80,50,50,20);jb.setBounds(80,80,50,20);fj.setBounds(80,110,50,20);in.setBounds(80,140,50,20);numtx.setBounds(160,50,100,20);jbtx.setBounds(160,80,100,20);fjtx.setBounds(160,110,100,20);intx.setBounds(160,140,100,20);numcho.setBounds(160,170,100,20);add.setBounds(60,220,50,20);exit.setBounds(300,220,50,20);add(add);add(exit);add(num);add(jb);add(fj);add(in);add(numtx);add(jbtx);add(fjtx);add(intx);add(numcho);//lbadd.addActionListener(this);exit.addActionListener(this);numcho.addItemListener(this);initnumcho();setVisible(true);addWindowListener(newWindowAdapter(){publicvoidwindowClosing(WindowEvente){dispose();}});}publicvoiditemStateChanged(ItemEventi){numtx.setText(numcho.getSelectedItem());}publicvoidinitnumcho(){conx=newcondb();sql="select*from扣除工資";numcho.removeAll();try{rs=conx.getrs(conx.con,sql);while(rs.next()){numcho.add(rs.getString("職工號"));}conx.dbclose(conx.con,rs);conx=null;rs=null;}catch(Exceptioneo){}}publicvoidactionPerformed(ActionEvente){conx=newcondb();if(e.getActionCommand().equals("退出"))this.dispose();if(e.getActionCommand().equals("增加")){sql="select*from扣除工資where職工號='"+numtx.getText()+"'";try{rs=conx.getrs(conx.con,sql);if(rs.next()){sql="insertinto扣除工資(職工號,稅收,醫(yī)療保險,養(yǎng)老保險)"+"values('"+numtx.getText().trim()+"',"+jbtx.getText()+","+fjtx.getText()+",'"+intx.getText()+"')";try{System.out.println(sql);conx.dbclose(conx.con,null);}catch(Exceptionue){System.out.println(""+ue);} JOptionPanejop=newJOptionPane();jop.showMessageDialog(null,"扣除工資添加成功!","添加成功",-1);conx.dbclose(conx.con,rs);numtx.setText("");jbtx.setText("");fjtx.setText("");conx=null;rs=null;}else{JOptionPanejop=newJOptionPane();jop.showConfirmDialog(null,"添加失敗!","警告!",-1);conx.dbclose(conx.con,rs);conx=null;rs=null;}}catch(SQLExceptionet){System.out.println(""+et);}}}}/*else*/bmcx.javaimportjava.awt.*;importjava.awt.event.*;importjava.sql.*;importjavax.swing.*;importjava.awt.Window;classbmcxextendsFrameimplementsActionListener{privatecondbconc=null;privateResultSetrs=null;privateStringsql=null;privateLabelchao=newLabel("職工號:");privateLabelcname=newLabel("姓名:");privateLabelcsex=newLabel("稅收:");privateLabelcage=newLabel("醫(yī)療保險:");privateLabelcdep=newLabel("退休保險:");privateTextFieldchaotx=newTextField();privateLabelcnametx=newLabel("");privateLabelcsextx=newLabel("");privateLabelcagetx=newLabel("");privateLabelcdeptx=newLabel("");privateButtoncx=newButton("查詢");privateButtontc=newButton("退出");publicbmcx(){setTitle("扣除工資查詢");setSize(400,250);setBackground(Color.LIGHT_GRAY);this.setLocationRelativeTo(this.getParent());this.setResizable(false);setLayout(null);chao.setBounds(80,50,50,20);cname.setBounds(80,80,50,20);csex.setBounds(80,110,50,20);cage.setBounds(80,140,50,20);cdep.setBounds(80,170,50,20);chaotx.setBounds(160,50,150,20);cnametx.setBounds(160,80,150,20);csextx.setBounds(160,110,150,20);cagetx.setBounds(160,140,150,20);cdeptx.setBounds(140,170,150,20);cx.setBounds(60,205,50,20);tc.setBounds(300,205,50,20);add(chao);add(cname);add(cagetx);add(cage);add(csex);add(cdep);add(chaotx);add(cnametx);add(csextx);add(cdeptx);add(cx);add(tc);setVisible(true);cx.addActionListener(this);tc.addActionListener(this);addWindowListener(newWindowAdapter(){publicvoidwindowClosing(WindowEvente){dispose();}});}publicvoidactionPerformed(ActionEvente){if(e.getActionCommand().equals("退出"))this.dispose();if(e.getActionCommand().equals("查詢")){conc=newcondb();sql="select姓名,稅收,醫(yī)療保險,退休保險from扣除工資,職工where扣除工資.職工號=職工.職工號and扣除工資.職工號='"+chaotx.getText()+"'";try{rs=conc.getrs(conc.con,sql); if(rs.next()) {cnametx.setText(rs.getString("姓名"));csextx.setText(rs.getString("稅收"));cagetx.setText(rs.getString("醫(yī)療保險"));cdeptx.setText(rs.getString("退休保險"));conc.dbclose(conc.con,rs);conc=null;rs=null;}else{JOptionPanejop=newJOptionPane();jop.showConfirmDialog(null,"該用戶不存在!","警告",-1);}}catch(Exceptionee){}}}}condb.javaimportjava.sql.*;publicclasscondb{publicConnectioncon;//在類頭定義連接對象publiccondb()//在此構(gòu)造方法中實現(xiàn)有關(guān)程序的加載,同時捕捉異常。{try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");}//加載驅(qū)動程序catch(java.lang.ClassNotFoundExceptione){System.out.println("error");};try{con=DriverManager.getConnection("jdbc:odbc:xin");}//連接數(shù)據(jù)源catch(SQLExceptione){System.out.println("connectdatabaseerror!");}}publicResultSetgetrs(Connectioncon,Stringsql)//自定義查詢數(shù)據(jù)庫返回記錄集的方法。{ResultSetrs=null;try{Statementstmt=con.createStatement();//創(chuàng)建發(fā)送sql語句的對象stmt.rs=stmt.executeQuery(sql);//執(zhí)行查詢語句sql,得記錄集。}catch(Exceptione){System.out.println(""+e);}returnrs;}//getrs()中行參sql為實現(xiàn)數(shù)據(jù)庫查詢的查詢語句,con表示數(shù)據(jù)庫連接對象。publicvoidmoddb(Connectioncon,Stringsql)//自定義具有對數(shù)據(jù)庫實現(xiàn)增加,刪除,修改功能的方法:{try{Statementstmt=con.createStatement();//創(chuàng)建發(fā)送sql語句的對象stmt.stmt.executeUpdate(sql);//實現(xiàn)增加,刪除,修改數(shù)據(jù)庫等操作。}catch(Exceptione){}}//方法.executeUpdate()根據(jù)sql語句實現(xiàn)對數(shù)據(jù)庫的增加,刪除,修改功能。publicvoiddbclose(Connectioncon,ResultSetrs)//定義關(guān)閉連接對象和記錄集的方法{try{con.close();//關(guān)閉連接對象rs.close();}//關(guān)閉記錄集catch(SQLExceptionrse){}}}dl.javaimportjava.awt.*;importjava.awt.event.*;importjava.sql.*;importjavax.swing.*;importjava.awt.geom.*;classdengluextendsFrame{publicLabelname=newLabel("用戶名");publicLabelpass=newLabel("密碼");publicTextFieldtxtname=newTextField();publicTextFieldtxtpass=newTextField();publicButtonbtok=newButton("登陸");publicButtonbtexit=newButton("取消");publiccondbconu=newcondb();privateStringsql=null;privateResultSetrs=null;privateImageimg;publicdenglu(){ img=getToolkit().getImage(getClass().getResource("/ww.jpg")); setTitle("歡迎使用工資管理系統(tǒng)");setLayout(null);setResizable(false);setSize(500,350);Dimensionscr=Toolkit.getDefaultToolkit().getScreenSize();Dimensionfrm=this.getSize();setLocation((scr.width-frm.width)/2,(scr.height-frm.height)/2-18);txtpass.setEchoChar('*');txtname.setBounds(120,260,120,27);txtpass.setBounds(120,300,120,27);btok.setBounds(340,260,100,28);btexit.setBounds(340,300,100,28);add(name);add(txtname);add(pass);add(txtpass);add(btok);add(btexit);setVisible(true);btexit.addActionListener(newActionListener(){publicvoidactionPerformed(ActionEvente){dispose();System.exit(0);}});btok.addActionListener(newActionListener(){publicvoidactionPerformed(ActionEvente){sql="select*from數(shù)據(jù)庫用戶where用戶名='"+txtname.getText()+"'and密碼='"+txtpass.getText()+"'";try{rs=conu.getrs(conu.con,sql); if(rs.next()){mainffmf=newmainff();dispose();mf.show();}else{JOptionPanejop=newJOptionPane();jop.showMessageDialog(null,"用戶名或密碼錯誤","信息提示!",-1);}}catch(Exceptionee){}}}); addWindowListener(newWindowAdapter(){publicvoidwindowClosing(WindowEvente){dispose();System.exit(0);}}); } publicvoidpaint(Graphicsg){g.setClip(newRectangle2D.Float(0,0,500,350));g.drawImage(img,0,0,this);} }publicclassdl{publicstaticvoidmain(Stringargs[]){dengludeng=newdenglu();}jz.javaimportjava.awt.*;importjava.awt.event.*;importjava.sql.*;importjavax.swing.*;classgzextendsFrameimplementsActionListener,ItemListener{privatecondbconx=null;privateResultSetrs=null;privateStringsql=null;privateLabelnum=newLabel("職工號");privateLabeljb=newLabel("普通請假");privateLabelfj=newLabel("病假");privateLabelin=newLabel("遲到");privateTextFieldnumtx=newTextField();privateTextFieldjbtx=newTextField();privateTextFieldfjtx=newTextField();privateTextFieldintx=newTextField();privateButtonadd=newButton("增加");privateButtonexit=newButton("退出");publicgz(){setTitle("職工休假");setSize(400,300);setBackground(Color.LIGHT_GRAY);this.setLocationRelativeTo(this.getParent());this.setResizable(false);setLayout(null);num.setBounds(80,50,50,20);jb.setBounds(80,80,50,20);fj.setBounds(80,110,50,20);in.setBounds(80,140,50,20);numtx.setBounds(160,50,100,20);jbtx.setBounds(160,80,100,20);fjtx.setBounds(160,110,100,20);intx.setBounds(160,140,100,20);add.setBounds(60,220,50,20);exit.setBounds(300,220,50,20);add(add);add(exit);add(num);add(jb);add(fj);add(in);add(numtx);add(jbtx);add(fjtx);add(intx);//lbadd.addActionListener(this);exit.addActionListener(this);setVisible(true);addWindowListener(newWindowAdapter(){publicvoidwindowClosing(WindowEvente){dispose();}});}publicvoiditemStateChanged(ItemEventi){}publicvoidactionPerformed(ActionEvente){conx=newcondb();if(e.getActionCommand().equals("退出"))this.dispose();if(e.getActionCommand().equals("增加")){sql="select*from職工where職工號='"+numtx.getText()+"'";try{rs=conx.getrs(conx.con,sql);if(rs.next()){sql="insertinto職工(職工號,普通請假,病假,遲到)"+"values('"+numtx.getText().trim()+"',"+jbtx.getText()+","+fjtx.getText()+",'"+intx.getText()+"')";try{System.out.println(sql);conx.dbclose(conx.con,null);}catch(Exceptionue){System.out.println(""+ue);} JOptionPanejop=newJOptionPane();jop.showMessageDialog(null,"職工休假添加成功!","添加成功",-1);conx.dbclose(conx.con,rs);numtx.setText("");jbtx.setText("");fjtx.setText("");conx=null;rs=null;} else{JOptionPanejop=newJOptionPane();jop.showConfirmDialog(null,"添加失敗!","警告!",-1);conx.dbclose(conx.con,rs);conx=null;rs=null;}}catch(SQLExceptionet){System.out.println(""+et);}}}}/**/gzcx.javaimportjava.awt.*;importjava.awt.event.*;importjava.sql.*;importjavax.swing.*;importjava.awt.Window;classgzcxextendsFrameimplementsActionListener{privatecondbconc=null;privateResultSetrs=null;privateStringsql=null;privateLabelchao=newLabel("職工號:");privateLabelcjb=newLabel("基本工資:");privateLabelcfj=newLabel("獎金:");privateLabelcsf=newLabel("扣除工資:");privateLabelin=newLabel("實發(fā)工資");privateTextFieldchaotx=newTextField();privateLabelcjbtx=newLabel("");privateLabelcfjtx=newLabel("");privateLabelcsftx=newLabel("");privateLabelintx=newLabel("");privateButtoncx=newButton("查詢");privateButtontc=newButton("退出");publicgzcx(){setTitle("職工工資查詢");setSize(400,250);setBackground(Color.LIGHT_GRAY);this.setLocationRelativeTo(this.getParent());this.setResizable(false);setLayout(null);chao.setBounds(80,50,50,20);cjb.setBounds(80,80,50,20);cfj.setBounds(80,110,50,20);csf.setBounds(80,140,50,20);in.setBounds(80,170,50,20);intx.setBounds(160,170,150,20);chaotx.setBounds(160,50,150,20);cjbtx.setBounds(160,80,150,20);cfjtx.setBounds(160,110,150,20);csftx.setBounds(160,140,150,20);cx.setBounds(60,205,50,20);tc.setBounds(300,205,50,20);add(chao);add(cjb);add(in);add(cfj);add(csf);add(intx);add(cjbtx);add(cfjtx);add(chaotx);add(csftx);add(cx);add(tc);setVisible(true);cx.addActionListener(this);tc.addActionListener(this);addWindowListener(newWindowAdapter(){publicvoidwindowClosing(WindowEvente){dispose();}});}publicvoidactionPerformed(ActionEvente){if(e.getActionCommand().equals("退出"))this.dispose();if(e.getActionCommand().equals("查詢")){conc=newcondb();sql="select*from工資where職工號='"+chaotx.getText()+"'";try{rs=conc.getrs(conc.con,sql); if(rs.next()) {cjbtx.setText(rs.getString("基本工資"));cfjtx.setText(rs.getString("獎金"));csftx.setText(rs.getString("扣除工資"));intx.setText(rs.getString("實發(fā)工資"));conc.dbclose(conc.con,rs);conc=null;rs=null;}else{JOptionPanejop=newJOptionPane();jop.showConfirmDialog(null,"該用戶不存在!","警告",-1);}}catch(Exceptionee){}}}}jiesh.javaimportjava.awt.*;importjava.awt.event.*;importjavax.swing.*;importjava.sql.*;classjieshextendsJFrameimplementsActionListener{privatecondbcon=null;privateResultSetrs=null;privateStringsql=null;privateJLabelq1=newJLabel("本軟件介紹");privateJTextAreajstx=newJTextArea();privateJButtond2=newJButton("返回主界面");publicjiesh(){super("軟件介紹");setSize(400,350);setBackground(Color.LIGHT_GRAY);this.setLocationRelativeTo(this.getParent());setResizable(false);Containercont=this.getContentPane();cont.setLayout(null);q1.setBounds(150,20,300,30);jstx.setBounds(40,50,300,200);jstx.setText("本軟件適用于人事工資管理不復(fù)雜的中小企業(yè)或其他類型\n企事業(yè)單位。軟件界面友好、操作簡單。");jstx.setEditable(false);d2.setBounds(240,260,100,30);cont.add(q1);cont.add(jstx);cont.add(d2);d2.addActionListener(this);setVisible(true);}publicvoidactionPerformed(ActionEventae){if(ae.getActionCommand().equals("返回主界面"))dispose();}}mainff.javaimportjava.awt.*;importjava.awt.event.*;importjava.awt.Window;importjavax.swing.*;importjavax.swing.tree.*;importjava.sql.*;importjava.awt.geom.*;classmainffextendsFrameimplementsActionListener{privatecondbcon=null;privateResultSetrs=null;Stringsql=null;Stringsqlb=null;privateJOptionPanejop=newJOptionPane();privateMenuBarmnubar=newMenuBar();privateMenugongzi=newMenu("工資管理");privateMenulookfor=newMenu("信息查詢");privateMenuinitsys=newMenu("系統(tǒng)初始化");privateMenuuser=newMenu("用戶管理");privateMenuhelp=newMenu("幫助信息");privateMenuItemgong1=newMenuItem("全部查詢");privateMenuItemsearch1=newMenuItem("扣除工資查詢");privateMenuItemsearch3=newMenuItem("職工工資查詢");privateMenuItemsearch2=newMenuItem("職工休假查詢");privateMenuItemdep=newMenuItem("添加工資");privateMenuItememp=newMenuItem("選擇支付方式");privateMenuItemselary=newMenuItem("添加休假");privateMenuItemuser1=newMenuItem("用戶管理");privateMenuItemhelp1=newMenuItem("系統(tǒng)介紹");privateMenuItemhelp2=newMenuItem("操作說明");privateMenuItemhelp3=newMenuItem("版本信息");privateImageimg;publicmainff(){super("歡迎使用工資管理系統(tǒng)!");setSize(800,600);setBackground(Color.LIGHT_GRAY);setLayout(null);//以下三句設(shè)置當(dāng)前框架位置。Dimensionscr=Toolkit.getDefaultToolkit().getScreenSize();Dimensionfrm=this.getSize();setLocation((int)(scr.getWidth()-frm.getWidth())/2,(int)(scr.getHeight()-frm.getHeight())/2-50);//設(shè)置水平居中。gongzi.add(gong1);lookfor.add(search1);lookfor.add(search2);lookfor.add(search3);initsys.add(dep);initsys.add(emp);initsys.add(selary);user.add(user1);mnubar.add(gongzi);mnubar.add(lookfor);mnubar.add(initsys);mnubar.add(user);mnubar.add(help);help.add(help1);help.add(help2);help.add(help3);img=getToolkit().getImage(getClass().getResource("/sk.jpg"));this.setMenuBar(mnubar);//設(shè)置菜單條,顯示菜單gongzi.addActionListener(this);initsys.addActionListener(this);lookfor.addActionListener(this);user.addActionListener(this);help.addActionListener(this);setVisible(true);//設(shè)置可顯性addWindowListener(newWindowAdapter(){publicvoidwindowClosing(WindowEvente){tuichtc=newtuich();}});//關(guān)閉窗口}publicvoidpaint(Graphicsg){g.setClip(newRectangle2D.Float(0,30,800,570));g.drawImage(img,0,0,this);}publicvoidactionPerformed(ActionEventae){if(ae.getActionCommand().equals("添加休假")){gzgong=newgz();//類調(diào)用}if(ae.getActionCommand().equals("選擇支付方式")){zgzhi=newzg();//類調(diào)用}if(ae.getActionCommand().equals("添加工資")){bmbu=newbm();}if(ae.getActionCommand().equals("職工工資查詢")){gzcxgongcx=newgzcx();}if(ae.getActionCommand().equals("扣除工資查詢")){bmcxbucx=newbmcx();}if(ae.getActionCommand().equals("職工休假查詢")){zgcxzhi=newzgcx();}if(ae.getActionCommand().equals("用戶管理")){useruse=newuser();}if(ae.getActionCommand().equals("全部查詢")){wholeuse1=newwhole();}if(ae.getActionCommand().equals("系統(tǒng)介紹")){jieshj=newjiesh();}if(ae.getActionCommand().equals("操作說明")){shuomsh=newshuom();}if(ae.getActionCommand().equals("版本信息")){xinxixx=newxinxi();//類調(diào)用}}}shuom.javaimportjava.awt.*;importjava.awt.event.*;importjavax.swing.*;importjava.sql.*;classshuomextendsJFrameimplementsActionListener{privatecondbcon=null;privateResultSetrs=null;privateStringsql=null;privateJLabelq1=newJLabel("本軟件操作說明");privateJTextAreajstx=newJTextArea();privateJButtond2=newJButton("返回主界面");publicshuom(){super("操作說明");setSize(400,350);setBackground(Color.LIGHT_GRAY);this.setLocationRelativeTo(this.getParent());setResizable(false);Containercont=this.getContentPane();cont.setLayout(null);q1.setBounds(120,20,300,30);jstx.setBounds(40,50,300,200);jstx.setText("具體說明見實驗報告");jstx.setEditable(false);d2.setBounds(240,260,100,30);cont.add(q1);cont.add(jstx);cont.add(d2);d2.addActionListener(this);setVisible(true);}publicvoidactionPerformed(ActionEventae){if(ae.getActionCommand().equals("返回主界面"))dispose();}}tuich.javaimportjava.awt.*;importjava.awt.event.*;importjavax.swing.*;importjava.sql.*;classtuichextendsJFrameimplementsActionListener{privatecondbcon=null;privateResultSetrs=null;privateStringsql=null;privateJLabelq1=newJLabel("是否確定退出本軟件?");privateJButtond1=newJButton("確認(rèn)");privateJButtond2=newJButton("返回");publictuich(){super("結(jié)束");setSize(300,180);setBackground(Color.LIGHT_GRAY);this.setLocationRelativeTo(this.getParent());setResizable(false);Containercont=this.getContentPane();cont.setLayout(null);q1.setBounds(80,20,200,30);d1.setBounds(50,80,80,30);d2.setBounds(150,80,80,30);cont.add(q1);cont.add(d1);cont.add(d2);d1.addActionListener(this);d2.addActionListener(this);setVisible(true);}publicvoidactionPerformed(ActionEventte){if(te.getActionCommand().equals("確認(rèn)")){dispose();System.exit(0);}if(te.getActionCommand().equals("返回"))dispose();}}user.javaimportjava.awt.*;importjava.util.*;importjava.awt.event.*;importjava.awt.Window;importjava.sql.*;importjavax.swing.*;classuserextendsFrameimplementsActionListener,ItemListener{privatecondbcon=null;privateResultSetrs=null;privateStringsql=null;privateButtonbtnadd=newButton("增加");privateButtonbtndel=newButton("刪除");privateButtonbtnmod=newButton("修改");privateButtonbtnexit=newButton("退出");privateLabellbname=newLabel("用戶");privateLabellbpwd=newLabel("密碼");privateLabellbuserchoice=newLabel("用戶列表");privateTextFieldtxtname=newTextField();privateTextFieldtxtpwd=newTextField();privateChoiceuserchoice=newChoice();publicuser(){super("系統(tǒng)用戶管理");setSize(410,250);this.setLocationRelativeTo(this.getParent());setResizable(false);setBackground(Color.LIGHT_GRAY);setLayout(null);lbname.setSize(50,20);lbpwd.setSize(50,20);lbuserchoice.setSize(50,20);txtname.setSize(170,20);txtpwd.setSize(170,20);userchoice.setSize(170,20);btnadd.setSize(50,20);btndel.setSize(50,20);btnmod.setSize(50,20);btnexit.setSize(50,20);lbname.setLocation(80,50);txtname.setLocation(160,50);lbpwd.setLocation(80,100);txtpwd.setLocation(160,100);userchoice.setLocation(160,150);btnadd.setLocation(60,200);btndel.setLocation(140,200);btnmod.setLocation(220,200);btnexit.setLocation(300,200);add(lbname);add(txtname);add(lbpwd);add(txtpwd);add(lbuserchoice);add(userchoice);add(btnadd);add(btndel);add(btnmod);add(btnexit);btnadd.addActionListener(this);btndel.addActionListener(this);btnmod.addActionListener(this);btnexit.addActionListener(this);setVisible(true);initchoice();userchoice.addItemListener(this);addWindowListener(newWindowAdapter(){publicvoidwindowClosing(WindowEvente){dispose();}});}publicvoidinitchoice(){try{con=newcondb();sql="select用戶名from數(shù)據(jù)庫用戶";rs=con.getrs(con.con,sql);while(rs.next()){userchoice.addItem(rs.getString("用戶名"));}con.dbclose(con.con,rs);con=null;}catch(Exceptione){}}publicvoidactionPerformed(ActionEventee){if(ee.getActionCommand().equals("退出"))dispose();if(ee.getActionCommand().equals("增加")){sql="select*from數(shù)據(jù)庫用戶where用戶名='"+txtname.getText()+"'";con=newcondb();try{rs=con.getrs(con.con,sql);if(rs.next()){JOptionPanejop=newJOptionPane();jop.showConfirmDialog(null,"該用戶已經(jīng)存在!","警告",-1);con.dbclose(con.con,rs);con=null;rs=null;}else{sql="insertinto數(shù)據(jù)庫用戶values('"+txtname.getText()+"','"+txtpwd.getText()+"')";con=newcondb();try{con.moddb(con.con,sql);con.con.close();}catch(SQLExceptionse){}userchoice.addItem(txtname.getText());txtname.setText("");txtpwd.setText("");con=null;}}catch(Exceptiona){}}if(ee.getActionCommand().equals("修改")){sql="update數(shù)據(jù)庫用戶set密碼='"+txtpwd.getText()+"'where用戶名='"+txtname.getText()+"'";con=newcondb();try{con.moddb(con.con,sql);con.con.close();}catch(SQLExceptionse){}txtname.setText("");txtpwd.setText("");con=null;}if(ee.getActionCommand().equals("刪除")){JOptionPanejopask=newJOptionPane();if(jopask.showConfirmDialog(null,"你要刪除?","請確認(rèn)",2)==0){con=newcondb();sql="deletefrom數(shù)據(jù)庫用戶where用戶名='"+txtname.getText()+"'";try{con.moddb(con.con,sql);con.con.close();}catch(SQLExceptionse){}con=null;userchoice.remove(userchoice.getSelectedIndex());txtname.setText("");txtpwd.setText("");}}}publicvoiditemStateChanged(ItemEventie){txtname.setText(userchoice.getSelectedItem());}}whole.javaimportjava.awt.*;importjava.awt.event.*;importjavax.swing.*;importjava.sql.*;classwholeextendsJDialogimplementsActionListener{privatecondbcon=null;privateResultSetrs=null;privateStringsql=null;privateJLabelbmhao=newJLabel("職工號:");privateJLabelbmname=newJLabel("姓名:");privateJTextFieldwholetx1=newJTextField();privateJTextFieldwholetx2=newJTextField();pr

溫馨提示

  • 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)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論