 
/**
* OrgVOJs class
* @return
*/
function OrgVOJs()
{
    this.orgId="";
    this.orgName="";    
    this.orgType="";  
    this.selOne ="N"; 
    this.orgCollection =new Array();
}


 
OrgVOJs.prototype.setOrgId=function (partment)
{
     this.orgId=partment;
}

OrgVOJs.prototype.getOrgId=function ()
{
    return this.orgId;
}

OrgVOJs.prototype.setOrgName=function (partment)
{
    this.orgName=partment;
}

OrgVOJs.prototype.getOrgName=function ()
{
    return this.orgName;
}

 

OrgVOJs.prototype.setOrgType=function (partment)
{
   this.orgType=partment;
}

OrgVOJs.prototype.getOrgType=function ()
{
  return this.orgType;
}

OrgVOJs.prototype.setSelOne=function (partment)
{
   this.selOne=partment;
}

OrgVOJs.prototype.getSelOne=function ()
{
  return this.selOne;
}

OrgVOJs.prototype.addOrg2=function (orgObject)
{
    var objCount=this.orgCollection.length;

    var Iweary=new OrgVOJs();

    Iweary.setOrgId(orgObject.getOrgId());
    Iweary.setOrgName(orgObject.getOrgName());     
    Iweary.setOrgType(orgObject.getOrgType());
    
    this.orgCollection[objCount]=Iweary;
}

/**
* 增加对象
*/
OrgVOJs.prototype.addOrg=function (orgId,orgName,orgType)
{
    this.orgId=orgId;
    this.orgName=orgName;    
    this.orgType=orgType;
    

    var objCount=this.orgCollection.length;
    var Iweary=new OrgVOJs();
    Iweary.setOrgId(orgId);
    Iweary.setOrgName(orgName);   
    Iweary.setOrgType(orgType);
   
    this.orgCollection[objCount]=Iweary;
}


OrgVOJs.prototype.permutation=function(code1,code2)
{
   var index1=this.getOrgIndex(code1);
   var index2=this.getOrgIndex(code2);
   if(index1==-1 || index2==-1)
      return;
   var temWeizhi=this.fndbyIndex(index1);
   this.orgCollection[index1]=this.fndbyIndex(index2);
   this.orgCollection[index2]=temWeizhi;
   temWeizhi=null;
}


OrgVOJs.prototype.swapup=function(orgId)
{
 
   var index1=this.getOrgIndex(orgId);
   var index2= index1 - 1;
   if(index1==-1 || index2==-1)
      return;
   var temWeizhi=this.fndbyIndex(index1);
   this.orgCollection[index1]=this.fndbyIndex(index2);
   this.orgCollection[index2]=temWeizhi;
   temWeizhi=null;
}


OrgVOJs.prototype.swapdown=function(orgId)
{
   var index1=this.getOrgIndex(orgId);
   var index2= index1 + 1;
   if(index1==-1 || index2==-1)
      return;
   if (index2 >= this.orgCollection.length) //end of bound
      return;
   var temWeizhi=this.fndbyIndex(index1);
   this.orgCollection[index1]=this.fndbyIndex(index2);
   this.orgCollection[index2]=temWeizhi;
   temWeizhi=null;
}

 
OrgVOJs.prototype.getOrgIndex=function(orgId)
{
  var index=-1;
  var objCount=this.orgCollection.length;
   for(var i=0;i<objCount;i++)
   {
      var tmpobj=this.orgCollection[i];
      if(tmpobj!=null)
      {
         if(tmpobj.getOrgId()==orgId)
         {
            index=i;
            break;
         }
      }
   }
   return index;
}

OrgVOJs.prototype.clearObj=function ()
{
  try
  {
   var objCount=this.orgCollection.length;
   this.orgCollection.splice(0,objCount);
  }catch(ex)
  {
  }

}

OrgVOJs.prototype.delOrgByIndex=function (index)
{
  try{
   
    this.orgCollection.splice(index,1);
  }catch(e){
    alert("删除对象失败！");
  }
}
 
OrgVOJs.prototype.delOrg=function (orgId)
{
   var objCount=this.orgCollection.length;

   for(var i=0;i<objCount;i++)
   {
      var tmpobj=this.orgCollection[i];
      if(tmpobj!=null)
      {
         if(tmpobj.getOrgId()==orgId)
         {
            this.orgCollection.splice(i,1);
            return;
         }
      }
      tmpobj=null;
   }
}
 
OrgVOJs.prototype.fndbyOrgId= function (orgId)
{
  if(orgId==null) return null;

  var objCount=this.orgCollection.length;
  var tmpobj=null;
   for(var i=0;i<objCount;i++)
   {
      tmpobj=this.orgCollection[i];
      if(tmpobj!=null)
      {
         if(tmpobj.getOrgId()==orgId)
         {
            return tmpobj;
         }
      }
      tmpobj=null;
   }
  return null;
}

/**
* 查找某个数组对象
*/
OrgVOJs.prototype.fndbyIndex= function (pindex)
{
  try
  {
     var tmpobj=this.orgCollection[pindex];
     return tmpobj
  }
  catch(ex)
  {
  }
  return null;
}

 



/**
*得到记录数
*/
OrgVOJs.prototype.getOrgCount=function ()
{
  return this.orgCollection.length;
}
 