Count Lines in Pages

Contents of Page: calcpickpoints.asp Number of Lines: 532 Last Modified: 4/20/2025 1:34:46 PM
0001: <% @Language = "VBScript" %>
0002: 
0003: <!-- #include FILE="include/adovbs.inc" -->
0004: <!-- #include FILE="include/constants.inc" -->
0005: 
0006: <%
0007: 
0008: CalculateAll = Trim(Request.QueryString("CalculateAll"))	
0009: 
0010: StartTime = Now()
0011: 
0012: 	Function getPts(fname, results, col)
0013: 		Dim sResults
0014: 		Select Case Left(fname, 1)
0015: 			Case "A"
0016: 				pos = 0
0017: 			Case "B"
0018: 				pos = 16
0019: 			Case "C"
0020: 				pos = 32
0021: 			Case "D"
0022: 				pos = 48
0023: 		End Select
0024: 		pos = pos + Int(Right(fname, 2))
0025:   
0026: 
0027: 		sResults = Split(results(pos), "|")
0028: 	tempPts = sResults(col)
0029: ' Response.Write("<br>Fname=" & fname &  "col=" & col & "temppts=" & tempPts)
0030: 
0031: 		If col = 6 then
0032: 			getpts = tempPts
0033: 		Else
0034: 			If tempPts <> "99" Then
0035: 				posspts = PossByRound(col)
0036: 			Else
0037: 				tempPts = 0
0038: 				posspts = 0
0039: 			End If
0040: 			getpts = tempPts & "|" & posspts
0041: 		End If
0042: 	End Function
0043: 
0044: 	yr = Request.QueryString("yr")
0045: 	flag = Request.QueryString("flag")
0046: 	If yr = "" Then yr = season
0047: 	Dim Regs(3)
0048: 	
0049: 	pos = 0
0050:    Dim F32(31)
0051:    Dim PossByRound(5)
0052:    PossByRound(0) = 1
0053:    PossByRound(1) = 2
0054:    PossByRound(2) = 4
0055:    PossByRound(3) = 8
0056:    PossByRound(4) = 16
0057:    PossByRound(5) = 32 
0058:    For IntI = 1 to 8
0059:    teamid = "A" & IntI
0060:    F32(pos) = teamid
0061:    pos = pos + 1
0062:    Next 
0063:     For IntI = 1 to 8
0064:    teamid = "B" & IntI
0065:    F32(pos) = teamid
0066:    pos = pos + 1
0067:    Next 
0068:  For IntI = 1 to 8
0069:    teamid = "C" & IntI
0070:    F32(pos) = teamid
0071:    pos = pos + 1
0072:    Next 
0073:  For IntI = 1 to 8
0074:    teamid = "D" & IntI
0075:    F32(pos) = teamid
0076:    pos = pos + 1
0077:    Next 
0078: 
0079:    Dim F16(15)
0080:    F16(0) = "A9"
0081:    F16(1) = "A10"
0082:    F16(2) = "A11"
0083:    F16(3) = "A12"
0084:    F16(4) = "B9"
0085:    F16(5) = "B10"
0086:    F16(6) = "B11"
0087:    F16(7) = "B12"
0088:    F16(8) = "C9"
0089:    F16(9) = "C10"
0090:    F16(10) = "C11"
0091:    F16(11) = "C12"
0092:    F16(12) = "D9"
0093:    F16(13) = "D10"
0094:    F16(14) = "D11"
0095:    F16(15) = "D12"
0096: 
0097:    Dim F8(7)
0098:    F8(0) = "A13"
0099:    F8(1) = "A14"
0100:    F8(2) = "B13"
0101:    F8(3) = "B14"
0102:    F8(4) = "C13"
0103:    F8(5) = "C14"
0104:    F8(6) = "D13"
0105:    F8(7) = "D14"
0106: 
0107:    Dim F4(3)
0108:    F4(0) = "A15"
0109:    F4(1) = "B15"
0110:    F4(2) = "C15"
0111:    F4(3) = "D15"
0112:    
0113:    Dim F2(1)
0114:    F2(0) = "S1"
0115:    F2(1) = "S2"
0116: 	 
0117: 	 	' get all the points for all the teams
0118: 		Dim results(65)
0119: 		Set rsResults = Server.CreateObject("ADODB.Recordset")
0120: 		sqlString = "SELECT * FROM mmResults WHERE Season = " & yr &  " ORDER BY ID"
0121: 		rsResults.Open sqlString, conn, adOpenDynamic, adLockOptimistic, adCmdText
0122: ' Response.Write("<br>" & sqlstring)
0123: 		Do Until rsResults.EOF
0124: 			Select Case Left(rsResults("ID").Value, 1)
0125: 				Case "A"
0126: 					pos = 0
0127: 				Case "B"
0128: 					pos = 16
0129: 				Case "C"
0130: 					pos = 32
0131: 				Case "D"
0132: 					pos = 48
0133: 			End Select
0134: 			pos = pos + Int(TRIM(Right(rsResults("ID").Value, 2)))
0135: 			results(pos) = 	rsResults("F32Pts").Value & "|" & _
0136: 											rsResults("F16Pts").Value & "|" & _
0137: 											rsResults("F8Pts").Value & "|" & _
0138: 											rsResults("F4Pts").Value & "|" & _
0139: 											rsResults("F2Pts").Value & "|" & _
0140: 											rsResults("F1Pts").Value & "|" & _
0141: 											rsResults("Name").Value
0142: 'Response.Write("<br>" & results(pos) & "pos=" & pos & "ID=" & Right(rsResults("ID").Value,2) )			
0143: rsResults.MoveNext
0144: 		Loop
0145: 		rsResults.Close
0146: 		Set rsResults = Nothing
0147: 		
0148:    pos = 0
0149: '   For InrR = 0 to 31
0150: '   Response.Write("(") & pos & ")"
0151: '   Response.Write(F32(pos)) & ".."
0152: '   pos = pos + 1
0153: '   Next 
0154:    Set cn = Server.CreateObject("ADODB.Connection")
0155: 	cn.Open conn
0156: 	sqlString = "DELETE FROM mmStandings " & _
0157: 							"WHERE Season = " & yr 
0158: 	cn.Execute sqlString, lngRecs, adExecuteNoRecords
0159: 	cn.Close
0160: 	Set cn = Nothing
0161: 
0162: 		Set rs = Server.CreateObject("ADODB.Recordset")
0163: 		sqlString = "SELECT * FROM mmPicks " & _
0164: 								"WHERE Season = " & yr & " " & _
0165: 								"AND Complete = 'Yes'"
0166: 		rs.Open sqlString, conn, adOpenDynamic, adLockOptimistic, adCmdText
0167: 	
0168: 		Do Until rs.EOF
0169: 		EntryName = rs("EntryName").Value
0170: 		UsedMobile = rs("UsedMobile").Value
0171: 		Email = rs("EmailAddress").Value
0172: 		PicksId = rs("ID").Value
0173: 		RegNumber = rs("RegNumber").Value
0174: 		Set rsEntry = Server.CreateObject("ADODB.Recordset")
0175:     	sqlString = "SELECT * FROM mmEntries " & _
0176: 							"WHERE EmailAddress = '" & Email & "' " & _
0177: 							"AND Season = " & season
0178: 	rsEntry.Open sqlString, conn, adOpenStatic, adLockReadOnly, adCmdText
0179: 	If Not rsEntry.EOF Then
0180: '	Response.Write("<BR>" & rsEntry("City").Value)
0181: 		CitySt = rsEntry("City").Value & ", " & rsEntry("State").Value
0182: 		GroupName = rsEntry("GroupName").Value
0183: 		GroupName2 = rsEntry("GroupName2").Value
0184: 		GroupName3 = rsEntry("GroupName3").Value	
0185: 		RealName = rsEntry("FirstName").Value & " " & rsEntry("Name").Value
0186: 		TextEmailAddress = rsEntry("TextEmailAddress").Value
0187: 				NumEntries = rsEntry("NumEntries").Value
0188: 		PaidEntries = rsEntry("PaidEntries").Value
0189: 		Num2ndEntries = rsEntry("Num2ndEntries").Value
0190: 		Paid2ndEntries = rsEntry("Paid2ndEntries").Value
0191: 		UnPaid = (NumEntries - PaidEntries) + (Num2ndEntries - Paid2ndEntries)
0192: 	End If
0193: 	rsEntry.Close
0194: 	Set rsEntry = Nothing
0195: 
0196: ' Response.Write("<br>EntryName=" & EntryName & "Email=" & Email)
0197:    
0198:   	  totpts = 0	
0199:   	  totposspts = 0
0200:   	  f32pts = 0
0201: '  	  Set rsResults = Server.CreateObject("ADODB.Recordset")
0202:           Dim BothPts
0203:  			For IntR = 0 to 31
0204: 				pts = getPts(rs(F32(IntR)).Value, results, 0)
0205: 				BothPts = split(pts,"|")
0206: 				f32pts = f32pts + BothPts(0)
0207: 				totposspts = totposspts + BothPts(1)
0208: 			Next
0209: 			totpts = totpts + f32pts
0210: 
0211: 			f16pts = 0
0212:  			For IntR = 0 to 15
0213: 				pts = getPts(rs(F16(IntR)).Value, results, 1)
0214: 				BothPts = split(pts,"|")
0215: 				f16pts = f16pts + BothPts(0)
0216: 				totposspts = totposspts + BothPts(1)
0217: 			Next
0218: 			totpts = totpts + f16pts
0219: 
0220: 			f8pts = 0
0221:  			For IntR = 0 to 7
0222: 				pts = getPts(rs(F8(IntR)).Value, results, 2)
0223: 				BothPts = split(pts,"|")
0224: 				f8pts = f8pts + BothPts(0)
0225: 				totposspts = totposspts + BothPts(1)
0226: 			Next
0227: 			totpts = totpts + f8pts
0228: 
0229: 			f4pts = 0
0230:  			For IntR = 0 to 3
0231: 				pts = getPts(rs(F4(IntR)).Value, results, 3)
0232: 				BothPts = split(pts,"|")
0233: 				f4pts = f4pts + BothPts(0)
0234: 				totposspts = totposspts + BothPts(1)
0235: 			Next
0236: 			totpts = totpts + f4pts
0237: 
0238: 			f2pts = 0
0239:  			For IntR = 0 to 1
0240: 				pts = getPts(rs(F2(IntR)).Value, results, 4)
0241: 				BothPts = split(pts,"|")
0242: 				f2pts = f2pts + BothPts(0)
0243: 				totposspts = totposspts + BothPts(1)
0244: 			Next
0245: 			totpts = totpts + f2pts
0246: 
0247: 			pts = getPts(rs("F1").Value, results, 5)
0248:               BothPts = split(pts,"|")
0249: 				f1pts =  BothPts(0)
0250: 				totposspts = totposspts + BothPts(1)
0251: 
0252: 			totpts = totpts + f1pts
0253: 			
0254: 			TeamName = getPts(rs("F1").Value, results, 6)
0255: 			SemiT1 = getPts(rs("S1").Value, results, 6)
0256: 			SemiT2 = getPts(rs("S2").Value, results, 6)
0257: 			F4T1 = getPts(rs("A15").Value, results, 6)
0258: 			f4T2 = getPts(rs("B15").Value, results, 6)
0259: 			F4T3 = getPts(rs("C15").Value, results, 6)
0260: 			F4T4 = getPts(rs("D15").Value, results, 6)
0261: 
0262:  			Pos1 = ""
0263: 			Pos2 = ""
0264: 			Pos3 = ""
0265: 			
0266: 			If SemiT1 = TeamName Then
0267: 				Pos1 = SemiT2
0268: 			Else
0269: 				Pos1 = SemiT1
0270: 			End If
0271: 			If F4T1 <> SemiT1 and F4T1 <> SemiT2 Then
0272: 				Pos2 = F4T1
0273: 			End If
0274: 			If F4T2 <> SemiT1 and F4T2 <> SemiT2 Then
0275: 				If Pos2 = "" Then
0276: 					Pos2 = F4T2
0277: 				Else
0278: 					Pos3 = F4T2
0279: 				End If
0280: 			End If
0281:           If F4T3 <> SemiT1 and F4T3 <> SemiT2 Then
0282: 				If Pos2 = "" Then
0283: 					Pos2 = F4T3
0284: 				Else
0285: 					Pos3 = F4T3
0286: 				End If
0287: 			End If
0288:           If F4T4 <> SemiT1 and F4T4 <> SemiT2 Then
0289: 				If Pos2 = "" Then
0290: 					Pos2 = F4T4
0291: 				Else
0292: 					Pos3 = F4T4
0293: 				End If
0294: 			End If
0295: 
0296: 
0297:        Set rsstand = Server.CreateObject("ADODB.Recordset")
0298: 		rsstand.Open "mmStandings", conn, adOpenDynamic, adLockOptimistic, adCmdTable
0299: 		rsstand.AddNew
0300: 		rsstand("Season").Value = yr
0301: '		rsstand("TextEmailAddress").Value = TextEmailAddress
0302: 		rsstand("RegNumber").Value = RegNumber
0303: 		rsstand("RealName").Value = RealName
0304: 		rsstand("Name").Value = EntryName
0305: 		rsstand("UsedMobile").Value = UsedMobile
0306: 		rsstand("Champion").Value = TeamName
0307: 		rsstand("City").Value = CitySt
0308: 		rsstand("Pts").Value = totpts
0309: 		rsstand("PossPts").Value = totposspts
0310: 		rsstand("Champion").Value = TeamName
0311: 		rsstand("RunnerUp").Value = Pos1 & "/ " & Pos2 & "," & Pos3
0312: 		rsstand("Round1").Value = F32pts
0313: 		rsstand("Sweet16").Value = F16pts
0314:        rsstand("Final8").Value = F8pts
0315: 		rsstand("Final4").Value = F4pts
0316: 		rsstand("Final2").Value = F2pts
0317:        rsstand("Final1").Value = F1pts
0318:        rsstand("PicksID").Value = PicksId
0319:        rsstand("GroupName").Value = GroupName
0320:        rsstand("GroupName2").Value = GroupName2
0321:        rsstand("GroupName3").Value = GroupName3   
0322: 	   If UnPaid <> 0 Then
0323: 	   rsstand("NotPaid") = "X"
0324: 	   End If	   
0325:        rsstand.Update
0326:        rsstand.Close
0327:        Set rsstand = Nothing
0328: 
0329: '			Response.Write(rs("ID").Value & "=" & rs("EntryName").Value & "Total = " & totpts & " Poss=" & totposspts & "<br>")
0330: 			rs("FPts").Value = totpts
0331: 			rs("Poss_Pts").Value = totposspts
0332:       rs.Update
0333:       rs.MoveNext
0334: 		Loop
0335: 
0336: 		rs.Close
0337: 		Set rs = Nothing
0338: 		Set rsResults = Nothing
0339: 		
0340: 		rank = 0
0341: 		Set rs = Server.CreateObject("ADODB.Recordset")
0342: 		sqlString = "SELECT * FROM mmStandings " & _
0343: 								"WHERE Season = " & yr & " " & _
0344: 								"ORDER BY PossPts DESC, Round1 DESC, Sweet16 DESC, Final8 DESC, Final4 DESC"	
0345: ' response.write(sqlstring)								
0346: 		rs.Open sqlString, conn, adOpenDynamic, adLockOptimistic, adCmdText
0347: 
0348: 		Do Until rs.EOF
0349:        	rank = rank + 1
0350:       		rs("Rank").Value = Rank
0351:        	rs.Update
0352:       		rs.MoveNext
0353: 		Loop
0354: 
0355: 		rs.Close
0356: 		Set rs = Nothing
0357: '
0358: ' Lets read them back
0359: '
0360: 
0361: 			Set rst = Server.CreateObject("ADODB.Recordset")
0362: 			sqlString = "SELECT COUNT(Season) as RecordCount FROM mmStandings " & _
0363: 						"WHERE Season = " & yr 
0364: 			rst.Open sqlString, conn, adOpenStatic, adLockReadOnly, adCmdText
0365: 	
0366: 			totpicks = CInt(rst("RecordCount").Value)
0367:             rst.Close
0368: 			Set rst = Nothing
0369: 
0370: 		Set rs = Server.CreateObject("ADODB.Recordset")
0371: 		sqlString = "SELECT * FROM mmStandings " & _
0372: 								"WHERE Season = " & yr & " " & _
0373: 								"ORDER BY Rank"
0374: 
0375: 		rs.Open sqlString, conn, adOpenStatic, adLockReadOnly, adCmdText
0376: 
0377: '      	totpicks = rs.RecordCount
0378:    	   	topten = CInt(totpicks / 10)
0379: 	   	TotProRate = 0
0380: 		Do Until rs.EOF
0381:        	rank = rs("Rank").Value
0382:        		If Rank <= topten Then
0383:       			TotProRate = TotProRate + rs("PossPts").Value
0384:       		End If
0385: 
0386:      		rs.MoveNext
0387: 		Loop
0388: 
0389: 		rs.Close
0390: 		Set rs = Nothing
0391: 
0392: '   	   	Response.Write("Totpicks=" & totpicks & " = " & topten & " + " & TotProRate & "<br>")
0393: 
0394: 		
0395: 		Set cn = Server.CreateObject("ADODB.Connection")
0396: 		cn.Open conn
0397: 		sqlString = "DELETE FROM mmTop10 " & _
0398: 							"WHERE Season = " & yr & " " & _
0399: 							"AND Contest = 'MC'"
0400: 		cn.Execute sqlString, lngRecs, adExecuteNoRecords
0401: 		cn.Close
0402: 		Set cn = Nothing
0403: 
0404: 	Set rsp = Server.CreateObject("ADODB.Recordset")
0405: 	sqlString = "SELECT * FROM mmPrizes " & _
0406: 			"WHERE Season = " & yr
0407: 	rsp.Open sqlString, conn, adOpenStatic, adLockReadOnly, adCmdText
0408: 
0409: ' Response.write("<br>" & sqlString)	
0410: 	
0411:       	
0412: ' Update TOP10 Table
0413: '	"WHERE Season = " & yr & _ '" ORDER BY Rank " 
0414:        tenpctnext = topten + 1
0415:  	 	halfprize = CInt(PrizeFund / 2)
0416: 		Set rs = Server.CreateObject("ADODB.Recordset")
0417: 		sqlString = "SELECT * FROM mmStandings " & _
0418: 								"WHERE Season = " & yr & " ORDER BY Rank " 
0419: '								" AND Rank < " & tenptcnext & " ORDER BY Rank"
0420: 		rs.Open sqlString, conn, adOpenDynamic, adLockOptimistic, adCmdText
0421: 		Do Until rs.EOF
0422:        Rank = rs("Rank").Value
0423: '       Response.Write("Rank = " & Rank & " <= " & topten & " = ")
0424:        If Rank <= topten Then
0425: 		topfive = 0
0426: 
0427:   TotalAmount = rsp("MTop10").Value
0428:  
0429:  	Select Case Rank
0430: 			Case 1
0431: 				TotalAmount = rsp("M1").Value
0432: 			Case 2
0433: 				TotalAmount = rsp("M2").Value
0434: 			Case 3
0435: 				TotalAmount = rsp("M3").Value
0436: 			Case 4
0437: 				TotalAmount = rsp("M4").Value
0438: 			Case 5
0439: 				TotalAmount = rsp("M5").Value
0440: 		End Select
0441: '		Select Case Rank
0442: '			Case 1
0443: '				topfive = CInt(halfprize * .45)
0444: '			Case 2
0445: '				topfive = CInt(halfprize * .25)
0446: '			Case 3
0447: '				topfive = CInt(halfprize * .15)
0448: '			Case 4
0449: '				topfive = CInt(halfprize * .10)
0450: '			Case 5
0451: '				topfive = CInt(halfprize * .05)
0452: '		End Select
0453: 		MyPts = rs("PossPts").Value
0454: 		Namenew = rs("RealName").Value
0455:        RegNumber = rs("RegNumber").Value
0456: '       EmailAddress = rs("EmailAddress").Value
0457: 		PicksID = rs("PicksID").Value
0458:        Citynew = rs("City").Value
0459:        PossPts = rs("PossPts").Value
0460: 		Ratio = MyPts / TotProRate
0461: 		topten2 = Cint(halfprize * Ratio)
0462: 		totalamt = topfive + topten2
0463: 		If Rank <= 10 Then
0464:  '      Response.Write(Namenew & " = " & Citynew & "-" & topfive & " = " & topten & " = " & totalamt & "<BR>")
0465: 	   End If
0466: 		Set rstopten = Server.CreateObject("ADODB.Recordset")
0467: 		rstopten.Open "mmTop10", conn, adOpenDynamic, adLockOptimistic, adCmdTable
0468: 		rstopten.AddNew
0469: 		rstopten("Season").Value = yr
0470: 		rstopten("Rank").Value = Rank
0471:         rstopten("RegNumber").Value = RegNumber
0472: '        rstopten("EmailAddress").Value = EmailAddress
0473: 		rstopten("Name").Value = Namenew
0474:        rstopten("PicksID").Value = PicksID
0475:        rstopten("City").Value = Citynew
0476:        rstopten("PossPts").Value = PossPts
0477:        rstopten("Contest").Value = "MC"
0478:        rstopten("TotalAmt").Value = TotalAmount
0479: 	   If UnPaid <> 0 Then
0480: 	   rstopten("NotPaid") = "X"
0481: 	   End If	 
0482: '       Response.Write(rstopten("Top5Amt").Value & " = " & rstopten("Top10Amt").Value & " = " & rstopten("TotalAmt").Value & "<BR>")
0483:        rstopten.Update
0484:        rstopten.Close
0485:        Set rstopten = Nothing
0486:        End If
0487: 		rs.MoveNext
0488: 		Loop
0489: 		rs.Close
0490: 		Set rs = Nothing
0491: 		Response.Write("Update Completed.")
0492: 
0493: 		EndTime = Now()
0494: 
0495: 		Elapsed = DateDiff("s",StartTime, EndTime)
0496: %>
0497: 
0498: <html>
0499: <body>
0500: <meta name="viewport" content="width=device-width">
0501: <table width="350">
0502: <tr>
0503: <td><big><big>
0504: <%
0505: 
0506: 		Response.Write("<br><br>Start Time: " & StartTime & "<br>End Time: " & EndTime & "<br><br>Elapsed Time (Seconds):<b> " & Elapsed)
0507: %>
0508: </td>
0509: </tr>
0510: <%
0511: 		Set rs = Server.CreateObject("ADODB.Recordset")
0512: 		sqlString = "SELECT * FROM mmConfig WHERE Element = 'STANDINGSUPDATED'" 
0513: 		rs.Open sqlString, conn, adOpenDynamic, adLockOptimistic, adCmdText
0514: 		NowTime = DateAdd("h",-2,Now())
0515: 		
0516: 		rs("Value").Value = NowTime
0517: 		rs.update
0518: 		rs.Close
0519: 		Set rs = Nothing
0520: 		
0521: 		If CalculateAll = "Y" then
0522: 			   Response.Redirect("biggestlosercalc.asp?yr=" & yr)
0523:         End If			   
0524: 
0525: 
0526: %>
0527: <tr><td><big><big><br><br>
0528: <a href="displaymenugen.asp?parent=40&title=March%20Madness%20-%20Scores / Standings Update">Return to menu</a>
0529: </td>
0530: </tr>
0531: </table>
0532: </html>