Ir para conteúdo
Fórum Script Brasil
  • 0

Erro Microsoft OLE DB Provider for ODBC Drivers erro '80040e21' O driver ODBC não oferece suporte para as propriedades solicitadas.


Marcelo Denisard

Pergunta

Bom dia estou tendo um retorno de erro 

Microsoft OLE DB Provider for ODBC Drivers erro '80040e21'

O driver ODBC não oferece suporte para as propriedades solicitadas.

/rotinas/rotinas.asp, linha 37

alguém tem alguma informação pra ajudar, desde já agradeço.

 

segue o script abaixo:

<link href="rotinas/estilo.css" type="text/css" rel="stylesheet">
<script LANGUAGE="JavaScript" SRC="javascript/funcoes.js"></script>
<!--#Include file="funcoesAno.asp"#-->
<%
response.write("<body  class=bodycolor>") 
 Dim conex
 Dim rst,rst2
 
 '---Cria e abre o objeto de conexão
 sub Wconex()
     set conex=server.CreateObject("ADODB.connection") 
    conex.open ("Driver={MySQL ODBC 8.0 ansi Driver};SERVER=localhost;UID=root;PASSWORD=;PORT=3306;OPTION=3;STMT=;DATABASE=Srh;")      
 
 end sub
 '---Executa sql-que não retorna registros
 sub SqlNoQuery(fsql)
    Wconex
    conex.execute(fsql)
    conex.close
    set conex=Nothing
'    response.write(fsql)
'    response.end 
 end sub
 
 '---Apagar tabelas
sub Drop_table(ftable)
    strSql="DROP TABLE IF EXISTS "& ftable &";"
    SqlNoQuery(strSql)
end sub
 '---Cria um objeto Recordset 
 sub Wrst(fsql)  
   if (session("logado") = "marcio-souza") then
      response.write(fsql)
    end if 
    Wconex
     set rst=server.CreateObject("ADODB.Recordset")         
     rst.open fsql,conex,3,3 
 end sub 
 
  '---Cria um outro objeto Recordset 
 sub Wrst2(fsql)
     Wconex    
     set rst2=server.CreateObject("ADODB.Recordset")     
     rst2.open fsql,conex,3,3 
 end sub 
 
'---Fecha a Conexão com o banco de dados
 sub fechaConexao()   
     set rst=nothing 
     conex.close
    set conex=Nothing 
 end sub

'---Função Dados para caixa de listagem
dim vetor,vetor_aux
function  MontaVetor(fSql,vetor,fexit) 
' response.write(fSql)
  Wrst(fSql) 
  MontaVetor=-1    
  If NOT rst.EOF then   
    vetor=rst.GetRows             

    '---nro de registros
//response.write(fSql)
MontaVetor=ubound(vetor,2)
  else
      if fexit=0 then
//        response.write(fSql)
        response.Write("<h3>Não Há dados para serem exibidos</h3>")
        response.end
    end if        
  end if    
  fechaConexao
end function


'---Item pré-selecionado
'---Rotina de Preenchimento da caixa de listagem/item_list(0,i)"código" e item_list(1,0) "Descrição"
dim Wdt_adm,Wfiltro
sub Montalista(fsql,nome,codigo)
    'response.Write(fsql&nome&codigo)        
    
    dim final
    dim Windice
      Wrst(fSql)        
    Select Case session("atividade")        
        case 1092
            Qsel="TODOS"
            Qvalue=""
        case else
            Qsel="SELECIONE"
            Qvalue=""
    End Select
  %>
    <select name="<%=nome%>" ""   <%=Qdisabled%> onChange="javascript:cbo(this)"  onFocus="<%=funcao2%>" onKeyDown="if(event.keyCode==13) event.keyCode=9;">    
<%  If lcase(nome) <> "def" And lcase(nome) <> "reabilitado" Then %>    
    <option value="<%=Qvalue%>" <%=selecao%> ><%=Qsel%></option> 
<%
    End If
    
      If NOT rst.EOF then   
        lista=rst.GetRows                 
        '---nro de registros
        final=ubound(lista,2)
        colunas=ubound(lista,1)        
        if instr(LCase(fsql),"from")=0 then                        
            for n=0 to colunas
            Windice=lista(n,0)
            selecao=""    
            if codigo <>"" then                            
                if cstr(Windice)=cstr(codigo) then    selecao="selected":    nome=Windice
            end if
            %>
            <option value="<%=Windice%>" <%=selecao%> ><%=Windice%> </option>
            <%
            next
            response.write("</select>")        
            exit sub
        end if
        for n=0 to final
            Windice=lista(0,n)
            selecao=""        
            if codigo <> "" then            
                if cstr(Windice)=cstr(codigo) then selecao="selected":nome=Windice            
            end if
            cols=""
            for k=1 to colunas            
                cols=cols & left(lista( k,n),60) & " - "            
            next 
            cols=limpaCaracter(cols,3)
            %>        
            <option value="<%=Windice%>" <%=selecao%> ><%=cols%></option>
            <%        
        next
        
    else        
        response.write("<option value="""">NÃO HÁ DADOS</option>")
    end if
    response.write("</select>")    
    fechaConexao
end sub
'----
Sub MtTabelaHorario(facao)    
    '---Monta Tabela conforme os elementos fornecidos
    if DadosServidor(RetornaValor("matri")) then        
        MontaServidor
        montahorario(session("matri"))
    end if
    response.write("<br><Table class=estilo_12 BORDER=0 CELLSPACING=0 CELLPADDING=1>")
    response.write("<tr><td colspan=2 align=center>REGISTRO DE HORÁRIOS</td></tr>")
    response.write("<tr><td>Matricula</td><td><input name=matri value='"&RetornaValor("matri")&"'  class=campos type=text onBlur='fonb8(this)' onKeyDown='if(event.keyCode==13) event.keyCode=9;' size='5' maxlength='5' ></td></tr>")    
    response.write("<tr><td>Data</td><td><input name=data_i  value='"&RetornaValor("data_i")&"' class=campos type=text onBlur='fonb4(this)' onKeyDown='if(event.keyCode==13) event.keyCode=9;' size='10' maxlength='10' ></td></tr>")    
    response.write("<tr><td>Documento</td><td>")
                preenchelista "tipo_d",RetornaValor("tipo_d")
    response.write("</td></tr>")
    response.write("<tr><td>Nro.</td><td><input name=nrodoc  value='"&RetornaValor("nrodoc")&"' class=campos type=text  onKeyDown='if(event.keyCode==13) event.keyCode=9;'></td></tr>")
    
        
    ArrCampos=split(Session("Campos"),",")
    ArrAuto_inc=split(Session("Auto_inc"),";")
    ArrTabela=split(Session("tbl"),";")
    ArrChave=split(Session("Chave"),";")
    ArrSize=split(session("size"),";")
    Arrfuncao=split(Session("func"),";")        
    
    If session("acao")=1 then
        RetornaDados("SELECT * FROM Srh.horario_novo WHERE id_horario='"&Request.QueryString("id_horario")&"';")    
    End if
                
    for i=0 to ubound(ArrCampos,1)                                                                             
            '---Campo Auto Numeração            
            if Arrfuncao(i) <> "0" then Arrfuncao(i) = Arrfuncao(i) & "(this)"
            Wevento=" onBlur="
            funcao2=""                                                
            Wtype="text"
            Wlabel=Labels(i)
            if  ArrAuto_inc(i)=1 then  nVisible(ArrAuto_inc(i))            
            Wcampo=ArrCampos(i)                                                                
            if Request.QueryString("id_horario")="" then
                valor=Request.Form(Wcampo)
            else                                        
                valor=dados(i)                            
            end if
        
        if i=4 then
            response.write("</table><Table class=estilo_3 BORDER=1 CELLSPACING=0 CELLPADDING=1 bordercolor=blue>")
            response.write("<br><br>")
            response.write("<tr class=estilo_5><td></td><td>Ent</td><td>Sai</td><td>Ent</td><td>Sai</td></tr>")
        end if
        if i > 4 then        
            Qini=right(Arrcampos(i),2)            
            if Qini="e1" then 
                response.write("<tr>")
                Qest="estilo_3"
                if i=5 then Qest="estilo_7"
                response.write("<TD class="&Qest&">"&Wlabel&"</TD>")
            end if
        else
            response.write("<tr>")
            response.write("<TD>"&Wlabel&"</TD>")
        end if
                    
        if ArrTabela(i)="0" then
            'campos com área maior            
            %>    
            <TD width="100" align="center"><input name="<%=Wcampo%>"   class="campos" type="<%=Wtype%>" value="<%=valor%>"  size=<%=ArrSize(i)%>   <%=Wevento%>"<%=Arrfuncao(i)%>"  onFocus="<%=funcao2%>" onKeyDown="if(event.keyCode==13) event.keyCode=9;"></TD>
            <%    
         else
            if  ArrChave(i)=0 or (Arrchave(i)=1 and facao=0) Then
                response.write("<td>")
                preenchelista ArrTabela(i),valor
                response.write("</td>")            
            else %>
            <TD width="450"><input name="<%=Wcampo%>"  type="%=Wtype%>" value="<%=valor%>"  size="5"    onBlur="<%=funcao%>"  onFocus="<%=funcao2%>" onFocus="<%=funcao2%>" onKeyDown="if(event.keyCode==13) event.keyCode=9;"></TD>
            <%
            end if
            if i > 3 then
                Qfinal=right(Arrcampos(i),2)            
                if Qfinal="s2" then response.write("</tr>")
            else
                response.write("</tr>")
            end if            
         end if
    next
    response.write("</table>")    
    botoes facao
    if request.form("matri")<>"" or request.QueryString("matri")<>"" then call MtLista
end sub
'----

'---Altera Contrato
function fMudaContrato(fcampo,fmatri,facao)    
    fMudaContrato="UPDATE Srh.contrato SET " & fcampo & "='" 
    if facao < 2 then
        '---inclusão e Alteração        
        select case cint(session("atividade"))            
            case 108
                 fMudaContrato=fMudaContrato & request.form("lotacao")
            case 118
                '---Reintegração
                 fMudaContrato=fMudaContrato & "1"
            case 123
                '---Alteração do Período Aquisitivo
                fMudaContrato=fMudaContrato & ConverteData(request.form("data_i"))
            case 129
                 fMudaContrato=fMudaContrato & request.form("nivel")
            case 130
                 fMudaContrato=fMudaContrato & request.form("ch")            
        end select    
        
    else
        select case cint(session("atividade"))            
            case 108
                '---transferência
                 fMudaContrato=fMudaContrato & fultlotacao
            case 118
                '---Reintegração
                 fMudaContrato=fMudaContrato & "0"
            case 123
                '---Alteração do Período Aquisitivo
                fMudaContrato=fMudaContrato & ConverteData(request.form("ultimo_pa"))
            case 129
                '---Mudança de Nível 
                strSql="SELECT nivel from Srh.historico"
                strSql=strSql & " WHERE matri='" & session("matri")
                strSql=strSql & "' AND tipo_h='08'"
                strSql=strSql & " ORDER BY data_i DESC LIMIT 1;"        
                strNivel = RetornaDescricao(strSql)
                ' Correção para evitar que o servidor fique com
                ' nível 0 ao excluir um registro de alteração de nível
                If strNivel <> "" Then
                    fMudaContrato=fMudaContrato & strNivel
                Else
                    fMudaContrato=fMudaContrato & "1"
                End If
                Wconex 
            case 130
                '---Mudança de Carga Horária 
                strSql="SELECT ch from Srh.historico"
                strSql=strSql & " WHERE matri='" & session("matri")
                strSql=strSql & "' AND subtipo_h='0901'"
                strSql=strSql & " ORDER BY data_i DESC LIMIT 1;"
                Qch=RetornaDescricao(strSql)
                if Qch="" then Qch=40                
                fMudaContrato=fMudaContrato &  Qch
                Wconex 
        end select    
    end if
    fMudaContrato=fMudaContrato & "' WHERE matri='" & fmatri & "';"
    'faux(fMudaContrato)    
end function
'
'---Montagem das Sqls
function WSql(facao)  
 Wtbl=session("strTabela") 
 ArrAuto_inc=split(Session("Auto_inc"),";")
 ArrChave=split(Session("Chave"),";")
 sqlInc = "INSERT INTO " & Wtbl & " (" & Session("Campos") & ") VALUES (" 
 sqlAlt = "UPDATE " & Wtbl & " SET "
 sqlDel = "DELETE FROM " & Wtbl         

    ArrCampos=split(Session("Campos"),",")
    For i = 0 To ubound(ArrCampos,1)    
        fcampo=ArrCampos(i)
        if facao=0 then                        
            If ArrAuto_inc(i)=1 Then
                WSql = WSql & chr(34) & "" & chr(34) & ","
            else                                            
                WSql= WSql & "'" & ConverteDados(request.Form(fcampo),fcampo)  & "',"              
            End If
        else     
            ' 13/06/2014 - Henrique Cordeiro
            ' Verifica se campo senha está vazio durante a alteração (1) ou exclusão (2) de cadastro e,
            ' em caso positivo, ignora este campo
            If (facao=1 OR facao=2) AND fcampo = "senha" AND Trim(request.Form(fcampo)) = "" Then
                For j=i To UBound(ArrCampos)-1
                    ArrCampos(j) = ArrCampos(j + 1)
                Next
                ReDim Preserve ArrCampos(UBound(ArrCampos) - 1)
            Else
                If ArrChave(i)=1 Then                        
                    sqlWhere = sqlWhere & fcampo & "='" & ConverteDados(request.Form(fcampo),fcampo) &  "' AND "        
                else
                    'If request.Form(fcampo)<>"" Then 
                      If(InStr(request.Form(fcampo),"'") > 0) Then
                        WSql = WSql & fcampo & "='" & ConverteDados(Replace(request.Form(fcampo),CHR(39),CHR(39)&CHR(39)),fcampo) & "',"
                      Else            
                        WSql= WSql & fcampo & "='" &  ConverteDados(request.Form(fcampo),fcampo)  & "',"
                      End If
                    'End If
                    'if request.Form(fcampo)<>"" then             
                    '    WSql= WSql & fcampo & "='" &  ConverteDados(request.Form(fcampo),fcampo)  & "',"
                    'end if
                end if
            End If
        end if                             
     Next    
    Select Case facao    
    case 0
        WSql=limpaCaracter (WSql,1)     
        WSql= sqlinc & WSql & ");"        
    case 1,2
        sqlwhere=" WHERE " & limpaCaracter(sqlwhere,5)
        if facao=1 then    
            WSql=limpaCaracter (WSql,1)   
            WSql= sqlAlt & WSql & sqlWhere & ";"
        else
            WSql= sqlDel & sqlWhere & ";"
        end if        
    end select    
'    response.write(WSql)
'    response.end()
end function

'
function fsqlWhere()
    Dim Arrchavefalsa
    Dim fgCF
    fgCF=false
    Arrchavefalsa=split(Session("Chavefalsa"),";")
    for m=0 to ubound(Arrchavefalsa,1)    
        If Arrchavefalsa(m)=1 Then 
            fgCF=true
            exit for
        end if
    next
    if fgCF then
        ArrChave=split(Session("Chavefalsa"),";")
    else
        ArrChave=split(Session("Chave"),";")
    End if    
    ArrCampos=split(Session("Campos"),",")
    For i = 0 To ubound(ArrCampos,1)
        fcampo=ArrCampos(i)
        If ArrChave(i)=1 Then                                                         
            fsqlWhere = fsqlWhere & fcampo & "='" & ConverteDados(request.form(fcampo),fcampo) &  "' AND "        
        end if
    next
    fsqlwhere=" WHERE " & limpaCaracter(fsqlwhere,5) & ";"
end function
'
'---Montagem das SqlPesquisa
'---Lançamento de inclusão
function SqlPesquisa() 
        SqlPesquisa= "SELECT * FROM " & session("strTabela") & fsqlWhere        
end function
'

'
function ConverteDados(frequest,fcampo)
'---Tratamento da Data(Conversão formato inglês)    
    
    if isdate(frequest) and instr(frequest,":")=0 then        
        if instr(frequest,".")=0 and fcampo<>"nrodoc" then                                                        
            ConverteDados= converteData(frequest)
        else
            ConverteDados=frequest
        end if
    else
        Select Case fcampo
            case "senha"        
                frequest=Crypt(trim(frequest))
        end Select
        ConverteDados=frequest                          
    end if    
end function
'
function fcmh(fminutos)
    if fminutos="00:00" or fminutos="" or isnull(fminutos) then exit function
    wminutos=cdbl(fminutos)    
    whora=right(cstr("00" & cdbl(wminutos\60)),2)        
    wminutos=left(cstr(wminutos-whora*60) & "00",2)    
    fcmh=whora & ":" & wminutos
end function  
'
function fcmht(fminutos)    

    if fminutos="00:00" or fminutos="" or isnull(fminutos) then 
        fcmht="00:00"
        exit function
    end if
    wminutos=cdbl(fminutos)    
    whora=cstr(cdbl(wminutos\60))    
    if len(whora)=1 then Whora="0" & Whora    
    wminutos=right("00"&cstr(wminutos-whora*60),2)
    fcmht=whora & ":" & wminutos    
end function 
function arrfcmht(h)
    dim a
    a=mid(h,1,instr(h,":")-1)
    b=mid(h,instr(h,":")+1,1)
    if b > 5 then a=cint(a)+1
    arrfcmht=a&":00"
end function 
function limpaCaracter(strValorSujo,fnroCter)
    limpaCaracter= left(strValorSujo,len(strvalorSujo)-fnroCter)
end function  

'---Abre o Recordset e coloca os valores no vetor e cria uma string
'---Alteração e Exclusão de Dados
function RetornaDados(fSql)    
    RetornaDados=false
      Wrst(fSql)            
    IF NOT rst.EOF then        
        Wetor=rst.GetRows        
        rst.close    
        '---preenche a string valor com os elementos do vetor                
        for i=0 to ubound(Wetor,1)    
            ValCampos=ValCampos & Wetor(i,0) & ";"
        next
        RetornaDados=True 
        ValCampos=limpaCaracter(ValCampos,1)                    
        dados=split(ValCampos,";")
    end if    
    fechaConexao
end function
'
'---Inclusão de Dados
dim dados
function LimpaCampos()
    Wcampos=split(Session("Campos"),",")
    nroCampos=ubound(Wcampos)
    redim dados(nroCampos)
    for K=0 to nroCampos
      dados(K)=""
     
      next
 end function 
 '----
 function RetornaDescricao(fSql) 
      RetornaDescricao=""
       Wrst(fSql)    
     If NOT rst.EOF then RetornaDescricao=rst(0)
     set rst=nothing     
 end function
'
'---Apresentações na Tela
function confData(fdata)

    if fdata="" then 
        confData="00-00-0000"
    else
        Wdia=day(fdata):Wmes=month(fdata)
        if Wdia < 10 then Wdia="0" & Wdia
        if Wmes < 10 then Wmes="0" & Wmes
        confData= Wdia &"-" & Wmes & "-" & year(fdata)

    end if
end function
'
'---Data no formato(ddmmyyyy) passada por código
function datacod(fdata)
    wdia=mid(fdata,1,2):wmes=mid(fdata,3,2):wano=mid(fdata,5,4)
    datacod= wdia & "-" & wmes & "-" & wano  
end function
'
function fDtfinal(fdata,fdias)
    fDtfinal=ConverteData(cdate(fdata)+cint(fdias)-1)
end function
'
'---Data no formato p/Banco de Dados.
function ConverteData(fdata)
Dim Wdia,Wmes
    if fdata="" then
        ConverteData="2050-01-01"    
    else            
        if fdata="00-00-0000" then 
            ConverteData="0000-00-00"
        else        
            Wdia=day(fdata):Wmes=month(fdata)
            if Wdia < 10 then Wdia="0" & Wdia
            if Wmes < 10 then Wmes="0" & Wmes
                        
            ConverteData=cstr(year(fdata)& "-" & Wmes & "-" & Wdia)                    
        end if
    end if    
end function
'
'--->Prepara a Data para o Header/Vale Alimentação
function ConvData(fdata)
    Dim fdia,fmes    
    fdia=day(fdata):fmes=month(fdata)
    if fdia < 10 then fdia="0" & fdia
    if fmes < 10 then fmes="0" & fmes            
    ConvData=cstr(fdia & fmes & year(fdata))
end function
'
Dim valor,Wtype,Wlabel
sub nVisible(fcampo)    
    Wtype="hidden": Wlabel=""
    select case fcampo
        case "data_l","data_inscricao"
            valor=Date
        case "tipo_h"
            valor=session("intTpHis")
        case "pf"
            valor=session("pf")        
        case else
    end Select
end sub
'
dim Qdisabled
Sub MtTabela(facao)
    intAtv = session("atividade")
    
    
    
    '---Monta Tabela conforme os elementos fornecidos
    response.write("<Table class=estilo_tbl2 BORDER=0 CELLSPACING=0 CELLPADDING=1>")
    response.write("<tr><td class=estilo_13 colspan=10>"&session("titulo")&"</td></tr>")
    Watv=session("atividade")    
    ArrCampos=split(Session("Campos"),",")
    ArrAuto_inc=split(Session("Auto_inc"),";")
    ArrTabela=split(Session("tbl"),";")
    ArrChave=split(Session("Chave"),";")
    ArrSize=split(session("size"),";")
    Arrfuncao=split(Session("func"),";")
        
    If intAtv = 32 Or intAtv = 33 Then
        strsql="SELECT " & listaAno(CStr(Year(Now)+1),"1990") & ";"
        Wrst(strsql)
        response.write("<tr>")
        response.write("<td>Ano:</td>")
        response.write("<td><select name='ano' onChange='javascript:cbo(this)'  onFocus='' onKeyDown='if(event.keyCode==13) event.keyCode=9;'>")            
        response.write("<option value=''  >SELECIONE</option>") 
        ' Verifica se o filtro de ano foi selecionado
        If request.form("ano")<>"" Then
            intAno = request.form("ano")
        End If
        For i = 0 To rst.fields.count - 1
            If intMes = rst(i) Then 
                selected = "selected"
            Else
                selected = ""
            End If
            response.write("<option value="&rst(i)&" "&selected&">"&rst(i)&"</option>")
        Next
        response.write("</select></td></tr>")
        
        strsql="SELECT '01','02','03','04','05','06','07','08','09','10','11','12';"
        Wrst(strsql)
        response.write("<tr>")
        response.write("<td>Mês:</td>")
        response.write("<td><select name='mes' onChange='javascript:cbo(this)'  onFocus='' onKeyDown='if(event.keyCode==13) event.keyCode=9;'>")            
        response.write("<option value=''  >SELECIONE</option>") 
        ' Verifica se o filtro de mês foi selecionado
        If request.form("mes")<>"" Then
            intMes = request.form("mes")
        End If
        For i = 0 To rst.fields.count - 1
            If intMes = rst(i) Then 
                selected = "selected"
            Else
                selected = ""
            End If
            response.write("<option value="&rst(i)&" "&selected&">"&rst(i)&"</option>")
        Next
        response.write("</select></td></tr>")
        
        strsql="SELECT * FROM GERAL.tipo_curso order by nome;"
        Wrst(strsql)
        response.write("<tr>")
        response.write("<td>Tipo:</td>")
        response.write("<td><select name='tipo' onChange='javascript:cbo(this)'  onFocus='' onKeyDown='if(event.keyCode==13) event.keyCode=9;'>")            
        response.write("<option value=''  >SELECIONE</option>") 
        ' Verifica se o filtro de tipo foi selecionado
        If request.form("tipo")<>"" Then
            intTipo = CInt(request.form("tipo"))
        End If
        While Not rst.eof
            If intTipo = CInt(rst("codigo")) Then 
                selected = "selected"
            Else
                selected = ""
            End If
            response.write("<option value="&rst("codigo")&" "&selected&">"&rst("Nome")&"</option>")
            rst.MoveNext
        Wend
        response.write("</select></td></tr>")
    End If

    Qlong=0    
    for i=0 to ubound(ArrCampos,1)
            Qdisabled=""                                                             
            '---Campo Auto Numeração
            
            if Arrfuncao(i) <> "0" then Arrfuncao(i) = Arrfuncao(i) & "(this)"
            Wevento=" onBlur="
            funcao2=""                                                
            Wtype="text"
            Wlabel=Labels(i) 
            if  ArrAuto_inc(i)=1 then  nVisible(ArrAuto_inc(i))            
            Wcampo=ArrCampos(i)                                                    
            if Request.QueryString("id")="" then
                valor=Request.Form(Wcampo)
                If Wcampo = "tipo_exame" Then
                   If valor = "" Or IsNull(valor) Then
                      valor = "0"
                   End If    
                End If    
            else
                valor=dados(i)    
                If (Wlabel = "Naturalidade") Then
                   If ((valor = "0") OR (valor = "") OR (IsNull(valor))) Then
                      valor = "1"
                   End If    
                End If                    
            end if
            if Wcampo="data_l" then nVisible(Wcampo)
            Select Case Wcampo
                case "nrodoc","dias","valor","hora_em","hora_sm","hora_et","hora_st","hora_en","hora_sn"
                case "hora_d","hora_n","hora_db"
                case else
                    
                    
                    if IsDate(valor)  and facao and not instr(":",valor) > 0 then        
                        valor=confdata(valor)    
                    end if
            end Select                
                
            Select case watv
                
                case 21
                    If Wcampo="CPF"  Then 
                        if valor = "" then
                         valor =    session("cpf")
                        end if
                    End If
                case 11
                    '---e-mail do usuário
                    if Wcampo="pf"  then nVisible(Wcampo)
                case 12
                    '---Cadastro no Sistema                    
                    If Wcampo="senha"  Then 
                        valor=""
                        Wtype="password"
                    End If
                case 13
                    '---registro de Salários
                    if Wcampo="cargo"  then nVisible(Wcampo)
                    if facao=0 then
                        if Wcampo="cargo"  then valor=request.QueryString("cargo")
                    else
                        if Wcampo="tbl_sal"  then nVisible(Wcampo)
                        if Wcampo="data_a"  then nVisible(Wcampo)
                    end if
                    
                case 22 '---Dependentes
                    if Wcampo="pf" then nVisible(Wcampo)
                        
                case 31    
                    '---Treinamento-Registro do Treinamento
                    if Wcampo="id_trein"  then nVisible(Wcampo)
                    if facao= 0 then
                        if Wcampo="ativo"  then nVisible(Wcampo)
                    else
                        if Wcampo="ativo"  then  Wtype="checkbox"
                    end if
                case 32
                    '---Datas do Treinamento                                
                    'hora_em,hora_sm,hora_et,hora_st
                    if facao=0 then
                        if Wcampo="hora_em" then    valor=RetornaValor("hora_em")                    
                        if Wcampo="hora_sm" then    valor=RetornaValor("hora_sm")                
                        if Wcampo="hora_et" then    valor=RetornaValor("hora_et")
                        if Wcampo="hora_st" then    valor=RetornaValor("hora_st")
                        if Wcampo="hora_en" then    valor=RetornaValor("hora_en")
                        if Wcampo="hora_sn" then    valor=RetornaValor("hora_sn")
                    else
                        if Wcampo="data_capacitacao" then Qdisabled="readonly"
                        if Wcampo="id_trein" then Qdisabled="readonly"
                    end if
                
                case 33
                    '---Inscrição no Treinamento
                    if facao > 0 then
                        if Wcampo="matri" then Qdisabled="readonly"
                    end if                    
                    if Wcampo="data_inscricao" then nVisible(Wcampo)
                case 34
                    '---Freqüência no Treinamento    
                    if facao=0 then
                        If Wcampo="id_datas" Then
                            Session("id_datas") = valor
                        ElseIf Wcampo="id_inscricao" Then
                            Session("id_inscricao") = valor
                        End If
                        If Session("id_datas") <> "" Then
                            If Left(Wcampo,4) = "hora" Then
                                strSQL = "SELECT " & Wcampo & " FROM Srh.tr_datas dt "
                                strSQL = strSQL & "LEFT JOIN Srh.tr_insc i ON dt.id_trein = i.id_trein "
                                strSQL = strSQL & "WHERE dt.id_datas = " & Session("id_datas") & " AND i.id_inscricao = " & Session("id_inscricao")
                                valor = RetornaDescricao(strSQL)
                                If valor <> "" Then
                                    valor = FormatDateTime(valor, 4)
                                Else
                                    valor = "00:00"
                                End If
                            End If
                        End If
                    end if
                    if Wcampo="aproveitamento"  then nVisible(Wcampo)                                
                case 37
                    '---avaliação
                    if Wcampo="id_avaliacao" then nVisible(Wcampo)
                    if facao=0 then
                        if Wcampo="id_avaliacao"  then valor=request.QueryString("avaliacao")
                    else
                        if Wcampo="id_questao" then nVisible(Wcampo)
                    end if
                case 51
                    if Wcampo="folha" then nVisible(Wcampo)
                    'if Wcampo="funcao" then nVisible(Wcampo)
                case 101,102,103,105,107,118
                    '--histórico
                    '---genérico|Med.Discip.|Atos de Merec.|Mud.Horário|Banco horas                    
                    '---reintegração    
                    if Wcampo="matri" then
                        if facao > 0 then 
                            nVisible(Wcampo)
                        else
                             valor=Request.form("matri")
                        end if
                    end if                                        
                    if Wcampo="data_i" and facao > 0 then Qdisabled="readonly":valor=confData(dados(i))                    
                                        
                    if Wcampo="tipo_h" then nVisible(Wcampo)
                    if Wcampo="tempo" then valor=fcmht(valor)
                    if Wcampo="ultimo_pa" then nVisible(Wcampo)
                    if Wcampo="lotacao"  then                    
                        Select Case Watv
                            case 118
                                '---reintegração
                                valor=374
                                nVisible(Wcampo) 
                            case else
                            if facao =0 then valor=session("Slotacao")
                        End select            
                    end if
                    if     Wcampo="origem" then
                        if facao=0 then                        
                            valor=session("SLotacao")
                        else
                            session("SLotacao")=valor
                        end if
                        nVisible(Wcampo)                        
                    end if                                    
                case 111
                    '--histórico:Susp.Contrato                        
                    if Wcampo="matri" then
                        if facao > 0 then 
                            nVisible(Wcampo)
                        else
                             valor=Request.form("matri")
                        end if
                    end if                                        
                    if Wcampo="data_i" and facao > 0 then Qdisabled="readonly":valor=confData(dados(i))
                    'if Wcampo="data_f" and facao > 0 then nVisible(Wcampo):valor="00-00-0000"
                    if Wcampo="tipo_h" then nVisible(Wcampo)                    
                case 106
                    '--histórico|Demissão                        
                    if Wcampo="matri" then
                        if facao > 0 then 
                            nVisible(Wcampo)
                        else
                             valor=Request.form("matri")
                        end if
                    end if                                        
                    if Wcampo="data_i" and facao > 0 then Qdisabled="readonly":valor=confData(dados(i))                    
                                        
                    if Wcampo="tipo_h" then nVisible(Wcampo)
                    if Wcampo="dias" then nVisible(Wcampo):valor=1                    
                case 117                    
                    '--histórico                    
                    '---atrasos                    
                    if Wcampo="matri" then
                        if facao > 0 then 
                            nVisible(Wcampo)
                        else
                             valor=Request.form("matri")
                        end if
                    end if
                                        
                    if Wcampo="tipo_h" then nVisible(Wcampo)
                    if Wcampo="subtipo_h" then nVisible(Wcampo):valor="1800"
                    if Wcampo="tipo_d" then nVisible(Wcampo):valor="13"
                    if Wcampo="nrodoc" then nVisible(Wcampo):valor="atrasos"
                    if Wcampo="tempo" then valor=fcmht(valor)                    
                    if Wcampo="data_i" and facao > 0 then    Qdisabled="readonly"
                case 114                    
                    'SEST-af_funcional
                    if Wcampo="matri"  then nVisible(Wcampo):valor=session("matri")
                                        
                    if Wcampo="tipo_h" then nVisible(Wcampo)
                    if Wcampo="lotacao" then nVisible(Wcampo):valor=session("SLotacao")
                    if facao > 0 then
                        if Wcampo="data_e" then    valor=confdata(valor)
                        if Wcampo="data_i" then valor=confdata(valor)
                    end if
                case 119,120,121,122                    
                    '--histórico
                    '---Designação de FG|exoneração de FG|designação de substituição|Alteração de contrato
                    if Wcampo="matri"  then nVisible(Wcampo):valor=session("matri")
                                        
                    if Wcampo="tipo_h" then nVisible(Wcampo)                    
                    if Wcampo="data_i" and facao > 0 then    nVisible(Wcampo)
                    
                    'if Wcampo="cargo" and Watv=120 then valor=session("cargocomis"):nVisible(Wcampo)
                    
                    If Wcampo="cargo" and Watv=120 then
                      If((session("cargocomis") <> 0) AND (session("cargocomis") <> "") AND (NOT IsNull(session("cargocomis")))) Then
                        valor = session("cargocomis"):nVisible(Wcampo)
                      Else
                        valor = session("cargo"):nVisible(Wcampo)
                      End If
                    End If
                    
                    if Wcampo="lotacao" and Watv=120 then valor=Session("SLotacao"):nVisible(Wcampo)
                    if     Wcampo="origem" then
                        if facao=0 then                        
                            valor=session("SLotacao")
                        else
                            session("SLotacao")=valor
                        end if
                        nVisible(Wcampo)                        
                    end if
                case 108                    
                    '--histórico-transferência                    
                    if Wcampo="matri" and facao > 0 then nVisible(Wcampo)
                                        
                    if Wcampo="tipo_h" then nVisible(Wcampo)
                    if Wcampo="data_i" and facao > 0 then Qdisabled="readonly":valor=confData(dados(i))        
                    if     Wcampo="origem" then nVisible(Wcampo)                    
                    '---Localizando a origem/Registro de Transferência|
                    if     Wcampo="origem" and facao < 2 then                                        
                        strSql="SELECT lotacao from Srh.historico,GERAL.unidades" _
                        & " WHERE matri='" & session("matri")& "' AND tipo_h='10'" _
                        & " AND data_i <'"& ConverteData(request.form("data_i")) _
                        & "' ORDER BY data_i DESC LIMIT 1;"                                                        
                        valor=RetornaDescricao(strSql)                                                 
                    end if
                    '
                case 109
                    'horaextra                                                
                    if facao=0 then
                        if Wcampo="data_i"  then valor=RetornaValor(Wcampo)
                        if Wcampo="lotacao"  then valor=RetornaValor(Wcampo)                        
                    else
                        if Wcampo="data_i"  then valor=confData(valor):Qdisabled="readonly"
                        if Wcampo="matri"  then nVisible(Wcampo)
                        if left(Wcampo,4)="hora" then valor=fcmht(valor)
                        if Wcampo="lotacao" then nVisible(Wcampo)
                    end if                
                    if Wcampo="nrodoc" then nVisible(Wcampo)
                    if Wcampo="ano_mes" then nVisible(Wcampo)
                                                                            
                case 110,113
                    '--histórico                    
                    '---Efetividade|Atestados    
                    if Wcampo="matri" then
                        if facao > 0 then 
                            nVisible(Wcampo)
                        else
                             valor=session("matri")
                        end if
                    end if                                        
                    if Wcampo="data_i" and facao > 0 then Qdisabled="readonly":valor=confData(dados(i))                    
                                        
                    if Wcampo="tipo_h" then nVisible(Wcampo)
                    if Wcampo="nrodoc" and session("atividade")=110 then nVisible(Wcampo)
                    if Wcampo="lotacao" and facao =0 then valor=fUltLotEfet(session("matri"),request.form("data_i"))
                    if Wcampo="dias_fs" then 
                        nVisible(Wcampo)
                        if request.form("subtipo_h")<>"0402" then valor=1
                    end if
                case 115
                    '--histórico
                    '---Admissão
                    
                    if (facao = 0) and (Wcampo="matri") then
                        novaMatricula = GeraNovaMatricula
                     end if
                    
                    
                    if Wcampo="matri" and facao > 0 then nVisible(Wcampo):valor=session("matri")
                    if Wcampo="matri" and facao = 0 then valor=novaMatricula
                    if Wcampo="pf" then valor=session("pf") :nVisible(Wcampo)
                    if Wcampo="servidor" then nVisible(Wcampo)
                    if Wcampo="folha" then nVisible(Wcampo)
                    if Wcampo="dt_adm" then nVisible(Wcampo)
                    if Wcampo="ultimo_pa" then nVisible(Wcampo)
                    if Wcampo="dt_svg" then nVisible(Wcampo)
                                        
                    if Wcampo="tipo_h" then nVisible(Wcampo)
                    if Wcampo="situacao" then nVisible(Wcampo)                    
                    if Wcampo="data_i" and facao > 0 then    nVisible(Wcampo)
                case 123
                    '--histórico
                    '---Alteração do Período Aquisitivo
                    if Wcampo="matri"  then nVisible(Wcampo):valor=session("matri")
                    
                    if Wcampo="ultimo_pa" then                                             
                        if facao=0 then valor=Session("ultimo_pa")
                        nVisible(Wcampo)
                    end if
                    if Wcampo="tipo_h" then nVisible(Wcampo)
                    if Wcampo="data_i" and facao > 0 then    nVisible(Wcampo)
                case 125
                    '--histórico                    
                    '---cedência    
                    if Wcampo="matri" then
                        if facao > 0 then 
                            nVisible(Wcampo)
                        else
                             valor=RetornaValor("matri")
                        end if
                    end if                                        
                    if Wcampo="data_i" and facao > 0 then 
                        Qdisabled="readonly"                        
                        valor=confData(dados(i))
                    end if                    
                    if Wcampo="dias" then nVisible(Wcampo)
                                        
                    if Wcampo="tipo_h" then nVisible(Wcampo)
                case 126            
                    '---histórico:prorrogação de cedência
                    if Request.form("matri")<>"" then
                        strSql="SELECT lotacao,ced_caged,ced_funcao FROM Srh.historico"
                        strsql=strsql &" WHERE matri='"& session("matri")
                        strsql=strsql &"' AND INSTR('0501_0502_0503_0504',subtipo_h)<>0 ORDER BY data_i DESC LIMIT 1;"
                        if MontaVetor(strSql,vetor_aux,-1)<>-1 then                        
                            Wlotacao=vetor_aux(0,0)
                            Wced_caged=vetor_aux(1,0)
                            Wced_funcao=vetor_aux(2,0)
                        else
                            call msgaviso(31)
                        end if
                    end if    
                    if Wcampo="matri" then
                        if facao > 0 then 
                            nVisible(Wcampo)
                        else
                             valor=RetornaValor("matri")
                        end if
                    end if                                        
                    if Wcampo="data_i" and facao > 0 then Qdisabled="readonly":    valor=confData(dados(i))
                    if Wcampo="tipo_h" then nVisible(Wcampo)
                    if Wcampo="subtipo_h" then valor="0504":nVisible(Wcampo)
                    if Wcampo="tipo_d" then valor="03":nVisible(Wcampo)
                    if Wcampo="lotacao" then nVisible(Wcampo):valor=Wlotacao
                    if Wcampo="ced_caged" then nVisible(Wcampo):valor=Wced_caged
                    if Wcampo="ced_funcao" then    valor=Wced_funcao:nVisible(Wcampo)
                    
                case 127
                    '--histórico                    
                    '---Retorno antecipado de cedência                    
                    if Wcampo="lotacao" and request.form("matri")<>"" then
                        strSql="SELECT lotacao,ced_caged,data_i FROM Srh.historico"
                        strsql=strsql &" WHERE matri='"& session("matri")
                        strsql=strsql &"' AND INSTR('0501_0502_0503_0504',subtipo_h)<>0 ORDER BY data_i DESC LIMIT 1;"
                        if MontaVetor(strSql,vetor_aux,-1)<>-1 then
                            valor=vetor_aux(0,0)
                            Wced_caged=vetor_aux(1,0)
                            nVisible(Wcampo)
                            session("data_i")=ConverteData(vetor_aux(2,0))
                        end if
                    end if
                    
                    if Wcampo="matri" then
                        if facao > 0 then 
                            nVisible(Wcampo)
                        else
                            valor=RetornaValor("matri")
                        end if
                    end if                                        
                    if Wcampo="data_i" and facao > 0 then Qdisabled="readonly":valor=confData(dados(i))                    
                    if Wcampo="tipo_h" then nVisible(Wcampo)
                    if Wcampo="subtipo_h" then valor="0505":nVisible(Wcampo)
                    if Wcampo="tipo_d" then valor="03":nVisible(Wcampo)
                    if Wcampo="lotacao" then nVisible(Wcampo)
                    if Wcampo="ced_caged" then  nVisible(Wcampo):valor=Wced_caged
                    
                case 128
                    '--Férias                    
                    '--->Recibo do Aviso de Férias    
                    if Wcampo="matri" then valor=RetornaValor("matri")                    
                    if Wcampo="tipo_h" then nVisible(Wcampo)
                    if Wcampo="data_i" then Qdisabled="readonly"
                    if Wcampo="data_retorno_doc" then valor=""
                case 129
                    '--histórico
                    '---Alterção de Nível                        
                    if Wcampo="matri" then
                        if facao > 0 then 
                            nVisible(Wcampo)
                        else
                             valor=Request.form("matri")
                        end if
                    end if                                                        
                    if Wcampo="data_i" and facao <> 0 then valor=confData(dados(i))                    
                    if Wcampo="chave" then nVisible(Wcampo)
                    if Wcampo="tipo_h" then nVisible(Wcampo)
                    if Wcampo="cargo" and facao=0 then valor=session("cargo")
                    if Wcampo="cargo" then nVisible(Wcampo)                
                    if Wcampo="tipo_d" then valor="03":nVisible(Wcampo)
                case 130
                    '--histórico
                    '---Alterção de Carga Horária                        
                    if Wcampo="matri" then
                        if facao > 0 then 
                            nVisible(Wcampo)
                        else
                             valor=Request.form("matri")
                        end if
                    end if                                        
                    if Wcampo="data_i" and facao > 0 then Qdisabled="readonly":valor=confData(dados(i))                    
                                        
                    if Wcampo="tipo_h" then nVisible(Wcampo)
                    if Wcampo="subtipo_h" then valor="0901":nVisible(Wcampo)                
                    if Wcampo="tipo_d" then valor="03":nVisible(Wcampo)    
                    if Wcampo="horario" then valor="3":nVisible(Wcampo)    
                 case 136,134
                    '--histórico                    
                    '---adidos    
                    if Wcampo="matri" then
                        if facao > 0 then 
                            nVisible(Wcampo)
                        else
                             valor=RetornaValor("matri")
                        end if
                    end if                                        
                    if Wcampo="data_i" and facao > 0 then 
                        Qdisabled="readonly"                        
                        valor=confData(dados(i))
                    end if                    
                    if Wcampo="dias" then nVisible(Wcampo)
                                        
                    if Wcampo="tipo_h" then nVisible(Wcampo)    
                case 137            
                    '---histórico:prorrogação de adidos
                    if Request.form("matri")<>"" then
                        strSql="SELECT lotacao,ced_caged,ced_funcao FROM Srh.historico"
                        strsql=strsql &" WHERE matri='"& session("matri")
                        strsql=strsql &"' AND INSTR('2201_2202_2203_2204',subtipo_h)<>0 ORDER BY data_i DESC LIMIT 1;"
                        
                        if MontaVetor(strSql,vetor_aux,-1) <> -1 then    
                                        
                            Wlotacao=vetor_aux(0,0)                                
                            Wced_caged=vetor_aux(1,0)                            
                            Wced_funcao=vetor_aux(2,0)                            
                        else
                            call msgaviso(31)
                        end if
                    end if    
                    if Wcampo="matri" then
                        if facao > 0 then 
                            nVisible(Wcampo)
                        else
                             valor=RetornaValor("matri")
                        end if
                    end if                                        
                    if Wcampo="data_i" and facao > 0 then Qdisabled="readonly":    valor=confData(dados(i))
                    if Wcampo="tipo_h" then nVisible(Wcampo)
                    if Wcampo="subtipo_h" then valor="2204":nVisible(Wcampo)
                    if Wcampo="tipo_d" then valor="03":nVisible(Wcampo)
                    if Wcampo="lotacao" then nVisible(Wcampo):valor=Wlotacao
                    if Wcampo="ced_caged" then nVisible(Wcampo):valor=Wced_caged
                    if Wcampo="ced_funcao" then    valor=Wced_funcao:nVisible(Wcampo)
                     
                case 138
                    '--histórico                    
                    '---Retorno antecipado de adidos                    
                    if Wcampo="lotacao" and request.form("matri")<>"" then
                        strSql="SELECT lotacao,ced_caged,data_i FROM Srh.historico"
                        strsql=strsql &" WHERE matri='"& session("matri")
                        strsql=strsql &"' AND INSTR('2201_2202_2203_2204',subtipo_h)<>0 ORDER BY data_i DESC LIMIT 1;"
                        if MontaVetor(strSql,vetor_aux,-1)<>-1 then
                            valor=vetor_aux(0,0)
                            Wced_caged=vetor_aux(1,0)
                            nVisible(Wcampo)
                            session("data_i")=ConverteData(vetor_aux(2,0))
                        end if
                    end if
                    
                    if Wcampo="matri" then
                        if facao > 0 then 
                            nVisible(Wcampo)
                        else
                            valor=RetornaValor("matri")
                        end if
                    end if                                        
                    if Wcampo="data_i" and facao > 0 then Qdisabled="readonly":valor=confData(dados(i))                    
                    if Wcampo="tipo_h" then nVisible(Wcampo)
                    if Wcampo="subtipo_h" then valor="2205":nVisible(Wcampo)
                    if Wcampo="tipo_d" then valor="03":nVisible(Wcampo)
                    if Wcampo="lotacao" then nVisible(Wcampo)
                    if Wcampo="ced_caged" then  nVisible(Wcampo):valor=Wced_caged

                    
                case 203
                    '--->Pedido Extra                
                    if Wcampo="matri" then
                        if facao > 0 then 
                            nVisible(Wcampo)
                        else
                            valor=RetornaValor("matri")
                        end if
                    end if                                            
                    if Wcampo="dtref" and facao =0 and request.form("dtref")<>"00-00-0000" then valor=ConfData(RetornaValor("dtref"))
                    if request.form("dtref")="00-00-0000" then valor=""
                    if Wcampo="mes" and facao =0 then valor=RetornaValor("mes")
                    if Wcampo="ano" and facao =0 then valor=RetornaValor("ano")
                    if Wcampo="operacao" and facao =0 then valor=RetornaValor("operacao")
                    if Wcampo="valor" then 
                        if request.form("operacao")="2aVia" then 
                            valor=0
                            nVisible(Wcampo)
                        end if                        
                    end if
                    if Wcampo="folhas" then 
                        if request.form("operacao")="2aVia" then 
                            valor=0
                        else
                            valor=1
                        end if
                        nVisible(Wcampo)
                    end if                        
                case 207
                    'acertos_Vavr
                    if Wcampo="matricula"  and facao > 0 then Qdisabled="readonly"
                    if Wcampo="data_i" and facao > 0 then Qdisabled="readonly"
                    if Wcampo="data_f" and facao = 0 then valor="2050-01-01":nVisible(Wcampo)                    
                    
                case 209
                    'vt_servidor
                    if Wcampo="matricula" then
                        if facao > 0 then 
                            nVisible(Wcampo)
                        else
                            valor=RetornaValor("matricula")
                        end if
                    end if
                    if Wcampo="data_i" and facao > 0 then    nVisible(Wcampo)
                    if Wcampo="cod_linha" and facao > 0 then    nVisible(Wcampo)                    
                    if Wcampo="tipo_d"then    nVisible(Wcampo):valor=34                    
                case 210
                    '---Linhas do VTU
                     if Wcampo="cod_linha" and facao > 0 then    nVisible(Wcampo)
                case 211
                    '---valor das Linhas do VTU
                     if Wcampo="cod_linha"  then nVisible(Wcampo)
                     if Wcampo="cod_linha" and facao =0 then valor=request.QueryString("cod_linha")
                     
                case 212
                    '---Empresas do Plano de Saúde
                     if Wcampo="cod_ps" and facao > 0 then nVisible(Wcampo)                    
                     
                case 213
                    '---Servidores no Plano de Saúde    
                     
                case 214
                    'recibos do plano de saúde
                    if facao =0 then
                        if Wcampo="plano_ps" then valor=RetornaValor("plano_ps")                        
                        if Wcampo="ano" then valor=RetornaValor("ano")
                        if Wcampo="mes" then valor=RetornaValor("mes")
                        if Wcampo="ano_pg" then valor=RetornaValor("ano_pg")
                        if Wcampo="mes_pg" then valor=RetornaValor("mes_pg")
                    end if
                    
                    if Wcampo="tipo_d" then nVisible(Wcampo):valor=26
                    
                case 216
                    '---Entrega no Balcão do VTU/movimento do vtu
                    if Wcampo="matricula" then
                        if facao > 0 then 
                            nVisible(Wcampo)
                        else
                            valor=RetornaValor("matricula")
                        end if
                    end if                    
                    if Wcampo="valor" then
                        valor=replace(RetornaDescricao("SELECT valor FROM Beneficios.vt_linhas WHERE cod_linha='"&Request.form("cod_linha")&"';"),",",".")
                        Qdisabled="readonly"
                    end if
                    
                    if Wcampo="nro_passes_rec" and Request.form("cod_linha") <>"" then
                        valor=RetornaDescricao("SELECT nro_passes FROM Beneficios.vt_servidor" _
                        &" WHERE cod_linha='"& Request.form("cod_linha") _
                        &"' AND matricula='"& Request.form("matricula")&"';")
                        Qdisabled="readonly"
                    end if
                    if Wcampo="tipo_mov" then    valor="retirada":nVisible(Wcampo)    
                case 217
                    '---Devolução do VTU/movimento do vtu
                    if Wcampo="matricula" then
                        if facao > 0 then 
                            nVisible(Wcampo)
                        else
                            valor=RetornaValor("matricula")
                        end if
                    end if                    
                    if Wcampo="valor"  then Qdisabled="readonly"
                    if Request.form("cod_linha") <>"" and Request.form("ano")<>""  AND Request.form("mes")<>"" then
                        if Wcampo="valor"  then
                            valor=RetornaDescricao("SELECT valor FROM Beneficios.vt_movimento" _
                            &" WHERE cod_linha='"&Request.form("cod_linha") _
                            & "' AND matricula='" & Request.form("matricula") _
                            & "' AND ano='" & Request.form("ano") _
                            & "' AND mes='" & Request.form("mes")&"';")                            
                        end if
                        if Wcampo="nro_passes_rec" then
                            valor=RetornaDescricao("SELECT nro_passes_rec FROM Beneficios.vt_movimento" _
                            &" WHERE cod_linha='"&Request.form("cod_linha") _
                            & "' AND matricula='" & Request.form("matricula") _
                            & "' AND ano='" & Request.form("ano") _
                            & "' AND mes='" & Request.form("mes")&"';")                            
                        end if                        
                    end if
                    if Wcampo="tipo_mov" then    valor="devolve":nVisible(Wcampo)                        
                case 218                                        
                    '---Compra/movimento do vtu                    
                    if Wcampo="matricula" and Watv=218 then
                        '---chefe do Núcleo de Benefícios
                        valor="00000"
                        nVisible(Wcampo)
                    end if 
                    if Wcampo="valor" then
                        valor=RetornaDescricao("SELECT REPLACE(valor,',','.') AS vlr FROM Beneficios.vt_linhas WHERE cod_linha='"&Request.form("cod_linha")&"';")
                        Qdisabled="readonly"
                    end if                    
                    if Wcampo="tipo_mov" then    valor="compra":nVisible(Wcampo)                                    
                case 400
                    'pcmso
                    if Wcampo="matricula" and facao >0 then nVisible(Wcampo)                    
                    if Wcampo="lotacao" then valor=session("Slotacao"):nVisible(Wcampo)
                    if Wcampo="repetir" and request.form("data")<>"" then
                            Widade=datediff("yyyy",session("data_n"),cdate(request.form("data")))
                            if widade < 45 then
                                valor="12 m."
                            else
                                valor="24 m."
                            end if                        
                    end if
                    
            end select            
         
        
             response.write("<tr><td>"&Wlabel&"</td><td>")        
            
        
         'response.write("<td>"&Wlabel&"</td>")
            
        if ArrTabela(i)="0" then
            'campos com área maior            
            if Wcampo="motivo" or (Wcampo="nome" and session("atividade")=36) then%>
            <%If((Wcampo = "motivo") AND (session("atividade") = 114)) Then
                Dim vl
                vl = Trim(valor)
                If(vl <> "") Then
                  If(InStr(1, vl, "|") <> 0) Then
                    valor = Left(vl, Len(vl) - 2)
                  Else
                    valor = vl
                  End IF
                End If
              %>
                <textarea name="<%=Wcampo%>" class="campos" rows="3"  cols="35" onFocus="<%=funcao2%>" onKeyDown="if(event.keyCode==13) event.keyCode=9;"><%=valor%></textarea>
              <%Else%>
                <textarea name="<%=Wcampo%>" class="campos" rows="3"  cols="35" onFocus="<%=funcao2%>" onKeyDown="if(event.keyCode==13) event.keyCode=9;"><%=valor%></textarea>
              <%End If %>
            <%'02/04/2014 - Henrique - garante que o campo email será digitado apenas em minúsculas
            Elseif((Wcampo = "email") AND (session("atividade") = 21)) Then
            %>
            <input name="<%=Wcampo%>"  class="campos" type="<%=Wtype%>" value="<%=valor%>"  size=<%=ArrSize(i)%> <%=Qdisabled%>  <%=Wevento%>"<%=Arrfuncao(i)%>"  onFocus="<%=funcao2%>" onKeyDown="if(event.keyCode==13) event.keyCode=9;" onKeyUp="toLCase(this);">
            <%'02/04/2014 - Henrique - garante que os campos contenham apenas letras maiúsculas
            Elseif((((Wcampo = "Nome") OR (Wcampo = "Endereco") OR _
                (Wcampo = "bairro") OR (Wcampo = "pai")  OR (Wcampo = "mae") _  
                OR (Wcampo = "conjuje") OR (Wcampo = "titulacao")) AND (session("atividade") = 21)) _
                OR ((Wcampo = "nome") AND (session("atividade") = 51))) Then
            %>
            <input name="<%=Wcampo%>"  class="campos" type="<%=Wtype%>" value="<%=valor%>"  size=<%=ArrSize(i)%> <%=Qdisabled%>  <%=Wevento%>"<%=Arrfuncao(i)%>"  onFocus="<%=funcao2%>" onKeyDown="if(event.keyCode==13) event.keyCode=9;" onKeyUp="toUCase(this);">
            <%'03/04/2014 - Henrique - aplica uma máscara nos campos Fone e Celular
            Elseif(((Wcampo = "Fone") OR (Wcampo = "Celular")) AND (session("atividade") = 21)) Then
            %>
            <input name="<%=Wcampo%>"  class="campos" type="<%=Wtype%>" value="<%=valor%>" maxlength=<%=ArrSize(i)%> size=<%=ArrSize(i)%> <%=Qdisabled%>  <%=Wevento%>"<%=Arrfuncao(i)%>"  onFocus="<%=funcao2%>" onKeyDown="if(event.keyCode==13) event.keyCode=9;" onKeyUp="if(event.keyCode!=37 && event.keyCode!=39 && event.keyCode!=8) mascara(this, mascaraTelefone);">
            <%'04/04/2014 - Henrique - aplica uma máscara no campo CEP
            Elseif((Wcampo = "CEP") AND (session("atividade") = 21)) Then
            %>
            <input name="<%=Wcampo%>"  class="campos" type="<%=Wtype%>" value="<%=valor%>" maxlength=<%=ArrSize(i)%> size=<%=ArrSize(i)%> <%=Qdisabled%>  <%=Wevento%>"<%=Arrfuncao(i)%>"  onFocus="<%=funcao2%>" onKeyDown="if(event.keyCode==13) event.keyCode=9;" onKeyUp="if(event.keyCode!=37 && event.keyCode!=39 && event.keyCode!=8) mascara(this, mascaraCEP);">
            <%'04/04/2014 - Henrique - desabilita edição do CPF
            Elseif((Wcampo = "CPF") AND (session("atividade") = 21)) Then
            %>
            <input name="<%=Wcampo%>"  class="campos" type="<%=Wtype%>" value="<%=valor%>" readOnly="true" maxlength=<%=ArrSize(i)%> size=<%=ArrSize(i)%> <%=Qdisabled%>  <%=Wevento%>"<%=Arrfuncao(i)%>"  onFocus="<%=funcao2%>" onKeyDown="if(event.keyCode==13) event.keyCode=9;">
            <%'24/07/2014 - Henrique - aplica uma máscara apenas para números no campo CBO
            Elseif((Wcampo = "cbo") AND (session("atividade") = 51)) Then
            %>
            <input name="<%=Wcampo%>"  class="campos" type="<%=Wtype%>" value="<%=valor%>" maxlength=<%=ArrSize(i)%> size=<%=ArrSize(i)%> <%=Qdisabled%>  <%=Wevento%>"<%=Arrfuncao(i)%>"  onFocus="<%=funcao2%>" onKeyDown="if(event.keyCode==13) event.keyCode=9;" onKeyUp="if(event.keyCode!=37 && event.keyCode!=39 && event.keyCode!=8) mascara(this, mascaraNum);">
            <% Elseif((Wcampo = "tempo") AND (session("atividade") = 105)) Then %>
            <input name='tre_horas'  type='hidden' value='<%=valor%>' />
            <input name="<%=Wcampo%>"  class="campos" type="<%=Wtype%>" value="<%=valor%>"  size="<%=ArrSize(i)%>" <%=Qdisabled%> <%=Wevento%>"<%=Arrfuncao(i)%>" onFocus="<%=funcao2%>" onKeyDown="if(event.keyCode==13) event.keyCode=9;">
            <% Elseif((Wcampo = "dias") AND (session("atividade") = 110)) Then %>
            <input name='dias_old'  type='hidden' value='<%=valor%>' />
            <input name="<%=Wcampo%>"  class="campos" type="<%=Wtype%>" value="<%=valor%>"  size="<%=ArrSize(i)%>" <%=Qdisabled%> <%=Wevento%>"<%=Arrfuncao(i)%>" onFocus="<%=funcao2%>" onKeyDown="if(event.keyCode==13) event.keyCode=9;">
            <%Else%>
            <input name="<%=Wcampo%>"  class="campos" type="<%=Wtype%>" value="<%=valor%>"  size=<%=ArrSize(i)%> <%=Qdisabled%>  <%=Wevento%>"<%=Arrfuncao(i)%>"  onFocus="<%=funcao2%>" onKeyDown="if(event.keyCode==13) event.keyCode=9;">
            <%End If
        else
            if  ArrChave(i) = 0 or (Arrchave(i)=1 and facao=0) Then                
                if wtype<>"hidden" then
                    preenchelista ArrTabela(i),valor
                else
                    %>
                    <input name="<%=Wcampo%>"  type="<%=Wtype%>" value="<%=valor%>"  size="60" >
                    <%
                end if            
            else %>
            
            <input name="<%=Wcampo%>"  type="<%=Wtype%>" value="<%=valor%>"  size="60"    onBlur="<%=funcao%>"  onFocus="<%=funcao2%>" onFocus="<%=funcao2%>" onKeyDown="if(event.keyCode==13) event.keyCode=9;">
            <%
            end if
        end if            
    response.write("</td></tr>")    
    next
    response.write("</table>")
        
    botoes facao
    
end sub
'---inicio

'---fim
'
'
'
Function DadosServidor(fnum)
'---Lotações virtuais:
'---367---Cont.susp.por Solicitação
'---368---cont.susp.Judicialmente
'---374---A disp.da coord.-aguarda lotação
'---375---Aposentadoria por invalidez
'---376---Lic.de Saúde/SAT
DadosServidor=false
if fnum="" then exit function
Watv= session("atividade")
strSql = "SELECT contrato.matri,contrato.pf,pessoafisica.nome,cargos.nome" _
&",unidades.codigo,unidades.nome,ultimo_pa,servidor,DATE_FORMAT(dt_adm,'%d-%m-%Y')," _
& "DATE_FORMAT(data_n,'%d-%m-%Y'),contrato.rc,contrato.ch,IF(contrato.horario=0,1,contrato.horario)AS horar,contrato.cargo_comis,contrato.cargo  " _
&",CONCAT(format((period_diff(date_format(now(),'%Y%m'),date_format(data_n,'%Y%m')))/12,0),' anos') AS anos,va_vr, Fazenda.id_Fazenda, Fazenda.vinculo " _
&" FROM Srh.contrato JOIN Srh.pessoafisica pessoafisica ON contrato.pf = pessoafisica.PF " _
&" JOIN GERAL.unidades ON unidades.codigo = contrato.lotacao " _
&" JOIN GERAL.cargos ON contrato.cargo = cargos.id_cargo " _
'&" JOIN Srh.Fazenda contrato.matri = Fazenda.matri " _
'&" WHERE "

   If(Len(fnum) = 7) Then
     strSql = strSql & " LEFT JOIN Srh.Fazenda ON contrato.matri = Fazenda.matri "
     strSql = strSql & " WHERE "
     strSql = strSql & " Fazenda.id_Fazenda = '"&fnum&"' ;"
   Else
     strSql = strSql & " LEFT JOIN Srh.Fazenda ON contrato.matri = Fazenda.matri "
     strSql = strSql & " WHERE "
     strSql = strSql & " contrato.matri = '" & fnum & "';"
   End If

    if RetornaDados(strSql) then
        DadosServidor=true        
        'Session("fazenda")=dados(17) & "-" & dados(18)        
        Session("fazenda")=dados(17)
        Session("nv")=dados(18)
        Session("matri")=dados(0)        
        session("pf")=dados(1)        
        Session("Servidor")=dados(2)
        Session("SCargo")=dados(3)
        Session("SLotacao")=dados(4)
        Session("SLotacao_nome")=dados(5)
        Session("ultimo_pa")=dados(6)
        Session("ativo")=dados(7)
        session("dt_adm")=dados(8)
        session("data_n")=dados(9)
        session("regime")=dados(10)
        session("ch")=dados(11)
        session("horario")=dados(12)
        session("cargocomis")=dados(13)
        session("cargo")=dados(14)
        session("idade")=dados(15)
        session("plano") = ""
        
        ' Obtém o cargo da última adesão de plano do servidor
        strSql = "SELECT h.Cargo, c.Nome FROM Srh.historico h, GERAL.cargos c WHERE h.matri = '"& Session("matri") &"' "
        strSql = strSql & " AND h.SubTipo_H = '9100'"
        strSql = strSql & " AND Cargo = ID_cargo ORDER BY h.Data_I DESC LIMIT 1;"
        Wrst(strSql)
        If(NOT rst.EOF) Then
            Session("SCargo") = rst("Nome")
            Session("cargo")  = rst("Cargo")
        End If
        
        ' Obtém o plano da última adesão de plano do servidor
        strSql = "SELECT pcs.sigla FROM Srh.adesao_plano ap"
        strSql = strSql & " LEFT JOIN Srh.PlanoCargosSalarios pcs ON pcs.Id = ap.id_plano"
        strSql = strSql & " WHERE ap.matri = '"& Session("matri") &"'"
        strSql = strSql & " ORDER BY ap.dt_adesao DESC LIMIT 1;"
        Wrst(strSql)
        If(NOT rst.EOF) Then
            session("plano") = rst("sigla")
        End If
        
        '---Análise p/movimentos        '
        Select Case Watv
            case 122    '---Designação de C.C para servidor fora do quadro. 
                if session("regime")<>"3" then msgAviso(13)
            case 108    '---Transferência de Servidor,Servidor c/contrato susp. por solic/ou judic.
                if Session("SLotacao")="367" or Session("SLotacao")="368" then
                    '---Veifica se tem férias pendentes.
                    strSql="SELECT data_i,data_f FROM Srh.historico" _
                    & " WHERE  matri='" & Session("matri") _
                    & "' AND tipo_h='06' ORDER BY  data_i DESC LIMIT 1;"                                        
                    call Retornadados(strSql)                    
                    strSql="SELECT COUNT(*) FROM Srh.historico" _
                    & " WHERE  matri='" & Session("matri")& "' AND tipo_h='11'" _
                    & " AND data_i BETWEEN '"& ConverteData(dados(0)) _
                    & "' AND '"& ConverteData(dados(1)) & "';"                    
                    Wrst(strSql)
                    if rst(0)<>"0" then msgaviso(22)
                end if
            case 120
                 
                  strSql = "SELECT cargo, nome from Srh.historico, GERAL.cargos WHERE matri = '"& Session("matri") &"' " _
                  & " AND subtipo_h in ('0311','0312') " _
                  & " AND cargo = id_cargo ORDER BY historico.data_i DESC LIMIT 1;"
                  Wrst(strSql)
                  If(NOT rst.EOF) Then
                   Session("SCargo") = rst("nome")
                   session("cargo")  = rst("cargo")
                  End If
                                   
            case 203              
                if dados(16)="n/r" then msgaviso(41)    
        End Select
        
    else
        msgAviso(4)'---Matrícula/CPF sem registro na tabela contrato.
    end if
End Function
'
'
function fmtmatri(fmatri)
    fmtmatri=left(fmatri,4)&"."& right(fmatri,1)
end function

Sub MontaServidor()
    Watv=session("atividade")
    Response.write("<table align=center class=estilo_3>")
    Response.write("<tr><td>Matrícula: "&fmtmatri(Session("matri"))&"</td>")
    SQL = "select pf.Nome, cg.Nome, u.Nome, c.servidor, h.data_i as admissao, pf.Data_N, "
    SQL = SQL & "f.id_fazenda, f.vinculo, " 
    SQL = SQL & "CONCAT(format((period_diff(date_format(now(),'%Y%m'),date_format(pf.Data_N,'%Y%m')))/12,0),' anos') as idade "
    SQL = SQL & "from Srh.contrato c "
    SQL = SQL & "left join Srh.pessoafisica pf on pf.pf = c.pf "
    SQL = SQL & "left join Srh.Fazenda f on f.matri = c.matri "
    SQL = SQL & "left join Srh.historico h on h.matri = c.matri "
    SQL = SQL & "left join GERAL.unidades u on u.Codigo = c.lotacao "
    SQL = SQL & "left join GERAL.cargos cg on cg.ID_cargo = c.cargo "
    SQL = SQL & "where h.Subtipo_h in ('0101','0102','0103','0105','0199') "
    SQL = SQL & "and c.matri = '" & Session("matri") & "'"

     response.write("Usuario Logado: " + session("logado"))
    if (session("logado") = "marcio-souza") then
      response.write(SQl)
    end if
    
    RetornaDados(SQL)
    

    strNome = dados(0)
    strCargo = dados(1)
    strLotacao = dados(2)
    strAtivo = dados(3)
    strDataAdm = dados(4)
    strDataNasc = dados(5)
    strIdFazenda = dados(6)
    strVinculo = dados(7)
    strIdade = dados(8)
    
    Response.write("<td>Nome: "&StrNome&"</td>")
    Response.write("<tr><td>Cargo: "&strCargo&"</td>")
    '---Servidor Demitido/Sem Lotação    
    If strAtivo ="1" then
        Response.write("<td>Lotação: "&strLotacao&"</td></tr>")
    Else
        SQL = "SELECT subtipo_h, data_i from Srh.historico where matri = '"& Session("matri") &"' ORDER BY data_i DESC limit 1;"
        RetornaDados(SQL)
        data_i = dados(1)
        subtipo_h = dados(0)
        
        SQL = "SELECT nome FROM GERAL.txthis WHERE codigo = '"& subtipo_h &"'"      
        
        RetornaDados(SQL)    

        nome = dados(0)
        
        Response.write("<td class=estilo_7>"& nome &" - "& data_i &"</td></tr>")
    End If
    
    Response.write("<tr><td>Admissão: "&strDataAdm&"</td>")
    Response.write("<td>Nascimento: "&strDataNasc&"</td></tr>")
    Select Case Watv
        case 213
            Response.write("<td class=estilo_7>idade "&strIdade&"</td></tr>")
    End select    
    
    'If((session("Fazenda") <> "") AND (Len(session("Fazenda")) = 9)) Then
    If(strIdFazenda <> "") Then
      id_fazenda = strIdFazenda
      nv = strVinculo
    Else
      id_fazenda = "(n&atilde;o informado)"
      nv = "N/I"
    End If
     
    Response.write("<tr><td colspan=1>ID funcional: "&id_fazenda&"</td><td colspan=1>NV: "&nv&"</td></tr>")
    Response.write("</table>")
End Sub 

'
Sub MontaTreinamento(ftreinamento)    
    strsql="SELECT cursos.nome AS CURSO,unidades.sigla AS LOCAL,DATE_FORMAT(c_DataInicial,'%d-%m-%Y'),turma"
    strsql=strsql &    " FROM Srh.tr_cursos,GERAL.cursos,GERAL.unidades"
    strsql=strsql & " WHERE c_curso=cursos.codigo"
    strsql=strsql & " AND c_local=unidades.codigo  and ativo = 1 "
    strsql=strsql & " AND id_trein='" & ftreinamento & "';"    
    
    RetornaDados(strsql)
    
    Response.write("<table align=center class=estilo_6>")
    Response.write("<tr><td>"&dados(0)&"</td>")
    Response.write("<td>"&dados(1)&"</td>")
    Response.write("<tr><td>Início"&dados(2)&"</td>")
    Response.write("<tr><td>Turma:"&dados(3)&"</td></tr>")
    Response.write("</table>")
end sub    
'
function DadosPessoafisica(fnumero,fatv)
session("pf")="":Session("Servidor")="":Session("matri")=""

if len(fnumero) > 5 then
    '---Testa na tbl:pessoafisica 
    strSql = "SELECT pf,nome FROM Srh.pessoafisica"
    strSql=strSql & " WHERE cpf='" & fnumero & "';"
    if RetornaDados(strSql) then
        DadosPessoafisica=true        
        session("pf")=dados(0)        
        Session("Servidor")=dados(1)
        '---Verificando se o servidor tem contrato ativo.
        strSql = "SELECT count(*) FROM Srh.pessoafisica,Srh.contrato"
        strSql=strSql & " WHERE pessoafisica.PF=contrato.PF"
        strSql=strSql & " AND servidor='1'"
        strSql=strSql & " AND contrato.pf='" & dados(0) & "';"        
        if RetornaDescricao(strSql)=cint(1) then msgaviso(11)
    else
        '---cadastro da pessoa fisica    
        if fatv<>21 then msgaviso(9)
    end if    
else
    'Testa na tbl:contrato
    strSql = "SELECT contrato.pf,pessoafisica.nome,contrato.matri FROM "
    strSql=strSql & " Srh.pessoafisica,Srh.contrato"
    strSql=strSql & " WHERE pessoafisica.PF=contrato.PF"
    strSql=strSql & " AND contrato.Matri='" & fnumero & "';"
        if RetornaDados(strSql) then
            DadosPessoafisica=true
            session("pf")=dados(0)        
            Session("Servidor")=dados(1)
            Session("matri")=dados(2)
        else            
            msgaviso(10)
        end if
end if 
end function
'
sub MontaPessoaFisica()
    response.write("<table><TR><td><h5>Cadastrado no Sistema:"&Session("Servidor")&"</h5></td></TR></table>")
end sub

'
sub MontaQuestao(fquestao,favaliacao)
    if fquestao<>"" then
        response.write("<table align=center>")
        response.write("<TR><td>Avaliacao:"&favaliacao&"</td></TR>")
        response.write("<TR><td>Questão:"&fquestao&"</td></TR>")
        response.write("</table>")    
    end if
end sub

sub botoes(condicao)
Select Case session("Atividade")
    case 131
        if condicao=0 then
            strBotao="INCLUIR"
        else
            strBotao="ALTERAR"
        end if
         condicao=4
    'case 14
    '    if condicao=0 then
    '        strBotao="INCLUIR"
    '    else
    '        strBotao="ALTERAR"
    '    end if
    '    strBotao=strBotao&",LIMPAR"
     '    condicao=5    
    case 14    
        strBotao=strBotao&"INCLUIR,ALTERAR,EXCLUIR,LIMPAR"
         condicao=5
    case else
        strBotao="INCLUIR,ALTERAR,EXCLUIR,LIMPAR,LISTA,SAIR"
End Select
nomebotao=split(strBotao,",")
nrobotoes=ubound(nomeBotao,1)
redim esmaecido(nrobotoes)
for K=0 to nrobotoes
    esmaecido(K)="disabled"
next
Select Case session("Atividade")
    case 131
    case 14
        esmaecido(1)=""
    case 111
        esmaecido(1) = ""
    case else
        esmaecido(4)=""
        esmaecido(5)=""
End Select
select case condicao
    case 0    '---Inclusão
        esmaecido(0)=""
        esmaecido(3)=""
        if session("atividade")=106 and session("ativo")=0 then esmaecido(0) ="disabled"
    case 1    '---Alteração/Exclusão
        esmaecido(1)=""
        esmaecido(2)=""
    case 2    '---Exclusão
        esmaecido(2)=""
    case 3    '---Alteração
        esmaecido(1)=""
    case 4    '---Botão Confirme
        esmaecido(0)=""
    case 5    '---horário
        esmaecido(0)=""
        esmaecido(1)=""    
        esmaecido(2)=""
        esmaecido(3)=""            
end select
    response.write("<br>")
    response.write("<table cellspacing=0 align=center>")
    response.write("<tr>")        
    for K=0 to nrobotoes
    %>
        <td ><input name="<%=nomebotao(k)%>"   value="<%=nomebotao(k)%>"type="button" class="botao" <%=esmaecido(K)%> onClick="javascript:botao(<%=k%>)"></td>
    <%
    next
    response.write("</tr></table>")
end sub 

function preparaSql(ftabela,fcampos)
    preparaSql="SELECT " & fcampos & " FROM " & ftabela &  " WHERE "
end function
'
'
'---prepara os dados para INCLUIR,ALTERAR E EXCLUIR
'---origem:incAltExc.asp
'---Carrega a função montaTabela
function geraSql()
    ArrCampos=split(Session("nomeChaves"),",")        
    Wchaves=split(request.QueryString("id"),";")
    For i = 0 To ubound(Wchaves,1)                                         
        WsqlWhere = WsqlWhere & ArrCampos(i) & "='" & ConverteDados(Wchaves(i),ArrCampos(i)) &  "' AND "
    next
    Wsqlwhere=" WHERE " & limpaCaracter(Wsqlwhere,5) & ";"        
    Select case session("atividade")
        case 32
            '---Datas do treinamento
            '---Formato que deve ser utilizado.
            fcampos ="id_datas,id_trein,DATE_FORMAT(data_capacitacao,'%d-%m-%Y') ,left(hora_em,5)"
            fcampos=fcampos & ",left(hora_sm, 5),left(hora_et,5),left(hora_st,5)"                    
            fcampos=fcampos & ",left(hora_en,5),left(hora_sn,5)"    
        case 34
            '---Freqüência nos Treinamentos
            fcampos ="id_freq,id_datas,id_inscricao,left(hora_em,5)"
            fcampos=fcampos & ",left(hora_sm, 5),left(hora_et,5),left(hora_st,5)"
            fcampos=fcampos & ",left(hora_en,5),left(hora_sn,5),aproveitamento"
        case else
            fcampos=Session("CamposCons")                        
    end select    
            geraSql="SELECT " &  fcampos & " FROM " & session("strTabela") & Wsqlwhere
            'faux(geraSql)                
end function
'
function ValChaves(n)    
    Wchaves=""
    for j=0 to NroChaves
        Wchaves=Wchaves & Vetor(j,n) & ";"
    next
    ValChaves=limpaCaracter(Wchaves,1)
end function
'

dim NroChaves
sub MtLista()

Dim Wsoma,Wtempo,Wnrolista
'response.write("1")
session("corpo")=""
Wsoma=0:Wtempo=0
Watv=session("atividade")
Klista="<dt class=estilo_3>&nbsp;&nbsp;&nbsp;"
Kespace="&nbsp;&nbsp;&nbsp;"
ArrChave=split(Session("nomeChaves"),",")
NroChaves=ubound(ArrChave,1)
response.write("<br>")
response.write("<ol class=listas >")
    '---chaves da lista        
    '---Informações da Lista(cabeçalhos)    
    Select Case Watv
        case 22
            '---Pessoa Física|Dependentes                 
            MontaPessoaFisica
        case 112 
            '---Férias
            response.write("<h5>Ano-Per.Aquisitivo:&nbsp;&nbsp;&nbsp;"&request.QueryString("Wano")&"</h5>")
    end select        
    '---origem:sql_select/sqllista
    Wnrolista=MontaVetor (sqlLista,vetor,0)
    for n=0 to  Wnrolista        
    Select case Watv
        case 12
            '---Cadastro no sistema
            if n > 0 then
                if vetor(3,n)<>vetor(3,n-1) then
                    response.write("<dl><dt class=estilo_7>Categoria:"&vetor(2,n)&"</dl>")
                end if
            else
                response.write("<dl><dt class=estilo_7>Categoria:"&vetor(2,n)&"</dl>")
            end if
            response.write("<li><a href=incAltExc.asp?id="&ValChaves(n)&">"&digmatri(vetor(0,n))&"&nbsp;&nbsp;&nbsp;"&vetor(1,n)&"</a></li>")            
        case 13
            '---Registro de Salários
             response.write("<li><a href=incAltExc.asp?id="&ValChaves(n)&">"&confData(vetor(0,n))&"&nbsp;&nbsp;&nbsp;Tabela " _
             &vetor(1,n)&"&nbsp;&nbsp;&nbsp;"&formatcurrency(vetor(3,n))&"</a></li>")
        case 14
            '---Registro de horários
             response.write("<li><a href=horario.asp?"&vetor(0,n)&">"&vetor(1,n)&"</a></li>")
             response.write("<dl><br></dl>")
        case 21
            '---Pessoa Física
            response.write("<li><a href=incAltExc.asp?id="&ValChaves(n)&">"&vetor(1,n)&"</a></li>")
            response.write("<dl><dt>CPF:"&vetor(2,n)&"</dl>")
        case 22
            '---Dependentes
            response.write("<li><a href=incAltExc.asp?id="&ValChaves(n)&">"&vetor(1,n)&"</a></li>")
            response.write("<dl><dt>&nbsp;&nbsp;&nbsp;Nascimento:&nbsp;"&vetor(2,n))
            response.write("<dt>&nbsp;&nbsp;&nbsp;"&vetor(3,n)&"</dl>")
        case 25 '---Unidades 
        
        %>
            
                        
        <li><a href="incAltExc.asp?id=<%=ValChaves(n)%>&classificacao=<%=vetor(6,n)%>"><%=vetor(1,n)%></a>
            <ul>
                <li>Penosidade:<%=vetor(2,n)%>&nbsp;&nbsp;&nbsp;
                <li>Fone:<%=vetor(3,n)%>&nbsp;&nbsp;&nbsp;Fax:<%=vetor(4,n)%>&nbsp;&nbsp;&nbsp;Ramal:<%=vetor(5,n)%>
            </ul>
        <%case 31 
            'Treinamento
            session("cursos")=request.QueryString("cursos")
            session("unidades")=request.querystring("unidades")
            session("areas_atuacao")=request.querystring("areas_atuacao")
            WmtTrein=vetor(2,n)& ";" & vetor(8,n)& ";" & vetor(3,n)            
            %>
            <li><a href="incAltExc.asp?id=<%=ValChaves(n)%>&WmtTrein=<%=WmtTrein%>"><%=vetor(2,n)%></a>                                    
                        
            <%
            response.write("<ul>")
        %>
                <li>Área:<%=vetor(12,n)%>
                <li>Início:<%=vetor(3,n)%>&nbsp;&nbsp;&nbsp;Término:<%=vetor(5,n)%>
                <li>CH:<%=vetor(6,n)%>&nbsp;&nbsp;&nbsp;HORÁRIO:<%=vetor(14,n)%>
                <li>Local:<%=vetor(8,n)%>
        <%
        response.write("</ul><br>")
        
        case 32      
            '---Datas do Treinamento             
            response.Write("<li><a href=incAltExc_efe2.asp?id="&ValChaves(n)&">"&confData(vetor(1,n))&"</a>")
            response.Write("<ul><li>Horários:"&vetor(2,n)&"&nbsp;&nbsp;&nbsp;"&vetor(3,n)&"&nbsp;&nbsp;&nbsp;"&vetor(4,n)&"&nbsp;&nbsp;&nbsp;"&vetor(5,n)&"&nbsp;&nbsp;&nbsp;"&vetor(6,n)&"&nbsp;&nbsp;&nbsp;"&vetor(7,n)&"</ul>")
        case 33 
        if n > 0 then
            if vetor(3,n)<>vetor(3,n-1)then                
                response.write("<dt class=estilo_6>"&vetor(3,n)&"</dt>")
            end if
        else
            response.write("<dt class=estilo_6>"&vetor(3,n)&"</dt>")
        end if 
            '---Inscritos no treinamento            
        response.write("<dt>&nbsp;&nbsp;&nbsp;<a href=incAltExc_efe2.asp?id="&ValChaves(n)&"&matri="&vetor(1,n)&">"&digmatri(vetor(1,n))&" "&vetor(2,n)&"</a>")
        case 34  
            '---freqüência no treinamento
        Qfalta=""
        if vetor(3,n)="00:00" And vetor(4,n)="00:00" And vetor(5,n)="00:00" And vetor(6,n)="00:00" And vetor(7,n)="00:00" And vetor(8,n)="00:00" then Qfalta="falta"
        response.write("<li><a href=incAltExc_efe2.asp?id="&ValChaves(n)&"&treinamento="&vetor(1,n)&">"&Confdata(vetor(2,n))&"</a></li>")
        response.write("<dt class=estilo_6>&nbsp;&nbsp;&nbsp;Manhã "&vetor(3,n)&"-"&vetor(4,n))
        response.write("&nbsp;&nbsp;&nbsp;Tarde "&vetor(5,n)&"-"&vetor(6,n))
        response.write("&nbsp;&nbsp;&nbsp;Noite "&vetor(7,n)&"-"&vetor(8,n) & "&nbsp;&nbsp;&nbsp;" &Qfalta &"</dt>")
        case 35,36  
            '---Treinamento:nome_avaliação,questões,Avaliação
            response.write("<li><a href=incAltExc.asp?id="&ValChaves(n)&">"&vetor(1,n)&"</a></li>")  
        case 37      
            '---Treinamento:Avaliação            
        %>
        <li><a href="incAltExc.asp?id=<%=ValChaves(n)%>&questao=<%=vetor(2,n)%>&aval=<%=vetor(3,n)%>"><%=vetor(2,n)%></a></li>
        <%
        '---Nacionalidade,Conselho,Nome da Avaliação,Questões da Avaliação,Áreas de Atuação
        '---vt_grupo
        case 23,24,38,39,40,201            
            response.write("<li><a href=incAltExc_efe2.asp?id="&ValChaves(n)&">"&vetor(1,n)&"</a></li>")         
        '---Cargos
        case 41
        '---participação em cursos
            response.write("<li><a href=incAltExc_efe2.asp?id="&ValChaves(n)&">"&vetor(1,n)&"</a></li>") 
            response.write("<dl class=estilo_6>"&vetor(2,n)&"</dl>")
            response.write("<dl class=estilo_6>"&vetor(3,n)&"</dl>")
            response.write("</dl><br>")
        case 51   
            response.write("<li><a href=incAltExc.asp?id="&ValChaves(n)&">"&vetor(1,n)&"</a></li>")
            response.write("<dl class=estilo_3>")
            response.write(klista &"Padrão: "&vetor(2,n)&" Folha: "&vetor(3,n)&" CBO: "&vetor(4,n))
            response.write("</dl>")
            response.write("<dl class=estilo_7>")
            Wdisponivel=cint(vetor(5,n))-cint(vetor(6,n))
            response.write(klista &"Nro Vagas: "&vetor(5,n)&"&nbsp;&nbsp;&nbsp;Ocupados: "&vetor(6,n)&"&nbsp;&nbsp;&nbsp;Disponíveis:"&Wdisponivel)                             
            response.write("</dl><br>")        
        '---historico:Genérico|Med.Disciplinares|Atos de Merec.|Alt.horário|Demissão|Imp.Sindical
        '---transferência|susp.Contrato|atrasos|alteração do P.A
        case 101,102,103,107,108,111,118,123,129,130
            'response.write("<li class=estilo_7><a href=incAltExc_efe2.asp?id="&ValChaves(n)&"&matri="&vetor(0,n)&">"&confData(vetor(1,n))&" "&vetor(3,n)&"</a>")     
            If(Watv = 108) Then
              response.write("<li class=estilo_7><a href=../incAltExc_efe2.asp?id="&ValChaves(n)&"&matri="&vetor(0,n)&">"&confData(vetor(1,n))&" "&vetor(3,n)&"</a>")     
            ElseIf(Watv = 129) Then
              response.write("<li class=estilo_7><a href=incAltExc_efe2.asp?id="&ValChaves(n)&"&matri="&vetor(1,n)&">"&confData(vetor(3,n))&" "&vetor(4,n)&"</a>")    
            Else
              response.write("<li class=estilo_7><a href=incAltExc_efe2.asp?id="&ValChaves(n)&"&matri="&vetor(0,n)&">"&confData(vetor(1,n))&" "&vetor(3,n)&"</a>")     
            End If    
            
            Select case Watv
                case 102 
                    response.write("<dl class=estilo_6>Dias de Suspensão:")& vetor(7,n)                
                                                        
                case 107 '---Imp.sindical
                    response.write("<dl class=estilo_7>&nbsp;&nbsp;&nbsp;Valor Recolhido&nbsp;R$" & vetor(8,n) &"</dl>")
                    response.write("<dl class=estilo_6>&nbsp;&nbsp;&nbsp;Sindicato&nbsp;"&vetor(7,n)&"</dl>")
                case 108 '---Transferência
                    response.write("<dl class=estilo_6>&nbsp;&nbsp;&nbsp;Local de Destino:"&vetor(7,n)&"</dl>")
                    response.write("<dl class=estilo_6>&nbsp;&nbsp;&nbsp;Responsável:"&vetor(8,n)&"</dl>")
                    if n=0 then
response.write(klista&"<a href=javascript:abrirJanela('../imprimir/MemorandoApresentacaoNPRT.asp?chave="&session("matri")&"memorando&acao="&Watv&"',300,200);><img src=http://info-555/images/print.gif border=0></a></TD></TR>")                        
                    end if
                case 111 '---Susp.contrato
                    response.write(klista&"Término:")&confData(vetor(7,n))
                case 123  '---Alteração do Perído Aquisitivo
                    response.write(klista&"Período Anterior:"&confData(vetor(7,n)))
                case 129
                    response.write("<dl class=estilo_6>&nbsp;&nbsp;&nbsp;Processo Nro "&vetor(5,n) &" Nível&nbsp;" & vetor(6,n) &"&nbsp;&nbsp;Refer&ecirc;ncia&nbsp;&nbsp;"&vetor(8, n)&"</dl>")
                    response.write("<dl class=estilo_6>&nbsp;&nbsp;&nbsp;Registro&nbsp;"&ConfData(vetor(7,n))&"</dl>")
                case 130
                    response.write("<dl class=estilo_6>&nbsp;&nbsp;&nbsp;Processo Nro "&vetor(4,n) &" C.H&nbsp;" & vetor(5,n) &"</dl>")
                    response.write("<dl class=estilo_6>&nbsp;&nbsp;&nbsp;Registro&nbsp;"&ConfData(vetor(6,n))&"</dl>")                        
            end select
            response.write("</dl>")
            '---Função gratificada:designação|exoneração|designação de substituição|Alt.Contrato
            case 105  '---Banco de Horas
                response.write("<li class=estilo_7><a href=incAltExc_efe2.asp?id="&ValChaves(n)&"&matri="&vetor(0,n)&">"&confData(vetor(1,n))&" "&vetor(3,n)&"</a>")     
                Wtempo=cdbl(vetor(7,n))
                    if(vetor(8,n)="2002") OR (vetor(8,n)="2004") OR (vetor(8,n)="2005") OR (vetor(8,n)="2006") then Wtempo=Wtempo*-1
                    Select Case vetor(8,n)
                        case "2003","2004","2005","2006"
                            WsomaTre=WsomaTre+Wtempo
                            response.write("&nbsp;&nbsp;&nbsp;"&vetor(7,n)/(8*60))
                        case "2001","2002"
                            Wsoma=Wsoma+Wtempo
                            response.write("&nbsp;&nbsp;&nbsp;")&fcmht(vetor(7,n))
                    End Select
            case 106  '---Demissão
                if n=0 then 
                    call Graf_matriEfet(vetor(0,n),vetor(1,n))
                end if
                response.write("<li class=estilo_7><a href=incAltExc_efe2.asp?id="&ValChaves(n)&"&matri="&vetor(0,n)&">"&confData(vetor(1,n))&" "&vetor(3,n)&"</a>")             
            case 117    '---Atrasos
                    response.write("<li class=estilo_7><a href=incAltExc_efe2.asp?id="&ValChaves(n)&"&matri="&vetor(0,n)&">"&confData(vetor(1,n))&" "&fcmht(vetor(7,n))&"</a>")         
                    Wtempo=cdbl(vetor(7,n))
                    Wsoma=Wsoma+Wtempo    
            case 119,120,121,122                                
                if instr(session("subTipohis"),vetor(10,n)) then
                    response.write("<li class=estilo_7>") 
                    response.write("<a href=incAltExc.asp?id="&ValChaves(n)&">"&confData(vetor(1,n))&" "&vetor(3,n)&"</a>")                  
                else
                    response.write("<li class=estilo_3>") 
                    response.write(confData(vetor(1,n))&" "&vetor(3,n))
                end if
                response.write("<dl class=estilo_8>") 
                  call AuxListahist (vetor(4,n),vetor(5,n),vetor(6,n))             
                  response.write(klista&"Designação:"&vetor(7,n))
                  response.write(klista&"Local:"&vetor(8,n))
                response.write("</dl>")                
                if vetor(9,n)<>"1/1/2050" then
                    response.write("<dl class=estilo_10>&nbsp;&nbsp;&nbsp;Térm.:"&Confdata(vetor(9,n)))
                    response.write("</dl>")        
                end if                
            '---SEST-af_funcional/Licenças etc ..                
            case 114
                Dim segmento, seg, aviso, aposentadoria, apos
                 
                if  vetor(13,n)="não" then
                    Qsit="Encaminhamento"
                    QData=vetor(12,n)
                else
                    Qsit="Licença"
                    Qdata=vetor(9,n)
                end if 
                response.write("<li><a href=incAltExc.asp?id="&ValChaves(n)&">"&Qsit&":&nbsp;"&confData(Qdata)&"&nbsp;&nbsp;&nbsp;"&vetor(1,n)&"</a></li>")                                  
                call AuxListahist (vetor(2,n),vetor(3,n),confdata(vetor(4,n)))                     
                response.write(klista &"Lotacao:")&vetor(8,n)                
                response.write(klista &"Deferimento:&nbsp;"&vetor(13,n))
                wtermino=confData(vetor(10,n))
                '
                if  vetor(13,n)<>"não" then                     
                    if wtermino="01-01-2050" then 
                        wsituacao=""
                        wtermino="Em Licença"
                    else
                        wsituacao="Término:"
                    end if        
                                        
                    segmento = vetor(14, n)
                    aposentadoria = vetor(15, n)
                  
                    If((IsNull(segmento)) OR (segmento = "") OR (segmento = 0)) Then
                      aviso = "Não"
                      seg = 0
                    Else
                      aviso = "Sim"
                      seg = 1
                    End If
                    
                    If((IsNull(aposentadoria)) OR (aposentadoria = "") OR (aposentadoria = 0)) Then
                      'aviso = "Não"
                      apos = 0
                    Else
                      'aviso = "Sim"
                      apos = 1
                    End If
                                                    
                    response.write("<dt class=estilo_7>&nbsp;&nbsp;&nbsp;<a href=alta_ls.asp?id_af="&ValChaves(n)&"&data_f="&confData(vetor(10,n))&"&data_i="&confData(vetor(9,n))&"&seg="&seg&"&apos="&apos&">"&wsituacao&wtermino&"</a></DT>")
                    Response.Write("<BR><TD>&nbsp;&nbsp;&nbsp;Apto:&nbsp;&nbsp;"& aviso & "</TD>")                    
                end if
                if wsituacao="Término:" then
                    response.write("<dt class=estilo_7>&nbsp;&nbsp;&nbsp;Dias >>"&DateDiff("d",vetor(9,n),vetor(10,n))+1)
                end if    
                response.write("<dt><br>")
                response.write("</dl>")

            case 115 
                'Admissão
                response.write("<li>")
                response.write("<a href=inAlEx_ad.asp?id="&ValChaves(n)&">"&vetor(1,n)&"&nbsp;&nbsp;&nbsp;"&vetor(3,n)&"</a>")
                response.write("<dl>")                
                  call AuxListahist (vetor(4,n),vetor(5,n),vetor(6,n))
                response.write("</dl>")
            case 113 
                '---SEST-Atestados Médicos
                Wintervalo=RetornaValor("intervalo")
                Wano=RetornaValor("ano")                
                if cdate(vetor(1,n)) <=cdate(session("dtFimefe")) then
                    if n=0 then 
                        call Graf_matriEfet(vetor(0,n),vetor(1,n))
                    end if
                    response.write("<dt class=estilo_3><a href=incAltExc_efe.asp?id="&ValChaves(n)&"&matri="&vetor(0,n)&"&intervalo="&Wintervalo&"&ano="&Wano&">")
                    response.write(confData(vetor(1,n))&"&nbsp;&nbsp;&nbsp;Dias&nbsp;"&vetor(3,n)&"&nbsp;&nbsp;&nbsp;"&vetor(4,n)&"&nbsp;&nbsp;&nbsp;Reg&nbsp;"&ConfData(vetor(5,n))&"&nbsp;&nbsp;&nbsp"&vetor(6,n)&"</a>")
                    response.write("<dt class=estilo_6>16 dia&nbsp;")& confData(dateadd("d",16,vetor(1,n)-1))
                else
                    response.write("<dt><br>")
                    response.write("<dt class=estilo_7>Registros no Próximo Período")
                    response.write("<dt><br>")
                    response.write("<dt class=estilo_6>Início&nbsp;"&confData(vetor(1,n))&"&nbsp;&nbsp;&nbsp;Dias&nbsp;"&vetor(3,n)&"&nbsp;&nbsp;&nbsp;"&vetor(4,n)&"&nbsp;&nbsp;&nbsp;Lançamento&nbsp;"&ConfData(vetor(5,n))&"&nbsp;&nbsp;&nbsp"&vetor(6,n)&"</a>")
                    
                end if
                response.write("<dt class=estilo_6>CID&nbsp;"& vetor(7,n) & kespace & "Descrição&nbsp;"& vetor(8,n))
            case 109  
                '---HoraExtra
                response.write("<dt><a href=incAltExc_efe2.asp?id="&ValChaves(n)&"&matri="&vetor(0,n)&">"&(vetor(3,n))&"&nbsp;&nbsp;&nbsp;Doc. "&vetor(7,n)&"</a>")
                
                response.write("<dt class=estilo_6>&nbsp;&nbsp;&nbsp;"&fcmht(vetor(4,n))&"&nbsp;&nbsp;&nbsp;"&fcmht(vetor(5,n))&"&nbsp;&nbsp;&nbsp;"&fcmht(vetor(8,n))&"&nbsp;&nbsp;&nbsp;"&fcmht(vetor(9,n))&"&nbsp;&nbsp;&nbsp;"&fcmht(vetor(6,n)))
            case 110  
                '---Efetividade
                Wintervalo=RetornaValor("intervalo")
                Wano=RetornaValor("ano")
                if n=0 then 
                    call Graf_matriEfet(vetor(0,n),vetor(1,n))
                end if                                            
                if instr("9010_9009_9008_9007_0401_0403_0418_0426_0404_0405_0406_0410_0415_0494_0496_0490_0484_0486_1101_1102_1103_1104_1105_1106",vetor(6,n)) <> 0 then                 
                    response.write("<dt class=estilo_6>"&confData(vetor(1,n))&"&nbsp;&nbsp;&nbsp;Dias&nbsp;"&menor_10(cint(vetor(3,n)))&"&nbsp;&nbsp;&nbsp"&vetor(4,n)&"&nbsp;&nbsp;&nbsp;Reg&nbsp;"&ConfData(vetor(5,n))&"&nbsp;&nbsp;&nbsp"&vetor(7,n)&"&nbsp;&nbsp;&nbspDoc "&vetor(8,n))                    
                else                    
                    response.write("<dt class=estilo_3><a href=incAltExc_efe.asp?id="&ValChaves(n)&"&matri="&vetor(0,n)&"&intervalo="&Wintervalo&"&ano="&Wano&">")
                    response.write(confData(vetor(1,n))&"&nbsp;&nbsp;&nbsp;Dias&nbsp;"&menor_10(cint(vetor(3,n)))&"&nbsp;&nbsp;&nbsp;"&vetor(4,n)&"&nbsp;&nbsp;&nbsp;Reg&nbsp;"&ConfData(vetor(5,n))&"&nbsp;&nbsp;&nbsp"&vetor(7,n)&"&nbsp;&nbsp;&nbspDoc "&vetor(8,n)&"</a>")
                end if                    
                
            case 112,1120    '---Férias 
            wchave=vetor(6,n)
            session("tipo_d")=vetor(11,n)
            session("nrodoc")=vetor(3,n)            
            if instr("1104;1105;1107;1109;1110",vetor(10,n))=0 and vetor(9,n) > "2003" then 
            
            %>
            <dt><a href="ferias.asp?codigo=<%=wchave%>&nrodoc=<%=vetor(3,n)%>&acao=1"><%=vetor(1,n)%>
            &nbsp;&nbsp;&nbsp;Documento:<%=vetor(2,n)%>
            &nbsp;&nbsp;&nbsp;Nro:<%=vetor(3,n)%></a>
            <%
            else
                response.write("<dt class=estilo_10>"&vetor(1,n)&"&nbsp;&nbsp;&nbsp;Documento:"&vetor(2,n)&"&nbsp;&nbsp;&nbsp;Nro:"&vetor(3,n))
            end if
            Wabono="Sim"
            if  vetor(7,n) =0 then Wabono="Não"
            Wantecipa="Sim"
            if  vetor(8,n) =0 then Wantecipa="Não"
            response.write("<dt class=estilo_3>&nbsp;&nbsp;&nbsp;Início:&nbsp;&nbsp;&nbsp;" & vetor(0,n) & Kespace & "Dias:" & vetor(4,n))            
            response.write("<dt class=estilo_3>&nbsp;&nbsp;&nbsp;Abono:&nbsp;&nbsp;&nbsp;" & Wabono)
            response.write("<dt class=estilo_3>&nbsp;&nbsp;&nbsp;Ant.Salarial:&nbsp;&nbsp;&nbsp;"& Wantecipa)
            response.write("<dt><br>")
            response.write("</dl>")
            if(n = Wnrolista) then
              chave = vetor(6, n)
              For i = 0 To Wnrolista
                if(InStr("1101;1102;1103", vetor(10, i))) then                 
                  chave = vetor(6, i)                                     
                  i = Wnrolista + 1
                end if              
              Next              
            %>              
              <a href="ferias.asp?codigo=<%=chave%>&nrodoc=<%=vetor(3,n)%>&acao=1">continuar</a>              
            <%                            
            end if  
            case 125,126,127
                '---Cedência,prorrogação e retorno antecipado
                if instr(session("subTipohis"),vetor(9,n)) then
                    response.write("<li>") 
                    response.write("<a href=incAltExc_efe2.asp?id="&ValChaves(n)&">"&confData(vetor(1,n))&" "&vetor(3,n)&"</a>")                  
                else
                    response.write("<li class=estilo_7>") 
                    response.write(confData(vetor(1,n))&" "&vetor(3,n))
                end if
                response.write("<dl class=estilo_6>")
                response.write(klista &"Local "&vetor(7,n))
                if vetor(9,n)<>"0505" then
                    response.write(klista & "CAGED "& vetor(10,n) & " ATO No. "& vetor(12,n) )
                    response.write(klista & "Função "& vetor(11,n))
                end if
                call AuxListahist (vetor(4,n),vetor(5,n),vetor(6,n))
                response.write("</dl>")
            case 128
                '--->Aviso de Férias
                Qdata=ConfData(vetor(4,n))
                if Qdata="01-01-2050" then Qdata="S/Retorno"
                response.write("<dt><a href=incAltExc_efe2.asp?id="&ValChaves(n)&"&matri="&vetor(0,n)&">"&confData(vetor(1,n))&"&nbsp;&nbsp;&nbsp;"&vetor(3,n)&"&nbsp;&nbsp;&nbsp;Aviso de Férias "&Qdata&"</a>")                
            case 131
                '--->Alteração do Tipo de Vale
                response.write("<li class=estilo_7>Tipo de Vale >> "&vetor(1,n)&"</li>")
            case 132
                '--->Alteração do Tipo de Vale
                response.write("<dt class=estilo_3><a href=incAltExc_efe.asp?id="&ValChaves(n)&"&matri="&vetor(0,n)&"&ano="&vetor(0,n)&">")
                response.write(vetor(1,n)&vetor(2,n)&"</a>")
            case 136,137,138               
                '---Cedência,prorrogação e retorno antecipado                            
                if instr(session("subTipohis"),vetor(9,n)) then                
                    response.write("<li>") 
                    response.write("<a href=incAltExc_efe2.asp?id="&ValChaves(n)&">"&confData(vetor(1,n))&" "&vetor(3,n)&"</a>")                  
                else                
                    response.write("<li class=estilo_7>") 
                    response.write(confData(vetor(1,n))&" "&vetor(3,n))
                end if
                response.write("<dl class=estilo_6>")
                response.write(klista &"Local "&vetor(7,n))
                if(vetor(9,n) <> "2208") then
                    response.write(klista & "CAGED "& vetor(10,n) & " ATO No. "& vetor(12,n) )
                    response.write(klista & "Função "& vetor(11,n))
                end if
                call AuxListahist (vetor(4,n),vetor(5,n),vetor(6,n))
                response.write("</dl>")
            case 203
                if n=0 then response.write("<li class=estilo_7>"&vetor(4,n)&"<br>")                
                response.write("<li class=estilo_7><a href=incAltExc_efe2.asp?id="&ValChaves(n)&"&matricula="&vetor(0,n)&">"&digmatri(vetor(0,n))&"-"&vetor(1,n)&"</a>&nbsp;&nbsp;&nbsp;")                                
                
                if Cint(vetor(3,n))<>0 then
                    response.write(formatcurrency(vetor(3,n),2,,false)&"</li>")
                else
                    response.write("</li>")
                end if
                
            case 207
                '---acertos_vAvr                
                Qclass="estilo_6"
                if vetor(3,n) < 0 then Qclass="estilo_7"
                response.write("<li ><a href=incAltExc_efe2.asp?id="&ValChaves(n)&"&matricula="&vetor(0,n)&">"&digmatri(vetor(0,n))&"-"&vetor(4,n)&"</a>&nbsp;&nbsp;&nbsp;" _                                
                &"<li class="&Qclass&">&nbsp;&nbsp;&nbsp;Período "&vetor(1,n)&" à "& vetor(2,n)&"&nbsp;&nbsp;&nbsp;"&formatcurrency(vetor(3,n),2,,false)&"</li>" _
                &"<li class=estilo_3>&nbsp;&nbsp;&nbsp;"&vetor(5,n)&"</li>")                
                response.Write("<li><br>")
            case 209
                '---vt_servidor
                
                if n=0 then
                    response.write(klista &"<a href=javascript:abrirJanela('imprimir/impDesconto.asp?chave="&Session("matri")&"vtu',200,100);><img src=http://info1/desenvolvimento/images/print.gif border=0></a></li>")
                end if
                response.write("<li><a href=incAltExc_efe2.asp?id="&ValChaves(n)&">"&"Empresa :"& vetor(1,n)& "&nbsp;&nbsp;&nbsp;Linha "&vetor(7,n)&"-"&vetor(6,n)&"</a></li>")
                response.write("<dl class=estilo_3>")
                response.write(klista &"Data de Início :"&confData(vetor(8,n)))
                response.write(klista &"Nro Passagens :"&vetor(4,n) _
                &klista &"Ativo:"&vetor(9,n))
                call AuxListahist (vetor(2,n),vetor(3,n),vetor(5,n))                
                response.write("</dl>")
            case 210
                '---linhas do VTU
                if n > 0 then
                    if vetor(3,n)<>vetor(3,n-1) then
                        response.write("<dt><hr>")
                        response.write("<dt><h5>"&vetor(4,n)&"</h5>")
                        response.write("<dt><br>")
                    end if
                else
                    response.write("<dt><h5>"&vetor(4,n)&"</h5>")
                    response.write("<dt><br>")
                end if
                response.write("<dt class=estilo_6><a href=incAltExc_efe2.asp?id="&ValChaves(n)&">"&vetor(1,n)&"</a>&nbsp;&nbsp;&nbsp;Passagem "& formatcurrency (vetor(2,n),2)&"</li>")
                response.write("<dt><br>")
                response.write("</dl>")            
            case 212
                '---Empresas do Plano de Saúde
                if n >0 then
                    if vetor(2,n)<>vetor(2,n-1)   then 
                        Response.Write("<li class=estilo_7>"&vetor(2,n)&"</td></tr>")
                        wsoma=0                                                                
                    end if
                else
                    Response.Write("<li class=estilo_7>"&vetor(2,n)&"</td></tr>")
                end if                                
                Wsoma=Wsoma+1
                response.write("<li ><a href=incAltExc_efe2.asp?id="&ValChaves(n)&" class=estilo_3>"&menor_10(Wsoma)&" - "&vetor(0,n)&" >> "&vetor(1,n)&"</a></li>")
                
                                
                response.write("<dl><br></dl>")
            case 213            
                '---Servidores do Plano de Saúde                
                response.write("<li><a href=incAltExc_efe2.asp?id="&ValChaves(n)&">"&vetor(2,n))
                response.write(klista &"Ativo:&nbsp;"&vetor(3,n))
                response.write(klista &"Registro no Sistema:&nbsp;"&confData(vetor(1,n)))
                response.write("<dt><br>")
                response.write("</dl>")                
            case 214
                response.write("<li><a href=incAltExc_efe2.asp?id="&ValChaves(n)&"&plano_ps="&vetor(8,n)&">"&digmatri(vetor(1,n))&"&nbsp;&nbsp;&nbsp"&vetor(2,n)&"</a></li>")
                response.write(klista &"Recibo Nro.:&nbsp;"&vetor(3,n))
                response.write(klista &"Pagamento:&nbsp;"&vetor(7,n)&"/"& vetor(6,n))                
                response.write(klista &"Valor Pago:&nbsp;"&formatcurrency(vetor(4,n),2))
                response.write("<dt class=estilo_6>&nbsp;&nbsp;&nbsp;Registro no Sistema:&nbsp;"&confData(vetor(5,n)))
                response.write("</dl>")
            case 216,217
                '---Entrega no Balcão do VTU/movimento do vtu
                '---Devolução do VTU/movimento do vtu
                '---Compra/movimento do vtu
                response.write("<li><a href=incAltExc_efe2.asp?id="&ValChaves(n)&"&matricula="&vetor(6,n)&">"&"&nbsp;&nbsp;&nbsp"&vetor(1,n))                
                response.write("</a></li>")
                response.write("<dl class=estilo_3>")
                response.write(klista &"&nbsp;&nbsp;&nbsp;Nro Passes "&vetor(2,n)&"x"&vetor(3,n)&"&nbsp;&nbsp;&nbspValor: "&formatcurrency(vetor(4,n),2))                
                response.write(klista &"&nbsp;&nbsp;&nbsp;Registro no sistema: "&confData(vetor(5,n)))
                response.write("<dt><br>")
                response.write("</dl>")    
            case 218
                '---Compra/movimento do vtu
                response.write("<li><a href=incAltExc.asp?id="&ValChaves(n)&">"&"&nbsp;&nbsp;&nbsp"&vetor(1,n))                
                response.write("</a></li>")
                response.write("<dl class=estilo_3>")
                response.write(klista &"&nbsp;&nbsp;&nbsp;Nro Passes "&vetor(2,n)&"x"&vetor(3,n)&"&nbsp;&nbsp;&nbspValor: "&formatcurrency(vetor(4,n),2))
                Wsoma=Wsoma+(cdbl(vetor(4,n)))
                response.write(klista &"&nbsp;&nbsp;&nbsp;Registro no sistema: "&confData(vetor(5,n)))
                response.write("<dt><br>")
                response.write("</dl>")                
            case 400 
                '---pcmso
                response.write("<li><a href=incAltExc_efe2.asp?id="&ValChaves(n)&"&matricula="&vetor(0,n)&">"&confData(vetor(1,n))&"</a></li>")
                response.write("<dl class=estilo_3>")
                If vetor(8,n) > 0 Then
                    response.write(klista &"Tipo: "&vetor(9,n))
                Else
                    response.write(klista &"Tipo: Não informado")
                End If
                response.write(klista &"Resultado: "&vetor(3,n)&" Repetir em: "&vetor(4,n))
                response.write(klista &"Observação: "&vetor(5,n))
                response.write("</dl>")
            case 1122
                response.write("<li><a href=cartao.asp?id="&vetor(0,n)&"&matricula="&vetor(1,n)&">"&digmatri(vetor(1,n))&"-"&vetor(2,n)&"</a></li>")
            case 1123
                response.write("<li><a href=cartao_nircip.asp?id="&vetor(0,n)&"&matricula="&vetor(1,n)&">"&digmatri(vetor(1,n))&"-"&vetor(2,n)&"</a></li>")
            case 1124
                if j =0 then 
                    response.write(klista &"<a href=javascript:abrirJanela('imprimir/folhaefetiv.asp',200,100);><img src=http://info1/desenvolvimento/images/print.gif border=0></a>")                    
                end if
                response.write("<li>"&digmatri(vetor(1,n))&"-"&vetor(2,n)&"</li>")    
        end select
        next    
        Select case Watv
            case 41
                aspas = "'"
                response.write("<li class=estilo_3>Relação Anual da Carga Horária Utilizada *** Cursos Deferidos</li><li><BR></li>")
                strSql=" SELECT year(data_inicial) as ano,sum(ch_curso)*5/ch as soma" _
                & " FROM Srh.tr_partcurso p,Srh.contrato c" _
                & " WHERE p.matricula=c.matri AND c.matri='" & session("matri") _                
                & "' AND deferimento <> 'não' "_
                & " AND deferimento <> " & aspas&"Pendente"&aspas & " GROUP BY year(data_inicial)"
                
                
                Wnrolista=MontaVetor (strSql,vetor,0)
                for n=0 to  Wnrolista
                    response.write("<li class=estilo_7>Ano "&vetor(0,n)&" Dias "&vetor(1,n)&"</li>")
                next    
                
            case 105
                 Dim Wdesc                             
                    Wdesc=" Crédito"
                    if Wsoma < 0 then Wdesc=" Débito":Wsoma=Wsoma*-1                
                    response.write("<br>&nbsp;&nbsp;&nbsp;HORAS "&Wdesc&"&nbsp;&nbsp;&nbsp;"&fcmht(Wsoma))
                    Wdesc=" Crédito"
                    WsomaTRE=WsomaTRE/(8*60)
                    if WsomaTRE < 0 then Wdesc=" Débito":WsomaTRE=WsomaTRE*-1                                     
                     response.write("<LI  class=estilo_6>&nbsp;&nbsp;&nbsp;Dias TRE "&Wdesc&" = " & WsomaTRE & " Dias ")
            case 117             
                 response.write("<br><LI  class=estilo_6>Total em Horas "&fcmht(Wsoma))
            case 203                    
              response.write("<br>")
             response.write("<br>")
             response.write("<li><a href=acao_vavr.asp?mes="&vetor(5,0)&"&ano="&vetor(6,0) _
                &"&datacred="&vetor(7,0)&"&operacao="&vetor(8,0)&"><img src=http://info-555/images/mail_send2.jpg border=0 alt='Gravar/Gerar Pedido'></a>")
                
                
                response.write("<br>")
                response.write("<br>")
                
                response.write("<li><a href=acao_excluir_vavr.asp"&"><img src=http://info-555/images/icn-backspace.gif border=0 alt='Limpar tela do pedido extra'></a>")
            
            
            case 218
                '---Compra do vtu
                response.write("&nbsp;&nbsp;&nbsp;Compra do Mês:&nbsp;&nbsp;&nbsp;"&formatcurrency(Wsoma))
            
            case 31 
                response.write("<a href=javascript:abrirJanela('imprimir/imptrein.asp',200,100);><img src=http://info1/desenvolvimento/images/print.gif border=0></a>")
            
        
        end Select
        response.write("</ol><hr>")    
end sub
'
'---funçoes de para a Lista
sub AuxListahist(fdoc,fnum,fdata_l)
    response.write("<dt class=estilo_6>&nbsp;&nbsp;&nbsp;Documento:&nbsp;&nbsp;&nbsp;"&fdoc&"&nbsp;&nbsp;&nbsp;Nro:&nbsp;&nbsp;&nbsp;"&fnum)
    response.write("<dt class=estilo_6>&nbsp;&nbsp;&nbsp;Registro no Sistema:&nbsp;&nbsp;&nbsp;"&fdata_l)
end sub
'
sub Graf_matriEfet(fmatri,fdata)
    response.write("<dt class=estilo_7>Registros no Período")
    response.write("&nbsp;&nbsp;&nbsp;<a href=graf_efetmatri.asp?numero="&fmatri&"&ano="&year(fdata)&" ><img src=http://info1/desenvolvimento/images/Graph07.ico border=0 width=20></a>")
    response.write("<dt><br>")
end sub
'
dim Wdtini_efe,Wdtfin_efe
function finifim(fperiodo,fano)    
    if fano="" then fano=2000
    if fperiodo <> "" then
        Wdtini_efe=ConverteData(cdate(mid(fperiodo,1,5)&"/"&fano))
        if mid(fperiodo,4,2)="12" then fano=cint(fano)+1
        Wdtfin_efe=ConverteData(cdate(mid(fperiodo,7,5)&"/"&fano))
        session("dtIniefe")=Wdtini_efe
        session("dtFimefe")=Wdtfin_efe
        session("Qdias")=DateDiff("d",cdate(Wdtini_efe),cdate(Wdtfin_efe))+1
    end if
end function
'
'---Avisos de Cancelamento
sub msgAviso(situacao)
    dim msg    
    select case situacao
        case 1
            msg="CONFLITO "&Waviso
        case 2
            msg="ESTE REGISTRO NÃO PODE SER EXCLUIDO OU ALTERADO!!!"
        case 3
            msg="SERVIDOR DEMITIDO - ESTE REGISTRO NÃO É PERMITIDO!!!" 
        case 4
            msg="MATRÍCULA/CPF NÃO RECONHECIDO!!!"
        case 5
            msg="NRO DE DIAS EM L.S/SAT ULTRAPASSA 180 DIAS!!!"
        case 6
            msg="NRO DE DIAS DE FALTAS ULTRAPASSA 32 DIAS!!!"
        case 7
            msg="SERVIDOR DO QUADRO!!!"
        case 8            
            msg="Servidor "& Waviso
        case 9            
            msg="CPF NÃO CADASTRADO NO SISTEMA!!!" 
        case 10            
            msg="NÃO EXISTE CONTRATO PARA ESTA MATRÍCULA!!!" 
        case 11            
            msg="ESTE CPF TEM UM CONTRATO COM A FUNDAÇÃO," & vbcrlf
            msg=msg & "PARA NOVA ADMISSÃO É PRECISO DEMITI-LO."
        case 12
            msg="ESTA MATRÍCULA JÁ ESTÁ RELACIONADA COM O CONTRATO DE" & vbcrlf & Wnome_contrato                            
        case 13            
            msg="O SERVIDOR DO QUADRO/REGISTRO NÃO PERMITIDO!!!" 
        case 14            
            msg="O SERVIDOR TEM CADASTRO COM ESTA EMPRESA DESDE :" & Wdatacred 
        case 15            
            msg="O SERVIDOR NÃO TEM CADASTRO COM ESTA EMPRESA !!!"
        case 16            
            msg="A DATA DA SOLICITAÇÃO TEM QUE SER " & Wdata_cred
        case 17            
            msg="ESTA MATRÍCULA JÁ POSSUI UMA SOLICITAÇÃO !!! "
        case 18            
            msg="Servidor encaminhado p/Lic.Saúde Em:" & confData(rst(0)) & "."
        case 19            
            msg="Servidor em "& rst(1)&" A partir de " & confData(rst(0)) 
        case 20            
            msg="Não Existe Lançamento de Atestado anterior!!!" 
        case 21
            msg="A Lic.de Saúde Não Foi Deferida!!!"
        case 22
            msg="Servidor com Férias em Haver Deverá passar no Núcleo de Pagamento Pessoal!!!"
        case 23
            msg="Servidor não tem horário neste Sistema!!!"
        case 24
            msg="Este cargo está ocupado por "& rst(0)&"-"&rst(1)
        case 25
            msg="A data deve estar entre "& confData(dados(0))&" e "&confData(dados(1))
        case 26
            msg="O horário de Entrada da Manhã é após as " & timevalue(dados(0))
        case 27
            msg="O horário de saída da Manhã é até as " & timevalue(dados(1))
        case 28
            msg="O horário de Entrada da Tarde é após as " & timevalue(dados(2))
        case 29
            msg="O horário de saída da Tarde é até as " & timevalue(dados(3))        
        case 31
            msg="A Prorrogação Exige uma Cedência Anterior!!!"
        case 32
            msg="O Servidor Não Encontra-se Cedido!!!"
        case 33
            msg="O Servidor tem data de Admissão posterior ao início deste período!!!"
        case 34
            msg="Servidor Demitido desde "& ConfData(rst.fields(0))
        case 35
            msg="O Servidor Não Tem direito a este Período Aquisitivo !!!" 
        case 36
            msg="Você não pode mais Atualizar este Período !!!" 
        case 37
            msg="Você deve Antes atualizar o perído " & Qperiodo
        case 38 
            msg="O servidor " & rst(0) &" está com os Dados Incompletos Verifique os dados c/NIRCIP " 
        case 39
            msg="Não foram Registradas as datas deste treinamento!!!"
        case 40            
            msg="Servidor Tem outro Registro Até o final desta Efetividade :"& rst(1)&" A partir de " & confData(rst(0)) 
        case 41
            msg="O Servidor consta como não retira Vale Alimentação!!!"
        case 42
            msg="O horário de Entrada da Noite é após as " & timevalue(dados(4))
        case 43
            msg="O horário de saída da Noite é até as " & timevalue(dados(5))    
        case else
            msg="ESTE REGISTRO JÁ FOI LANÇADO!!!"
    end select    
    Select Case session("atividade") 
        case 33,109,110,203,204,1122
            Wvoltar=-2        
        case else
            Wvoltar=-1            
    end Select 
    response.write("<h3>"&msg&"</h3>")    
    Select Case session("atividade")
        case 34
        case 203
            response.end    
        case else            
            response.write("<h3><a href=javascript:history.go("&Wvoltar&")>Voltar</a></h3>")
    end Select 
    response.write("<hr>")                           
    response.end
end sub
'
Function TestaRelacionamentos(FCampoOrigem)
   dim QcampoOrigem
   dim strSql         
   if FCampoOrigem="" then exit function
   TestaRelacionamentos = False   
   strSql = "SELECT BDDestino,TabelaDestino,Campodestino FROM GERAL.relacionamentos "
   strSql=strSql  & "WHERE  CampoOrigem='" & FCampoOrigem & "' ORDER BY CampoOrigem;"    
   Wrst(strSql)  
   With rst
      Do While Not .EOF
           QcampoOrigem= request.form(FcampoOrigem)
           if isDate(request.form(FcampoOrigem)) then QcampoOrigem=ConverteData(request.form(FcampoOrigem))
        
         strSql = "SELECT COUNT(*) FROM " & .Fields("BDDestino") & "." & .Fields("TabelaDestino") 
         strSql=strSql & " WHERE " & .Fields("Campodestino") & "='" & QcampoOrigem & "';"                     
         'faux(strSql) 
         Wrst2(strSql)         
         If rst2.Fields(0) > 0 Then
            TestaRelacionamentos = True            
            exit do
         End If
         .MoveNext
      Loop
   End With   
End Function
'---Histórico:efetividade
'
function testa_ls(fmatri,fdtini)
    '---testa Lic.Saúde/Sat/Aposent.por Invalidez    
    testa_ls=""
    strSql="SELECT data_e,data_i,txthis.nome,tipo_h FROM Srh.af_funcional,GERAL.txthis" _    
    & " WHERE af_funcional.subtipo_h=txthis.codigo AND data_f ='2050-01-01' AND deferimento='sim'" _
    &" AND matri='" &fmatri& "';"
                    
    Wrst(strSql) 
    
    With rst                    
        IF Not .EOF then
            Waviso="&nbsp;Em "&.fields(2) & "&nbsp;Desde&nbsp;"& ConfData(.fields(0)) 
            if session("atividade")=2101 then
                testa_ls=Waviso                
            else
                '---Demissão/aposentadoria por Invalidez
                if session("atividade") <> 106 and .fields(3) <>"19"  and 2 = 3 then                    
                    if cdate(.fields(0))<= cdate(fdtini) then call msgAviso(8)                    
                end if
            end if                
        end if
    End With
    fechaConexao
end function
'
function testa_Demissao(fmatri,fdtini)
    strSql="SELECT data_i,txthis.nome,tipo_h FROM Srh.historico,GERAL.txthis" _    
    & " WHERE historico.subtipo_h=txthis.codigo" _
    & " AND tipo_h IN('07','01') "  _
    & " AND matri='" &fmatri& "' ORDER BY data_i DESC LIMIT 1;"
    
    'retirado ::::::::>> AND data_i <='"& ConverteData(fdtini)
    
    Wrst(strSql)    
    With rst
        IF Not .EOF then
            '--->reintegração
            if session("atividade")=118 then
                if .fields(2)<>"07" then call msgAviso(7)
            else
                if .fields(2)<>"01" then call msgAviso(34)                    
            end if
        end if
    End With
    fechaConexao
end function
'
dim wAviso
function fConcDatas(fdtini,fdias,fmatri,facao,ftipo)
    
    fConcDatas=false
    if CInt(fdias)<>0 then
    Dim Wdtfin        
    Wdtfin=ConverteData(cdate(fdtini)+cint(fdias)-1)                
    call testa_demissao(fmatri,Wdtfin) 
    call testa_ls(fmatri,Wdtfin)

    strSql="SELECT DATE_FORMAT(data_i,'%d-%m-%Y'),DATE_FORMAT(DATE_ADD(data_i,INTERVAL dias-1 DAY),'%d-%m-%Y') AS dt_final,txthis.nome,tipo_h FROM Srh.historico,GERAL.txthis" _ 
    & " WHERE tipo_h IN("&ftipo&")" _
    & " AND historico.subtipo_h=txthis.codigo AND data_i <='" & Wdtfin _
    & " ' AND date_add(data_i,interval dias-1 day)>='" & ConverteData(fdtini) _
    & "' AND matri='"&fmatri&"' AND dias<>0 LIMIT 1"
    
    Wrst(strSql)
    With rst
        IF Not .EOF then
            '---Pular o próprio registro  na alteração
            if not(Cdate(fdtini)=cdate(.fields(0)) and .fields(3)=session("intTpHis") and facao=1) then                                            
                wAviso=.fields(2) & " De " & .fields(0) & " à " & .fields(1)                                
                fConcDatas = True
            end if
         End if
    End With 
 end if
End Function

'---Criptografia
function Crypt(Senha) 
Dim strTempChar
For i = 1 To Len(Senha)
    If Asc(Mid(Senha, i, 1)) < 128 Then
        strTempChar = Asc(Mid(Senha, i, 1)) + 128
    Else 
        strTempChar = Asc(Mid(Senha, i, 1)) - 128
    End If
Crypt = Crypt & strTempChar 
Next 
End Function
'
'---gera uma data com um mês maior
function fdtfinEF(fdata)
 dia=day(fdata)
 mes=month(fdata)
 ano=year(fdata) 
 if dia >=15 then
     if mes=12 then 
        mes=1
        ano=ano+1 
     else
        mes=mes+1
     end if
end if
fdtfinEF=cdate(15 & "-" & mes & "-" & ano)
end function
'
'---Configura Digito
function digmatri(fmatri)
    digmatri=left(fmatri,4)&"."&right(fmatri,1)
end function
function faux(ftexto)
    response.write(ftexto)
    response.End()
end function
'
'

Sub PreparaCampos(fcampos)        
    WArr=split(fCampos,",")            
    WstrChave="":WStrtbl="":WStrAuto_inc="":WnomeChaves="":WstrFunc="":WstrChavefalsa=""
    Redim WArrCons(ubound(WArr,1))        
    For i = 0 To ubound(WArr,1)    
        fcampos=WArr(i)
        Wfunc=0
        if Instr(fcampos,"/") then 
            Wpos=Instr(fcampos,"/")
            Wfunc=mid(fcampos,Wpos+1,len(fcampos))
            fcampos=limpaCaracter(fcampos,len(fcampos)-(Wpos-1))            
        end if
        Wchave=0
        If InStr(fcampos, "*") <> 0 Then 
            fcampos = limpaCaracter(fcampos, 1)
            Wchave=1                    
        end if
        Wchavefalsa=0
        If InStr(fcampos, "!") <> 0 Then 
            fcampos = limpaCaracter(fcampos, 1)
            Wchavefalsa=1                    
        end if
        Wtbl="0"                
        if instr(fcampos,"#") then    
            fcampos=limpaCaracter(fcampos,1)
            Wtbl=fcampos
        end if
        Wauto_inc=0
        If InStr(fcampos, "*") <> 0 Then 
            fcampos = limpaCaracter(fcampos, 1)
            Wauto_inc=1
        end if
        if Wchave=1 then
            WnomeChaves=WnomeChaves & session("strTabela") & "." & fcampos & ","        
        end if
        WArr(i)=fcampos
        '
        '---Formatação para consulta.Sql
        if fcampos="data_i" then fcampos="DATE_FORMAT(data_i,'%d-%m-%Y')"
        if fcampos="data_f" then fcampos="DATE_FORMAT(data_f,'%d-%m-%Y')"        
        
            
        WArrCons(i)=fcampos                
        '
        WstrChavefalsa=WstrChavefalsa & Wchavefalsa & ";"            
        WstrChave=WstrChave & Wchave & ";"
        WStrtbl=WStrtbl & Wtbl & ";"
        WStrAuto_inc=WStrAuto_inc & Wauto_inc & ";"
        WstrFunc=WstrFunc & Wfunc &";"
        
    Next 
    
    Session("CamposCons")=join(WArrCons,",")        
    Session("Campos")=join(WArr,",")        
    Session("Chave")=limpaCaracter(WstrChave,1)        
    Session("Chavefalsa")=limpaCaracter(WstrChavefalsa,1)    
    Session("tbl")=limpaCaracter(WStrtbl,1)    
    Session("Auto_inc")=limpaCaracter(WStrAuto_inc,1)
    Session("nomeChaves")=limpaCaracter(WnomeChaves, 1)        
    Session("func")=limpaCaracter(WstrFunc, 1)
    
end Sub

function unidades(num)
dim vet_unidades, str, aux
vet_unidades = Array("um", "dois", "três", "quatro", "cinco", "seis", "sete", "oito", "nove", "dez", "onze", "doze", "treze", "quatorze", "quinze", "dezesseis", "dezessete", "dezoito", "dezenove")
aux = Right(num,2)
if int(aux) < 20 then
if int(aux) > 0 then
str = vet_unidades(int(aux)-1)
else
str = ""
end if
else
str = vet_unidades(int(right(num,1)) - 1)
end if
unidades = str
end function

function dezenas(num)
dim vet_dezenas, aux, str
vet_dezenas = Array(VBNullString, "vinte", "trinta", "quarenta", "cinquenta", "sessenta", "setenta", "oitenta", "noventa")
aux = Right(num,2)
aux = Left(aux,1)
if len(num) >= 2 then
if int(aux) >= 2 then
str = vet_dezenas(int(aux)-1)
if right(num,1) > 0 then
str = str &" e "&unidades(num)
end if
else
str = unidades(num)
end if
else
str = unidades(num)
end if
dezenas = str
end function

function centenas(num, numero)
dim vet_centenas, aux, str
vet_centenas = Array("cem", "duzentos", "trezentos", "quatrocentos", "quinhentos", "seiscentos", "setecentos", "oitocentos", "novecentos")
if int(num) > 99 then
aux = Right(num, 3)
aux = Left(aux, 1)
if int(right(num,2)) > 0 then
vet_centenas(0) = "cento"
end if
str = vet_centenas(aux-1)
if int(right(num, 2)) > 0 then
str = str & " e "
end if
else
str = ""
end if
centenas = str & dezenas(num)
end function

function milhares(num, numero)
dim str, aux, auxstr
aux = right(numero,3)
aux = left(aux,1)
if int(aux) > 0 then
auxstr = ", "
else
auxstr = " e "
end if
if int(num) <> 0 then
str = centenas(num, numero)&" mil"&auxstr
else
str = ""
end if
milhares = str
end function

function milhoes(num, numero)
dim str, aux, strmilhao
aux = int(num)
if aux > 0 then
if aux = 1 then
strmilhao = "milhão,"
else
strmilhao = "milhões,"
end if
str = centenas(num, numero)&" "&strmilhao&" "
else
str = ""
end if
milhoes = str
end function

function bilhoes(num, numero)
dim str, aux, strbilhao
aux = int(num)
if aux > 0 then
if aux = 1  then
strbilhao = "bilhão,"
else
strbilhao = "bilhões,"
end if
str = centenas(num, numero)&" "&strbilhao&" "
else
str = ""
end if
bilhoes = str
end function

function centavos(num)
dim str, aux, strcent
num = "0"&num
if int(num) > 0 then
if int(num) = 1 then
strcent = " centavo"
else
strcent = " centavos"
end if
str = centenas(num, num)&strcent
else
str = ""
end if
centavos = str
end function

function extenso(num)
dim sizenum, strsinal, inteiro, cents, aux_array, aux, bilhar, milhao, milhar, centena, dezena
dim strreal, strvirgula
dim strextenso

num = Replace(num, ".", "")
aux_array = split(num, ",")
if num = "" then
extenso = ""
exit function
end if
if UBound(aux_array) > 0 then
inteiro = aux_array(0)
cents = left(aux_array(1),2)
else
inteiro = aux_array(0)
cents = "00"
end if
if InStr(1, inteiro, "-") > 0 then
inteiro = right(inteiro, len(inteiro) - 1)
strsinal = "menos "
else
strsinal = ""
end if
sizenum = len(inteiro)
aux = string(12 - sizenum, "0")
inteiro = aux & inteiro
bilhar = mid(inteiro, 1, 3)
milhao = mid(inteiro, 4, 3)
milhar = mid(inteiro, 7, 3)
centena = mid(inteiro, 10, 3)
if int(inteiro) = 1 then
strreal = " real "
else
if int(inteiro) = 0 then
strreal = ""
else
strreal = " reais "
end if
end if
if int(cents) > 0 and int(inteiro) > 0 then
strvirgula = "e "
else
strvirgula = ""
end if
strextenso = bilhoes(bilhar, inteiro)
strextenso = strextenso & milhoes(milhao, inteiro)
strextenso = strextenso & milhares(milhar, inteiro)
strextenso = strextenso & centenas(centena, inteiro)
strextenso = strsinal & strextenso & strreal & strvirgula & centavos(cents)
extenso = strextenso
end function
'

sub cadatroAtualVtu(fmatri)
    call Drop_table("Beneficios.cadastro_temp2")    
    '
    strSql="CREATE TABLE Beneficios.cadastro_temp1"
    strSql=strSql & " SELECT matricula AS m,cod_linha AS c,MAX(data_i) AS d"
    strSql=strSql & " FROM Beneficios.vt_servidor"
    strSql=strSql & " GROUP BY matricula,cod_linha;"
    SqlNoQuery(strSql)    
    '
    strSql="CREATE TABLE Beneficios.cadastro_temp2"
    strSql=strSql & " SELECT vt_servidor.matricula,vt_servidor.cod_linha,nro_passes"
    strSql=strSql & " FROM Beneficios.cadastro_temp1,Beneficios.vt_servidor"
    strSql=strSql & " WHERE vt_servidor.data_i=cadastro_temp1.d"
    strSql=strSql & " AND vt_servidor.cod_linha=cadastro_temp1.c"
    strSql=strSql & " AND vt_servidor.matricula=cadastro_temp1.m"
    if fmatri<>"%" then
        strSql=strSql & " AND vt_servidor.matricula='"& fmatri &"';"
    else
        strSql=strSql & ";"
    end if
    '
    SqlNoQuery(strSql)
    '
    call Drop_table("Beneficios.cadastro_temp1")    
    '
    strSql="ALTER TABLE Beneficios.cadastro_temp2 ADD PRIMARY KEY(matricula,cod_linha);"
    SqlNoQuery(strSql)    
end sub
'
function RetornaValor(fcampo)
    if  request.form(fcampo)<>"" then 
        RetornaValor=request.form(fcampo)
    else    
        if request.querystring(fcampo)<>"" then 
            RetornaValor=request.querystring(fcampo)
        end if
    end if
end function
'---Salário Básico|Penosidade|Tempo de serviço dos servidores Ativos
Sub Sal_folhaTodos()
    '---última tabela criada.
    call Drop_table("Srh.Servidor_temp2")    
    '
    Qmes=month(date):if Qmes < 9 then Qmes="0"& Qmes
    Qper=year(date)&Qmes    
    strSql="CREATE TABLE Srh.Servidor_temp1 SELECT matri,dt_adm,cargos.folha,penosidade," 
    strSql=strSql & " format((period_diff('"&Qper&"',date_format(dt_adm,'%Y%m')))/12,0) AS tempo,nivel,ch"
    strSql=strSql & " FROM Srh.contrato,GERAL.unidades,GERAL.cargos"
    strSql=strSql & " WHERE contrato.servidor='1'"
    strSql=strSql & " AND unidades.codigo=contrato.lotacao"
    strSql=strSql & " AND cargos.id_cargo=contrato.cargo" 
    strSql=strSql & " ORDER BY matri;"    
    SqlNoQuery(strSql)
    '
    '---salário Básico    
    '
    strSql="CREATE TABLE GERAL.sal_temp1"
    strSql=strSql & " SELECT folha as f,MAX(data_a) as d"
    strSql=strSql & " FROM GERAL.salarios"
    strSql=strSql & " GROUP BY folha;"    
    SqlNoQuery(strSql)
    '
    strSql="CREATE TABLE GERAL.sal_temp2"
    strSql=strSql & " SELECT folha AS f,sal_basico"
    strSql=strSql & " FROM GERAL.salarios,GERAL.sal_temp1"
    strSql=strSql & " WHERE salarios.data_a=sal_temp1.d"
    strSql=strSql & " AND salarios.folha=sal_temp1.f"        
    '
    SqlNoQuery(strSql)
    '
    strSql="CREATE TABLE Srh.Servidor_temp2 SELECT Servidor_temp1.*,sal_basico"
    strSql=strSql & " FROM Srh.Servidor_temp1,GERAL.sal_temp2"
    strSql=strSql & " WHERE Servidor_temp1.folha=sal_temp2.f ORDER BY matri"
    SqlNoQuery(strSql)
    '
    call Drop_table("GERAL.sal_temp1")    
    '
    call Drop_table("Srh.Servidor_temp1")    
    '
    call Drop_table("GERAL.sal_temp2")    
end sub
Dim Qsal
Sub Sal_folhaInd(fmatri)    
    Qmes=month(date):if Qmes < 10 then Qmes="0"& Qmes
    Qper=year(date)&Qmes    
    strSql="SELECT cargos.id_cargo,penosidade," 
    strSql=strSql & " format((period_diff('"&Qper&"',date_format(dt_adm,'%Y%m')))/12,0) AS tempo,nivel,cbo,letra.nome,ch"
    strSql=strSql & " FROM Srh.contrato,GERAL.unidades,GERAL.cargos,GERAL.letra"
    strSql=strSql & " WHERE contrato.servidor='1'"
    strSql=strSql & " AND unidades.codigo=contrato.lotacao"
    strSql=strSql & " AND cargos.id_cargo=contrato.cargo" 
    strSql=strSql & " AND letra.codigo=contrato.nivel"
    strSql=strSql & " AND matri='"& fmatri & "';"
    
    '
    call MontaVetor(strSql,vetor,-1)    '
    '---salário Básico            
    strSql="SELECT  sal_basico FROM GERAL.salarios"
    strSql=strSql & " WHERE cargo='" & vetor(0,0)
    strSql=strSql & "' ORDER BY data_a DESC limit 1 "    
    Qsal=RetornaDescricao(strSql)    
end sub
'---Gráficos
function fFontColor(fcor)
    Select Case fcor
        case "#666666","#006600","#000000","#9966FF","#663399","#BB5454","#3DD33D","#0000FF","#FF0000","#00AA00"
            fFontColor="#FFFFFF"
        case "#FFFFFF"
            fFontColor="red"
        case "#FFFF99"
            fFontColor="blue"
        case "#CCCCCC"
            fFontColor="#CCCCCC"
        case else
            fFontColor="#000000"
    End Select
end function

sub legenda_graf()
    Response.write("<br>")
    Response.write("<Table class=estilo_3>")
    Response.write("<tr><td bgcolor=white>S/Inf.</td>")
    Response.write("<td bgcolor=#FFFF99>Férias</td>")
    Response.write("<td bgcolor=#CCCC00>Atest</td>")
    Response.write("<td bgcolor=#006600><font color=#FFFFFF>Ls/Gest</td>")
    Response.write("<td bgcolor=#00CC00>Ls</td>")
    Response.write("<td bgcolor=#663399><font color=#FFFFFF>Sat</td>")
    Response.write("<td bgcolor=#009999>Lic.Div</td>")
    Response.write("<td bgcolor=#00FF99>Faf-F</td>")
    Response.write("<td bgcolor=#9966FF><font color=#FFFFFF>Faf-D</td>")
    Response.write("<td bgcolor=black ><font color=#FFFFFF>Falta</td>")
    Response.write("<td bgcolor=#666666 ><font color=#FFFFFF>M.D.S</td>")
    Response.write("<td bgcolor=#999999 ><font color=#FFFFFF>S.Cont</td>")
    Response.write("<td bgcolor=#FFCCCC>Trein.</td>")
    Response.write("<td bgcolor=#33CCFF>Disp.</td>")
    Response.write("<td bgcolor=#6699CC>Efetivo</td>")
    Response.write("<td bgcolor=#996600><font color=#FFFFFF>ApInv</td>")
    Response.write("<td bgcolor=#FF9933>Dem.</td>")
    Response.write("<td bgcolor=#8B419>Folga Extra</td></tr>")    
    Response.write("<td bgcolor=#8B4513>Atest.Apos</td>")
    Response.write("<td bgcolor=#778899>LS.Reativ.Jud</td>")
    Response.write("<td bgcolor=#CD661D>SAT.Reativ.Jud</td>")
    Response.write("<td bgcolor=#CD2626>SAT.Doença Reativ.Jud</td>")
    Response.write("<td bgcolor=#BB5454><font color=#FFFFFF>SAT. 15 DIAS</font></td>")
    Response.write("<td bgcolor=#3DD33D><font color=#FFFFFF>SAT. 30 DIAS</font></td>")
    Response.write("<td bgcolor=#F4A460><font color=#FFFFFF>Faf-Trein.</td>")
    Response.write("<td bgcolor=#0000FF><font color=#FFFFFF>Ativ. Sindical Curso</td>")
    Response.write("<td bgcolor=#FF0000><font color=#FFFFFF>Ativ. Sindical Reunião Ordinária</td>")
    Response.write("<td bgcolor=#00AA00><font color=#FFFFFF>Ativ. Sindical Reunião Extra</td></tr>")
    end sub

'
sub legenda_grafFG()
    Response.write("<Table>")
    Response.write("<tr align=center><td ><font color=red>Legenda</td></tr>")
    Response.write("<tr><td bgcolor=white>S/Inf.</td>")
    Response.write("<td bgcolor=#FFFF99>Diretor</td>")
    Response.write("<td bgcolor=#CCCC00>CC1-Dir.E</td>")
    Response.write("<td bgcolor=#00CC00>CC2-A.Dir</td>")
    Response.write("<td bgcolor=#009999>GF1-Coord.</td>")
    Response.write("<td bgcolor=#00FF99>GF2-Ch.Núcleo</td>")
    Response.write("<td bgcolor=black ><font color=#FFFFFF>GF3-Ch.Eq.</td>")
    Response.write("<td bgcolor=#999999 ><font color=#FFFFFF>GF4-Ch.Set.</td>")
    Response.write("<td bgcolor=#FFCCCC>GAS-1</td>")
    Response.write("<td bgcolor=#33CCFF>GAS-2</td>")
    Response.write("<td bgcolor=#6699CC>GAS-3</td></tr>")
end sub

'
function fcorFG(fcargo)            
    Select Case fcargo            
        case "83"'---Assessor C
           fcorFG="#6699CC"            
        case "94","95","1010"'---Dir.Admin./Dir.Exec./Dir.Qual.Prof
           fcorFG="#FFFF99"            
        case "74","1017"'---Chefe de Núcleo/Chefe do SesT
            fcorFG="#00FF99"            
        case "86"'---Assist.de Direção
            fcorFG="#00CC00"
        case "93"'---Coordenador
            fcorFG="#009999"
        case "1011"'---Chefe de Equipe
            fcorFG="black"            
        case "87","1016"'---Diretor de Estab./Dir. CSE
            fcorFG="#CCCC00"                        
        case "85"'---Assessor A
            fcorFG="#FFCCCC"
        case "73"'---Chefe de Setor
            fcorFG="#999999"
        case "84"'---Assessor B
            fcorFG="#33CCFF"
        case else
           fcorFG="red"
    End Select
end function
'
'---Efetividade
function perEfetiv(fano,fintervalo)
    Dim Qano    
    Qano=fano        
    if mid(fintervalo,4,2)="12" then Qano=Qano+1
    perEfetiv=left(Wintervalo,5) &"-"& fano & " à " & right(Wintervalo,5) & "-"& Qano        
end function
'---Fim da Efetividade
'---Férias
Redim Wetapa(2),wdias(2),Wcancela(2),Wdata_i(2)
Dim Wperaquis,Wap,Was,Waut
Dim Wcod
sub codferias(fcod)
    Wcod=split(fcod,"|")        
    Wetapa(0)=datacod(Wcod(0)):Wdias(0)=Wcod(1)
    Wetapa(1)=datacod(Wcod(2)):Wdias(1)=Wcod(3)        
    Wetapa(2)=datacod(Wcod(4)):Wdias(2)=Wcod(5)
    Waut=Wcod(6):Wap=Wcod(7):Was=Wcod(8)
    Wperaquis=datacod(Wcod(9))    
end sub
'
function dtcodigo(fdada)
    dtcodigo=mid(fdada,1,2) & mid(fdada,4,2) & mid(fdada,7,4)
end function
'
dim WiniPer,wfimPer,WiniGozo,WfimGozo
sub periodos(fdia,fmes,fano)
    WiniPer=confData(fdia & "-" & fmes & "-" & cstr(fano-1))    
    wfimPer=confData(dateadd("d",-1,cdate(fdia & "-" & fmes & "-" & fano)))
    '
    WiniGozo=confData(cdate(fdia & "-" & fmes & "-" & fano))                
    WfimGozo=confData(dateadd("d",-1,cdate(fdia & "-" & fmes & "-" & fano+1)))
end sub
'

function fdiasAutferias(ffaltas)   
    '---Número de Dias Autorizados
    if ffaltas < 6 then fdiasAutferias=30
    if ffaltas >=6  and ffaltas < 15 then fdiasAutferias=24
    if ffaltas >=15 and ffaltas < 24 then fdiasAutferias=18
    if ffaltas >=24 and ffaltas < 33 then fdiasAutferias=12
    ' 25/03/2015 - Henrique Cordeiro - Permite registro de férias
    ' para servidores com mais de 32 faltas no PA
    'if ffaltas > 32 then msgAviso(6)
    if ffaltas > 32 then fdiasAutferias=11
end function
'
'---Fim das Férias
'---Html
sub cabecalho_html()
    response.write("<html>")
    response.write("<head><title>"&session("frmname")&"</title></head>")        
end sub
'
sub titulo_html()
    response.write("<b class=estilo_3>"&session("titulo")&"<br><br>")
end sub
'
sub rodape_html
    response.write("</form></body></html>

 

 

 

 

Link para o comentário
Compartilhar em outros sites

0 respostass a esta questão

Posts Recomendados

Até agora não há respostas para essa pergunta

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,1k
    • Posts
      651,8k
×
×
  • Criar Novo...