oa_car_informationbean.java
来自「java开发的办公系统 1.系统管理 (地区管理,部门管理,菜单管理,用户管理」· Java 代码 · 共 640 行 · 第 1/2 页
JAVA
640 行
package com.vere.oa.car.bean; import java.sql.*; import java.util.*; import com.vere.db.*; import com.vere.oa.car.item.*; public class Oa_car_informationBean { private ResultSet rs=null; private int keyId; private int totalRecord; private Access access = null; public Oa_car_informationBean() { try { access=new Access(); } catch(Exception e) { System.out.println(e.toString()); } } /** * @author Administrator * @param 无 * @return ArrayList:Oa_car_informationItem 对象的 ArrayList 数组 * @see 取出 oa_car_information 表中的所有记录,每一条记录存储在一个 Oa_car_informationItem 对象中 */ public List find(){ ArrayList list=new ArrayList(); try { String sql="select * from "+T.OA_CAR_INFORMATION; rs = executeQuery(sql); while(rs.next()){ Oa_car_informationItem item=new Oa_car_informationItem(); item.setId(rs.getString("id")); item.setCar_no(rs.getString("car_no")); item.setBrand(rs.getString("brand")); item.setModel(rs.getString("model")); item.setColor(rs.getString("color")); item.setBuy_date(rs.getString("buy_date")); item.setValid_time(rs.getString("valid_time")); item.setPrice(rs.getString("price")); item.setSupplier(rs.getString("supplier")); item.setSupply_contact(rs.getString("supply_contact")); item.setSupply_telephone(rs.getString("supply_telephone")); item.setMaintain_site(rs.getString("maintain_site")); item.setMaintain_contact(rs.getString("maintain_contact")); item.setMaintain_telephone(rs.getString("maintain_telephone")); item.setPilot(rs.getString("pilot")); item.setMemo(rs.getString("memo")); item.setDiscard_time(rs.getString("discard_time")); item.setStatus(rs.getString("status")); list.add(item); } }catch(SQLException e){ System.out.print(e.toString()); } finally{ DBclose(); } return list; } /** * @author Administrator * @param 无 * @return ArrayList:Oa_car_informationItem 对象的 ArrayList 数组 * @see 取出 oa_car_information 表中的所有记录,每一条记录存储在一个 Oa_car_informationItem 对象中 */ public List findByIds(String ids){ ArrayList list=new ArrayList(); try { String sql="select * from "+T.OA_CAR_INFORMATION+" where id in ("+ids+")"; rs = executeQuery(sql); while(rs.next()){ Oa_car_informationItem item=new Oa_car_informationItem(); item.setId(rs.getString("id")); item.setCar_no(rs.getString("car_no")); item.setBrand(rs.getString("brand")); item.setModel(rs.getString("model")); item.setColor(rs.getString("color")); item.setBuy_date(rs.getString("buy_date")); item.setValid_time(rs.getString("valid_time")); item.setPrice(rs.getString("price")); item.setSupplier(rs.getString("supplier")); item.setSupply_contact(rs.getString("supply_contact")); item.setSupply_telephone(rs.getString("supply_telephone")); item.setMaintain_site(rs.getString("maintain_site")); item.setMaintain_contact(rs.getString("maintain_contact")); item.setMaintain_telephone(rs.getString("maintain_telephone")); item.setPilot(rs.getString("pilot")); item.setMemo(rs.getString("memo")); item.setDiscard_time(rs.getString("discard_time")); item.setStatus(rs.getString("status")); list.add(item); } }catch(SQLException e){ System.out.print(e.toString()); } finally{ DBclose(); } return list; } /** * @author Administrator * @param id: 当前要修改记录的id号 * @return Oa_car_informationItem * @see 取出 oa_car_information 表中的指定id号的一条记录存储在一个 Oa_car_informationItem 对象中 */ public Oa_car_informationItem find(String id){ try { String sql="select a.*,b.name as pilot_name from "+T.OA_CAR_INFORMATION+" as a,"+T.OA_CAR_PILOT+" as b where a.pilot=b.id and a.id="+id; rs = executeQuery(sql); Oa_car_informationItem item=new Oa_car_informationItem(); if(rs.next()){ item.setId(rs.getString("id")); item.setCar_no(rs.getString("car_no")); item.setBrand(rs.getString("brand")); item.setModel(rs.getString("model")); item.setColor(rs.getString("color")); item.setBuy_date(rs.getString("buy_date")); item.setValid_time(rs.getString("valid_time")); item.setPrice(rs.getString("price")); item.setSupplier(rs.getString("supplier")); item.setSupply_contact(rs.getString("supply_contact")); item.setSupply_telephone(rs.getString("supply_telephone")); item.setMaintain_site(rs.getString("maintain_site")); item.setMaintain_contact(rs.getString("maintain_contact")); item.setMaintain_telephone(rs.getString("maintain_telephone")); item.setPilot(rs.getString("pilot")); item.setMemo(rs.getString("memo")); item.setDiscard_time(rs.getString("discard_time")); item.setStatus(rs.getString("status")); Oa_car_pilotItem car_pilotItem=new Oa_car_pilotItem(); car_pilotItem.setName(rs.getString("pilot_name")); item.setOa_car_pilotItem(car_pilotItem); } return item; }catch(SQLException e){ System.out.print(e.toString()); return null; } finally{ DBclose(); } } /** * @author Administrator * @param aItem: 查询的数据对象,page: 翻页时的当前页,pageSize: 翻页的每页显示的记录条数 * @return ArrayList:Oa_car_informationItem 对象的 ArrayList 数组 * @see 查出 oa_car_information 表中的指定数据,页号,页大小的每一条记录存储在一个 Oa_car_informationItem 对象中 */ public List find(Oa_car_informationItem aItem,int page,int pageSize){ int nextPageSize=pageSize*(page-1); ArrayList list=new ArrayList(); try { boolean b=false; StringBuffer filter=new StringBuffer(); String fvalue=null; fvalue=aItem.getCar_no(); if(fvalue!=null && fvalue.length()>0) { if(b) filter.append(" and"); filter.append(" a.car_no like '%"+fvalue+"%' "); b=true; } fvalue=aItem.getBrand(); if(fvalue!=null && fvalue.length()>0) { if(b) filter.append(" and"); filter.append(" a.brand like '%"+fvalue+"%' "); b=true; } fvalue=aItem.getModel(); if(fvalue!=null && fvalue.length()>0) { if(b) filter.append(" and"); filter.append(" a.model like '%"+fvalue+"%' "); b=true; } fvalue=aItem.getColor(); if(fvalue!=null && fvalue.length()>0) { if(b) filter.append(" and"); filter.append(" a.color like '%"+fvalue+"%' "); b=true; } fvalue=aItem.getPrice(); if(fvalue!=null && fvalue.length()>0) { if(b) filter.append(" and"); filter.append(" a.price ="+fvalue+" "); b=true; } fvalue=aItem.getSupplier(); if(fvalue!=null && fvalue.length()>0) { if(b) filter.append(" and"); filter.append(" a.supplier like '%"+fvalue+"%' "); b=true; } fvalue=aItem.getSupply_contact(); if(fvalue!=null && fvalue.length()>0) { if(b) filter.append(" and"); filter.append(" a.supply_contact like '%"+fvalue+"%' "); b=true; } fvalue=aItem.getSupply_telephone(); if(fvalue!=null && fvalue.length()>0) { if(b) filter.append(" and"); filter.append(" a.supply_telephone like '%"+fvalue+"%' "); b=true; } fvalue=aItem.getMaintain_site(); if(fvalue!=null && fvalue.length()>0) { if(b) filter.append(" and"); filter.append(" a.maintain_site like '%"+fvalue+"%' "); b=true; } fvalue=aItem.getMaintain_contact(); if(fvalue!=null && fvalue.length()>0) { if(b) filter.append(" and"); filter.append(" a.maintain_contact like '%"+fvalue+"%' "); b=true; } fvalue=aItem.getMaintain_telephone(); if(fvalue!=null && fvalue.length()>0) { if(b) filter.append(" and"); filter.append(" a.maintain_telephone like '%"+fvalue+"%' "); b=true; } fvalue=aItem.getPilot(); if(fvalue!=null && fvalue.length()>0) { if(b) filter.append(" and"); filter.append(" a.pilot ="+fvalue+" "); b=true; } fvalue=aItem.getMemo(); if(fvalue!=null && fvalue.length()>0) { if(b) filter.append(" and"); filter.append(" a.memo like '%"+fvalue+"%' "); b=true; } fvalue=aItem.getStatus(); if(fvalue!=null && fvalue.length()>0) { if(b) filter.append(" and"); filter.append(" a.status ="+fvalue+" "); b=true; } StringBuffer sql=new StringBuffer(); sql.append(" select top "+pageSize+" a.*,b.name as pilot_name from "+T.OA_CAR_INFORMATION+" as a,"+T.OA_CAR_PILOT+" as b where "); if(b) { sql.append(" "+filter.toString()+" and "); } sql.append(" (a.id not in (SELECT TOP "+Integer.toString(nextPageSize)+" a.id from "+T.OA_CAR_INFORMATION+" as a,"+T.OA_CAR_PILOT+" as b "); if(b) { sql.append(" where "+filter.toString()+" "); } sql.append(" order by a.id desc )) order by a.id desc "); rs = executeQuery(sql.toString()); while(rs.next()){ Oa_car_informationItem item=new Oa_car_informationItem(); item.setId(rs.getString("id")); item.setCar_no(rs.getString("car_no")); item.setBrand(rs.getString("brand")); item.setModel(rs.getString("model")); item.setColor(rs.getString("color")); item.setBuy_date(rs.getString("buy_date")); item.setValid_time(rs.getString("valid_time")); item.setPrice(rs.getString("price")); item.setSupplier(rs.getString("supplier")); item.setSupply_contact(rs.getString("supply_contact")); item.setSupply_telephone(rs.getString("supply_telephone")); item.setMaintain_site(rs.getString("maintain_site")); item.setMaintain_contact(rs.getString("maintain_contact")); item.setMaintain_telephone(rs.getString("maintain_telephone")); item.setPilot(rs.getString("pilot")); item.setMemo(rs.getString("memo")); item.setDiscard_time(rs.getString("discard_time")); item.setStatus(rs.getString("status")); Oa_car_pilotItem car_pilotItem=new Oa_car_pilotItem(); car_pilotItem.setName(rs.getString("pilot_name")); item.setOa_car_pilotItem(car_pilotItem); list.add(item); } String sql1="select count(*) as total from "+T.OA_CAR_INFORMATION+" as a,"+T.OA_CAR_PILOT+" as b "; if(b) sql1+=" where "+filter.toString(); rs = executeQuery(sql1); if(rs.next()){ totalRecord=rs.getInt("total"); } }catch(SQLException e){ System.out.print(e.toString()); } finally{ DBclose(); } return list; } /** * @author Administrator * @param 无
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?