Count Lines in Pages

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