54 lines
1.9 KiB
Java
54 lines
1.9 KiB
Java
package com.tenwa.customer.handler.group;
|
|
import jbo.app.tenwa.customer.CUSTOMER_GROUP_RELATION;
|
|
|
|
import com.amarsoft.are.jbo.BizObject;
|
|
import com.amarsoft.are.jbo.BizObjectManager;
|
|
import com.amarsoft.are.jbo.JBOException;
|
|
import com.amarsoft.are.jbo.JBOFactory;
|
|
import com.amarsoft.awe.dw.handler.impl.CommonHandler;
|
|
public class CustomerGroupRelationHandler extends CommonHandler{
|
|
@Override
|
|
protected void initDisplayForAdd(BizObject bo) throws Exception {
|
|
//获取当前客户ID
|
|
String group_no=this.asPage.getAttribute("group_id").toString();
|
|
bo.setAttributeValue("group_id",group_no);
|
|
super.initDisplayForAdd(bo);
|
|
}
|
|
|
|
@Override
|
|
protected boolean validityCheck(BizObject bo, boolean isInsert) {
|
|
try {
|
|
String Id = bo.getAttribute("id").getString();
|
|
String customerId = bo.getAttribute("customer_id").getString();
|
|
String groupId = bo.getAttribute("group_id").getString();
|
|
BizObjectManager bom = JBOFactory.getBizObjectManager(CUSTOMER_GROUP_RELATION.CLASS_NAME);
|
|
if("".equals(Id)){
|
|
|
|
BizObject cgr = bom.createQuery("group_id=:group_id and customer_id=:customer_id ").setParameter("group_id",groupId).setParameter("customer_id",customerId).getSingleResult(false);
|
|
if(cgr!=null){
|
|
this.errors="该集团已存在此客户!";
|
|
return false;
|
|
}
|
|
}else{
|
|
BizObject b=bom.createQuery("id=:id").setParameter("id", Id).getSingleResult(false);
|
|
String bcustomerId=b.getAttribute("customer_id").toString();
|
|
if(!(bcustomerId.equals(customerId))){
|
|
BizObject cgr = bom.createQuery("group_id=:group_id and customer_id=:customer_id ").setParameter("group_id",groupId).setParameter("customer_id",customerId).getSingleResult(false);
|
|
if(cgr!=null){
|
|
this.errors="该集团已存在此客户!";
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
} catch (JBOException e) {
|
|
// TODO Auto-generated catch block
|
|
e.printStackTrace();
|
|
}
|
|
|
|
return super.validityCheck(bo, isInsert);
|
|
}
|
|
|
|
}
|