package com.tenwa.customer.handler.RelatedParty; import jbo.app.tenwa.customer.CUSTOMER_RELATEDPARTY; import jbo.app.tenwa.customer.CUSTOMER_STOCKHOLDER; import com.amarsoft.are.jbo.BizObject; import com.amarsoft.are.jbo.BizObjectManager; import com.amarsoft.are.jbo.BizObjectQuery; import com.amarsoft.are.jbo.JBOFactory; import com.amarsoft.are.jbo.JBOTransaction; import com.amarsoft.awe.dw.handler.impl.CommonHandler; public class CustomerRelatedPartyHandler extends CommonHandler{ @Override protected void initDisplayForAdd(BizObject bo) throws Exception { //获取当前客户ID String customerId=this.asPage.getAttribute("customerId").toString(); bo.setAttributeValue("customerid",customerId); super.initDisplayForAdd(bo); } @Override protected boolean validityCheck(BizObject bo, boolean isInsert) { try { String oldcerttype=""; String oldcertid=""; String customerId=this.asPage.getParameter("customerId"); //查询证件是否存在股东信息表中 String certtype=bo.getAttribute("CERTTYPE").toString(); String id=bo.getAttribute("id").toString(); String certid=bo.getAttribute("CERTID").toString(); if(!("".equals(id))){ BizObjectManager oldbom=JBOFactory.getBizObjectManager(CUSTOMER_RELATEDPARTY.CLASS_NAME); BizObject oldbo1=oldbom.createQuery("id=:id").setParameter("id", id).getSingleResult(false); oldcerttype=oldbo1.getAttribute("CERTTYPE").toString(); oldcertid=oldbo1.getAttribute("certid").toString(); } if(!(certtype.equals(oldcerttype)&&certid.equals(oldcertid))){ BizObjectManager bom=JBOFactory.getBizObjectManager(CUSTOMER_RELATEDPARTY.CLASS_NAME); BizObject bo1=bom.createQuery("CERTTYPE=:CERTTYPE and CERTID=:CERTID and CUSTOMERID=:CUSTOMERID").setParameter("CERTTYPE", certtype) .setParameter("CERTID", certid).setParameter("CUSTOMERID", customerId).getSingleResult(false); if(bo1!=null){ this.errors="该类型证件号已经存在"; return false; } } } catch (Exception e) { // TODO: handle exception } return super.validityCheck(bo, isInsert); } }