zclbbean.java~9~
来自「一个经典的java编写的固定资定管理源码。值得下载!」· JAVA~9~ 代码 · 共 106 行
JAVA~9~
106 行
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 EMPLOYEE where empno="+zgId);
if(rs.next())
return false;
} catch (SQLException ex) {
}
return true;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?