Advertisement
gkpoll

Untitled

Feb 13th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.75 KB | None | 0 0
  1.  public static bool jaConstaLevandoEmContaIEeCNPJ
  2.                                   (List<IdentificationNumber> lista, IdentificationNumber novoItem)
  3.         {
  4.             switch (novoItem.IdentificationType)
  5.             {
  6.                 case IdentificationType.Cpf:
  7.                 case IdentificationType.Cnpj:
  8.                 case IdentificationType.IE:
  9.                     break;
  10.  
  11.                 default:
  12.                     throw new Exception("Tipo de identificação inválido para o envio " +
  13.                         "de comunicações eletrônicas (válidos: CPF, CNPJ ou IE)." +
  14.                         DtoConfiguracoes.envieEmailaoSuporte);
  15.             }
  16.  
  17.             // cobre CPF e IE, CNPJ quando coincide o tipo:
  18.             if (lista.Any(l => l.ToString(false) == novoItem.ToString(false))) return true;
  19.            
  20.             if(novoItem.IdentificationType==IdentificationType.Cnpj)
  21.             {
  22.                 if(SvcCadastro.possuiInscricaoEstadual(novoItem))
  23.                 {
  24.                     string InscricaoEstadual = SvcCadastro.getInscricaoEstadual((Cnpj)novoItem);
  25.  
  26.                     InscricaoEstadual = SvcDtec.limpaCPFCNPJIE(InscricaoEstadual);
  27.  
  28.                     if (lista.Any(l => l.ToString(false) == InscricaoEstadual)) return true;
  29.                 }
  30.             }
  31.  
  32.             if (novoItem.IdentificationType == IdentificationType.IE)
  33.             {
  34.                 if (SvcCadastro.isPessoaJuridica((IE)novoItem))
  35.                 {
  36.                     string CNPJ = SvcCadastro.getCNPJ(novoItem);
  37.  
  38.                     CNPJ = SvcDtec.limpaCPFCNPJIE(CNPJ);
  39.  
  40.                     if (lista.Any(l => l.ToString(false) == CNPJ)) return true;
  41.                 }
  42.             }
  43.  
  44.             return false;
  45.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement