<% function Numera(wTP_DOCUMENTO) Set strConexao = Server.CreateObject("ADODB.Connection") strConexao.Open stringconexao Set rstemp = Server.CreateObject("ADODB.Recordset") Set rstemp = strConexao.Execute("select * from Documentos where TP_DOCUMENTO='" & wTP_DOCUMENTO & "'") wNM_ULTIMO=rstemp("NM_ULTIMO") + 1 Set rsNumera = strConexao.Execute("Update Documentos set NM_Ultimo=" & wNM_ULTIMO & " where TP_DOCUMENTO='" & wTP_DOCUMENTO & "'") Numera=wNM_ULTIMO rstemp.close strConexao.close set rstemp=nothing set strConexao=nothing end function %> <% FUNCTION CALCDIG10(cadeia) mult=(len(cadeia) mod 2) mult=mult+1 total=0 for pos=1 to len(cadeia) res= mid(cadeia, pos, 1) * mult if res>9 then res=int(res/10) + (res mod 10) end if total=total+res if mult=2 then mult=1 else mult=2 end if next total=((10-(total mod 10)) mod 10 ) CALCDIG10=total END FUNCTION %> <% FUNCTION CALCDIG11(cadeia,limitesup,lflag) mult=1 + (len(cadeia) mod (limitesup-1)) if mult=1 then mult=limitesup end if total=0 for pos=1 to len(cadeia) total=total+(mid(cadeia,pos,1) * mult) mult=mult-1 if mult=1 then mult=limitesup end if Next nresto=(total mod 11) if lflag = 1 then calcdig11=nresto else if nresto=0 or nresto=1 or nresto=10 then ndig=1 else ndig=11 - nresto end if calcdig11=ndig end if END FUNCTION %> <% function FormatarValor(wValor) wValor=replace(wValor, ".", "") wValor=replace(wValor, ",", ".") 'wwValor=Mid(wValor, 1, Len(wValor) - 2) & "." & Mid(wValor, Len(wValor) - 1, 2) FormatarValor=wValor end function %> <% function InverteData(wValor) wValor=replace(wValor, "/", ".") InverteData=wValor end function %> <% function VerificaNulo(wValor) if wValor="" then wValor="" end if VerificaNulo=wValor end function %> <% Function DataBr(str) datas = str if IsDate(datas) = False then datas = False else if Day(datas) <= 9 AND len(Day(datas)) <=2 then dia = "0" & Day(datas) else dia = Day(datas) end if if month(datas) <= 9 AND len(Month(datas)) <=2 then mes = "0" & month(datas) else mes = month(datas) end if if Year(datas) <= 9 AND len(Year(datas)) <=2 then ano = Left(Year(Now),2) & Year(datas) else ano = Year(datas) end if datas = dia & "/" & mes & "/" & ano end if DataBr = datas end function %> <% Function IsCNPJ(ByVal intNumero) 'Validando o formato do CNPJ com expressão regular Set regEx = New RegExp 'Cria o Objeto Expressão regEx.Pattern = "\d{2}.?\d{3}.?\d{3}/?\d{4}-?\d{2}" ' Expressão Regular regEx.IgnoreCase = True ' Sensitivo ou não regEx.Global = True Retorno = RegEx.Test(intNumero) Set regEx = Nothing 'Caso seja verdadeiro posso validar se o CNPJ é válido If Retorno = True Then 'Validando a sequencia números Dim CNPJ_temp CNPJ_temp = intNumero CNPJ_temp = Replace(CNPJ_temp, ".", "") CNPJ_temp = Replace(CNPJ_temp, "/", "") CNPJ_temp = Replace(CNPJ_temp, "-", "") CNPJ_Digito_temp = Right(CNPJ_temp, 2) 'Somando os 12 primeiros digitos do CNPJ Soma = (Clng(Mid(CNPJ_temp,1,1)) * 5) + (Clng(Mid(CNPJ_temp,2,1)) * 4) + (Clng(Mid(CNPJ_temp,3,1)) * 3) + (Clng(Mid(CNPJ_temp,4,1)) * 2) + (Clng(Mid(CNPJ_temp,5,1)) * 9) + (Clng(Mid(CNPJ_temp,6,1)) * 8)+ (Clng(Mid(CNPJ_temp,7,1)) * 7) + (Clng(Mid(CNPJ_temp,8,1)) * 6) + (Clng(Mid(CNPJ_temp,9,1)) * 5) + (Clng(Mid(CNPJ_temp,10,1)) * 4) + (Clng(Mid(CNPJ_temp,11,1)) * 3) + (Clng(Mid(CNPJ_temp,12,1)) * 2) '---------------------------------- 'Calculando o 1º dígito verificador '---------------------------------- 'Pegando o resto da divisão por 11 Resto = (Soma Mod 11) If Resto < 2 Then DigitoHum = 0 Else DigitoHum = Cstr(11-Resto) End If '---------------------------------- '---------------------------------- 'Calculando o 2º dígito verificador '---------------------------------- 'Somando os 12 primeiros digitos do CNPJ mais o 1º dígito Soma = (Clng(Mid(CNPJ_temp,1,1)) * 6) + (Clng(Mid(CNPJ_temp,2,1)) * 5) + (Clng(Mid(CNPJ_temp,3,1)) * 4) + (Clng(Mid(CNPJ_temp,4,1)) * 3) + (Clng(Mid(CNPJ_temp,5,1)) * 2) + (Clng(Mid(CNPJ_temp,6,1)) * 9) + (Clng(Mid(CNPJ_temp,7,1)) * 8) + (Clng(Mid(CNPJ_temp,8,1)) * 7) + (Clng(Mid(CNPJ_temp,9,1)) * 6) + (Clng(Mid(CNPJ_temp,10,1)) * 5) + (Clng(Mid(CNPJ_temp,11,1)) * 4) + (Clng(Mid(CNPJ_temp,12,1)) * 3) + (DigitoHum * 2) 'Pegando o resto da divisão por 11 Resto = (Soma Mod 11) If Resto < 2 Then DigitoDois = 0 Else DigitoDois = Cstr(11-Resto) End If '---------------------------------- 'Verificando se os digitos são iguais aos digítados. DigitoCNPJ = Cstr(DigitoHum) & Cstr(DigitoDois) If Cstr(CNPJ_Digito_temp) = Cstr(DigitoCNPJ) Then Retorno = True Else Retorno = False End If End If IsCNPJ = Retorno End Function %> <% Function FormatarCPF(CPF) FormatarCPF = mid(CPF, 1, 3) & "." & mid(CPF, 4, 3) & "." & mid(CPF, 7, 3) & "-" & mid(CPF, 10, 2) end function %> <% Function FormatarCNPJ(CNPJ) FormatarCNPJ = mid(CPF, 1, 2) & "." & mid(CPF, 3, 3) & "." & mid(CPF, 6, 3) & "/" & mid(CPF, 9, 4) & "-" & mid(CPF, 13, 2) end function %> <% '----------------------------------------------------- 'Funcao: IsCPF(ByVal intNumero) 'Sinopse: Verifica se o valor passado é um CPF válido ' Formatos aceitos: XXX.XXX.XXX-XX ou ' XXXXXXXXXXXXXX 'Parametro: intNumero 'Retorno: Booleano 'Autor: Gabriel Fróes - www.roccofroes.com '----------------------------------------------------- Function IsCPF(ByVal intNumero) 'Validando o formato do CPF com expressão regular Set regEx = New RegExp 'Cria o Objeto Expressão regEx.Pattern = "\d{3}\.?\d{3}\.?\d{3}\-?\d{2}" ' Expressão Regular regEx.IgnoreCase = True ' Sensitivo ou não regEx.Global = True ' Não sei exatamente o que faz Retorno = RegEx.Test(intNumero) Set regEx = Nothing 'Caso seja verdadeiro posso validar se o CPF é válido If Retorno = True Then 'Validando a sequencia números Dim CPF_temp CPF_temp = intNumero CPF_temp = Replace(CPF_temp, ".", "") CPF_temp = Replace(CPF_temp, "-", "") CPF_temp = Replace(CPF_temp, "/", "") CPF_temp = Replace(CPF_temp, " ", "") CPF_Digito_temp = Right(CPF_temp, 2) 'Somando os nove primeiros digitos do CPF Soma = (Clng(Mid(CPF_temp,1,1)) * 10) + (Clng(Mid(CPF_temp,2,1)) * 9) + (Clng(Mid(CPF_temp,3,1)) * 8) + (Clng(Mid(CPF_temp,4,1)) * 7) + (Clng(Mid(CPF_temp,5,1)) * 6) + (Clng(Mid(CPF_temp,6,1)) * 5) + (Clng(Mid(CPF_temp,7,1)) * 4) + (Clng(Mid(CPF_temp,8,1)) * 3) + (Clng(Mid(CPF_temp,9,1)) * 2) '---------------------------------- 'Calculando o 1º dígito verificador '---------------------------------- 'Pegando o resto da divisão por 11 Resto = (Soma Mod 11) If Resto = 1 Or Resto = 0 Then DigitoHum = 0 Else DigitoHum = Cstr(11-Resto) End If '---------------------------------- '---------------------------------- 'Calculando o 2º dígito verificador '---------------------------------- 'Somando os 9 primeiros digitos do CPF mais o 1º dígito Soma = (Clng(Mid(CPF_temp,1,1)) * 11) + (Clng(Mid(CPF_temp,2,1)) * 10) + (Clng(Mid(CPF_temp,3,1)) * 9) + (Clng(Mid(CPF_temp,4,1)) * 8) + (Clng(Mid(CPF_temp,5,1)) * 7) + (Clng(Mid(CPF_temp,6,1)) * 6) + (Clng(Mid(CPF_temp,7,1)) * 5) + (Clng(Mid(CPF_temp,8,1)) * 4) + (Clng(Mid(CPF_temp,9,1)) * 3) + (DigitoHum * 2) 'Pegando o resto da divisão por 11 Resto = (Soma Mod 11) If Resto = 1 Or Resto = 0 Then DigitoDois = 0 Else DigitoDois = Cstr(11-Resto) End If '---------------------------------- 'Verificando se os digitos são iguais aos digítados. DigitoCPF = Cstr(DigitoHum) & Cstr(DigitoDois) If Cstr(CPF_Digito_temp) = Cstr(DigitoCPF) Then Retorno = True Else Retorno = False End If End If IsCPF = Retorno End Function %> <% function StringConexao StringConexao="DRIVER=Firebird/InterBase(r) driver; UID=vidasimples;PWD=7yo7f56t; DBNAME=200.189.63.202:D:\BancoDados\VSCP.GDB;" end function %> <% function StringConexaoLondrina StringConexao="DRIVER=Firebird/InterBase(r) driver; UID=vidasimples;PWD=7yo7f56t; DBNAME=200.189.63.202:D:BancoDados\VSSEG.GDB;" end function %> VIDA SIMPLES - CONTROLE DE PROPOSTA