crm_project_reportbean.java

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

JAVA
511
字号
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_reportBean	{		private ResultSet rs=null;		private int keyId;		private int totalRecord;		private Access access = null;		public Crm_project_reportBean()		{			try {				access=new Access();			}			catch(Exception e) {				System.out.println(e.toString());			}		}		/**		 * @author	Administrator		 * @param	无		 * @return	ArrayList:Crm_project_reportItem 对象的 ArrayList 数组		 * @see		取出 crm_project_report 表中的所有记录,每一条记录存储在一个 Crm_project_reportItem 对象中		 */		public List find(){			ArrayList list=new ArrayList();			try {				String sql="select * from "+T.CRM_PROJECT_REPORT;				rs = executeQuery(sql);				while(rs.next()){					Crm_project_reportItem item=new Crm_project_reportItem();					item.setId(rs.getString("id"));					item.setCrm_project_info_id(rs.getString("crm_project_info_id"));					item.setCrm_customer_id(rs.getString("crm_customer_id"));					item.setCrm_customer_contact_id(rs.getString("crm_customer_contact_id"));					item.setReport_date(rs.getString("report_date"));					item.setReport_people(rs.getString("report_people"));					item.setDepartment(rs.getString("department"));					item.setFinish_info(rs.getString("finish_info"));					item.setDifficult_info(rs.getString("difficult_info"));					list.add(item);				}			}catch(SQLException e){				System.out.print(e.toString());			}			finally{				DBclose();			}			return list;		}		/**		 * @author	Administrator		 * @param	无		 * @return	ArrayList:Crm_project_reportItem 对象的 ArrayList 数组		 * @see		取出 crm_project_report 表中的所有记录,每一条记录存储在一个 Crm_project_reportItem 对象中		 */		public List findByIds(String ids){			ArrayList list=new ArrayList();			try {				String sql="select * from "+T.CRM_PROJECT_REPORT+" where id in ("+ids+")";				rs = executeQuery(sql);				while(rs.next()){					Crm_project_reportItem item=new Crm_project_reportItem();					item.setId(rs.getString("id"));					item.setCrm_project_info_id(rs.getString("crm_project_info_id"));					item.setCrm_customer_id(rs.getString("crm_customer_id"));					item.setCrm_customer_contact_id(rs.getString("crm_customer_contact_id"));					item.setReport_date(rs.getString("report_date"));					item.setReport_people(rs.getString("report_people"));					item.setDepartment(rs.getString("department"));					item.setFinish_info(rs.getString("finish_info"));					item.setDifficult_info(rs.getString("difficult_info"));					list.add(item);				}			}catch(SQLException e){				System.out.print(e.toString());			}			finally{				DBclose();			}			return list;		}		/**		 * @author	Administrator		 * @param	id: 当前要修改记录的id号		 * @return	Crm_project_reportItem		 * @see		取出 crm_project_report 表中的指定id号的一条记录存储在一个 Crm_project_reportItem 对象中		 */		public Crm_project_reportItem find(String id){			try {				String sql="select  "+T.CRM_PROJECT_REPORT+".* ,"+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  from   "+T.CRM_PROJECT_REPORT+" ,"+T.CRM_PROJECT_INFO+" ,"+T.CRM_CUSTOMER_INFO+" ,"+T.CRM_CUSTOMER_CONTACT+"  where "+T.CRM_PROJECT_REPORT+".crm_project_info_id = "+T.CRM_PROJECT_INFO+".id  and "+T.CRM_PROJECT_REPORT+".crm_customer_id = "+T.CRM_CUSTOMER_INFO+".id  and "+T.CRM_PROJECT_REPORT+".crm_customer_contact_id = "+T.CRM_CUSTOMER_CONTACT+".id  and   "+T.CRM_PROJECT_REPORT+".id="+id;				rs = executeQuery(sql);				Crm_project_reportItem item=new Crm_project_reportItem();				if(rs.next()){					item.setId(rs.getString("id"));					item.setCrm_project_info_id(rs.getString("crm_project_info_id"));					item.setCrm_customer_id(rs.getString("crm_customer_id"));					item.setCrm_customer_contact_id(rs.getString("crm_customer_contact_id"));					item.setReport_date(rs.getString("report_date"));					item.setReport_people(rs.getString("report_people"));					item.setDepartment(rs.getString("department"));					item.setFinish_info(rs.getString("finish_info"));					item.setDifficult_info(rs.getString("difficult_info"));					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"));					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_reportItem 对象的 ArrayList 数组		 * @see		查出 crm_project_report 表中的指定数据,页号,页大小的每一条记录存储在一个 Crm_project_reportItem 对象中		 */		public List find(Crm_project_reportItem 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_REPORT+".crm_project_info_id ="+fvalue+" ");					b=true;				}				fvalue=aItem.getCrm_customer_id();				if(fvalue!=null &&   fvalue.length()>0)				{					if(b) filter.append(" and");					filter.append(" "+T.CRM_PROJECT_REPORT+".crm_customer_id ="+fvalue+" ");					b=true;				}				fvalue=aItem.getCrm_customer_contact_id();				if(fvalue!=null &&   fvalue.length()>0)				{					if(b) filter.append(" and");					filter.append(" "+T.CRM_PROJECT_REPORT+".crm_customer_contact_id ="+fvalue+" ");					b=true;				}				fvalue=aItem.getReport_date();				if(fvalue!=null &&   fvalue.length()>0)				{					if(b) filter.append(" and");					filter.append(" DATEDIFF(day,"+T.CRM_PROJECT_REPORT+".report_date,'"+fvalue+"')=0 ");					b=true;				}				fvalue=aItem.getReport_people();				if(fvalue!=null &&   fvalue.length()>0)				{					if(b) filter.append(" and");					filter.append(" "+T.CRM_PROJECT_REPORT+".report_people like '%"+fvalue+"%' ");					b=true;				}				fvalue=aItem.getDepartment();				if(fvalue!=null &&   fvalue.length()>0)				{					if(b) filter.append(" and");					filter.append(" "+T.CRM_PROJECT_REPORT+".department like '%"+fvalue+"%' ");					b=true;				}				fvalue=aItem.getFinish_info();				if(fvalue!=null &&   fvalue.length()>0)				{					if(b) filter.append(" and");					filter.append(" "+T.CRM_PROJECT_REPORT+".finish_info like '%"+fvalue+"%' ");					b=true;				}				fvalue=aItem.getDifficult_info();				if(fvalue!=null &&   fvalue.length()>0)				{					if(b) filter.append(" and");					filter.append(" "+T.CRM_PROJECT_REPORT+".difficult_info like '%"+fvalue+"%' ");					b=true;				}				fvalue="has_link_table";				if(fvalue!=null &&   fvalue.length()>0)				{					if(b) filter.append(" and");					filter.append(" "+T.CRM_PROJECT_REPORT+".crm_project_info_id = "+T.CRM_PROJECT_INFO+".id  and ");					filter.append(" "+T.CRM_PROJECT_REPORT+".crm_customer_id = "+T.CRM_CUSTOMER_INFO+".id  and ");					filter.append(" "+T.CRM_PROJECT_REPORT+".crm_customer_contact_id = "+T.CRM_CUSTOMER_CONTACT+".id   ");					b=true;				}				StringBuffer sql=new StringBuffer();				sql.append(" select top "+pageSize+"  "+T.CRM_PROJECT_REPORT+".* ,"+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  from   "+T.CRM_PROJECT_REPORT+" ,"+T.CRM_PROJECT_INFO+" ,"+T.CRM_CUSTOMER_INFO+" ,"+T.CRM_CUSTOMER_CONTACT+"   where ");				if(b)				{					sql.append("  "+filter.toString()+" and ");				}				sql.append("  ("+T.CRM_PROJECT_REPORT+".id not in (SELECT TOP "+Integer.toString(nextPageSize)+" "+T.CRM_PROJECT_REPORT+".id from   "+T.CRM_PROJECT_REPORT+" ,"+T.CRM_PROJECT_INFO+" ,"+T.CRM_CUSTOMER_INFO+" ,"+T.CRM_CUSTOMER_CONTACT+"  ");				if(b)				{					sql.append(" where "+filter.toString()+"  ");				}				sql.append(" order by "+T.CRM_PROJECT_REPORT+".id desc  ))  order by "+T.CRM_PROJECT_REPORT+".id desc ");				rs = executeQuery(sql.toString());				while(rs.next()){					Crm_project_reportItem item=new Crm_project_reportItem();					item.setId(rs.getString("id"));					item.setCrm_project_info_id(rs.getString("crm_project_info_id"));					item.setCrm_customer_id(rs.getString("crm_customer_id"));					item.setCrm_customer_contact_id(rs.getString("crm_customer_contact_id"));					item.setReport_date(rs.getString("report_date"));					item.setReport_people(rs.getString("report_people"));					item.setDepartment(rs.getString("department"));					item.setFinish_info(rs.getString("finish_info"));					item.setDifficult_info(rs.getString("difficult_info"));					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"));					item.setCrm_customer_contactItem(crm_customer_contactItem);					list.add(item);				}				String sql1="select count(*) as total from   "+T.CRM_PROJECT_REPORT+" ,"+T.CRM_PROJECT_INFO+" ,"+T.CRM_CUSTOMER_INFO+" ,"+T.CRM_CUSTOMER_CONTACT+"  ";				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{

⌨️ 快捷键说明

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