Private Sub ricercapertemponuova()
iconta = 0
totavv = 0
'totale = 0
FXG_DVD.Clear
'stit = TXT_RicDVD.Text
Set gRsDVD = New ADODB.Recordset
gsSQL = "SELECT * FROM Percorsi"
gRsDVD.Open gsSQL, gCnDatabase
lcontatot = 0
iconta = 0
txt_dal.Text = "" & txt_mdal.Text & "/" & txt_gdal.Text & "/" & txt_adal.Text & ""
txt_al.Text = "" & txt_mal.Text & "/" & txt_gal.Text & "/" & txt_aal.Text & ""
FXG_DVD.ColWidth(0) = 0
FXG_DVD.ColWidth(1) = 3500
FXG_DVD.ColWidth(2) = 800
FXG_DVD.ColWidth(3) = 1000
FXG_DVD.ColWidth(4) = 720
FXG_DVD.ColWidth(5) = 650
FXG_DVD.ColWidth(6) = 650
FXG_DVD.ColWidth(7) = 500
FXG_DVD.ColWidth(8) = 500
' FXG_DVD.ColWidth(9) = 800
FXG_DVD.Row = 0
FXG_DVD.rows = 1
FXG_DVD.ColWidth(0) = 0
FXG_DVD.Row = 0
FXG_DVD.Col = 7
FXG_DVD.Text = "%"
FXG_DVD.Col = 1
FXG_DVD.Text = "Percorso"
FXG_DVD.Col = 2
FXG_DVD.Text = "CODICE"
FXG_DVD.Col = 3
FXG_DVD.Text = "Posti Auto"
FXG_DVD.Col = 4
FXG_DVD.Text = "Costi"
FXG_DVD.Col = 5
FXG_DVD.Text = "Tot Pro"
FXG_DVD.Col = 6
FXG_DVD.Text = "Tot Eff"
FXG_DVD.Col = 7
FXG_DVD.Text = "%"
FXG_DVD.Col = 8
FXG_DVD.Text = "S/P"
' FXG_DVD.Col = 9
' FXG_DVD.Text = "S/P.A"
Do While gRsDVD.EOF = False
FXG_DVD.rows = FXG_DVD.rows + 1
FXG_DVD.Row = FXG_DVD.rows - 1
FXG_DVD.Col = 0
FXG_DVD.Text = gRsDVD("ID")
igen = gRsDVD("Codice")
icalcolaposti = 0
itot = 0
FXG_DVD.Col = 1
FXG_DVD.Text = gRsDVD("Camminamento")
FXG_DVD.Col = 2
FXG_DVD.Text = gRsDVD("Codice")
FXG_DVD.Col = 5
iconta = 0
primoconta = 0
ivia = 0
PBarXp.WaitBarStyle = True
Me.Refresh
DoEvents
Set gRsGenere = New ADODB.Recordset
gsSQL = "SELECT COD_VIA,STALLI_100 FROM COD_PERCORSI WHERE COD_PERCORSO = " & _
igen
gRsGenere.Open gsSQL, gCnDatabase
Do While gRsGenere.EOF = False
ivia = gRsGenere("COD_VIA")
icontaper = gRsGenere("STALLI_100")
icontaposti = 0
iconta = 0
primoconta = 0
' totale = 0
'-------------------------------------------------------------------------------------------------
FXG_DVD.Col = 3
Set gRscalcolaposti = New ADODB.Recordset
gsSQL = "SELECT * FROM COD_PERCORSI WHERE COD_VIA = " & ivia & " And COD_PERCORSO = " & igen & ""
gRscalcolaposti.Open gsSQL, gCnDatabase
Do While gRscalcolaposti.EOF = False
icalcolaposti = gRscalcolaposti("STALLI_TARIFFATI") + icalcolaposti
gRscalcolaposti.MoveNext
Loop
icontaposti = icalcolaposti + icontaposti
gRscalcolaposti.Close
'-------------------------------------------------------------------------------------------------
FXG_DVD.Col = 4
iprovaacontare = 0
PBarXp.WaitBarStyle = True
Me.Refresh
DoEvents
Set gRscalcoliamo = New ADODB.Recordset
gsSQL = "SELECT NUM_VRB FROM " & scerca & " WHERE DTA_RIL between #" & txt_dal.Text & "# AND #" & txt_al.Text & "# AND TME_RIL between """ & txt_orai.Text & """ AND """ & txt_oraf.Text & """ AND LGO_RIL = " & ivia & ""
gRscalcoliamo.Open gsSQL, gCnDatabase
Do While gRscalcoliamo.EOF = False
iconta = iconta + 1
gRscalcoliamo.MoveNext
Loop
ipercentuale = (Val(icontaper) / 100) * iconta
icontailtutto = ipercentuale + icontailtutto
gRscalcoliamo.Close
FXG_DVD.Col = 5
iconta = 0
percpro = 0
contaprogrammato = 0
itotaleeffettivo = 0
If iframe = 1 Then
Set gRscalcolaprogrammato = New ADODB.Recordset
gsSQL = "SELECT * FROM Servizi WHERE data between #" & txt_dal.Text & "# and #" & txt_al.Text & "# AND Turno < 4 AND RCodPer = " & igen & ""
gRscalcolaprogrammato.Open gsSQL, gCnDatabase
End If
If iframe = 2 Then
Set gRscalcolaprogrammato = New ADODB.Recordset
gsSQL = "SELECT * FROM Servizi WHERE data between #" & txt_dal.Text & "# and #" & txt_al.Text & "# AND Turno = 4 AND RCodPer = " & igen & ""
gRscalcolaprogrammato.Open gsSQL, gCnDatabase
End If
If gRscalcolaprogrammato.EOF = True Then
FXG_DVD.Text = "-"
End If
Do While gRscalcolaprogrammato.EOF = False
icontaorario = gRscalcolaprogrammato("Turno")
txt_datas.Text = Format(gRscalcolaprogrammato("data"), "mm/dd/yyyy")
primoconta = 0
contaprogrammato = contaprogrammato + 1
If contaprogrammato = 0 Then
FXG_DVD.Text = "-"
End If
percpro = contaprogrammato
gRscalcolaprogrammato.MoveNext
Loop
gRscalcolaprogrammato.Close
gRsGenere.MoveNext
Loop
gRsGenere.Close
FXG_DVD.Col = 3
FXG_DVD.Text = icontaposti
totprog = contaprogrammato + totprog
Call calcolanuovoeffettivo
gRsDVD.MoveNext
totale = 0
FXG_DVD.Col = 4
FXG_DVD.Text = icontailtutto
lcalcolatotcam = icontailtutto + lcalcolatotcam
' ICONTAILTUTTO = 0
FXG_DVD.Col = 5
FXG_DVD.Text = contaprogrammato
FXG_DVD.Col = 7
If contaprogrammato <> 0 And totalizziamo <> 0 Then
totperc = Val(totalizziamo) / Val(contaprogrammato) * 100
FXG_DVD.Text = totperc
Else
FXG_DVD.Text = "-"
End If
FXG_DVD.Col = 8
If icontailtutto <> 0 And totalizziamo <> 0 Then
FXG_DVD.Text = Format(Val(icontailtutto) / Val(totalizziamo), "0")
Else
FXG_DVD.Text = "-"
End If
icontailtutto = 0
Loop
gRsDVD.Close
Call calcolatxt
txt_totProg.Text = totprog
txt_totEffe.Text = toteffe
If toteffe <> 0 And totprog <> 0 Then
txt_rapPE.Text = Format(Val(toteffe) / Val(totprog) * 100, "0.0")
End If
'txt_rapPE.Text = (Val(totprog) / Val(toteffe))
txt_totavvcam.Text = lcalcolatotcam
lcalcolatotcam = 0
txt_percamsumese.Text = Val(txt_totavvcam.Text) - Val(txt_totavv.Text)
PBarXp.WaitBarStyle = True
Me.Refresh
DoEvents
End Sub