?? apc.java
字號:
package myBean;import java.sql.*;import myBeans.SQLBean;public class APC { private String code; private String description; public String getCode() { return code; } public void setCode(String code) { this.code = code; } public String getDescription() { return description; } public void setDescription(String description) { this.description = description; }
public String findTable(String code){
if(code.startsWith("A"))
return "award_levels";
else if(code.startsWith("P"))
return "punish_levels";
else
return "change_code";
}
public ResultSet getAPC(String s){
String table = ""; if(s.equals("A")){ table = "award_levels"; }else if(s.equals("P")){ table = "punish_levels"; }else{ table = "change_code"; } String sql="select CODE,DESCRIPTION from "+table; SQLBean db = new SQLBean(); ResultSet rs = db.executeQuery(sql); return rs; } public boolean hasLogin(String code,String description){ boolean f=false;
String table = findTable(code); String sql="select * from "+table+" where CODE ='"+code+"' or DESCRIPTION='"+description+"'"; SQLBean db =new SQLBean(); try{ ResultSet rs=db.executeQuery(sql); if(rs.next()){ f=true;} else{ f=false;} }catch(Exception e){ e.getMessage();} return f; } public void addAPC(){
String table = findTable(code); String sql="insert into "+table+"(CODE,DESCRIPTION) "+ "values ('"+code+"','"+description+"') "; try{ SQLBean db =new SQLBean(); db.executeInsert(sql); } catch(Exception e){System.out.print(e.toString());} } public void updateAPC(String code,String description){
String table = findTable(code); String sql="update "+table+ " set DESCRIPTION='"+description+"'"+ " where CODE='"+code+"'"; SQLBean db= new SQLBean(); db.executeInsert(sql); } public int deleteAPC(String code){ int num=0;
String table = findTable(code); String sql="delete from "+table+" where CODE ='"+code+"'"; SQLBean db= new SQLBean(); num=db.executeDelete(sql); return num; } }
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -