📄 zclbbean.java~1~
字号:
package zcgl;
import javax.swing.*;
import java.sql.*;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2008</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class ZcLbBean extends JPanel {
BorderLayout borderLayout1 = new BorderLayout();
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 DBConn().getConnection();
PreparedStatement pstm = null;
try {
pstm = con.prepareStatement("insert into CATEGORY values(?,?,?,?)");
if(pstm.getResultSet().next())
{
pstm.setInt(1,zlId);
pstm.setString(2,zlName);
pstm.setInt(3,subId);
pstm.setString(4,subName);
pstm.executeUpdate();
return true;
}
else
{
JOptionPane.showMessageDialog(null,"此信息已经存在!");
return false;
}
} catch (Exception ex) {
return false;
}
}
public boolean del(){
con = new DBConn().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 DBConn().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 DBConn().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;
}
}
public ZcLbBean() {
try {
jbInit();
} catch (Exception exception) {
exception.printStackTrace();
}
}
private void jbInit() throws Exception {
setLayout(borderLayout1);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -