codice:
Dim strFold, FSO, FileFold, Fold, RSFile, swTrovato
Dim arrFile, strConn, Conn, RS, strSql, NomeFile, NDel, Nuove
strConn = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & server.MapPath("mdb-database/Sito Claudio.mdb")
Set Conn = Server.CreateObject("ADODB.connection")
Conn.Open strConn
If Len(Trim(request.form("Oggetto"))) > 0 Then Call InsDB
Set FSO = Server.CreateObject("Scripting.FileSystemObject")
strFold = "/public/Documenti/delibere"
Set Fold = FSO.GetFolder(server.MapPath(strFold))
NDel = 0
swTrovato = true
Nuove = 0
For Each FileFold In Fold.Files
NomeFile = Trim(Replace(Replace(FileFold.Name, "..", "."), " ", " "))
if FileFold.Name <> NomeFile then FileFold.Name = NomeFile
Next
For Each FileFold In Fold.Files
NomeFile = Replace(FileFold.Name, ".pdf", "")
arrFile = Split(Trim(NomeFile), " ")
strSql = "select * from Delibere where anno = " & arrFile(0)
strSql = strSql & " and Tipo = " & Chr(34) & arrFile(1) & Chr(34)
strSql = strSql & " and NdelAlfa = " & Chr(34) & arrFile(2) & Chr(34)
Set RSFile = server.CreateObject("ADODB.Recordset")
RSFile.Open strSql, Conn, 3, 3
If RSFile.EOF = True Then
If swTrovato = True Then
Call CreaForm(fileFold, arrFile)
swTrovato = false
End If
Nuove = Nuove + 1
End If
If RSFile.State = 1 Then RSFile.Close
Set RSFile = Nothing
Next
response.Write("<div id='nuove'>Nuove Delibere: " & Nuove & " su " & Fold.Files.Count)
If IsObject(RSFile) Then
If Not RSFile Is Nothing Then
If RSFile.State = 1 Then RSFile.Close
Set RSFile = Nothing
End If
End If
If Conn.State = 1 Then Conn.Close
Set Conn = Nothing
If swTrovato=true then%>
<script language="javascript" type="text/jscript">window.close();</script>
<%end if%>
<%
Sub InsDB()
Dim NDel, Car, strRicerca, i
NDel = request.form("NDelAlfa")
strRicerca = "ABCDEFGHILMNOPQRSTUVZXYWKJ"
i = 1
Do While Not i > Len(Trim(NDel))
Car = Mid(NDel, i, 1)
If InStr(1, strRicerca, Car, vbTextCompare) > 0 Then
NDel = Replace(NDel, Car, "")
i = 0
End If
i = i + 1
Loop
strSql = "Select * from Delibere"
Set RS = server.CreateObject("ADODB.Recordset")
RS.Open strSql, Conn, 3, 3
With RS
.addnew
.Fields("Anno") = request.form("Anno")
.Fields("Tipo") = request.form("Tipo")
.Fields("NDel") = NDel
.Fields("NDelAlfa") = request.form("NDelAlfa")
.Fields("File") = request.form("File")
.Fields("Oggetto") = UCase(Replace(Replace(request.form("Oggetto"), "'", "*/"), Chr(34), "-/"))
.Fields("Mese")=request.form("Mese")
.Fields("creazfile") = request.form("CreazFile")
.Update
If .State = 1 Then .Close
End With
Set RS = Nothing
End Sub
sub CreaForm(FileDel, arrValore) 'andrà sostituita con una wondows form
end sub
Function W(Stringa)
Response.Write(Stringa & vbCrLf)
End Function