Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim Game As clsGame
Dim Course As clsCourse
Dim nCourseID As Integer
Dim nYear As Integer
Dim bLoading As Boolean
Dim nCurrentGame As Integer
Dim nGameCount As Integer
Dim sSaveType As String
Dim bNewGame As Boolean
Try
If Request.QueryString("SaveType") = "Game" Then
UpdateGame()
End If
If Request.QueryString("SaveType") = "Course" Then
UpdateCourse()
End If
If Request.QueryString("SaveType") = "NewGame" Then
bNewGame = True
End If
nCourseID = CInt(Request.QueryString("CourseID"))
sSaveType = Request.Form("SaveType")
m_Season = New clsSeason
m_Game = New clsGame
If Not Page.IsPostBack Then
Course = New clsCourse
Course.Load(nCourseID)
m_lCourseID.Value = nCourseID
cboSeason.DataSource = m_Season.YearsPlayed
cboSeason.DataValueField = "Year"
cboSeason.DataBind()
If Session("SelectedYear") <> "" Then
cboSeason.Text = Session("SelectedYear")
Else
Session("SelectedYear") = cboSeason.Text
End If
txtCourseName.Text = Course.Name
txtWebSite.Text = Course.Hyperlink
Course = Nothing
bLoading = True
End If
nYear = CInt(cboSeason.Text)
m_Season.CurrentYear = nYear
If m_lCourseID.Value > 0 Then
m_Season.LoadGames(m_lCourseID.Value)
End If
If m_Season.Games.Count > 0 Then
Game = m_Season.Games.Item(1)
nGameCount = 0
lstGames.Visible = True
If lstGames.SelectedIndex = -1 Then
'-1 is used the first time it loads, so set the selected game to 0 for game 1
nCurrentGame = 0
Else
'Anything else has been selected from the list
nCurrentGame = lstGames.SelectedIndex
End If
lstGames.Items.Clear()
'reset the boxes
txtDetails.Text = ""
txtExtraDetails.Text = ""
txtPrice.Text = "0.00"
txtImagePath.Text = ""
txtTitle.Text = ""
chkLeagueGame.Checked = False
cboHours.Text = "00"
cboHours.Text = "00"
calGame.TodaysDate = Date.Now
For Each Game In m_Season.Games
'Loop through all the games for the selected season
lstGames.Items.Add("Game " & nGameCount + 1)
If nCurrentGame = nGameCount And Not bNewGame Then
'If the game id matches the selected game fill the boxes
txtDetails.Text = Game.Details
txtExtraDetails.Text = Game.ExtraInformation
txtPrice.Text = Game.Price
txtTitle.Text = Game.Name
txtImagePath.Text = Game.ImageLocation
chkLeagueGame.Checked = Game.LeagueGame
cboHours.Text = Game.MatchDate.ToString("hh")
cboHours.Text = Game.MatchDate.ToString("mm")
calGame.TodaysDate = Game.MatchDate
calGame.SelectedDate = Game.MatchDate
m_GameID.Value = Game.ID
End If
nGameCount = nGameCount + 1
Next Game
lstGames.SelectedIndex = nCurrentGame
lblNone.Visible = False
Game = Nothing
Else
lblNone.Visible = True
lstGames.Visible = False
End If
m_Season = Nothing
Catch es As Exception
End Try
End Sub
Protected Sub cboSeason_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cboSeason.SelectedIndexChanged
Session("SelectedYear") = cboSeason.Text
End Sub
Protected Sub cmdUpdateGame_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdUpdateGame.Click
Dim context As HttpContext = HttpContext.Current
Dim dtMatchDate As Date
Dim sDatePlayed As String
Dim Game As New clsGame
dtMatchDate = calGame.TodaysDate
sDatePlayed = cboSeason.Text & "-" & dtMatchDate.ToString("MM-dd ") _
& " " & cboHours.Text & ":" & cboMins.Text
Game.CourseID = m_lCourseID.Value
Game.DateAsString = sDatePlayed
Game.Details = txtDetails.Text
Game.ExtraInformation = txtExtraDetails.Text
Game.ImageLocation = txtImagePath.Text
Game.Price = txtPrice.Text
Game.LeagueGame = chkLeagueGame.Checked
Game.Name = txtTitle.Text
Game.ID = m_GameID.Value
Game.save()
Game = Nothing
MsgBox("Update Complete")
End Sub