⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 group.java

📁 OA典型例子
💻 JAVA
字号:

/*
 * Group.java
 * Generated using xgen and texen from bean.vm
 * Tue Nov 18 10:09:40 CST 2003
 */

package com.sure.oa.addresslist;
import java.sql.SQLException;
import java.util.NoSuchElementException;
import java.util.Vector;
import com.sure.businesslogic.NotFoundException;
import com.sure.businessmodel.Page;
import com.sure.dataabstraction.DBPoolException;
import com.sure.oa.orgnization.*;
import com.sure.util.StringUtils;
import com.sure.dataabstraction.DBManager;
import java.sql.Connection;

/**
 * 存放单位群组信息
 * @author mailto:datonghuiren@sohu.com
 */
public class Group extends GroupBase {
  private int pageSize = 10;
   protected Vector members = new Vector();

   /**
    * 取得群组中成员
    * @return 群组成员
    * @throws Exception
    */
   public Vector getMember() throws Exception{
     if(members.size() == 0)
       loadmembers();
     return members;
   }

   /**
    * 取得群组中成员数目
    * @return 成员数目
    * @throws Exception
    */
   public int getMemberCount() throws Exception{
     if(members.size() == 0)
       loadmembers();
     return members.size();
   }

   /**
    * 以分页形式取得群组中成员列表
    * @param start 开始位置
    * @return 成员列表
    * @throws Exception
    */
   public Page getMemberList(int start) throws Exception{
     int count = getMemberCount();
     if(count == 0)
       return new  Page(pageSize);
     start = Page.getValidStart(start, count, pageSize);
     return new Page(members, start, count, pageSize);
   }

   /**
    * 取得群组中成员名称
    * @return 以空格分隔的群组成员名称
    * @throws Exception
    */
   public String getMemberListAsString() throws Exception{
     String strReturn = "";
     int i;
     i = getMemberCount();
     if(i == 0)
       return strReturn;
     Unit unit;
     for(i = 0; i < members.size(); i++){
         unit = (Unit)members.elementAt(i);
         strReturn = strReturn + unit.getUnitName() + " ";
     }
     return strReturn;
   }

   /**
    * 取得群组中成员列表
    * @throws Exception
    */
   private void  loadmembers() throws Exception
   {
     if(content == null || content.equals(""))
       return;
     String strIds[] = StringUtils.split(content, ",");
     String where="";
     Vector beans;
     Connection cn = DBManager.getConnection();
     int i;
     Unit u;
     UnitManager uMg = new UnitManager();
     try{
         for(i = 0; i < strIds.length; i++){
             where = "Where unitId = " + strIds[i] + "";
             beans = UnitPersistent.load(cn, where);
             if (beans.size()>0){
               u=(Unit)beans.firstElement();//取Vector对象的第一个元素
               members.add(u);
             }
           }
      }
      catch(NoSuchElementException ne){ }
      finally {
          cn.close();
      }
   }

   /**
    * 添加群组成员
    * @param memberId 待添加的成员id
    */
   public void addContent(String memberId){
     if(content == null || content.equals(""))
       content = memberId;
     else
       content = content + "," + memberId;
   }

   /**
    * 删除群组成员
    * @param memberId 待删除的成员id
    */
   public void  deleteContent(String memberId){
     String strIds[] = StringUtils.split(content, ",");
     StringBuffer strTemp = new StringBuffer("");
     int i;
     for(i = 0; i < strIds.length; i++){
       if(!strIds[i].equals(memberId))
         if(strTemp == null || strTemp.equals(""))
           strTemp.append(strIds[i]);
         else
           strTemp.append("," + strIds[i]);
     }
     content = new String(strTemp);
   }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -