XGMM xgmm=new XGMM(ygname); xgmm.create(); }
if (b3.equals(e.getSource())) {// 返回 DL dl=new DL(); dl.create(); f.dispose(); } } }
void chaxun(){
Connection con; Statement sql; ResultSet rs; try {
Class.forName(\ } catch (ClassNotFoundException e1) {
JOptionPane.showMessageDialog(this, \连接数据库失败!\ }
try { con = DriverManager.getConnection(\ba\ sql = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY); for (int i = 0; i < 50; i++) for (int j = 0; j < 6; j++) table.setValueAt(\ rs = sql.executeQuery(\ no,name,jbgz,jt,mm from yg order by jbgz+jt\
int k = -1;
while (rs.next()) { k++;
String no = rs.getString(1); String name = rs.getString(2); String jt = rs.getString(4); String jbgz = rs.getString(3);
int sum= rs.getInt(3)+rs.getInt(4); String mm = rs.getString(5);
19
table.setValueAt(no, k, 0); table.setValueAt(name, k, 1); table.setValueAt(jt, k, 2); table.setValueAt(jbgz, k, 3); table.setValueAt(sum,k,4); table.setValueAt(mm,k,5); }
con.close();
sql.close(); } catch (SQLException e1) { if(chaxun.equals(chaxun)) {
JOptionPane.showMessageDialog(this, \查询失败!\ }
else{
JOptionPane.showMessageDialog(this, \刷新失败!\
} } }
public void actionPerformed(ActionEvent e) {
if (b1.equals(e.getSource())) { // 添加新员工信息 //if(power.equals(\ Connection con; Statement sql; ResultSet rs; try {
Class.forName(\ } catch (ClassNotFoundException e1) {
JOptionPane.showMessageDialog(this, \连接数据库失败!\ }
try { con = DriverManager.getConnection(\ba\ sql = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_READ_ONLY); rs=sql.executeQuery(\power from gly where glname='\ while(rs.next()){
power=rs.getString(\
20
}
if(power.equals(\ try{ String insertStr = \INTO yg (no,name,jt,jbgz,mm)VALUES('\ext()+\tText()+\
sql.executeUpdate(insertStr);JOptionPane.showMessageDialog(this, \添加成功!\ }
catch(SQLException e2){
JOptionPane.showMessageDialog(this, \输入数值有误\ }
tf1.setText(\Text(\ chaxun(); con.close(); }
else{
JOptionPane.showMessageDialog(this, \管理员权限不足!\ tf1.setText(\Text(\ }
con.close(); sql.close();
} catch (SQLException e1) {
JOptionPane.showMessageDialog(this, \添加失败!\ } }
if (b2.equals(e.getSource())) {// 修改员工信息 Connection con; Statement sql; ResultSet rs; try {
Class.forName(\ } catch (ClassNotFoundException e1) {
JOptionPane.showMessageDialog(this, \连接数据库失败!\ }
try { con =
21
DriverManager.getConnection(\ba\ sql = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
rs=sql.executeQuery(\power from gly where glname='\ while(rs.next()){
power=rs.getString(\ }
rs=null;
if(power.equals(\
rs=sql.executeQuery(\* from yg where no='\ if(rs.next()){
String updateStr = \ yg SET jt='\getText()+\no='\
sql.executeUpdate(updateStr);JOptionPane.showMessageDialog(this, \修改成功!\ tf1.setText(\Text(\ con.close(); }
else{
JOptionPane.showMessageDialog(this, \查无此人!\ tf1.setText(\Text(\ } }
else{
JOptionPane.showMessageDialog(this, \管理员权限不足!\ tf1.setText(\Text(\ }
con.close(); sql.close();
} catch (SQLException e1) {
JOptionPane.showMessageDialog(this, \请再确认你要更改的信息!\ }
22
}
if (b3.equals(e.getSource())) {// 删除员工信息 //if(power.equals(\ Connection con; Statement sql; ResultSet rs; try {
Class.forName(\ } catch (ClassNotFoundException e1) {
JOptionPane.showMessageDialog(this, \连接数据库失败!\ }
try { con = DriverManager.getConnection(\ba\ sql = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);//
rs=sql.executeQuery(\* from gly where glname='\
while(rs.next()){
power=rs.getString(\ }
rs=null;
if(power.equals(\
rs=sql.executeQuery(\no FROM yg where no='\ if(rs.next()) {
sql.executeUpdate(\FROM yg where no='\
JOptionPane.showMessageDialog(this, \删除成功!\ con.close(); }
else{
JOptionPane.showMessageDialog(this, \请输入正确的员工工号!\
tf6.setText(\ } }
else{
JOptionPane.showMessageDialog(this,\管理员
23