List of LeagueTables.aspx
(Listing of LeagueTables.aspx.vb after this above listing)
<%@ Page Language="VB" MasterPageFile="~/MasterPage.master"
AutoEventWireup="false" CodeFile="LeagueTables.aspx.vb"
Inherits="LeagueTable" title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlacerHolder"
Runat="Server">
<div>
<div class="tabContents">
<asp:Label ID="lblDivName" runat="server"
Text="DivisionName"></asp:Label>
<asp:MultiView ID="mvLeagueTable" ActiveViewIndex="1"
runat="server">
<!-- VIEW 1 -->
<asp:View id="View1" Runat="Server">
<asp:GridView ID="gvLeagueTable" runat="server"
GridLines="None">
</asp:GridView>
<asp:Label ID="lblLeagueTableText" runat="server">
</asp:Label>
</asp:View>
<!-- VIEW 2 -->
<asp:View id="View2" Runat="Server">
<asp:GridView ID="gvResultsGrid" runat="server"
AutoGenerateColumns="False" DataSourceID="AccessDataSource1"
GridLines="None" CssClass="LeagueDivisionText">
<Columns>
<asp:TemplateField ShowHeader="False">
<ItemTemplate>
<table style="border: solid 1px Navy">
<tr>
<td Width="250pt">
Played at
<%#HomeTeamName(Eval("Home1"),Eval("Team1"),Eval("Team2"))%>
</td>
<td Width="200pt">
<%#Eval("MatchResultText")%>
</td>
<td rowspan="3">
<asp:HyperLink ID="HyperLink1"
runat="server"
ImageUrl="~/Images/NewScorebook.GIF"
NavigateUrl='<%#
"Scoresheet.aspx?FixID=" & Eval("FixtureID")%>'>
</asp:HyperLink>
</td>
</tr>
<tr>
<td>
<%#
CricketScore(Eval("Team1"),Eval("Score1"),Eval("Wkts1"),Eval("Dec"),Eval("Overs1"))%>
</td>
<td>
<%#
TeamGamePoints(Eval("Team1"),Eval("Points1"))%>
</td>
</tr>
<tr>
<td>
<%#CricketScore(Eval("Team2"),
Eval("Score2"), Eval("Wkts2"), False, Eval("Overs2"))%>
</td>
<td>
<%#
TeamGamePoints(Eval("Team2"),Eval("Points2"))%>
</td>
</tr>
<tr>
<td style="border-top: navy 1px
solid;" colspan="3">
</td>
</tr>
</table>
</ItemTemplate>
<ItemStyle CssClass="ResultsGrid" />
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:AccessDataSource ID="AccessDataSource1" runat="server"
DataFile="~/App_Data/NewMCCL.mdb"
SelectCommand="SELECT * FROM
[web_MatchReportingByWeekID]">
</asp:AccessDataSource>
</asp:View>
</asp:MultiView>
</div>
<asp:Menu
id="Menu1"
Orientation="Horizontal"
StaticMenuItemStyle-CssClass="tab"
StaticSelectedStyle-CssClass="selectedTab"
CssClass="tabs"
OnMenuItemClick="Menu1_MenuItemClick"
Runat="server">
<Items>
<asp:MenuItem Text="League Table" Value="0" Selected="true" />
<asp:MenuItem Text="Fixtures/Results" Value="1" />
<asp:MenuItem Text="Statistics" Value="2" />
</Items>
</asp:Menu>
</div>
</asp:Content>
'==========================================================================
List of LeagueTables.aspx.vb
Partial Class LeagueTable
Inherits System.Web.UI.Page
Sub Menu1_MenuItemClick(ByVal sender As Object, ByVal e As
MenuEventArgs)
Dim index As Integer = Int32.Parse(e.Item.Value)
mvLeagueTable.ActiveViewIndex = index
End Sub
Function CricketScore(ByVal Team, ByVal Score, ByVal Wkts, ByVal Dec,
ByVal Overs) As String
Dim STeam As String
STeam = Team
Dim sScore As String
sScore = Score
Dim sWkts As String
sWkts = Wkts
Dim sDec As String
If Dec Then
sDec = " Dec"
Else
sDec = ""
End If
Dim sOvers As String
sOvers = " (" & Overs & " overs)"
CricketScore = STeam & " " & sScore & "-" & sWkts & sDec & sOvers
End Function
Function HomeTeamName(ByVal Home1, ByVal Team1, ByVal Team2) As String
Dim bHome1 As Boolean
bHome1 = Home1
If bHome1 Then
HomeTeamName = Team1
Else
HomeTeamName = Team2
End If
End Function
Function TeamGamePoints(ByVal Team, ByVal Points) As String
Dim sTeam As String
sTeam = Team
Dim iPoints As Int16
iPoints = Points
If iPoints = 1 Then
TeamGamePoints = sTeam & " " & iPoints & "pt"
Else
TeamGamePoints = sTeam & " " & iPoints & "pts"
End If
End Function
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
'Establish Connection
Dim sDBPath = "Data Source=D:\MCCL\AccessDB\NewMCCL.mdb;"
Dim sConnString = "Provider=Microsoft.Jet.OLEDB.4.0;" & sDBPath
Dim myConnection As New OleDbConnection(sConnString)
Dim iYearNo As Int32 = 2007
Dim iDivNo As Int16
iDivNo = Request.QueryString("DivNo")
If iDivNo = 0 Then iDivNo = 1
Dim MyCommand1 As New OleDbCommand("", myConnection)
MyCommand1.CommandType = CommandType.StoredProcedure
MyCommand1.CommandText = "web_LeagueTables"
MyCommand1.Parameters.AddWithValue("DivisionID", iDivNo)
Dim myAdapter1 As OleDbDataAdapter = New
OleDbDataAdapter(MyCommand1)
Dim MyCommand2 As New OleDbCommand("", myConnection)
MyCommand2.CommandType = CommandType.StoredProcedure
MyCommand2.CommandText = "web_LeagueTablesComments"
MyCommand2.Parameters.AddWithValue("YearNo", iYearNo)
MyCommand2.Parameters.AddWithValue("DivNo", iDivNo)
Dim myAdapter2 As OleDbDataAdapter = New
OleDbDataAdapter(MyCommand2)
myConnection.Open()
Dim MyDataSet As New DataSet
myAdapter1.Fill(MyDataSet, "LeagueTable")
myAdapter2.Fill(MyDataSet, "Notes")
myConnection.Close()
gvLeagueTable.DataSource = MyDataSet.Tables("LeagueTable")
gvLeagueTable.DataBind()
gvResultsGrid.datasource = MyDataSet.Tables("WeekResults")
gvResultsGrid.DataBind()
Dim bTiedGamesPresent As Boolean
Dim bDrawn3GamesPresent As Boolean
Dim bPenaltyPointsPresent As Boolean
'===Divison Label
lblDivName.CssClass = "DivisionName"
lblDivName.Text = MyDataSet.Tables("LeagueTable").Rows(0)(0)
'===League Table
Dim GridRow As GridViewRow
For Each GridRow In gvLeagueTable.Rows
If Len(GridRow.Cells(3).Text) = 0 Then
bTiedGamesPresent = True
End If
If Len(GridRow.Cells(5).Text) = 0 Then
bDrawn3GamesPresent = True
End If
If Len(GridRow.Cells(9).Text) = 0 Then
bPenaltyPointsPresent = True
End If
Next
gvLeagueTable.HeaderRow.Cells(0).Visible = False
If bTiedGamesPresent = False Then
gvLeagueTable.HeaderRow.Cells(3).Visible = False
End If
If bDrawn3GamesPresent = False Then
gvLeagueTable.HeaderRow.Cells(5).Visible = False
End If
If bPenaltyPointsPresent = False Then
gvLeagueTable.HeaderRow.Cells(9).Visible = False
End If
For Each GridRow In gvLeagueTable.Rows
GridRow.Cells(0).Visible = False
GridRow.Cells(1).HorizontalAlign = HorizontalAlign.Left
If bTiedGamesPresent = False Then
GridRow.Cells(3).Visible = False
End If
If bDrawn3GamesPresent = False Then
GridRow.Cells(5).Visible = False
End If
If bPenaltyPointsPresent = False Then
GridRow.Cells(9).Visible = False
End If
Next
With gvLeagueTable
.CssClass = "TableGrid"
.HeaderRow.Cells(1).Text = ""
.HeaderRow.Cells(1).Width = "120"
.HeaderRow.Cells(2).Text = "Won<br/>10pts"
.HeaderRow.Cells(3).Text = "Tied<br/>5pts"
.HeaderRow.Cells(4).Text = "Drawn<br/>4pts"
.HeaderRow.Cells(5).Text = "Drawn<br/>3pts"
.HeaderRow.Cells(6).Text = "Drawn<br/>1pt"
.HeaderRow.Cells(7).Text = "Aband<br/>1pt"
.HeaderRow.Cells(8).Text = "lost<br/>0pts"
.HeaderRow.Cells(9).Text = "Penalty<br/>points"
.HeaderRow.Cells(10).Text = "Total<br/>points"
.HeaderStyle.CssClass = "LeagueTableTitle"
.RowStyle.CssClass = "LeagueTableBody"
End With
'===League Table Text
lblLeagueTableText.CssClass = "LeagueTableText"
lblLeagueTableText.Text = MyDataSet.Tables("Notes").Rows(0)("Text")
'========================================================================================================
End Sub
End Class