Public Class Setlist

    Private mySetlistNumber As Integer
    Private myShowNumber As Integer
    Private mySong01 As Integer
    Private mySong02 As Integer
    Private mySong03 As Integer
    Private mySong04 As Integer
    Private mySong05 As Integer
    Private mySong06 As Integer
    Private mySong07 As Integer
    Private mySong08 As Integer
    Private mySong09 As Integer
    Private mySong10 As Integer
    Private mySong11 As Integer
    Private mySong12 As Integer
    Private mySong13 As Integer
    Private mySong14 As Integer
    Private mySong15 As Integer
    Private mySong16 As Integer
    Private mySong17 As Integer
    Private mySong18 As Integer
    Private mySong19 As Integer
    Private mySong20 As Integer
    Private mySong21 As Integer
    Private mySong22 As Integer
    Private mySong23 As Integer
    Private mySong24 As Integer
    Private mySong25 As Integer
    Public Event DBError(ByVal message As String)

    Public Property SetlistNumber() As Integer
        Get
            Return mySetlistNumber
        End Get
        Set(ByVal value As Integer)
            mySetlistNumber = value
        End Set
    End Property

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

    Public Property Song01() As Integer
        Get
            Return mySong01
        End Get
        Set(ByVal value As Integer)
            mySong01 = value
        End Set
    End Property

    Public Property Song02() As Integer
        Get
            Return mySong02
        End Get
        Set(ByVal value As Integer)
            mySong02 = value
        End Set
    End Property

    Public Property Song03() As Integer
        Get
            Return mySong03
        End Get
        Set(ByVal value As Integer)
            mySong03 = value
        End Set
    End Property

    Public Property Song04() As Integer
        Get
            Return mySong04
        End Get
        Set(ByVal value As Integer)
            mySong04 = value
        End Set
    End Property

    Public Property Song05() As Integer
        Get
            Return mySong05
        End Get
        Set(ByVal value As Integer)
            mySong05 = value
        End Set
    End Property

    Public Property Song06() As Integer
        Get
            Return mySong06
        End Get
        Set(ByVal value As Integer)
            mySong06 = value
        End Set
    End Property

    Public Property Song07() As Integer
        Get
            Return mySong07
        End Get
        Set(ByVal value As Integer)
            mySong07 = value
        End Set
    End Property

    Public Property Song08() As Integer
        Get
            Return mySong08
        End Get
        Set(ByVal value As Integer)
            mySong08 = value
        End Set
    End Property

    Public Property Song09() As Integer
        Get
            Return mySong09
        End Get
        Set(ByVal value As Integer)
            mySong09 = value
        End Set
    End Property

    Public Property Song10() As Integer
        Get
            Return mySong10
        End Get
        Set(ByVal value As Integer)
            mySong10 = value
        End Set
    End Property

    Public Property Song11() As Integer
        Get
            Return mySong11
        End Get
        Set(ByVal value As Integer)
            mySong11 = value
        End Set
    End Property

    Public Property Song12() As Integer
        Get
            Return mySong12
        End Get
        Set(ByVal value As Integer)
            mySong12 = value
        End Set
    End Property

    Public Property Song13() As Integer
        Get
            Return mySong13
        End Get
        Set(ByVal value As Integer)
            mySong13 = value
        End Set
    End Property

    Public Property Song14() As Integer
        Get
            Return mySong14
        End Get
        Set(ByVal value As Integer)
            mySong14 = value
        End Set
    End Property

    Public Property Song15() As Integer
        Get
            Return mySong15
        End Get
        Set(ByVal value As Integer)
            mySong15 = value
        End Set
    End Property

    Public Property Song16() As Integer
        Get
            Return mySong16
        End Get
        Set(ByVal value As Integer)
            mySong16 = value
        End Set
    End Property

    Public Property Song17() As Integer
        Get
            Return mySong17
        End Get
        Set(ByVal value As Integer)
            mySong17 = value
        End Set
    End Property

    Public Property Song18() As Integer
        Get
            Return mySong18
        End Get
        Set(ByVal value As Integer)
            mySong18 = value
        End Set
    End Property

    Public Property Song19() As Integer
        Get
            Return mySong19
        End Get
        Set(ByVal value As Integer)
            mySong19 = value
        End Set
    End Property

    Public Property Song20() As Integer
        Get
            Return mySong20
        End Get
        Set(ByVal value As Integer)
            mySong20 = value
        End Set
    End Property

    Public Property Song21() As Integer
        Get
            Return mySong21
        End Get
        Set(ByVal value As Integer)
            mySong21 = value
        End Set
    End Property

    Public Property Song22() As Integer
        Get
            Return mySong22
        End Get
        Set(ByVal value As Integer)
            mySong22 = value
        End Set
    End Property

    Public Property Song23() As Integer
        Get
            Return mySong23
        End Get
        Set(ByVal value As Integer)
            mySong23 = value
        End Set
    End Property

    Public Property Song24() As Integer
        Get
            Return mySong24
        End Get
        Set(ByVal value As Integer)
            mySong24 = value
        End Set
    End Property

    Public Property Song25() As Integer
        Get
            Return mySong25
        End Get
        Set(ByVal value As Integer)
            mySong25 = value
        End Set
    End Property

    Public Function Exists(ByVal setlistnumber As Integer) As Boolean
        If SetlistTableAdapter.Exists3(setlistnumber) > 0 Then
            Return True
        Else
            Return False
        End If
    End Function

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

    Public Function GetSetlistNumberByShow(ByVal shownumber As Integer) As Integer
        Return SetlistTableAdapter.GetSetByShow(shownumber)
    End Function

    Public Function Save()
        Try
            Dim drwNewSetlist As DataRow
            drwNewSetlist = DsMetallica1.Setlist.NewRow
            drwNewSetlist("ShowNumber") = Me.ShowNumber
            drwNewSetlist("Song01") = Me.Song01
            If Not Me.Song02 = 0 Then
                drwNewSetlist("Song02") = Me.Song02
            End If
            If Not Me.Song03 = 0 Then
                drwNewSetlist("Song03") = Me.Song03
            End If
            If Not Me.Song04 = 0 Then
                drwNewSetlist("Song04") = Me.Song04
            End If
            If Not Me.Song05 = 0 Then
                drwNewSetlist("Song05") = Me.Song05
            End If
            If Not Me.Song06 = 0 Then
                drwNewSetlist("Song06") = Me.Song06
            End If
            If Not Me.Song07 = 0 Then
                drwNewSetlist("Song07") = Me.Song07
            End If
            If Not Me.Song08 = 0 Then
                drwNewSetlist("Song08") = Me.Song08
            End If
            If Not Me.Song09 = 0 Then
                drwNewSetlist("Song09") = Me.Song09
            End If
            If Not Me.Song10 = 0 Then
                drwNewSetlist("Song10") = Me.Song10
            End If
            If Not Me.Song11 = 0 Then
                drwNewSetlist("Song11") = Me.Song11
            End If
            If Not Me.Song12 = 0 Then
                drwNewSetlist("Song12") = Me.Song12
            End If
            If Not Me.Song13 = 0 Then
                drwNewSetlist("Song13") = Me.Song13
            End If
            If Not Me.Song14 = 0 Then
                drwNewSetlist("Song14") = Me.Song14
            End If
            If Not Me.Song15 = 0 Then
                drwNewSetlist("Song15") = Me.Song15
            End If
            If Not Me.Song16 = 0 Then
                drwNewSetlist("Song16") = Me.Song16
            End If
            If Not Me.Song17 = 0 Then
                drwNewSetlist("Song17") = Me.Song17
            End If
            If Not Me.Song18 = 0 Then
                drwNewSetlist("Song18") = Me.Song18
            End If
            If Not Me.Song19 = 0 Then
                drwNewSetlist("Song19") = Me.Song19
            End If
            If Not Me.Song20 = 0 Then
                drwNewSetlist("Song20") = Me.Song20
            End If
            If Not Me.Song21 = 0 Then
                drwNewSetlist("Song21") = Me.Song21
            End If
            If Not Me.Song22 = 0 Then
                drwNewSetlist("Song22") = Me.Song22
            End If
            If Not Me.Song23 = 0 Then
                drwNewSetlist("Song23") = Me.Song23
            End If
            If Not Me.Song24 = 0 Then
                drwNewSetlist("Song24") = Me.Song24
            End If
            If Not Me.Song25 = 0 Then
                drwNewSetlist("Song25") = Me.Song25
            End If
            DsMetallica1.Setlist.AddSetlistRow(drwNewSetlist)
            SetlistTableAdapter.Update(DsMetallica1.Setlist)
        Catch ex As Exception
            RaiseEvent DBError(ex.Message)
        End Try
        Me.SetlistNumber = SetlistTableAdapter.GetIdentity()
    End Function

    Public Function Update() As Boolean
        If Me.Exists(Me.SetlistNumber) Then
            Try
                Dim drwTemp As DataRow
                drwTemp = DsMetallica1.Setlist.Rows.Find(Me.SetlistNumber)
                drwTemp("Song01") = Me.Song01
                drwTemp("Song02") = Me.Song02
                drwTemp("Song03") = Me.Song03
                drwTemp("Song04") = Me.Song04
                drwTemp("Song05") = Me.Song05
                drwTemp("Song06") = Me.Song06
                drwTemp("Song07") = Me.Song07
                drwTemp("Song08") = Me.Song08
                drwTemp("Song09") = Me.Song09
                drwTemp("Song10") = Me.Song10
                drwTemp("Song11") = Me.Song11
                drwTemp("Song12") = Me.Song12
                drwTemp("Song13") = Me.Song13
                drwTemp("Song14") = Me.Song14
                drwTemp("Song15") = Me.Song15
                drwTemp("Song16") = Me.Song16
                drwTemp("Song17") = Me.Song17
                drwTemp("Song18") = Me.Song18
                drwTemp("Song19") = Me.Song19
                drwTemp("Song20") = Me.Song20
                drwTemp("Song21") = Me.Song21
                drwTemp("Song22") = Me.Song22
                drwTemp("Song23") = Me.Song23
                drwTemp("Song24") = Me.Song24
                drwTemp("Song25") = Me.Song25
                SetlistTableAdapter.Update(DsMetallica1.Setlist)
                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 setlistnumber As Integer) As Boolean
        If Me.Exists(setlistnumber) Then
            Try
                Dim drwTemp As DataRow
                drwTemp = DsMetallica1.Setlist.Rows.Find(Me.SetlistNumber)
                drwTemp.Delete()
                SetlistTableAdapter.Update(DsMetallica1.Setlist)
                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 setlistnumber As Integer)
        Dim tblTemp As DataTable
        tblTemp = SetlistTableAdapter.Find(setlistnumber)
        Dim drwTemp As DataRow
        drwTemp = tblTemp.Rows.Find(setlistnumber)
        Me.SetlistNumber = drwTemp("SetlistNumber")
        Me.ShowNumber = drwTemp("ShowNumber")
        Me.Song01 = drwTemp("Song01")
        If Not drwTemp("Song02") Is System.DBNull.Value Then
            Me.Song02 = drwTemp("Song02")
        End If
        If Not drwTemp("Song03") Is System.DBNull.Value Then
            Me.Song03 = drwTemp("Song03")
        End If
        If Not drwTemp("Song04") Is System.DBNull.Value Then
            Me.Song04 = drwTemp("Song04")
        End If
        If Not drwTemp("Song05") Is System.DBNull.Value Then
            Me.Song05 = drwTemp("Song05")
        End If
        If Not drwTemp("Song06") Is System.DBNull.Value Then
            Me.Song06 = drwTemp("Song06")
        End If
        If Not drwTemp("Song07") Is System.DBNull.Value Then
            Me.Song07 = drwTemp("Song07")
        End If
        If Not drwTemp("Song08") Is System.DBNull.Value Then
            Me.Song08 = drwTemp("Song08")
        End If
        If Not drwTemp("Song09") Is System.DBNull.Value Then
            Me.Song09 = drwTemp("Song09")
        End If
        If Not drwTemp("Song10") Is System.DBNull.Value Then
            Me.Song10 = drwTemp("Song10")
        End If
        If Not drwTemp("Song11") Is System.DBNull.Value Then
            Me.Song11 = drwTemp("Song11")
        End If
        If Not drwTemp("Song12") Is System.DBNull.Value Then
            Me.Song12 = drwTemp("Song12")
        End If
        If Not drwTemp("Song13") Is System.DBNull.Value Then
            Me.Song13 = drwTemp("Song13")
        End If
        If Not drwTemp("Song14") Is System.DBNull.Value Then
            Me.Song14 = drwTemp("Song14")
        End If
        If Not drwTemp("Song15") Is System.DBNull.Value Then
            Me.Song15 = drwTemp("Song15")
        End If
        If Not drwTemp("Song16") Is System.DBNull.Value Then
            Me.Song16 = drwTemp("Song16")
        End If
        If Not drwTemp("Song17") Is System.DBNull.Value Then
            Me.Song17 = drwTemp("Song17")
        End If
        If Not drwTemp("Song18") Is System.DBNull.Value Then
            Me.Song18 = drwTemp("Song18")
        End If
        If Not drwTemp("Song19") Is System.DBNull.Value Then
            Me.Song19 = drwTemp("Song19")
        End If
        If Not drwTemp("Song20") Is System.DBNull.Value Then
            Me.Song20 = drwTemp("Song20")
        End If
        If Not drwTemp("Song21") Is System.DBNull.Value Then
            Me.Song21 = drwTemp("Song21")
        End If
        If Not drwTemp("Song22") Is System.DBNull.Value Then
            Me.Song22 = drwTemp("Song22")
        End If
        If Not drwTemp("Song23") Is System.DBNull.Value Then
            Me.Song23 = drwTemp("Song23")
        End If
        If Not drwTemp("Song24") Is System.DBNull.Value Then
            Me.Song24 = drwTemp("Song24")
        End If
        If Not drwTemp("Song25") Is System.DBNull.Value Then
            Me.Song25 = drwTemp("Song25")
        End If
    End Function

    Public Function NumTimesPlayed(ByVal songnumber As Integer) As Integer
        Return SetlistTableAdapter.NumTimesPlayed(songnumber)
    End Function

    Public Function NumberOfSetlists() As Integer
        Return SetlistTableAdapter.NumRows()
    End Function

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