package com.tenwa.customer.controller.tell; import jbo.app.tenwa.customer.CUSTOMER_TEL; import com.amarsoft.are.jbo.BizObjectManager; import com.amarsoft.are.jbo.BizObjectQuery; import com.amarsoft.are.jbo.JBOFactory; import com.amarsoft.are.jbo.JBOTransaction; public class CustomerTelAction { private String customerid=""; private String customerId=""; private String id=""; private String teltype=""; public String getCustomerId() { return customerId; } public void setCustomerId(String customerId) { this.customerId = customerId; } public String getTeltype() { return teltype; } public void setTeltype(String teltype) { this.teltype = teltype; } public String getId() { return id; } public void setId(String id) { this.id = id; } public String getCustomerid() { return customerid; } public void setCustomerid(String customerid) { this.customerid = customerid; } /** * * @param tx * @return * @throws Exception */ public String areValid(JBOTransaction tx)throws Exception { BizObjectManager bm = JBOFactory.getBizObjectManager(CUSTOMER_TEL.CLASS_NAME); tx.join(bm); BizObjectQuery boq = bm.createQuery("update O set isnew = 'yes' where id=:id "); boq.setParameter("id", id); boq.executeUpdate(); BizObjectQuery bq2 = bm.createQuery("update O set isnew = 'no' where id<>:id ").setParameter("id", id); bq2.executeUpdate(); return "true"; } /** * * @param tx * @return * @throws Exception */ public String checkNoNew(JBOTransaction tx)throws Exception { BizObjectManager bm = JBOFactory.getBizObjectManager(CUSTOMER_TEL.CLASS_NAME); tx.join(bm); BizObjectQuery bq2 = bm.createQuery("update O set isnew = 'no' where id=:id ").setParameter("id", id); int i = bq2.executeUpdate(); String s = ""; if(i == 1){ s = "true"; } return s; } /** * 更新是否默认电话 * @param tx * @return * @throws Exception */ public void updateisadd(JBOTransaction tx)throws Exception { BizObjectManager bom = JBOFactory.getBizObjectManager(CUSTOMER_TEL.CLASS_NAME); tx.join(bom); //先将所有电话设为非最新 BizObjectQuery boq1 = bom.createQuery("update O set isnew = 'no' where customerid=:customerid and teltype=:teltype"); boq1.setParameter("customerid", customerId).setParameter("teltype",teltype); boq1.executeUpdate(); //将此联系电话设为最新 BizObjectQuery boq2 = bom.createQuery("update O set isnew = 'yes' where id=:id ").setParameter("id", id); boq2.executeUpdate(); } /** * 更新是否最新 * @param tx * @return * @throws Exception */ public void updateisnew(JBOTransaction tx)throws Exception { BizObjectManager bom = JBOFactory.getBizObjectManager(CUSTOMER_TEL.CLASS_NAME); tx.join(bom); //先将所有联系电话设为非最新 BizObjectQuery boq1 = bom.createQuery("update O set isnew = 'no' where customerid=:customerid and teltype=:teltype"); boq1.setParameter("customerid", customerId).setParameter("teltype",teltype); boq1.executeUpdate(); //将此联系电话设为最新 BizObjectQuery boq2 = bom.createQuery("update O set isnew = 'yes' where id=:id ").setParameter("id", id); boq2.executeUpdate(); } /** * 取消最新 * @param tx * @return * @throws Exception */ public String cancelNew(JBOTransaction tx)throws Exception { BizObjectManager bom = JBOFactory.getBizObjectManager(CUSTOMER_TEL.CLASS_NAME); tx.join(bom); //将此联系电话更新为非最新 BizObjectQuery boq = bom.createQuery("update O set isnew = 'no' where id=:id ").setParameter("id", id); int i = boq.executeUpdate(); String s = ""; if(i == 1){ s = "yes"; } return s; } public String setNew(JBOTransaction tx)throws Exception { BizObjectManager bom = JBOFactory.getBizObjectManager(CUSTOMER_TEL.CLASS_NAME); tx.join(bom); //先将此类联系电话其它联系电话设为非最新 BizObjectQuery boq1 = bom.createQuery("update O set isnew = 'no' where customerid=:customerid and teltype=:teltype"); boq1.setParameter("customerid", customerId).setParameter("teltype",teltype); boq1.executeUpdate(); //将此联系电话设为最新 BizObjectQuery boq2 = bom.createQuery("update O set isnew = 'yes' where id=:id ").setParameter("id", id); int i = boq2.executeUpdate(); String s = ""; if(i == 1){ s = "yes"; } return s; } }