Imports System.Data
Imports LYB.VB
Imports LYB.VB.CLASSES

Partial Class group1_recordings
    Inherits System.Web.UI.Page
    Private member As Member
    Private data As New DataUtils

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim lnkRepertoar As LinkButton = Master.FindControl("lnkRepertoar")
        lnkRepertoar.Style.Add("color", "yellow")
        Dim lnkParty As LinkButton = Master.FindControl("lnkParty")
        lnkParty.Style.Add("color", "yellow")
        Dim lnkMR As LinkButton = Master.FindControl("lnkMR")
        lnkMR.Style.Add("color", "yellow")
        Dim lnkMusicFiles As LinkButton = Master.FindControl("lnkMusicFiles")
        lnkMusicFiles.Style.Add("color", "white")
        Dim btnChangePassword As LinkButton = Master.FindControl("btnChangePassword")
        btnChangePassword.Style.Add("color", "yellow")
        Dim btnLogout As LinkButton = Master.FindControl("btnLogout")
        btnLogout.Style.Add("color", "yellow")
        MultiView1.ActiveViewIndex = 0
        DisplayList("RE", "recordingsTable")

    End Sub
    Public Sub DisplayList(ByVal listType As String, ByVal table As String)
        member = CType(Session("member"), Member)
        Dim display As New Display
        Dim data As New DataUtils
        Dim listTable As Table = Me.MultiView1.FindControl(table)
        listTable.CellSpacing = 0
        listTable.CellPadding = 5
        Dim tbrowHeading As New TableRow
        tbrowHeading.Cells.Add(display.MakeTableHeaderCell("Musikstycke", member.FontFamily, member.FontSize, 2))
        tbrowHeading.Cells.Add(display.MakeTableHeaderCell("Kompositör / Arr.", member.FontFamily, member.FontSize))
        'tbrowHeading.Cells.Add(display.MakeTableHeaderCell("Piano"))
        listTable.Rows.Add(tbrowHeading)
        Dim dw As DataView = data.GetDocuments(member.CurrentLoginGroup, listType)
        If Not IsNothing(dw) Then
            Dim savedCompositionName As String = ""
            For Each row As DataRowView In dw
                Dim tbrow As New TableRow
                If Not row.Item("HeadingID") Is System.DBNull.Value Then
                    Dim tbrowEmpty As New TableRow
                    tbrowEmpty.Cells.Add(display.MakeTableCell("&nbsp;", member.FontFamily, member.FontSize, 3))
                    listTable.Rows.Add(tbrowEmpty)
                    tbrow.Cells.Add(display.MakeTableCell(row.Item("HeadingText").ToString, row.Item("HeadingFontSize").ToString, "bold", 3))
                Else
                    If Not row.Item("CompositionID") Is System.DBNull.Value Then
                        If row.Item("CompositionName").ToString = savedCompositionName Then
                            ' show only document icon
                            row.Item("CompositionID") = System.DBNull.Value
                            row.Item("ComposerID") = System.DBNull.Value
                        End If
                        savedCompositionName = row.Item("CompositionName").ToString
                    End If
                    If Not row.Item("CompositionID") Is System.DBNull.Value Then
                        tbrow.Cells.Add(display.MakeTableCell(row.Item("CompositionName").ToString, member.FontFamily, CStr(Session("DefaultFontSize"))))
                    Else
                        tbrow.Cells.Add(display.MakeTableCell("&nbsp;", member.FontFamily, member.FontSize))
                    End If
                    Dim documentLink As String
                    Dim documentLinkAddition As String = ""
                    If Not row.Item("Path") Is System.DBNull.Value Then
                        Select Case LCase(row.Item("type").ToString)
                            Case "pdf"
                                documentLinkAddition = "pdf/"
                            Case "mp3"
                                documentLinkAddition = "mp3/"
                            Case "doc"
                                documentLinkAddition = "word/"
                            Case "wma"
                                documentLinkAddition = "wma/"
                            Case "wmv"
                                documentLinkAddition = "videos/"
                            Case "nwc"
                                documentLinkAddition = "noteworthy/"
                        End Select
                        documentLink = "<a href='http://a1.leif-b.se/webfiles/common/" & documentLinkAddition
                        'documentLink = "<a href='http://www.filipstadsbacken.net/common/documents/"
                        documentLink = documentLink & row.Item("path").ToString & "." & row.Item("type").ToString
                        documentLink = documentLink & "' target='_blank'><img src='../images/" & LCase(row.Item("type").ToString) & "_ico.gif' border='no' /></a>"
                    Else
                        documentLink = "&nbsp;"
                    End If
                    tbrow.Cells.Add(display.MakeTableCell(documentLink, member.FontFamily, member.FontSize))
                    Dim celltext As String
                    If Not row.Item("ComposerID") Is System.DBNull.Value Then
                        If Not row.Item("CommentBeforeComposer") Is System.DBNull.Value Then
                            celltext = "&nbsp;&nbsp;&nbsp;" & row.Item("CommentBeforeComposer").ToString & "&nbsp;" & row.Item("ComposerName").ToString
                        Else
                            celltext = "&nbsp;&nbsp;&nbsp;" & row.Item("ComposerName").ToString
                        End If
                        If Not row.Item("CommentAfterComposer") Is System.DBNull.Value Then
                            celltext = celltext & ",&nbsp;" & row.Item("CommentAfterComposer").ToString
                        End If
                    ElseIf Not row.Item("CommentBeforeComposer") Is System.DBNull.Value Then
                        celltext = "&nbsp;&nbsp;&nbsp;" & row.Item("CommentBeforeComposer").ToString
                    Else
                        celltext = "&nbsp;"
                    End If
                    tbrow.Cells.Add(display.MakeTableCell(celltext, member.FontFamily, member.FontSize))
                    If Session("emailAddress") = "leif.bjorkman@comhem.se" Then
                        celltext = row.Item("sortorder").ToString
                        tbrow.Cells.Add(display.MakeTableCell(celltext, member.FontFamily, member.FontSize))
                    End If
                End If
                listTable.Rows.Add(tbrow)
            Next
        End If

    End Sub
End Class
