Funções básicas
Iniciando o primeiro post desta categoria mostrando algumas das funções básicas (Mas essenciais) na utilização da NFe com .NET.
Módulo 11 – Para calculo do digito verificado da Chave.
Com certeza esta função pode ser reduzida para menos linhas… se o fizer, por favor deixe um comentário com o código, sugestões são sempre bem vindas
public static int modulo11(string chaveNFE)
{
if (chaveNFE.Length != 43)
throw new Exception("Chave inválida, não é possível calcular o digito verificador");
string baseCalculo = "4329876543298765432987654329876543298765432";
int somaResultados = 0;
for (int i = 0; i <= chaveNFE.Length - 1; i++)
{
int numNF = Convert.ToInt32(chaveNFE[i].ToString());
int numBaseCalculo = Convert.ToInt32(baseCalculo[i].ToString());
somaResultados += (numBaseCalculo * numNF);
}
int restoDivisao = (somaResultados % 11);
int dv = 11 - restoDivisao;
if ((dv == 0) || (dv > 9))
return 0;
else
return dv;
}
Remover Acentos
Esta função não é de minha autoria, peguei no Google um tempo atrás e realmente não lembro mais de onde ela foi retirada.
public static string TirarAcento(string palavra)
{
string palavraSemAcento = "";
string caracterComAcento = "áàãâäéèêëíìîïóòõôöúùûüçÁÀÃÂÄÉÈÊËÍÌÎÏÓÒÕÖÔÚÙÛÜÇ";
string caracterSemAcento = "aaaaaeeeeiiiiooooouuuucAAAAAEEEEIIIIOOOOOUUUUC";
for (int i = 0; i < palavra.Length; i++)
{
if (caracterComAcento.IndexOf(Convert.ToChar(palavra.Substring(i, 1))) >= 0)
{
int car = caracterComAcento.IndexOf(Convert.ToChar(palavra.Substring(i, 1)));
palavraSemAcento += caracterSemAcento.Substring(car, 1);
}
else
{
palavraSemAcento += palavra.Substring(i, 1);
}
}
return palavraSemAcento;
}
Remove formatação
Remove formatação de CNPJ/IE/RG/CPF, entre outros
public static string removeFormatacao(string texto)
{
string txt = "";
txt = texto.Replace(".", "");
txt = txt.Replace("-", "");
txt = txt.Replace("/", "");
txt = txt.Replace("(", "");
txt = txt.Replace(")", "");
txt = txt.Replace(" ", "");
return txt;
}
Por enquanto é isso, em breve (Ainda esta semana acredito eu) estarei postando uma classe para geração de XML, assim como exemplos para conexão com WebService, assinatura digital, cadeias de certificado, utilização de certificados A1 e A3 e etc.
Abraços
You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
Cheap@Generic.Actonel” rel=”nofollow”>……
Buywithout prescription xiu…
Cheap@Actonel.35mg” rel=”nofollow”>……
Buyit now oil…
Cheap@Actoplus.Met.Online” rel=”nofollow”>..…
Buygeneric meds qmo…
Buy@Cheap.Actos” rel=”nofollow”>..…
Buygeneric drugs krg…
Order@Actos.Without.Prescription” rel=”nofollow”>..…
Buygeneric pills zdg…
Cheap@Generic.Actos.15mg.30mg” rel=”nofollow”>.…
Buygeneric drugs zfk…
Purchase@Adalat.Online” rel=”nofollow”>.…
Buyno prescription luw…
Order@Coral.Calcium.Online” rel=”nofollow”>..…
Buynow it tly…
Purchase@Abilify.Without.Prescription” rel=”nofollow”>..…
Buygeneric meds abx…
Purchase@Generic.Abilify.5mg.10mg.15mg.20mg.30mg” rel=”nofollow”>..…
Buywithout prescription yen…
Purchase@Cheap.Acai” rel=”nofollow”>..…
Buyno prescription tao…
Purchase@Discount.Acai” rel=”nofollow”>……
Buydrugs without prescription jlg…
Buy@Generic.Acai.Without.Prescription” rel=”nofollow”>……
Buywithout prescription ccw…
Order@Generic.Acai” rel=”nofollow”>..…
Buyno prescription wkp…
Purchase@Generic.Acai” rel=”nofollow”>..…
Buydrugs without prescription faj…
Purchase@Generic.Acai.500mg” rel=”nofollow”>.…
Buygeneric drugs itj…
Acai@500mg.Without.Prescription” rel=”nofollow”>.…
Buynow it lmg…
Buy@Discount.Accutane” rel=”nofollow”>.…
Buygeneric drugs nih…
Purchase@Discount.Accutane” rel=”nofollow”>.…
Buygeneric drugs mby…
Buy@Generic.Accutane” rel=”nofollow”>……
Buygeneric meds svb…
Buy@Generic.Accutane.Without.Prescription” rel=”nofollow”>.…
Buygeneric drugs axm…
Buy@Accutane.10mg.20mg” rel=”nofollow”>……
Buynow it zdg…
Purchase@Generic.Aciphex” rel=”nofollow”>..…
Buydrugs without prescription ygy…
Cheap@Aciphex.Without.Prescription” rel=”nofollow”>……
Buyit now sge…
Buy@Cheap.Actonel” rel=”nofollow”>……
Buydrugs without prescription vrg…
Order@Actonel.Online” rel=”nofollow”>……
Buynow fjl…
Get@Actonel.Online” rel=”nofollow”>..…
Buygeneric drugs ajd…
Order@Actonel.Without.Prescription” rel=”nofollow”>..…
Buyno prescription jwi…
Purchase@Advair.Online” rel=”nofollow”>..…
Buyno prescription jui…
Buy@Generic.Advair” rel=”nofollow”>.…
Buygeneric drugs ouw…
Buy@Advair.Without.Prescription” rel=”nofollow”>.…
Buygeneric drugs hwi…
Order@Advair.Without.Prescription” rel=”nofollow”>.…
Buyit now ojb…
Cheap@Generic.Advair” rel=”nofollow”>.…
Buydrugs without prescription xab…
Order@Discount.Aggrenox” rel=”nofollow”>..…
Buyno prescription lka…
Purchase@Cheap.Albenza” rel=”nofollow”>……
Buyit now knc…
coral@calcium.vitamin.explanation” rel=”nofollow”>.…
Buywithout prescription…
calcium@coral.buy” rel=”nofollow”>.…
Buydrugs without prescription…
aleve@cold.tablets” rel=”nofollow”>……
Buygeneric pills…
aloe@ferox.gel.buy” rel=”nofollow”>.…
Buynow it…
arcoxia@120mg.buy” rel=”nofollow”>……
Buygeneric drugs…
coral@calcium.supplements” rel=”nofollow”>……
Buygeneric meds…
abilify@and.sleep.issues” rel=”nofollow”>..…
Buydrugs without prescription…
abilify@does.it.work” rel=”nofollow”>……
Buygeneric meds…
accutane@verdict.buy” rel=”nofollow”>..…
Buydrugs without prescription…
allopurinol@atrial.fibrillation” rel=”nofollow”>.…
Buygeneric pills…
aloe@vera.juice.for.sale” rel=”nofollow”>..…
Buyit now…
side@effects.of.aricept” rel=”nofollow”>..…
Buyit now…
Gems form the internet…
[...]very few websites that happen to be detailed below, from our point of view are undoubtedly well worth checking out[...]……
kredi karti borcu taksitlendirme…
this was a sheer entertaining read. i enjoyed it very much!|Thanks for this article! How in the world….
lung cancer survival rates…
Buy_generic meds…