crm_project_spacebean.java

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

JAVA
149
字号
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_spaceBean	{		private ResultSet rs=null;		private int keyId;		private int totalRecord;		private Access access = null;		public Crm_project_spaceBean()		{			try {				access=new Access();			}			catch(Exception e) {				System.out.println(e.toString());			}		}				/**		 * @author	Administrator		 * @param	id: 当前要修改记录的id号		 * @return	Crm_project_spaceItem		 * @see		取出 crm_project_space 表中的指定id号的一条记录存储在一个 Crm_project_spaceItem 对象中		 */		public Crm_project_spaceItem find(String crm_project_info_id){			try {				String sql="select  "+T.CRM_PROJECT_SPACE+".* ,"+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 ,"+T.CRM_CUSTOMER_CONTACT+".id as  "+T.CRM_CUSTOMER_CONTACT+"_contact_id from   "+T.CRM_PROJECT_INFO+" ,"+T.CRM_CUSTOMER_INFO+" ,"+T.CRM_CUSTOMER_CONTACT+","+T.CRM_PROJECT_SPACE+"  where  "+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_SPACE+".crm_project_info_id="+T.CRM_PROJECT_INFO+".id and "+T.CRM_PROJECT_SPACE+".crm_project_info_id="+crm_project_info_id;				rs = executeQuery(sql);				Crm_project_spaceItem item=new Crm_project_spaceItem();				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.setTest_address(rs.getString("test_address"));					item.setTest_space(rs.getString("test_space"));					item.setOnline_address(rs.getString("online_address"));					item.setOnline_space(rs.getString("online_space"));					Crm_project_infoItem crm_project_infoItem=new Crm_project_infoItem();					crm_project_infoItem.setProject_name(rs.getString("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"));					crm_customer_contactItem.setId(rs.getString(T.CRM_CUSTOMER_CONTACT+"_contact_id"));					item.setCrm_customer_contactItem(crm_customer_contactItem);				}				return item;			}catch(SQLException e){				System.out.print(e.toString());				return null;			}			finally{				DBclose();			}		}				/**		 * @author	Administrator		 * @param	item:要修改的数据对象Crm_project_spaceItem		 * @return	boolean:如果修改成功返回true,否则返回false		 * @see		修改一条记录		 */		public boolean updateItem(Crm_project_spaceItem item){			try{				String sql="update "+T.CRM_PROJECT_SPACE+" set "+							"crm_project_info_id="+item.getCrm_project_info_id()+","+							"crm_customer_id="+item.getCrm_customer_id()+","+							"crm_customer_contact_id="+item.getCrm_customer_contact_id()+","+							"test_address='"+item.getTest_address()+"',"+							"test_space='"+item.getTest_space()+"',"+							"online_address='"+item.getOnline_address()+"',"+		   	 			   	"online_space='"+item.getOnline_space()+"' where crm_project_info_id="+item.getCrm_project_info_id();				return executeUpdate(sql);			}catch(Exception e){				System.out.println(e.toString());				return false;			}			finally{				DBclose();			}		}				/**		 * @author	Administrator		 * @param	sql:要更新的sql 语句		 * @return	boolean:如果执行成功返回true,否则返回false		 * @see		执行更新一条sql 语句		 */		public boolean executeUpdate(String sql){			try{				access.getConnection();				return access.executeUpdate(sql);			}			catch(Exception e){				System.out.println(e.toString());				return false;			}		}		/**		 * @author	Administrator		 * @param	sql:要查询的sql 语句		 * @return	boolean:如果执行成功返回true,否则返回false		 * @see		执行查询一条sql 语句		 */		public ResultSet executeQuery(String sql){			try			{				access.getConnection();				rs=access.executeQuery(sql);				return rs;			}			catch(Exception e){				System.out.println(e.toString());				return null;			}		}		/**		 * @author	Administrator		 * @param	无		 * @return	无		 * @see		关闭数据库操作对象		 */		public void DBclose(){			try {				access.DBclose(rs);			}			catch(Exception e) {				System.out.println(e.toString());			}		}}

⌨️ 快捷键说明

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