01.Blogs :
mauriciogonzatto  
.NET, C#, Oracle, Web, tecnologia em geral e diversidades.

Validação para PIS/PASEP

Como tinha dito em post anterior, fui ao INSS e peguei os algorítmos para validação de CEI e PIS/PASEP.

Segue o código C# para validação do PIS:

  // Validar PIS/PASEP
  public bool validaPIS( string parametro )
  {
   bool retorno = false;
   if( parametro.Length == 14 ){
    if( Regex.IsMatch( parametro, @"[0-9]{3}.[0-9]{5}.[0-9]{2}-[0-9]{1}" ) ){
     string _pis = parametro.Replace(".","");
     _pis = _pis.Replace("-","");
     string digitoVerificador = _pis.Substring(10,1);
     int tot =  ( Convert.ToInt32( _pis.Substring(0,1) ) * 3);
      tot += ( Convert.ToInt32( _pis.Substring(1,1) ) * 2);
      tot += ( Convert.ToInt32( _pis.Substring(2,1) ) * 9);
      tot += ( Convert.ToInt32( _pis.Substring(3,1) ) * 8);
      tot += ( Convert.ToInt32( _pis.Substring(4,1) ) * 7);
      tot += ( Convert.ToInt32( _pis.Substring(5,1) ) * 6);
      tot += ( Convert.ToInt32( _pis.Substring(6,1) ) * 5);
      tot += ( Convert.ToInt32( _pis.Substring(7,1) ) * 4);
      tot += ( Convert.ToInt32( _pis.Substring(8,1) ) * 3);
      tot += ( Convert.ToInt32( _pis.Substring(9,1) ) * 2);
     string dv = (11 - (tot % 11 )).ToString();
     if( dv == digitoVerificador ){
      retorno = true;
     }
    }
   }
   return retorno;
  }

Bom proveito!

Dúvidas, críticas ou sugestões estamos ae! heheh

[]'s

posted on Thursday, January 05, 2006 4:14 AM by mauriciogonzatto

# re: Validação para PIS/PASEP @ Thursday, January 05, 2006 12:42 PM

Boa essa tb!

[]s Juliano

julianocarvalho


 
03.UPDATE CALENDAR :
<January 2006>
SunMonTueWedThuFriSat
25262728293031
1234567
891011121314
15161718192021
22232425262728
2930311234

05.MY LINKS :

07.Subscriptions :

Subscriptions


© Copyright 2005 Microsoft Corporation. All Rights Reserved.
Terms of Use | Privacy Statement | Code of Conduct | Hosted by MaximumASP for Microsoft
WHO-BAR