【人事】人事工资管理系统源代码java
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
【关键字】人事
bm.java
import java.awt.*;
import ;
import java.sql.*;
import javax.swing.*;
class bm extends Frame implements ActionListener,ItemListener { private condb conx=null;
private ResultSet rs=null;
private String sql=null;
private Label num=new Label("职工号");
private Label jb=new Label("税收");
private Label fj=new Label("医疗保障");
private Label in=new Label("退休保障");
private TextField numtx=new TextField();
private TextField jbtx=new TextField();
private TextField fjtx=new TextField();
private TextField intx=new TextField();
private Choice numcho=new Choice();
private Button add=new Button("增加");
private Button exit=new Button("退出");
public bm()
{ 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);
//lb
add.addActionListener(this);
exit.addActionListener(this);
numcho.addItemListener(this);
initnumcho();
setVisible(true);
addWindowListener(new WindowAdapter()
{ public void windowClosing(WindowEvent e)
{dispose();}
}
);
}
public void itemStateChanged(ItemEvent i)
{ numtx.setText(numcho.getSelectedItem());
}
public void initnumcho()
{ conx=new condb();
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(Exception eo){}
}
public void actionPerformed(ActionEvent e)
{ conx=new condb();
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="insert into 扣除工资(职工号,税收,医疗保险,养老保险)"+
"values('"+numtx.getText().trim()+"',"+
jbtx.getText()+","+fjtx.getText()+",'"+intx.getText()+"')";
try { ;
conx.dbclose(conx.con,null);
}
catch(Exception ue){""+ue);}
JOptionPane jop=new JOptionPane();
jop.showMessageDialog(null," 扣除工资添加成功!","添加成功",-1);
conx.dbclose(conx.con,rs);
numtx.setText("");
jbtx.setText("");
fjtx.setText("");
conx=null;
rs=null;
}
else { JOptionPane jop=new JOptionPane();
jop.showConfirmDialog(null,"添加失败!","警告!",-1);
conx.dbclose(conx.con,rs);
conx=null;
rs=null;
}
} catch(SQLException et){""+et);}
}
}
}
/*
else
*/
bmcx.java
import java.awt.*;
import ;
import java.sql.*;
import javax.swing.*;
import ;
class bmcx extends Frame implements ActionListener
{ private condb conc=null;
private ResultSet rs=null;
private String sql=null;
private Label chao=new Label("职工号:");
private Label cname=new Label("姓名:");
private Label csex=new Label("税收:");
private Label cage=new Label("医疗保险:"); private Label cdep=new Label("退休保险: "); private TextField chaotx=new TextField(); private Label cnametx=new Label("");
private Label csextx=new Label("");
private Label cagetx=new Label("");
private Label cdeptx=new Label("");
private Button cx=new Button("查询");
private Button tc=new Button("退出");
public bmcx()
{ 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(new WindowAdapter()
{ public void windowClosing(WindowEvent e)
{dispose();}
}
);
}
public void actionPerformed(ActionEvent e)
{ if(e.getActionCommand().equals("退出"))
this.dispose();
if(e.getActionCommand().equals("查询"))
{ conc=new condb();
sql="select 姓名,税收,医疗保险,退休保险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("医疗保险"));
cdeptx.setText(rs.getString("退休保险"));
conc.dbclose(conc.con,rs);
conc=null;
rs=null;}
else {JOptionPane jop=new JOptionPane();
jop.showConfirmDialog(null,"该用户不存在!","警告",-1);
}
}
catch(Exception ee){}
}
}
}
condb.java
import java.sql.*;
public class condb
{ public Connection con;//在类头定义连接对象
public condb()//在此构造方法中实现有关程序的加载,同时捕捉异常。
{ try{ Class.forName("");}//加载驱动程序
catch( e){"error");};
try{ con=DriverManager.getConnection("jdbc:odbc:xin");}//连接数据源
catch(SQLException e){"connect database error!");}
}
public ResultSet getrs(Connection con,String sql)//自定义查询数据库返回记录集的方法。
{ ResultSet rs=null;
try{ Statement stmt=con.createStatement();//创建发送sql语句的对象stmt.
rs=stmt.executeQuery(sql);//执行查询语句sql,得记录集。
}
catch(Exception e){""+e);}
return rs;
}
//getrs()中行参sql为实现数据库查询的查询语句,con表示数据库连接对象。
public void moddb(Connection con,String sql)
//自定义具有对数据库实现增加,删除,修改功能的方法:
{ try{ Statement stmt=con.createStatement(); //创建发送sql语句的对象stmt.
stmt.executeUpdate(sql); //实现增加,删除,修改数据库等操作。
}
catch(Exception e){}
}
//方法.executeUpdate()根据sql语句实现对数据库的增加,删除,修改功能。
public void dbclose(Connection con,ResultSet rs)
//定义关闭连接对象和记录集的方法
{ try { con.close();//关闭连接对象
rs.close(); }//关闭记录集
catch(SQLException rse){}
}
}
dl.java
import java.awt.*;
import ;
import java.sql.*;
import javax.swing.*;
import ;
class denglu extends Frame
{
public Label name=new Label("用户名");
public Label pass=new Label("密码");
public TextField txtname=new TextField();
public TextField txtpass=new TextField();
public Button btok=new Button("登陆");
public Button btexit=new Button("取消");
public condb conu=new condb();
private String sql=null;
private ResultSet rs=null;
private Image img;
public denglu()
{
img=getToolkit().getImage(getClass().getResource("/ww.jpg"));
setTitle("欢迎使用工资管理系统");
setLayout(null);
setResizable(false);
setSize(500,350);
Dimension scr=Toolkit.getDefaultToolkit().getScreenSize();
Dimension frm=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(new ActionListener(){
public void actionPerformed(ActionEvent e){
dispose();
System.exit(0);
} });
btok.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
sql="select * from 数据库用户where 用户名='"+txtname.getText()+"' and 密码='"+txtpass.getText()+"'";
try {
rs=conu.getrs(conu.con,sql);
if(rs.next())
{ mainff mf=new mainff();
dispose();
mf.show();
}
else { JOptionPane jop=new JOptionPane();
jop.showMessageDialog(null,"用户名或密码错误","信息提示!",-1);}
}catch(Exception ee){}
}
} );
addWindowListener( new WindowAdapter()
{public void windowClosing(WindowEvent e)
{ dispose();
System.exit(0);
}
} );
}
public void paint(Graphics g)
{
g.setClip(new Rectangle2D.Float(0,0,500,350));
g.drawImage(img,0,0,this);
}
}
public class dl
{ public static void main(String args[])
{ denglu deng=new denglu();
}
jz.java
import java.awt.*;
import ;
import java.sql.*;
import javax.swing.*;
class gz extends Frame implements ActionListener,ItemListener { private condb conx=null;
private ResultSet rs=null;
private String sql=null;
private Label num=new Label("职工号");
private Label jb=new Label("普通请假");
private Label fj=new Label("病假");
private Label in=new Label("迟到");
private TextField numtx=new TextField();
private TextField jbtx=new TextField();
private TextField fjtx=new TextField();
private TextField intx=new TextField();
private Button add=new Button("增加");
private Button exit=new Button("退出");
public gz()
{ 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);
//lb
add.addActionListener(this);
exit.addActionListener(this);
setVisible(true);
addWindowListener(new WindowAdapter()
{ public void windowClosing(WindowEvent e)
{dispose();}
}
);
}
public void itemStateChanged(ItemEvent i)
{
}
public void actionPerformed(ActionEvent e)
{ conx=new condb();
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="insert into 职工(职工号,普通请假,病假,迟到)"+
"values('"+numtx.getText().trim()+"',"+
jbtx.getText()+","+fjtx.getText()+",'"+intx.getText()+"')";
try { ;
conx.dbclose(conx.con,null);
}
catch(Exception ue){""+ue);}
JOptionPane jop=new JOptionPane();
jop.showMessageDialog(null," 职工休假添加成功!","添加成功",-1);
conx.dbclose(conx.con,rs);
numtx.setText("");
jbtx.setText("");
fjtx.setText("");
conx=null;
rs=null;
}
else{ JOptionPane jop=new JOptionPane();
jop.showConfirmDialog(null,"添加失败!","警告!",-1);
conx.dbclose(conx.con,rs);
conx=null;
rs=null;
}
} catch(SQLException et){""+et);}
}
}
}
/*
*/
gzcx.java
import java.awt.*;
import ;
import java.sql.*;
import javax.swing.*;
import ;
class gzcx extends Frame implements ActionListener
{ private condb conc=null;
private ResultSet rs=null;
private String sql=null;
private Label chao=new Label("职工号:");
private Label cjb=new Label("基本工资:");
private Label cfj=new Label("奖金:");
private Label csf=new Label("扣除工资:");
private Label in=new Label("实发工资");
private TextField chaotx=new TextField();
private Label cjbtx=new Label("");
private Label cfjtx=new Label("");
private Label csftx=new Label("");
private Label intx=new Label("");
private Button cx=new Button("查询");
private Button tc=new Button("退出");
public gzcx()
{ 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(new WindowAdapter()
{ public void windowClosing(WindowEvent e)
{dispose();}
}
);
}
public void actionPerformed(ActionEvent e)
{ if(e.getActionCommand().equals("退出"))
this.dispose();
if(e.getActionCommand().equals("查询"))
{ conc=new condb();
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("实发工资"));
conc.dbclose(conc.con,rs);
conc=null;
rs=null;}
else {JOptionPane jop=new JOptionPane();
jop.showConfirmDialog(null,"该用户不存在!","警告",-1);
}
}catch(Exception ee){}
}
}
}
jiesh.java
import java.awt.*;
import ;
import javax.swing.*;
import java.sql.*;
class jiesh extends JFrame implements ActionListener
{ private condb con=null;
private ResultSet rs=null;
private String sql=null;
private JLabel q1=new JLabel("本软件介绍");
private JTextArea jstx=new JTextArea();
private JButton d2=new JButton("返回主界面");
public jiesh()
{ super("软件介绍");
setSize(400,350);
setBackground(Color.LIGHT_GRAY);
this.setLocationRelativeTo(this.getParent());
setResizable(false);
Container cont=this.getContentPane();
cont.setLayout(null);
q1.setBounds(150,20,300,30);
jstx.setBounds(40,50,300,200);
jstx.setText(" 本软件适用于人事工资管理不复杂的中小企业或其他类型\n企事业单位。
软件界面友好、操作简单。
");
jstx.setEditable(false);
d2.setBounds(240,260,100,30);
cont.add(q1);
cont.add(jstx);
cont.add(d2);
d2.addActionListener(this);
setVisible(true);
}
public void actionPerformed(ActionEvent ae)
{
if(ae.getActionCommand().equals("返回主界面"))
dispose();
}
}
mainff.java
import java.awt.*;
import ;
import ;
import javax.swing.*;
import ;
import java.sql.*;
import ;
class mainff extends Frame implements ActionListener
{ private condb con=null;
private ResultSet rs=null;
String sql=null;
String sqlb=null;
private JOptionPane jop=new JOptionPane();
private MenuBar mnubar=new MenuBar();
private Menu gongzi=new Menu("工资管理");
private Menu lookfor=new Menu("信息查询");
private Menu initsys=new Menu("系统初始化");
private Menu user=new Menu("用户管理");
private Menu help=new Menu("帮助信息");
private MenuItem gong1=new MenuItem("全部查询");
private MenuItem search1=new MenuItem("扣除工资查询");
private MenuItem search3=new MenuItem("职工工资查询");
private MenuItem search2=new MenuItem("职工休假查询");
private MenuItem dep=new MenuItem("添加工资");
private MenuItem emp=new MenuItem("选择支付方式");
private MenuItem selary=new MenuItem("添加休假");
private MenuItem user1=new MenuItem("用户管理");
private MenuItem help1=new MenuItem("系统介绍");
private MenuItem help2=new MenuItem("操作说明");
private MenuItem help3=new MenuItem("版本信息");
private Image img;
public mainff()
{ super("欢迎使用工资管理系统!");
setSize(800,600);
setBackground(Color.LIGHT_GRAY);
setLayout(null);
//以下三句设置当前框架位置。
Dimension scr=Toolkit.getDefaultToolkit().getScreenSize();
Dimension frm=this.getSize();
setLocation((int)(scr.getWidth()-frm.getWidth())/2,
(int)(scr.getHeight()-frm.getHeight())/2-50);//设置水平居中。
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);//设置菜单条,显示菜单
gongzi.addActionListener(this);
initsys.addActionListener(this);
lookfor.addActionListener(this);
user.addActionListener(this);
help.addActionListener(this);
setVisible(true);//设置可显性
addWindowListener(new WindowAdapter()
{ public void windowClosing(WindowEvent e)
{
tuich tc=new tuich();
}
}
);//关闭窗口
}
public void paint(Graphics g)
{
g.setClip(new Rectangle2D.Float(0,30,800,570));
g.drawImage(img,0,0,this);
}
public void actionPerformed(ActionEvent ae)
{
if(ae.getActionCommand().equals("添加休假"))
{
gz gong=new gz();//类调用
}
if(ae.getActionCommand().equals("选择支付方式"))
{
zg zhi=new zg();//类调用
}
if(ae.getActionCommand().equals("添加工资"))
{
bm bu=new bm();
}
if(ae.getActionCommand().equals("职工工资查询"))
{
gzcx gongcx=new gzcx();
}
if(ae.getActionCommand().equals("扣除工资查询"))
{
bmcx bucx=new bmcx();
}
if(ae.getActionCommand().equals("职工休假查询"))
{
zgcx zhi=new zgcx();
}
if(ae.getActionCommand().equals("用户管理"))
{
user use=new user();
}
if(ae.getActionCommand().equals("全部查询"))
{
whole use1=new whole();
}
if(ae.getActionCommand().equals("系统介绍"))
{
jiesh j=new jiesh();
}
if(ae.getActionCommand().equals("操作说明"))
{
shuom sh=new shuom();
}
if(ae.getActionCommand().equals("版本信息"))
{
xinxi xx=new xinxi();//类调用
}
}
}
shuom.java
import java.awt.*;
import ;
import javax.swing.*;
import java.sql.*;
class shuom extends JFrame implements ActionListener { private condb con=null;
private ResultSet rs=null;
private String sql=null;
private JLabel q1=new JLabel("本软件操作说明");
private JTextArea jstx=new JTextArea();
private JButton d2=new JButton("返回主界面");
public shuom()
{ super("操作说明");
setSize(400,350);
setBackground(Color.LIGHT_GRAY);
this.setLocationRelativeTo(this.getParent());
setResizable(false);
Container cont=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);
}
public void actionPerformed(ActionEvent ae)
{
if(ae.getActionCommand().equals("返回主界面"))
dispose();
}
}
tuich.java
import java.awt.*;
import ;
import javax.swing.*;
import java.sql.*;
class tuich extends JFrame implements ActionListener
{ private condb con=null;
private ResultSet rs=null;
private String sql=null;
private JLabel q1=new JLabel("是否确定退出本软件?");
private JButton d1=new JButton("确认");
private JButton d2=new JButton("返回");
public tuich()
{ super("结束");
setSize(300,180);
setBackground(Color.LIGHT_GRAY);
this.setLocationRelativeTo(this.getParent());
setResizable(false);
Container cont=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);
}
public void actionPerformed(ActionEvent te)
{
if(te.getActionCommand().equals("确认"))
{ dispose();System.exit(0);}
if(te.getActionCommand().equals("返回"))
dispose();
}
}
user.java
import java.awt.*;
import java.util.*;
import ;
import ;
import java.sql.*;
import javax.swing.*;
class user extends Frame implements ActionListener ,ItemListener { private condb con=null;
private ResultSet rs=null;
private String sql=null;
private Button btnadd=new Button("增加");
private Button btndel=new Button("删除");
private Button btnmod=new Button("修改");
private Button btnexit=new Button("退出");
private Label lbname=new Label("用户");
private Label lbpwd=new Label("密码");
private Label lbuserchoice=new Label("用户列表");
private TextField txtname=new TextField();
private TextField txtpwd=new TextField();
private Choice userchoice=new Choice();
public user()
{ super("系统用户管理");
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(new WindowAdapter()
{ public void windowClosing(WindowEvent e)
{dispose();}
}
);
}
public void initchoice()
{ try { con=new condb();
sql="select 用户名from 数据库用户";
rs=con.getrs(con.con,sql);
while(rs.next())
{ userchoice.addItem(rs.getString("用户名"));
}
con.dbclose(con.con,rs);
con=null;
}
catch(Exception e){}
}
public void actionPerformed(ActionEvent ee)
{ if(ee.getActionCommand().equals("退出"))
dispose();
if(ee.getActionCommand().equals("增加"))
{ sql="select * from 数据库用户where 用户名='"+txtname.getText()+"'";
con=new condb();
try{ rs=con.getrs(con.con,sql);
if(rs.next())
{ JOptionPane jop=new JOptionPane();
jop.showConfirmDialog(null,"该用户已经存在!","警告",-1);
con.dbclose(con.con,rs);
con=null;
rs=null;
}
else { sql="insert into 数据库用户values('"+txtname.getText()+
"','"+txtpwd.getText()+"')";
con=new condb();
try{ con.moddb(con.con,sql);
;
}
catch(SQLException se){}
userchoice.addItem(txtname.getText());
txtname.setText("");
txtpwd.setText("");
con=null; }
}catch(Exception a){}
}
if(ee.getActionCommand().equals("修改"))
{ sql="update 数据库用户set 密码='"+txtpwd.getText()
+"'where 用户名='"+txtname.getText()+"'";
con=new condb();
try{ con.moddb(con.con,sql);
;
}
catch(SQLException se){}
txtname.setText("");
txtpwd.setText("");
con=null;
}
if(ee.getActionCommand().equals("删除"))
{ JOptionPane jopask=new JOptionPane();
if(jopask.showConfirmDialog(null,"你要删除?","请确认",2)==0)
{ con=new condb();
sql="delete from 数据库用户where 用户名='"+txtname.getText()+"'";
try{ con.moddb(con.con,sql);
;
}
catch(SQLException se){}
con=null;
userchoice.remove(userchoice.getSelectedIndex());
txtname.setText("");
txtpwd.setText("");
}
}
}
public void itemStateChanged(ItemEvent ie)
{txtname.setText(userchoice.getSelectedItem());}
}
whole.java
import java.awt.*;
import ;
import javax.swing.*;
import java.sql.*;
class whole extends JDialog implements ActionListener
{ private condb con=null;
private ResultSet rs=null;
private String sql=null;
private JLabel bmhao=new JLabel("职工号:");
private JLabel bmname=new JLabel("姓名:");
private JTextField wholetx1=new JTextField();
private JTextField wholetx2=new JTextField();
private JButton ok=new JButton("查询");
private JOptionPane jop=new JOptionPane();
private JTable ta=null;
private JScrollPane taooo=new JScrollPane();
private String col[]={"职工号","姓名","普通请假","病假","迟到","基本工资",
"奖金","扣除工资","实发工资"};
private Object rowline[][]=new String[45][10];
private boolean tf=false;
public whole()
{ setTitle("全部信息");
setSize(600,300);
getContentPane().setBackground(Color.LIGHT_GRAY);
getContentPane().setLayout(null);
Dimension scr=Toolkit.getDefaultToolkit().getScreenSize();
Dimension frm=getSize();
setLocation((int)(scr.getWidth()-frm.getWidth())/2,150);
bmhao.setBounds(50,20,80,30);
wholetx1.setBounds(140,20,50,20);
bmname.setBounds(210,20,80,30);
wholetx2.setBounds(300,20,50,20);
ok.setBounds(400,20,100,30);
getContentPane().add(bmhao);
getContentPane().add(wholetx1);
getContentPane().add(bmname);
getContentPane().add(wholetx2);
getContentPane().add(ok);
ok.addActionListener(this);
setVisible(true);
}
public void initTable(Object row[][],String col[])
{
con=new condb();
if(wholetx1.getText().equals("")==true && wholetx2.getText().equals("")==true)
{ sql ="select 职工.职工号,姓名, 普通请假,病假, 迟到,基本工资,奖金,扣除工资,实发工资from 职工,工资where 职工.职工号=工资.职工号";
}
else if(wholetx1.getText().equals("")==false)
{ sql ="select 职工.职工号,姓名, 普通请假,病假, 迟到,基本工资,奖金,扣除工资,实发工资from 职工,工资where 职工.职工号=工资.职工号and 职工.职工号='"+wholetx1.getText()+"'";
} //职工.职工号=工资.职工号and
else if(wholetx2.getText().equals("")==false)
{ sql ="select 职工.职工号,姓名, 普通请假,病假, 迟到,基本工资,奖金,扣除工资,实发工资from 职工,工资where 职工.职工号=工资.职工号and 职工.姓名='"+wholetx2.getText()+"'";
}
// 职工.职工号=工资.职工号and
try{ rs=con.getrs(con.con,sql);
int cnt=0;
while(rs.next())
{
rowline[cnt][0]=rs.getString("职工号");
rowline[cnt][1]=rs.getString("姓名");
rowline[cnt][2]=rs.getString("普通请假");
rowline[cnt][3]=rs.getString("病假");
rowline[cnt][4]=rs.getString("迟到");
rowline[cnt][5]=rs.getString("基本工资");
rowline[cnt][6]=rs.getString("奖金");
rowline[cnt][7]=rs.getString("扣除工资");
rowline[cnt][8]=rs.getString("实发工资");
cnt++;。