
<%

	'*****************************************************************************
	'* Step 1: Acquisisco i parametri                                            *
	'*****************************************************************************
	response.write "<br />***************************<br />"
	giornoMinimo = annoInput & "0100"
	giornoMinimo = clng(giornoMinimo)

	giornoMassimo = annoInput & "1232"
	giornoMassimo = clng(giornoMassimo)

	'response.write giornoMinimo & " - " & giornoMassimo & "<br />"
	
	
	strSql = "SELECT tblRegistro.idGiorno FROM tblRegistro WHERE idGiorno < " & giornoMassimo & " AND idGiorno > " & giornoMinimo & " ORDER BY tblRegistro.idGiorno;"
	Set rs=Server.CreateObject("ADODB.RecordSet")
		rs.ActiveConnection = connDB
		rs.Open strSql
		Do while not rs.EOF 
			idGiorno = rs("idGiorno")
			settGG = giornoSettimana(idGiorno)
			if settGG = 1 then
				giornoFestivo2 = -1
				chkFestivo = "si"
			else
				giornoFestivo2 = 0
				chkFestivo = "no"
			end if
			
			'response.write "idGiorno: " & idGiorno & "settGG: " & settGG & " - giornoFestivo? " & chkFestivo & "<br />"

			if chkFestivo = "si" then
				strAggiornaFestivo = "UPDATE tblRegistro SET giornoFestivo = -1 WHERE tblRegistro.idGiorno = " & idGiorno & ";"
				connDB.Execute(strAggiornaFestivo)
				response.write strAggiornaFestivo & "<br />"
			end if
		rs.MoveNext
		Loop
		rs.Close
	set rs = Nothing

	strNuovoAggiornamento = "UPDATE tblRegistro SET giornoFestivo = -1 WHERE tblRegistro.idGiorno = " & annoInput & "0101 OR tblRegistro.idGiorno = " & annoInput & "0106" & " OR tblRegistro.idGiorno = " & annoInput & "0425" & " OR tblRegistro.idGiorno = " & annoInput & "0501 OR tblRegistro.idGiorno = " & annoInput & "0602 OR tblRegistro.idGiorno = " & annoInput & "0815 OR tblRegistro.idGiorno = " & annoInput & "0908 OR tblRegistro.idGiorno = " & annoInput & "1101 OR tblRegistro.idGiorno = " & annoInput & "1208 OR tblRegistro.idGiorno = " & annoInput & "1225 OR tblRegistro.idGiorno = " & annoInput & "1226;"
	connDB.Execute(strNuovoAggiornamento)
	'response.write strNuovoAggiornamento

'	i = 1
'	strNuovaSql = "SELECT * FROM tblRegistro WHERE idGiorno < " & giornoMassimo & " AND idGiorno > " & giornoMinimo & ";"
'	Set rs=Server.CreateObject("ADODB.RecordSet")
'		rs.ActiveConnection = connDB
'		rs.Open strNuovaSql
'		Do while not rs.EOF 
'			idGiorno = rs("idGiorno")
'			giornoFestivo = rs("giornoFestivo")
'			if not giornoFestivo then
'				stringa = "UPDATE tblRegistro SET lottoProdottoFinito = " & i & " WHERE tblRegistro.idGiorno = " & idGiorno & ";"
'				ConnDB.Execute (stringa)
'				i = i + 1
'			end if
'		rs.MoveNext
'		Loop
'		rs.Close
'	set rs = Nothing
%>	
	
	
	
