package com.tenwa.customer.handler.stockholder; import com.amarsoft.are.jbo.BizObject; import jbo.app.tenwa.customer.CUSTOMER_STOCKHOLDER; import com.amarsoft.are.jbo.BizObjectManager; import com.amarsoft.are.jbo.JBOFactory; import com.amarsoft.are.jbo.JBOTransaction; import com.amarsoft.awe.dw.handler.impl.CommonHandler; public class CustomerStockholder extends CommonHandler { @Override protected void initDisplayForAdd(BizObject bo) throws Exception { String customerId=this.asPage.getParameter("customerId"); bo.setAttributeValue("CUSTOMERID", customerId); super.initDisplayForAdd(bo); } @Override protected void initDisplayForEdit(BizObject bo) throws Exception { super.initDisplayForEdit(bo); } @Override protected void beforeInsert(JBOTransaction tx, BizObject bo) throws Exception { double OUGHTSUM=bo.getAttribute("OUGHTSUM").getDouble(); double INVESTMENTSUM=bo.getAttribute("INVESTMENTSUM").getDouble(); if(OUGHTSUM==0.0) bo.setAttributeValue("OUGHTSUM",null ); if(INVESTMENTSUM==0.0) bo.setAttributeValue("INVESTMENTSUM",null ); } @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_STOCKHOLDER.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_STOCKHOLDER.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); } }