Count Lines in Pages

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