Count Lines in Pages

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