?? zclbbean.java
字號:
package zcgl;
import javax.swing.*;
import java.sql.*;
public class ZcLbBean extends JPanel {
private int zlId;
private String zlName;
private int subId;
private String subName;
private Connection con=null;
public int getZlId() {
return zlId;
}
public String getZlName() {
return zlName;
}
public int getSubId() {
return subId;
}
public String getSubName() {
return subName;
}
public void setZlId(int zlId) {
this.zlId = zlId;
}
public void setZlName(String zlName) {
this.zlName = zlName;
}
public void setSubId(int subId) {
this.subId = subId;
}
public void setSubName(String subName) {
this.subName = subName;
}
public boolean insert(){
con = new DbCon().getConnection();
PreparedStatement pstm = null;
try {
pstm = con.prepareStatement("insert into CATEGORY values(?,?,?,?)");
pstm.setInt(1,zlId);
pstm.setString(2,zlName);
pstm.setInt(3,subId);
pstm.setString(4,subName);
pstm.executeUpdate();
return true;
} catch (Exception ex) {
return false;
}
}
public boolean del(){
con = new DbCon().getConnection();
PreparedStatement pstm = null;
try {
pstm = con.prepareStatement("delete from CATEGORY where cateid=?");
pstm.setInt(1,zlId);
pstm.executeUpdate();
return true;
} catch (Exception ex) {
return false;
}
}
public boolean modify(){
con = new DbCon().getConnection();
PreparedStatement pstm = null;
int Id=zlId;
try {
pstm = con.prepareStatement("update CATEGORY set cateid=?,catename=?,subcateid=?,subcatename=? where cateid="+Id);
pstm.setInt(1,zlId);
pstm.setString(2,zlName);
pstm.setInt(3,subId);
pstm.setString(4,subName);
pstm.executeUpdate();
return true;
} catch (Exception ex) {
return false;
}
}
public boolean isNull() {
con = new DbCon().getConnection();
Statement smt = null;
try {
smt = con.createStatement();
ResultSet rs=smt.executeQuery("select * from CATEGORY where cateid="+zlId);
if(rs.next())
return false;
} catch (SQLException ex) {
}
return true;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -