<% if (Request.Form("txtRGM") <> "") then sRGM = Formata(Request.Form("txtRGM"), 5) Set oBDOco = Server.CreateObject("ADODB.Connection") oBDOco.ConnectionString = sCnnOco : oBDOco.Open '------------------------- Acao = Request.Form("Acao") sData = Request.Form("txtData") sSerie = Request.Form("cboSerie") sTurma = Request.Form("cboTurma") CodOco = Request.Form("cboOCO") CodDiscip = Request.Form("cboDiscip") sMsg = "" '------------------------- If Acao = "2" Then 'Salva Dados On Error Resume Next sDataQry = Split(sData, "/") Dim N : N = 0 sRGM = Request.Form("hRGM") : sCodOco = Request.Form("hCodOco") sSQL = "Delete from OCORREN Where DATA = '" & _ Right(sDataQry(2),2) & "/" & sDataQry(1) & "/" & sDataQry(0) & "' And RGM = '" & sRGM & "' And COD_DESCRI = '" & sCodOco & "'" 'Response.Write sSQL ': Response.End() oBD.Execute(sSQL) For Each item In Request.Form if Left(item, 4) = "chk_" then N = N + 1 aVar = Split(item, "_") 'chk_sRGM_CodDiscip sRGM = aVar(1) : CodDiscip = aVar(2) 'if N = 1 then'excluo tudo do aluno 1 vez soh 'end if if CodDiscip <> "000" then Set rsDiscip = oBD.Execute("Select MATDESMAT From ADEDMAT Where MATCODMAT = '" & CodDiscip & "'") if not rsDiscip.Eof Then sDescDiscip = rsDiscip(0) if rsDiscip.State = 1 then rsDiscip.Close Set rsDiscip = Nothing end if Set rsOCOR = oBDOco.Execute("Select DESCRICAO From TIPOCORRENCIA Where CODIGO = " & CodOco) sDescOco = "" if not rsOCOR.Eof Then sDescOco = rsOCOR(0) if rsOCOR.State = 1 then rsOCOR.Close Set rsOCOR = Nothing sAno = Year(date) sSQL = "Insert Into OCORREN(RGM,DATA,COD_DISCIP,COD_DESCRI,DESCRI,ANO,MES) Values ('" & sRGM & "','" & _ Right(sDataQry(2),2) & "/" & sDataQry(1) & "/" & sDataQry(0) & "','" & CodDiscip & "','" & CodOco & "','" & _ sDataQry(0) & "/" & sDataQry(1) & "/" & sDataQry(2) & " - " & sDescOco & " " & sDescDiscip & "','" & sAno & "','" & sDataQry(1) & "')" 'Response.Write sSQL oBD.Execute(sSQL) '& " - " & Request.form(item) & "
") end if Next sDescDiscip = "" if err.number = 0 then sMsg = "Dados Gravados com Sucesso" else sMsg = "ERRO - " & err.number & " - " & Replace(err.Description, "'", "") end if Acao = "" ElseIf Acao = "3" Then 'Exclue Dados sQuery = "Delete from TIPOCORRENCIA Where CODIGO = " & CodOco 'Response.Write(sQuery) : Response.End() oBD.Execute sQuery if err.number = 0 then sMsg = "Registro Excluido com Sucesso" else sMsg = "ERRO - " & err.number & " - " & Replace(err.Description, "'", "") end if Acao = "" ElseIf Acao = "4" Then 'Cancelou -> apenas ZERA Acao = "" End If %> <% if sMsg <> "" then Response.Write("") %> <% if Acao = "1" then Set rsOCOR = oBDOco.Execute("Select DESCRICAO,DISCIP From TIPOCORRENCIA Where CODIGO = " & CodOco) sDescOco = "" if not rsOCOR.Eof Then sDescOco = rsOCOR(0) if rsOCOR(1) = "N" then CodDiscip = "000" end if if rsOCOR.State = 1 then rsOCOR.Close Set rsOCOR = Nothing '----------------------------- 'Set rsDiscip = oBD.Execute("Select MATDESMAT From ADEDMAT Where MATCODMAT = '" & CodDiscip & "'") 'response.Write("Select MATDESMAT From ADEDMAT Where MATDESMAT = '" & CodDiscip & "'") ': Response.End() 'sDescDiscip = "" 'if not rsDiscip.Eof Then sDescDiscip = rsDiscip(0) 'if rsDiscip.State = 1 then rsDiscip.Close 'Set rsDiscip = Nothing '----------------------------- sSQL = "Select RGM,NOME,SERIE,TURMA,NUMERO From ALUNOS Where RGM = '" & sRGM & "' Order By NUMERO" 'Response.Write sSQL Set rsAlunos = oBD.Execute(sSQL) If Not rsAlunos.Eof Then sDataQry = Split(sData, "/") sSerie = rsAlunos("SERIE") sTurma = rsAlunos("TURMA") sNome = rsAlunos("NOME") sSQL = "SELECT MATCODMAT,MATDESMAT FROM ADEDMAT ORDER BY MATDESMAT" Set rsMat = oBD.Execute(sSQL) %>
<% Do While Not rsMat.Eof sDESCMAT = rsMat("MATDESMAT") CodDiscip = rsMat("MATCODMAT") sQuery = "Select 1 from OCORREN Where DATA = '" & _ Right(sDataQry(2),2) & "/" & sDataQry(1) & "/" & sDataQry(0) & "' And RGM = '" & sRGM & "' And COD_DISCIP = '" & _ CodDiscip & "' And COD_DESCRI = '" & CODOCO & "'" 'Response.Write(sQuery) ': Response.End() Set rsVerifica = oBD.Execute(sQuery) bAchou = False if not rsVerifica.Eof then bAchou = True if rsVerifica.state = 1 then rsVerifica.Close %> <% rsMat.MoveNext Loop rsMat.Close : Set rsMat = Nothing %>
Data Oco.: <%= sData %> Série: <%= sSerie %> Turma: <%= sTurma %> <%= sDescOco %>
<%= sRGM & " / " & sNome %>
<%=sDESCMAT%> checked="checked" <% end if %> type="checkbox" value="S">

<%else response.write "
Aluno nao encontrado. Reveja os dados e tente novamente.
" End If 'if not rsMat.Eof rsAlunos.Close : Set rsAlunos = Nothing End If 'Acao = 1 %> <% if Acao = "" then %>
Informe os dados:
Data: <% Function pd(n, totalDigits) if totalDigits > len(n) then pd = String(totalDigits-len(n),"0") & n else pd = n end if End Function If sData = "" then sData = pd(DAY(date()),2) & "/" & _ pd(MONTH(date()),2) & "/" & _ YEAR(Date()) End If %>
RGM:
Ocorrência:
<% End If 'Acao = "" %> <% if oBD.State=1 then oBD.Close Set oBD = Nothing if oBDOco.State=1 then oBDOco.Close Set oBDOco = Nothing %>