⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tphmtypelistimpl.java

📁 HW-中国移动企业信息机,请查看
💻 JAVA
字号:
package com.sxit.phonemanager;
import com.sxit.common.ListImpl;
import java.util.*;
import java.sql.*;
/**
 * <p>类名: TphmtypeListImpl</p>
 * <p>功能: 类型</p>
 * <p>公司: 深讯信科</p>
 * <p>版本: 1.0</p>
 * @程序 sxit
 * @日期 2005-03-22
 * @修改纪录
 */
public class TphmtypeListImpl extends ListImpl
{
     public TphmtypeListImpl()
     {
          super();
     }
     /**
      * 创建全部列表
      */
     public void createList(Connection con) throws SQLException
     {
          createList(con,0,0,"");
     }
     /**
      * 有条件创建全部列表
      */
     public void createList(Connection con,String strSearch) throws SQLException
     {
          createList(con,0,0,strSearch);
     }
     /**
      * 创建分页列表
      */
     public void createList(Connection con,int pageNo,int pageSize) throws SQLException
     {
          createList(con,pageNo,pageSize,"");
     }
     /**
      * 有条件创建分页列表
      */
     public void createList(Connection con,int pageNo,int pageSize,String strSearch) throws SQLException
     {
          PreparedStatement stmt=null;
          ResultSet rs=null;
          String sql="";
          int i=0;
          try{
               if(pageNo==0 && pageSize==0){
                    strSearch=" where 1=1 "+strSearch;
                    recList=new ArrayList();
                    sql="select typeid,brandid,modeid,typename,statusid from tphmtype "+strSearch;
                    stmt=con.prepareStatement(sql);
                    rs=stmt.executeQuery();
                    i=0;
                    while(rs.next()){
                         Tphmtype tphmtype=new Tphmtype();
                         tphmtype.setTypeid(rs.getLong("typeid"));
                         tphmtype.setBrandid(rs.getLong("brandid"));
                         tphmtype.setModeid(rs.getLong("modeid"));
                         tphmtype.setTypename(rs.getString("typename"));
                         tphmtype.setStatusid(rs.getInt("statusid"));
                         recList.add(tphmtype);
                         i++;
                    }
                    stmt.close();
               }else{
                    this.pageNo=pageNo;
                    this.pageSize=pageSize;
                    recList=new ArrayList();
                    sql="select typeid,brandid,modeid,typename,statusid from tphmtype "+strSearch;
                    stmt=con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
                    rs=stmt.executeQuery();
                    rs.last();
                    recCount=rs.getRow();
                    if(pageSize*(pageNo-1)==0){
                         rs.beforeFirst();
                    }else{
                         rs.absolute(pageSize*(pageNo-1));
                    }
                    i=0;
                    while(rs.next() && i<pageSize){
                         Tphmtype tphmtype=new Tphmtype();
                         tphmtype.setTypeid(rs.getLong("typeid"));
                         tphmtype.setBrandid(rs.getLong("brandid"));
                         tphmtype.setModeid(rs.getLong("modeid"));
                         tphmtype.setTypename(rs.getString("typename"));
                         tphmtype.setStatusid(rs.getInt("statusid"));
                         recList.add(tphmtype);
                         i++;
                    }
                    stmt.close();
//                    this.pageNo=pageNo;
//                    this.pageSize=pageSize;
//                    strSearch=" where 1=1 "+strSearch;
//                    sql="select count(*) as cnt from tphmtype "+strSearch;
//                    stmt = con.prepareStatement(sql);
//                    rs = stmt.executeQuery();
//                    if(rs.next()){
//                         recCount=rs.getInt("cnt");
//                    }
//                    stmt.close();
//                    recList=new ArrayList();
//                    sql="select typeid,brandid,modeid,typename,statusid from tphmtype "+strSearch;
//                    stmt=con.prepareStatement(sql);
//                    rs=stmt.executeQuery();
//                    i=0;
//                    while(i<pageSize*(pageNo-1)){
//                         rs.next();
//                         i++;
//                    }
//                    i=0;
//                    while(rs.next() && i<pageSize){
//                         Tphmtype tphmtype=new Tphmtype();
//                         tphmtype.setTypeid(rs.getLong("typeid"));
//                         tphmtype.setBrandid(rs.getLong("brandid"));
//                         tphmtype.setModeid(rs.getLong("modeid"));
//                         tphmtype.setTypename(rs.getString("typename"));
//                         tphmtype.setStatusid(rs.getInt("statusid"));
//                         recList.add(tphmtype);
//                         i++;
//                    }
//                    stmt.close();
               }
          }
          finally{
               if(stmt!=null) stmt.close();
          }
     }
     /**
      * 有条件创建分页列表(含关联的表字段)
      */
     public void createList1(Connection con,int pageNo,int pageSize,String strSearch) throws SQLException
     {
          PreparedStatement stmt=null;
          ResultSet rs=null;
          String sql="";
          int i=0;
          try{
               if(pageNo==0 && pageSize==0){
                    recList=new ArrayList();
                    sql="select a.typeid,a.typename,a.statusid,a.brandid,b.brandname,a.modeid,c.modename from tphmtype a,tphmbrand b,tphmmode c where 1=1  and a.brandid=b.brandid(+) and a.modeid=c.modeid(+) "+strSearch;
                    stmt=con.prepareStatement(sql);
                    rs=stmt.executeQuery();
                    i=0;
                    while(rs.next()){
                         Tphmtype tphmtype=new Tphmtype();
                         tphmtype.setTypeid(rs.getLong("typeid"));
                         tphmtype.setBrandid(rs.getLong("brandid"));
                         tphmtype.setModeid(rs.getLong("modeid"));
                         tphmtype.setTypename(rs.getString("typename"));
                         tphmtype.setStatusid(rs.getInt("statusid"));
                         tphmtype.setBrandname(rs.getString("brandname"));
                         tphmtype.setModename(rs.getString("modename"));
                         recList.add(tphmtype);
                         i++;
                    }
                    stmt.close();
               }else{
                    this.pageNo=pageNo;
                    this.pageSize=pageSize;
                    recList=new ArrayList();
                    sql="select a.typeid,a.typename,a.statusid,a.brandid,b.brandname,a.modeid,c.modename from tphmtype a,tphmbrand b,tphmmode c where 1=1  and a.brandid=b.brandid(+) and a.modeid=c.modeid(+) "+strSearch;
                    stmt=con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
                    rs=stmt.executeQuery();
                    rs.last();
                    recCount=rs.getRow();
                    if(pageSize*(pageNo-1)==0){
                         rs.beforeFirst();
                    }else{
                         rs.absolute(pageSize*(pageNo-1));
                    }
                    i=0;
                    while(rs.next() && i<pageSize){
                         Tphmtype tphmtype=new Tphmtype();
                         tphmtype.setTypeid(rs.getLong("typeid"));
                         tphmtype.setBrandid(rs.getLong("brandid"));
                         tphmtype.setModeid(rs.getLong("modeid"));
                         tphmtype.setTypename(rs.getString("typename"));
                         tphmtype.setStatusid(rs.getInt("statusid"));
                         tphmtype.setBrandname(rs.getString("brandname"));
                         tphmtype.setModename(rs.getString("modename"));
                         recList.add(tphmtype);
                         i++;
                    }
                    stmt.close();
//                    this.pageNo=pageNo;
//                    this.pageSize=pageSize;
//                    sql="select count(*) as cnt from tphmtype a,tphmbrand b,tphmmode c where 1=1  and a.brandid=b.brandid(+) and a.modeid=c.modeid(+) "+strSearch;
//                    stmt = con.prepareStatement(sql);
//                    rs = stmt.executeQuery();
//                    if(rs.next()){
//                         recCount=rs.getInt("cnt");
//                    }
//                    stmt.close();
//                    recList=new ArrayList();
//                    sql="select a.typeid,a.typename,a.statusid,a.brandid,b.brandname,a.modeid,c.modename from tphmtype a,tphmbrand b,tphmmode c where 1=1  and a.brandid=b.brandid(+) and a.modeid=c.modeid(+) "+strSearch;
//                    stmt=con.prepareStatement(sql);
//                    rs=stmt.executeQuery();
//                    i=0;
//                    while(i<pageSize*(pageNo-1)){
//                         rs.next();
//                         i++;
//                    }
//                    i=0;
//                    while(rs.next() && i<pageSize){
//                         Tphmtype tphmtype=new Tphmtype();
//                         tphmtype.setTypeid(rs.getLong("typeid"));
//                         tphmtype.setBrandid(rs.getLong("brandid"));
//                         tphmtype.setModeid(rs.getLong("modeid"));
//                         tphmtype.setTypename(rs.getString("typename"));
//                         tphmtype.setStatusid(rs.getInt("statusid"));
//                         tphmtype.setBrandname(rs.getString("brandname"));
//                         tphmtype.setModename(rs.getString("modename"));
//                         recList.add(tphmtype);
//                         i++;
//                    }
//                    stmt.close();
               }
          }
          finally{
               if(stmt!=null) stmt.close();
          }
     }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -