package com.tenwa.customer.controller.account; import java.util.List; import jbo.app.tenwa.customer.CUSTOMER_ACCOUNT; import jbo.app.tenwa.customer.CUSTOMER_INFO; import jbo.app.tenwa.customer.DISTRIBUTOR_INFO_TEMP; 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.are.jbo.JBOTransaction; public class CustomerAccountController { private String customer_id=""; private String id=""; private String account; public String getAccount() { return account; } public void setAccount(String account) { this.account = account; } public String getId() { return id; } public void setId(String id) { this.id = id; } public String getCustomer_id() { return customer_id; } public void setCustomer_id(String customer_id) { this.customer_id = customer_id; } /** * 新增时查询当前客户有无主账户 * @param tx * @return * @throws Exception */ public String selectAccount(JBOTransaction tx)throws Exception { BizObjectManager bom = JBOFactory.getBizObjectManager(CUSTOMER_ACCOUNT.CLASS_NAME); tx.join(bom); //查询当前客户有无主账户 List CUSTOMER_ACCOUNTS = bom.createQuery("customerid=:customerid and is_main='yes'").setParameter("customerid",customer_id).getResultList(false); if(CUSTOMER_ACCOUNTS != null && CUSTOMER_ACCOUNTS.size() > 0){ return "true"; } return "false"; } /** * 修改时查询当前客户有无主账户 * @param tx * @return * @throws Exception */ public String selectEditAccount(JBOTransaction tx)throws Exception { BizObjectManager bom = JBOFactory.getBizObjectManager(CUSTOMER_ACCOUNT.CLASS_NAME); tx.join(bom); //修改时查询当前客户有无主账户 List CUSTOMER_ACCOUNTS = bom.createQuery("customerid=:customerid and id<>:id and is_main='yes' ").setParameter("customerid",customer_id).setParameter("id",id).getResultList(false); if(CUSTOMER_ACCOUNTS != null && CUSTOMER_ACCOUNTS.size() > 0){ return "true"; } return "false"; } //带值 public String selectAccountName(JBOTransaction tx) throws JBOException{ BizObjectManager bs = JBOFactory.getBizObjectManager(CUSTOMER_INFO.CLASS_NAME,tx); BizObject dgc = bs.createQuery("customerid=:customerid").setParameter("customerid",customer_id).getSingleResult(false); String distributorName =dgc!=null?dgc.getAttribute("customername").toString():""; return distributorName; } }