String wNumber1=(""+Database.rs.getString("W_Number"));
String wName1=Database.rs.getString("W_Name");
String wBasicWage1=Database.rs.getString("W_BasicWage");
String wBoon1=Database.rs.getString("W_Boon");
String wBonus1=Database.rs.getString("W_Bonus");
String wCountMethod1=Database.rs.getString("W_CountMethod");
String wFactWage1=Database.rs.getString("W_FactWage");
stid.setText(wNumber1);
stname.setText(wName1);
stsalary.setText(wBasicWage1);
stboon.setText(wBoon1);
stprize.setText(wBonus1);
stcounter.setText(wCountMethod1);
stfact.setText(wFactWage1);
}
else{
new JOptionPane().showMessageDialog(null,"添加数据不成功!");
}
}
catch(Exception esave){
new JOptionPane().showMessageDialog(null,"添加数据不成功!");
}
}
}
});
//删除
delete.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent edel){
try{
String sqle="delete from WageInformation where W_Number ='"+stid.getText()+"'";
System.out.println(sqle);
if(Database.executeSQL(sqle)){
new JOptionPane().showMessageDialog(null,"数据删除成功!");
Database.joinDB();
String sqll="select * from WageInformation";
Database.query(sqll);
Database.rs.last();
String wNumber1=(""+Database.rs.getString("W_Number"));
String wName1=Database.rs.getString("W_Name");
String wBasicWage1=Database.rs.getString("W_BasicWage");
String wBoon1=Database.rs.getString("W_Boon");
String wBonus1=Database.rs.getString("W_Bonus");
String wCountMethod1=Database.rs.getString("W_CountMethod");
String wFactWage1=Database.rs.getString("W_FactWage");
stid.setText(wNumber1);
stname.setText(wName1);
stsalary.setText(wBasicWage1);
stboon.setText(wBoon1);
stprize.setText(wBonus1);
stcounter.setText(wCountMethod1);
stfact.setText(wFactWage1);
}
}
catch(Exception edelete){
System.out.println("数据删除失败!");
}
}
});
//修改
updete.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent eupd){
try{
String supdate="update WageInformation set W_Name='"+ stname.getText()+"',W_BasicWage='"+ stid.getText() +"',W_Boon='"+stboon.getText()+"',W_Bonus='"+stprize.getText()+"',W_CountMethod='"+stcounter.getText()+"',W_FactWage='"+stfact.getText()+"' where W_Number='"+ stid.getText()+"'";
if(Database.executeSQL(supdate)){
new JOptionPane().showMessageDialog(null,"数据修改成功!");
Database.joinDB();
String sqll="select * from WageInformation";
Database.query(sqll);
Database.rs.last();
String wNumber1=(""+Database.rs.getString("W_Number"));
String wName1=Database.rs.getString("W_Name");
String wBasicWage1=Database.rs.getString("W_BasicWage");
String wBoon1=Database.rs.getString("W_Boon");
String wBonus1=Database.rs.getString("W_Bonus");
String wCountMethod1=Database.rs.getString("W_CountMethod");
String wFactWage1=Database.rs.getString("W_FactWage");
stid.setText(wNumber1);
stname.setText(wName1);
stsalary.setText(wBasicWage1);
stboon.setText(wBoon1);
stprize.setText(wBonus1);
stcounter.setText(wCountMethod1);
stfact.setText(wFactWage1);
}
}
catch(Exception eupdete){
System.out.println("修改数据失败!");
} setSize(460,350);
this.setClosable(true);
setVisible(true);