crm_customer_contactbean.java
来自「java开发的办公系统 1.系统管理 (地区管理,部门管理,菜单管理,用户管理」· Java 代码 · 共 1,059 行 · 第 1/3 页
JAVA
1,059 行
* @param 无 * @return KeyId:插入记录时当前记录的id号 * @see 获得插入记录时当前记录的id号 */ public int getKey(){ return keyId; } /** * @author Administrator * @param 无 * @return (totalRecord):插入记录时当前记录的id号 * @see 获得插入记录时当前记录的id号 */ public int getTotalRecord(){ return totalRecord; } /** * @author Administrator * @param item:要添加的数据对象Crm_customer_contactItem * @return boolean:是否添加成功,如果添加成功返回true,否则返回false * @see 添加一条记录 */ public boolean addItem(Crm_customer_contactItem item){ try{ String sql="insert into "+T.CRM_CUSTOMER_CONTACT+"("+ "customer_id,"+ "contact_name,"+ "sex,"+ "department,"+ "duty,"+ "office_telephone,"+ "mobie,"+ "email,"+ "qq,"+ "msm,"+ "skype,"+ "is_main,"+ "introduction,"+ "home_telephone,"+ "born,"+ "idcard,"+ "address,"+ "register_date,"+ "register_username,"+ "register_name,"+ "register_department_id,"+ "register_department_nodepath,"+ "register_department,"+ "register_area_id,"+ "register_area_nodepath,"+ "register_area)values("+ ""+item.getCustomer_id()+","+ "'"+item.getContact_name()+"',"+ ""+item.getSex()+","+ "'"+item.getDepartment()+"',"+ "'"+item.getDuty()+"',"+ "'"+item.getOffice_telephone()+"',"+ "'"+item.getMobie()+"',"+ "'"+item.getEmail()+"',"+ "'"+item.getQq()+"',"+ "'"+item.getMsm()+"',"+ "'"+item.getSkype()+"',"+ ""+item.getIs_main()+","+ "'"+item.getIntroduction()+"',"+ "'"+item.getHome_telephone()+"',"+ "'"+item.getBorn()+"',"+ "'"+item.getIdcard()+"',"+ "'"+item.getAddress()+"',"+ "'"+item.getRegister_date()+"',"+ "'"+item.getRegister_username()+"',"+ "'"+item.getRegister_name()+"',"+ ""+item.getRegister_department_id()+","+ "'"+item.getRegister_department_nodepath()+"',"+ "'"+item.getRegister_department()+"',"+ ""+item.getRegister_area_id()+","+ "'"+item.getRegister_area_nodepath()+"',"+ "'"+item.getRegister_area()+"')"; return executeUpdate(sql); }catch(Exception e){ System.out.println(e.toString()); return false; } finally{ DBclose(); } } /** * @author Administrator * @param item:要添加的数据对象UsersItem * @return keyId:当前添加记录的id号 否则返回 0 * @see 添加一条记录 */ public int addItemAndMaxId(Crm_customer_contactItem item){ try{ String sql="insert into "+T.CRM_CUSTOMER_CONTACT+"("+ "customer_id,"+ "contact_name,"+ "sex,"+ "department,"+ "duty,"+ "office_telephone,"+ "mobie,"+ "email,"+ "qq,"+ "msm,"+ "skype,"+ "is_main,"+ "introduction,"+ "home_telephone,"+ "born,"+ "idcard,"+ "address,"+ "register_date,"+ "register_username,"+ "register_name,"+ "register_department_id,"+ "register_department_nodepath,"+ "register_department,"+ "register_area_id,"+ "register_area_nodepath,"+ "register_area)values("+ ""+item.getCustomer_id()+","+ "'"+item.getContact_name()+"',"+ ""+item.getSex()+","+ "'"+item.getDepartment()+"',"+ "'"+item.getDuty()+"',"+ "'"+item.getOffice_telephone()+"',"+ "'"+item.getMobie()+"',"+ "'"+item.getEmail()+"',"+ "'"+item.getQq()+"',"+ "'"+item.getMsm()+"',"+ "'"+item.getSkype()+"',"+ ""+item.getIs_main()+","+ "'"+item.getIntroduction()+"',"+ "'"+item.getHome_telephone()+"',"+ "'"+item.getBorn()+"',"+ "'"+item.getIdcard()+"',"+ "'"+item.getAddress()+"',"+ "'"+item.getRegister_date()+"',"+ "'"+item.getRegister_username()+"',"+ "'"+item.getRegister_name()+"',"+ ""+item.getRegister_department_id()+","+ "'"+item.getRegister_department_nodepath()+"',"+ "'"+item.getRegister_department()+"',"+ ""+item.getRegister_area_id()+","+ "'"+item.getRegister_area_nodepath()+"',"+ "'"+item.getRegister_area()+"')"; executeUpdate(sql); sql = "select max(id) as id from "+T.CRM_CUSTOMER_CONTACT; rs = executeQuery(sql); if (rs.next()) { keyId = rs.getInt("id"); return keyId; } else return 0; }catch(SQLException e){ System.out.println(e.toString()); return 0; } finally{ DBclose(); } } /** * @author Administrator * @param item:要修改的数据对象Crm_customer_contactItem * @return boolean:如果修改成功返回true,否则返回false * @see 修改一条记录 */ public boolean updateItem(Crm_customer_contactItem item){ try{ String sql="update "+T.CRM_CUSTOMER_CONTACT+" set "+ "customer_id="+item.getCustomer_id()+","+ "contact_name='"+item.getContact_name()+"',"+ "sex="+item.getSex()+","+ "department='"+item.getDepartment()+"',"+ "duty='"+item.getDuty()+"',"+ "office_telephone='"+item.getOffice_telephone()+"',"+ "mobie='"+item.getMobie()+"',"+ "email='"+item.getEmail()+"',"+ "qq='"+item.getQq()+"',"+ "msm='"+item.getMsm()+"',"+ "skype='"+item.getSkype()+"',"+ "is_main="+item.getIs_main()+","+ "introduction='"+item.getIntroduction()+"',"+ "home_telephone='"+item.getHome_telephone()+"',"+ "born='"+item.getBorn()+"',"+ "idcard='"+item.getIdcard()+"',"+ "address='"+item.getAddress()+"',"+ "register_area='"+item.getRegister_area()+"' where id="+item.getId(); return executeUpdate(sql); }catch(Exception e){ System.out.println(e.toString()); return false; } finally{ DBclose(); } } /** * @author Administrator * @param item:要修改的数据对象Crm_customer_contactItem * @return boolean:如果修改成功返回true,否则返回false * @see 修改一条记录 */ public boolean updateItemNoFile(Crm_customer_contactItem item){ try{ String sql="update "+T.CRM_CUSTOMER_CONTACT+" set "+ "customer_id="+item.getCustomer_id()+","+ "contact_name='"+item.getContact_name()+"',"+ "sex="+item.getSex()+","+ "department='"+item.getDepartment()+"',"+ "duty='"+item.getDuty()+"',"+ "office_telephone='"+item.getOffice_telephone()+"',"+ "mobie='"+item.getMobie()+"',"+ "email='"+item.getEmail()+"',"+ "qq='"+item.getQq()+"',"+ "msm='"+item.getMsm()+"',"+ "skype='"+item.getSkype()+"',"+ "is_main="+item.getIs_main()+","+ "introduction='"+item.getIntroduction()+"',"+ "home_telephone='"+item.getHome_telephone()+"',"+ "born='"+item.getBorn()+"',"+ "idcard='"+item.getIdcard()+"',"+ "address='"+item.getAddress()+"',"+ "register_area='"+item.getRegister_area()+"' where id="+item.getId(); return executeUpdate(sql); }catch(Exception e){ System.out.println(e.toString()); return false; } finally{ DBclose(); } } /** * @author Administrator * @param item:要删除的数据对象Crm_customer_contactItem * @return boolean:如果删除成功返回true,否则返回false * @see 删除一条记录 */ public boolean removeItem(Crm_customer_contactItem item){ try{ String sql="delete from "+T.CRM_CUSTOMER_CONTACT+" where id="+item.getId() ; return executeUpdate(sql); }catch(Exception e){ System.out.println(e.toString()); return false; } finally{ DBclose(); } } /** * @author Administrator * @param ids:要删除的记录的ids数组 * @return boolean:如果删除成功返回true,否则返回false * @see 批量删除条记录 */ public int removeItems(String[] ids) { int flag=1; try{ //判断是否存在联系人 String sql1 = "select count(*) as num from "+T.CRM_PROJECT_INFO+" where customer_contact_id in ("; String sql="delete from "+T.CRM_CUSTOMER_CONTACT+" where id in ("; String filter=""; for(int i=0;i<ids.length-1;i++){ filter+=ids[i]+","; } filter+=ids[ids.length-1]+")"; sql+=filter; sql1+=filter; rs = executeQuery(sql1); if (rs.next()&&rs.getInt("num")>0) { flag=2; } if(flag==1) { flag=3; executeUpdate(sql); } }catch(Exception e){ System.out.println(e.toString()); } finally{ DBclose(); } return flag; } /** * @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 + -
显示快捷键?