Public Class Show

    Private myShowNumber As Integer
    Private myYear As Integer
    Private myMonth As Integer
    Private myDay As Integer
    Private myCity As String
    Private myState As String
    Private myCountry As String
    Private myVenue As String
    Private myNotes As String
    Private myVerified As Boolean
    Public Event DBError(ByVal message As String)

    Public Property ShowNumber() As Integer
        Get
            Return myShowNumber
        End Get
        Set(ByVal value As Integer)
            myShowNumber = value
        End Set
    End Property

    Public Property Year() As Integer
        Get
            Return myYear
        End Get
        Set(ByVal value As Integer)
            myYear = value
        End Set
    End Property

    Public Property Month() As Integer
        Get
            Return myMonth
        End Get
        Set(ByVal value As Integer)
            myMonth = value
        End Set
    End Property

    Public Property Day() As Integer
        Get
            Return myDay
        End Get
        Set(ByVal value As Integer)
            myDay = value
        End Set
    End Property

    Public Property City() As String
        Get
            Return myCity
        End Get
        Set(ByVal value As String)
            myCity = value
        End Set
    End Property

    Public Property State() As String
        Get
            Return myState
        End Get
        Set(ByVal value As String)
            myState = value
        End Set
    End Property

    Public Property Country() As String
        Get
            Return myCountry
        End Get
        Set(ByVal value As String)
            myCountry = value
        End Set
    End Property

    Public Property Venue() As String
        Get
            Return myVenue
        End Get
        Set(ByVal value As String)
            myVenue = value
        End Set
    End Property

    Public Property Notes() As String
        Get
            Return myNotes
        End Get
        Set(ByVal value As String)
            myNotes = value
        End Set
    End Property

    Public Property Verified() As Boolean
        Get
            Return myVerified
        End Get
        Set(ByVal value As Boolean)
            myVerified = value
        End Set
    End Property

    Public Function Exists(ByVal shownumber As Integer) As Boolean
        If ShowTableAdapter.Exists(shownumber) > 0 Then
            Return True
        Else
            Return False
        End If
    End Function

    Public Function Save()
        Try
            Dim drwNewShow As DataRow
            drwNewShow = DsMetallica1.Show.NewRow
            drwNewShow("Year") = Me.Year
            drwNewShow("Month") = Me.Month
            drwNewShow("Day") = Me.Day
            drwNewShow("City") = Me.City
            drwNewShow("State") = Me.State
            drwNewShow("Country") = Me.Country
            drwNewShow("Venue") = Me.Venue
            drwNewShow("Notes") = Me.Notes
            drwNewShow("Verified") = Me.Verified
            DsMetallica1.Show.AddShowRow(drwNewShow)
            ShowTableAdapter.Update(DsMetallica1.Show)
        Catch ex As Exception
            RaiseEvent DBError(ex.Message)
        End Try
        Me.ShowNumber = ShowTableAdapter.GetIdentity()
    End Function

    Public Function Update() As Boolean
        If Me.Exists(Me.ShowNumber) Then
            Try
                ShowTableAdapter.UpdateQuery(Me.Year, Me.Month, Me.Day, Me.City, Me.State, Me.Country, Me.Venue, Me.Notes, Me.Verified, Me.ShowNumber)
                Return True
            Catch exc As SqlClient.SqlException
                RaiseEvent DBError("Record could not be updated: " & exc.Message)
                Return False
            End Try
        Else
            RaiseEvent DBError("Your information was not found!")
        End If
    End Function

    Public Function Delete(ByVal shownumber As Integer) As Boolean
        If Me.Exists(shownumber) Then
            Try
                Dim drwTemp As DataRow
                drwTemp = DsMetallica1.Show.Rows.Find(Me.ShowNumber)
                drwTemp.Delete()
                ShowTableAdapter.Update(DsMetallica1.Show)
                Return True
            Catch exc As SqlClient.SqlException
                RaiseEvent DBError("Record could not be deleted: " & exc.Message)
                Return False
            End Try
        Else
            RaiseEvent DBError("Your information was not found!")
        End If
    End Function

    Public Function Item(ByVal shownumber As Integer)
        Dim tblTemp As DataTable
        tblTemp = ShowTableAdapter.Find(shownumber)
        Dim drwTemp As DataRow
        drwTemp = tblTemp.Rows.Find(shownumber)
        Me.ShowNumber = drwTemp("ShowNumber")
        Me.Year = drwTemp("Year")
        Me.Month = drwTemp("Month")
        Me.Day = drwTemp("Day")
        Me.City = drwTemp("City")
        If Not drwTemp("State") Is System.DBNull.Value Then
            Me.State = drwTemp("State")
        End If
        Me.Country = drwTemp("Country")
        Me.Venue = drwTemp("Venue")
        If Not drwTemp("Notes") Is System.DBNull.Value Then
            Me.Notes = drwTemp("Notes")
        End If
        Me.Verified = drwTemp("Verified")
    End Function

    Public Function NumberOfShows() As Integer
        Return ShowTableAdapter.NumRows()
    End Function

    Public Function GetAll() As DataTable
        Return ShowTableAdapter.GetData()
    End Function
End Class