Count Lines in Pages

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