crm_project_contractbean.java

来自「java开发的办公系统 1.系统管理 (地区管理,部门管理,菜单管理,用户管理」· Java 代码 · 共 600 行 · 第 1/2 页

JAVA
600
字号
package com.vere.crm.project.bean;	import java.sql.*;	import java.util.*;	import com.vere.db.*;	import com.vere.crm.customer.item.*;	import com.vere.crm.project.item.*;	public class Crm_project_contractBean	{		private ResultSet rs=null;		private int keyId;		private int totalRecord;		private Access access = null;		public Crm_project_contractBean()		{			try {				access=new Access();			}			catch(Exception e) {				System.out.println(e.toString());			}		}		/**		 * @author	Administrator		 * @param	无		 * @return	ArrayList:Crm_project_contractItem 对象的 ArrayList 数组		 * @see		取出 crm_project_contract 表中的所有记录,每一条记录存储在一个 Crm_project_contractItem 对象中		 */		public List find(){			ArrayList list=new ArrayList();			try {				String sql="select * from "+T.CRM_PROJECT_CONTRACT;				rs = executeQuery(sql);				while(rs.next()){					Crm_project_contractItem item=new Crm_project_contractItem();					item.setId(rs.getString("id"));					item.setCrm_project_info_id(rs.getString("crm_project_info_id"));					item.setCustomer_id(rs.getString("customer_id"));					item.setCustomer_contact_id(rs.getString("customer_contact_id"));					item.setContact_type(rs.getString("contact_type"));					item.setSupply_company(rs.getString("supply_company"));					item.setSupply_name(rs.getString("supply_name"));					item.setSign_date(rs.getString("sign_date"));					item.setEnd_date(rs.getString("end_date"));					item.setMaintain_start_date(rs.getString("maintain_start_date"));					item.setMaintain_end_date(rs.getString("maintain_end_date"));					item.setSign_address(rs.getString("sign_address"));					item.setContact_doc(rs.getString("contact_doc"));					item.setMemo(rs.getString("memo"));					list.add(item);				}			}catch(SQLException e){				System.out.print(e.toString());			}			finally{				DBclose();			}			return list;		}		/**		 * @author	Administrator		 * @param	无		 * @return	ArrayList:Crm_project_contractItem 对象的 ArrayList 数组		 * @see		取出 crm_project_contract 表中的所有记录,每一条记录存储在一个 Crm_project_contractItem 对象中		 */		public List findByIds(String ids){			ArrayList list=new ArrayList();			try {				String sql="select * from "+T.CRM_PROJECT_CONTRACT+" where id in ("+ids+")";				rs = executeQuery(sql);				while(rs.next()){					Crm_project_contractItem item=new Crm_project_contractItem();					item.setId(rs.getString("id"));					item.setCrm_project_info_id(rs.getString("crm_project_info_id"));					item.setCustomer_id(rs.getString("customer_id"));					item.setCustomer_contact_id(rs.getString("customer_contact_id"));					item.setContact_type(rs.getString("contact_type"));					item.setSupply_company(rs.getString("supply_company"));					item.setSupply_name(rs.getString("supply_name"));					item.setSign_date(rs.getString("sign_date"));					item.setEnd_date(rs.getString("end_date"));					item.setMaintain_start_date(rs.getString("maintain_start_date"));					item.setMaintain_end_date(rs.getString("maintain_end_date"));					item.setSign_address(rs.getString("sign_address"));					item.setContact_doc(rs.getString("contact_doc"));					item.setMemo(rs.getString("memo"));					list.add(item);				}			}catch(SQLException e){				System.out.print(e.toString());			}			finally{				DBclose();			}			return list;		}		/**		 * @author	Administrator		 * @param	id: 当前要修改记录的id号		 * @return	Crm_project_contractItem		 * @see		取出 crm_project_contract 表中的指定id号的一条记录存储在一个 Crm_project_contractItem 对象中		 */		public Crm_project_contractItem find(String crm_project_info_id){			try {				String sql="select  "+T.CRM_PROJECT_CONTRACT+".* ,"+T.CRM_PROJECT_INFO+".project_name as  "+T.CRM_PROJECT_INFO+"_project_name ,"+T.CRM_CUSTOMER_INFO+".customer_name as  "+T.CRM_CUSTOMER_INFO+"_customer_name,"+T.CRM_CUSTOMER_INFO+".id as  "+T.CRM_CUSTOMER_INFO+"_customer_id ,"+T.CRM_CUSTOMER_CONTACT+".contact_name as  "+T.CRM_CUSTOMER_CONTACT+"_contact_name   from   "+T.CRM_PROJECT_CONTRACT+" ,"+T.CRM_PROJECT_INFO+" ,"+T.CRM_CUSTOMER_INFO+" ,"+T.CRM_CUSTOMER_CONTACT+"  where "+T.CRM_PROJECT_CONTRACT+".crm_project_info_id = "+T.CRM_PROJECT_INFO+".id  and "+T.CRM_PROJECT_INFO+".customer_id = "+T.CRM_CUSTOMER_INFO+".id  and "+T.CRM_PROJECT_INFO+".customer_contact_id = "+T.CRM_CUSTOMER_CONTACT+".id    and   "+T.CRM_PROJECT_CONTRACT+".crm_project_info_id="+crm_project_info_id;				rs = executeQuery(sql);				Crm_project_contractItem item=new Crm_project_contractItem();				if(rs.next()){					item.setId(rs.getString("id"));					item.setCrm_project_info_id(rs.getString("crm_project_info_id"));					item.setCustomer_id(rs.getString("customer_id"));					item.setCustomer_contact_id(rs.getString("customer_contact_id"));					item.setContact_type(rs.getString("contact_type"));					item.setSupply_company(rs.getString("supply_company"));					item.setSupply_name(rs.getString("supply_name"));					item.setSign_date(rs.getString("sign_date"));					item.setEnd_date(rs.getString("end_date"));					item.setMaintain_start_date(rs.getString("maintain_start_date"));					item.setMaintain_end_date(rs.getString("maintain_end_date"));					item.setSign_address(rs.getString("sign_address"));					item.setContact_doc(rs.getString("contact_doc"));					item.setMemo(rs.getString("memo"));					Crm_project_infoItem crm_project_infoItem=new Crm_project_infoItem();					crm_project_infoItem.setProject_name(rs.getString(T.CRM_PROJECT_INFO+"_project_name"));					item.setCrm_project_infoItem(crm_project_infoItem);					Crm_customer_infoItem crm_customer_infoItem=new Crm_customer_infoItem();					crm_customer_infoItem.setCustomer_name(rs.getString(T.CRM_CUSTOMER_INFO+"_customer_name"));					crm_customer_infoItem.setId(rs.getString(T.CRM_CUSTOMER_INFO+"_customer_id"));					item.setCrm_customer_infoItem(crm_customer_infoItem);					Crm_customer_contactItem crm_customer_contactItem=new Crm_customer_contactItem();					crm_customer_contactItem.setContact_name(rs.getString(T.CRM_CUSTOMER_CONTACT+"_contact_name"));					item.setCrm_customer_contactItem(crm_customer_contactItem);				}				return item;			}catch(SQLException e){				System.out.print(e.toString());				return null;			}			finally{				DBclose();			}		}		/**		 * @author	Administrator		 * @param	aItem: 查询的数据对象,page: 翻页时的当前页,pageSize: 翻页的每页显示的记录条数		 * @return	ArrayList:Crm_project_contractItem 对象的 ArrayList 数组		 * @see		查出 crm_project_contract 表中的指定数据,页号,页大小的每一条记录存储在一个 Crm_project_contractItem 对象中		 */		public List find(Crm_project_contractItem 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.getCrm_project_info_id();				if(fvalue!=null &&   fvalue.length()>0)				{					if(b) filter.append(" and");					filter.append(" "+T.CRM_PROJECT_CONTRACT+".crm_project_info_id ="+fvalue+" ");					b=true;				}				fvalue=aItem.getCustomer_id();				if(fvalue!=null &&   fvalue.length()>0)				{					if(b) filter.append(" and");					filter.append(" "+T.CRM_PROJECT_CONTRACT+".customer_id ="+fvalue+" ");					b=true;				}				fvalue=aItem.getCustomer_contact_id();				if(fvalue!=null &&   fvalue.length()>0)				{					if(b) filter.append(" and");					filter.append(" "+T.CRM_PROJECT_CONTRACT+".customer_contact_id ="+fvalue+" ");					b=true;				}				fvalue=aItem.getContact_type();				if(fvalue!=null &&   fvalue.length()>0)				{					if(b) filter.append(" and");					filter.append(" "+T.CRM_PROJECT_CONTRACT+".contact_type ="+fvalue+" ");					b=true;				}				fvalue=aItem.getSupply_company();				if(fvalue!=null &&   fvalue.length()>0)				{					if(b) filter.append(" and");					filter.append(" "+T.CRM_PROJECT_CONTRACT+".supply_company like '%"+fvalue+"%' ");					b=true;				}				fvalue=aItem.getSupply_name();				if(fvalue!=null &&   fvalue.length()>0)				{					if(b) filter.append(" and");					filter.append(" "+T.CRM_PROJECT_CONTRACT+".supply_name like '%"+fvalue+"%' ");					b=true;				}				fvalue=aItem.getSign_date();				if(fvalue!=null &&   fvalue.length()>0)				{					if(b) filter.append(" and");					filter.append(" DATEDIFF(day,"+T.CRM_PROJECT_CONTRACT+".sign_date,'"+fvalue+"')=0 ");					b=true;				}				fvalue=aItem.getEnd_date();				if(fvalue!=null &&   fvalue.length()>0)				{					if(b) filter.append(" and");					filter.append(" DATEDIFF(day,"+T.CRM_PROJECT_CONTRACT+".end_date,'"+fvalue+"')=0 ");					b=true;				}				fvalue=aItem.getMaintain_start_date();				if(fvalue!=null &&   fvalue.length()>0)				{					if(b) filter.append(" and");					filter.append(" DATEDIFF(day,"+T.CRM_PROJECT_CONTRACT+".maintain_start_date,'"+fvalue+"')=0 ");					b=true;				}				fvalue=aItem.getMaintain_end_date();				if(fvalue!=null &&   fvalue.length()>0)				{					if(b) filter.append(" and");					filter.append(" DATEDIFF(day,"+T.CRM_PROJECT_CONTRACT+".maintain_end_date,'"+fvalue+"')=0 ");					b=true;				}				fvalue=aItem.getSign_address();				if(fvalue!=null &&   fvalue.length()>0)				{					if(b) filter.append(" and");					filter.append(" "+T.CRM_PROJECT_CONTRACT+".sign_address like '%"+fvalue+"%' ");					b=true;				}				fvalue=aItem.getContact_doc();				if(fvalue!=null &&   fvalue.length()>0)				{					if(b) filter.append(" and");					filter.append(" "+T.CRM_PROJECT_CONTRACT+".contact_doc like '%"+fvalue+"%' ");					b=true;				}				fvalue=aItem.getMemo();				if(fvalue!=null &&   fvalue.length()>0)				{					if(b) filter.append(" and");					filter.append(" "+T.CRM_PROJECT_CONTRACT+".memo like '%"+fvalue+"%' ");					b=true;				}				fvalue="has_link_table";				if(fvalue!=null &&   fvalue.length()>0)				{					if(b) filter.append(" and");					filter.append(" "+T.CRM_PROJECT_CONTRACT+".crm_project_info_id = "+T.CRM_PROJECT_INFO+".id  and ");					filter.append(" "+T.CRM_PROJECT_CONTRACT+".customer_id = "+T.CRM_CUSTOMER_INFO+".id  and ");					filter.append(" "+T.CRM_PROJECT_CONTRACT+".customer_contact_id = "+T.CRM_CUSTOMER_CONTACT+".id  and ");					filter.append(" "+T.CRM_PROJECT_CONTRACT+".contact_type =  contact_type_dictionary.code and  ");					filter.append(" contact_type_dictionary.num = 26   ");					b=true;				}				StringBuffer sql=new StringBuffer();				sql.append(" select top "+pageSize+"  "+T.CRM_PROJECT_CONTRACT+".* ,"+T.CRM_PROJECT_INFO+".project_name as  "+T.CRM_PROJECT_INFO+"_project_name ,"+T.CRM_CUSTOMER_INFO+".customer_name as  "+T.CRM_CUSTOMER_INFO+"_customer_name ,"+T.CRM_CUSTOMER_CONTACT+".contact_name as  "+T.CRM_CUSTOMER_CONTACT+"_contact_name ,contact_type_dictionary.code_name as  contact_type_dictionaryname  from   "+T.CRM_PROJECT_CONTRACT+" ,"+T.CRM_PROJECT_INFO+" ,"+T.CRM_CUSTOMER_INFO+" ,"+T.CRM_CUSTOMER_CONTACT+" ,"+T.OA_DICTIONARY+"  as  contact_type_dictionary   where ");				if(b)				{					sql.append("  "+filter.toString()+" and ");				}				sql.append("  ("+T.CRM_PROJECT_CONTRACT+".id not in (SELECT TOP "+Integer.toString(nextPageSize)+" "+T.CRM_PROJECT_CONTRACT+".id from   "+T.CRM_PROJECT_CONTRACT+" ,"+T.CRM_PROJECT_INFO+" ,"+T.CRM_CUSTOMER_INFO+" ,"+T.CRM_CUSTOMER_CONTACT+" ,"+T.OA_DICTIONARY+"  as  contact_type_dictionary  ");				if(b)				{					sql.append(" where "+filter.toString()+"  ");				}				sql.append(" order by "+T.CRM_PROJECT_CONTRACT+".id desc  ))  order by "+T.CRM_PROJECT_CONTRACT+".id desc ");				rs = executeQuery(sql.toString());				while(rs.next()){					Crm_project_contractItem item=new Crm_project_contractItem();					item.setId(rs.getString("id"));					item.setCrm_project_info_id(rs.getString("crm_project_info_id"));					item.setCustomer_id(rs.getString("customer_id"));					item.setCustomer_contact_id(rs.getString("customer_contact_id"));					item.setContact_type(rs.getString("contact_type"));					item.setSupply_company(rs.getString("supply_company"));					item.setSupply_name(rs.getString("supply_name"));					item.setSign_date(rs.getString("sign_date"));					item.setEnd_date(rs.getString("end_date"));					item.setMaintain_start_date(rs.getString("maintain_start_date"));					item.setMaintain_end_date(rs.getString("maintain_end_date"));					item.setSign_address(rs.getString("sign_address"));					item.setContact_doc(rs.getString("contact_doc"));					item.setMemo(rs.getString("memo"));					Crm_project_infoItem crm_project_infoItem=new Crm_project_infoItem();					crm_project_infoItem.setProject_name(rs.getString(T.CRM_PROJECT_INFO+"_project_name"));					item.setCrm_project_infoItem(crm_project_infoItem);					Crm_customer_infoItem crm_customer_infoItem=new Crm_customer_infoItem();					crm_customer_infoItem.setCustomer_name(rs.getString(T.CRM_CUSTOMER_INFO+"_customer_name"));					item.setCrm_customer_infoItem(crm_customer_infoItem);					Crm_customer_contactItem crm_customer_contactItem=new Crm_customer_contactItem();					crm_customer_contactItem.setContact_name(rs.getString(T.CRM_CUSTOMER_CONTACT+"_contact_name"));

⌨️ 快捷键说明

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