📄 doccontroltypedao.java
字号:
package com.jasson.business.system;
/**
* <p>Title: DocControlTypeDAO</p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2003,by wingroup</p>
* <p>Company: wingroup</p>
* @author jarrywen
* @version 1.0
*/
import java.io.*;
import java.sql.*;
import java.util.Properties;
import java.util.Collection;
import java.util.ArrayList;
import com.jasson.business.common.DbConn;
import com.jasson.common.*;
public class DocControlTypeDAO {
private int ControlTypeID;
private String ControlTypeNO;
private String ControlTypeName;
private String ActiveTag;
public DocControlTypeDAO( int ControlTypeID, String ControlTypeNO, String ControlTypeName, String ActiveTag ){
this.ControlTypeID = ControlTypeID;
this.ControlTypeNO = ControlTypeNO;
this.ControlTypeName = ControlTypeName;
this.ActiveTag = ActiveTag;
}
public DocControlTypeDAO() {
}
public int getControlTypeID(){
return ControlTypeID;
}
public void setControlTypeID(int ControlTypeID){
this.ControlTypeID = ControlTypeID;
}
public String getControlTypeNO(){
return ControlTypeNO;
}
public void setControlTypeNO(String ControlTypeNO){
this.ControlTypeNO = ControlTypeNO;
}
public String getControlTypeName(){
return ControlTypeName;
}
public void setControlTypeName(String ControlTypeName){
this.ControlTypeName = ControlTypeName;
}
public String getActiveTag(){
return ActiveTag;
}
public void setActiveTag(String ActiveTag){
this.ActiveTag = ActiveTag;
}
public static DocControlTypeDAO find(int ControlTypeID){
ExtendString ExStr = new ExtendString();
Connection con = null;
PreparedStatement ps = null;
ResultSet rs = null;
DocControlTypeDAO result = null;
try {
DbConn dbConn = new DbConn();
con = dbConn.getConnection();
ps = con.prepareStatement("select ControlTypeID, ControlTypeNO, ControlTypeName, ActiveTag from TControlType where ControlTypeID = ?");
ps.setInt(1, ControlTypeID);
rs = ps.executeQuery();
if (rs.next()) {
result = new DocControlTypeDAO( rs.getInt(1), ExStr.dbDecode(rs.getString(2)), ExStr.dbDecode(rs.getString(3)), ExStr.dbDecode(rs.getString(4)));
}
rs.close();
rs = null;
ps.close();
ps = null;
con.close();
con = null;
}
catch (SQLException sqlException) {
System.out.println(sqlException.getMessage());
}
finally {
if (rs != null) {
try {
rs.close();
}
catch (SQLException sqlException) {
}
rs = null;
}
if (ps != null) {
try {
ps.close();
}
catch (SQLException sqlException) {
}
ps = null;
}
if (con != null) {
try {
con.close();
}
catch (SQLException sqlException) {
}
con = null;
}
}
return result;
}
public static DocControlTypeDAO[] findAll() {
ExtendString ExStr = new ExtendString();
Connection con = null;
PreparedStatement ps = null;
ResultSet rs = null;
DocControlTypeDAO result = null;
Collection results = new ArrayList();
try {
DbConn dbConn = new DbConn();
con = dbConn.getConnection();
ps = con.prepareStatement("select ControlTypeID, ControlTypeNO, ControlTypeName, ActiveTag from TControlType");
rs = ps.executeQuery();
while (rs.next()) {
result = new DocControlTypeDAO( rs.getInt(1), ExStr.dbDecode(rs.getString(2)), ExStr.dbDecode(rs.getString(3)), ExStr.dbDecode(rs.getString(4)));
results.add(result);
}
rs.close();
rs = null;
ps.close();
ps = null;
con.close();
con = null;
}
catch (SQLException sqlException) {
System.out.println(sqlException.getMessage());
}
finally {
if (rs != null) {
try {
rs.close();
}
catch (SQLException sqlException) {
}
rs = null;
}
if (ps != null) {
try {
ps.close();
}
catch (SQLException sqlException) {
}
ps = null;
}
if (con != null) {
try {
con.close();
}
catch (SQLException sqlException) {
}
con = null;
}
}
return (DocControlTypeDAO[])results.toArray(new DocControlTypeDAO[0]);
}
public long insert() {
Connection con = null;
PreparedStatement ps = null;
ResultSet rs = null;
long lngSQLReturn = -1;
long lngReturn = -1;
try {
DbConn dbConn = new DbConn();
con = dbConn.getConnection();
if (con != null) {
ps = con.prepareStatement("select MAX(ControlTypeID) from TControlType");
rs = ps.executeQuery();
if (rs.next()){
int maxControlTypeID = rs.getInt(1);
this.setControlTypeID(maxControlTypeID);
}
ps = con.prepareStatement("insert into TControlType ( ControlTypeID, ControlTypeNO, ControlTypeName, ActiveTag) values ( ?, ?, ?, ?)");
ps.setInt(1, getControlTypeID());
ps.setString(2, getControlTypeNO());
ps.setString(3, getControlTypeName());
ps.setString(4, getActiveTag());
lngSQLReturn = ps.executeUpdate();
lngReturn = lngSQLReturn;
}
rs.close();
rs = null;
ps.close();
ps = null;
con.close();
con = null;
}
catch (SQLException sqlException) {
System.out.println(sqlException.getMessage());
}
finally {
if (rs != null) {
try {
rs.close();
}
catch (SQLException sqlException) {
}
rs = null;
}
if (ps != null) {
try {
ps.close();
}
catch (SQLException sqlException) {
}
ps = null;
}
if (con != null) {
try {
con.close();
}
catch (SQLException sqlException) {
}
con = null;
}
}
return lngReturn;
}
public boolean delete(int ControlTypeID) {
Connection con = null;
PreparedStatement ps = null;
boolean blnReturn = false;
try {
DbConn dbConn = new DbConn();
con = dbConn.getConnection();
if (con != null) {
ps = con.prepareStatement("delete TControlType where ControlTypeID = ?");
ps.setInt(1, ControlTypeID);
blnReturn = (ps.executeUpdate() == 1);
ps.close();
}
con.close();
}
catch (SQLException sqlException) {
System.out.println(sqlException.getMessage());
}
finally {
if (ps != null) {
try {
ps.close();
}
catch (SQLException sqlException) {
}
ps = null;
}
if (con != null) {
try {
con.close();
}
catch (SQLException sqlException) {
}
con = null;
}
}
return blnReturn;
}
public boolean update() {
Connection con = null;
PreparedStatement ps = null;
boolean blnReturn = false;
try {
DbConn dbConn = new DbConn();
con = dbConn.getConnection();
if (con != null) {
ps = con.prepareStatement("update TControlType set ControlTypeID = ?, ControlTypeNO = ?, ControlTypeName = ?, ActiveTag = ? where ControlTypeID = ?");
ps.setInt(1, getControlTypeID());
ps.setString(2, getControlTypeNO());
ps.setString(3, getControlTypeName());
ps.setString(4, getActiveTag());
ps.setInt(5, getControlTypeID());
blnReturn = (ps.executeUpdate() == 1);
ps.close();
}
con.close();
}
catch (SQLException sqlException) {
System.out.println(sqlException.getMessage());
}
finally {
if (ps != null) {
try {
ps.close();
}
catch (SQLException sqlException) {
}
ps = null;
}
if (con != null) {
try {
con.close();
}
catch (SQLException sqlException) {
}
con = null;
}
}
return blnReturn;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -