📄 doctypedao.java
字号:
package com.jasson.business.system;
/**
* <p>Title: DocTypeDAO</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 DocTypeDAO {
private int TypeID;
private String TypeNO;
private String TypeName;
private String ActiveTag;
public DocTypeDAO( int TypeID, String TypeNO, String TypeName, String ActiveTag ){
this.TypeID = TypeID;
this.TypeNO = TypeNO;
this.TypeName = TypeName;
this.ActiveTag = ActiveTag;
}
public DocTypeDAO() {
}
public int getTypeID(){
return TypeID;
}
public void setTypeID(int TypeID){
this.TypeID = TypeID;
}
public String getTypeNO(){
return TypeNO;
}
public void setTypeNO(String TypeNO){
this.TypeNO = TypeNO;
}
public String getTypeName(){
return TypeName;
}
public void setTypeName(String TypeName){
this.TypeName = TypeName;
}
public String getActiveTag(){
return ActiveTag;
}
public void setActiveTag(String ActiveTag){
// Next 1 line remarked by David, 2003/06/26
// this.ActiveTag = ActiveTag;
// Next 6 lines added by David, 2003/06/26
this.ActiveTag = "0";
if (ActiveTag != null) {
if (ActiveTag.equals("1")) {
this.ActiveTag = ActiveTag;
}
}
}
public static DocTypeDAO find(int TypeID){
ExtendString ExStr = new ExtendString();
Connection con = null;
PreparedStatement ps = null;
ResultSet rs = null;
DocTypeDAO result = null;
try {
DbConn dbConn = new DbConn();
con = dbConn.getConnection();
ps = con.prepareStatement("select TypeID, TypeNO, TypeName, ActiveTag from TType where TypeID = ?");
ps.setInt(1, TypeID);
rs = ps.executeQuery();
if (rs.next()) {
result = new DocTypeDAO( 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 DocTypeDAO[] findSelectAll() {
ExtendString ExStr = new ExtendString();
Connection con = null;
PreparedStatement ps = null;
ResultSet rs = null;
DocTypeDAO result = null;
Collection results = new ArrayList();
try {
DbConn dbConn = new DbConn();
con = dbConn.getConnection();
ps = con.prepareStatement("select TypeID, TypeNO, TypeName, ActiveTag from TType");
rs = ps.executeQuery();
while (rs.next()) {
result = new DocTypeDAO( 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 (DocTypeDAO[])results.toArray(new DocTypeDAO[0]);
}
public static DocTypeDAO[] findAll() {
ExtendString ExStr = new ExtendString();
Connection con = null;
PreparedStatement ps = null;
ResultSet rs = null;
DocTypeDAO result = null;
Collection results = new ArrayList();
try {
DbConn dbConn = new DbConn();
con = dbConn.getConnection();
ps = con.prepareStatement("select TypeID, TypeNO, TypeName, ActiveTag from TType where ActiveTag = 1");
rs = ps.executeQuery();
while (rs.next()) {
result = new DocTypeDAO( 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 (DocTypeDAO[])results.toArray(new DocTypeDAO[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(TypeID) from TType");
rs = ps.executeQuery();
if (rs.next()){
//remarked by jarrywen, 2003/06/26
int maxTypeID = rs.getInt(1)+1;
this.setTypeID(maxTypeID);
}
ps = con.prepareStatement("insert into TType ( TypeID, TypeNO, TypeName, ActiveTag) values ( ?, ?, ?, ?)");
ps.setInt(1, getTypeID());
ps.setString(2, getTypeNO());
ps.setString(3, getTypeName());
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 TypeID) {
Connection con = null;
PreparedStatement ps = null;
boolean blnReturn = false;
try {
DbConn dbConn = new DbConn();
con = dbConn.getConnection();
if (con != null) {
ps = con.prepareStatement("delete TType where TypeID = ?");
ps.setInt(1, TypeID);
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 TType set TypeID = ?, TypeNO = ?, TypeName = ?, ActiveTag = ? where TypeID = ?");
ps.setInt(1, getTypeID());
ps.setString(2, getTypeNO());
ps.setString(3, getTypeName());
ps.setString(4, getActiveTag());
ps.setInt(5, getTypeID());
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 + -