Imports Mediatheek.data
Imports Mediatheek.DataAcces

Public Class frmLocatieZoeken
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents lvwLocatiesZoeken As System.Windows.Forms.ListView
    Friend WithEvents clhRek As System.Windows.Forms.ColumnHeader
    Friend WithEvents clhVak As System.Windows.Forms.ColumnHeader
    Friend WithEvents clhSchap As System.Windows.Forms.ColumnHeader
    Friend WithEvents clhSoort As System.Windows.Forms.ColumnHeader
    Friend WithEvents clhMaxAantal As System.Windows.Forms.ColumnHeader
    Friend WithEvents lvwGevondenAlbums As System.Windows.Forms.ListView
    Friend WithEvents cmhAlbum As System.Windows.Forms.ColumnHeader
    Friend WithEvents cmHJaar As System.Windows.Forms.ColumnHeader
    Friend WithEvents PictureBox1 As System.Windows.Forms.PictureBox
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(frmLocatieZoeken))
        Me.lvwLocatiesZoeken = New System.Windows.Forms.ListView
        Me.clhRek = New System.Windows.Forms.ColumnHeader
        Me.clhVak = New System.Windows.Forms.ColumnHeader
        Me.clhSchap = New System.Windows.Forms.ColumnHeader
        Me.clhSoort = New System.Windows.Forms.ColumnHeader
        Me.clhMaxAantal = New System.Windows.Forms.ColumnHeader
        Me.lvwGevondenAlbums = New System.Windows.Forms.ListView
        Me.cmhAlbum = New System.Windows.Forms.ColumnHeader
        Me.cmHJaar = New System.Windows.Forms.ColumnHeader
        Me.PictureBox1 = New System.Windows.Forms.PictureBox
        Me.SuspendLayout()
        '
        'lvwLocatiesZoeken
        '
        Me.lvwLocatiesZoeken.Columns.AddRange(New System.Windows.Forms.ColumnHeader() {Me.clhRek, Me.clhVak, Me.clhSchap, Me.clhSoort, Me.clhMaxAantal})
        Me.lvwLocatiesZoeken.FullRowSelect = True
        Me.lvwLocatiesZoeken.Location = New System.Drawing.Point(16, 112)
        Me.lvwLocatiesZoeken.MultiSelect = False
        Me.lvwLocatiesZoeken.Name = "lvwLocatiesZoeken"
        Me.lvwLocatiesZoeken.Size = New System.Drawing.Size(456, 208)
        Me.lvwLocatiesZoeken.Sorting = System.Windows.Forms.SortOrder.Ascending
        Me.lvwLocatiesZoeken.TabIndex = 21
        Me.lvwLocatiesZoeken.View = System.Windows.Forms.View.Details
        '
        'clhRek
        '
        Me.clhRek.Text = "Rek"
        Me.clhRek.Width = 80
        '
        'clhVak
        '
        Me.clhVak.Text = "Vak"
        Me.clhVak.Width = 80
        '
        'clhSchap
        '
        Me.clhSchap.Text = "Schap"
        Me.clhSchap.Width = 80
        '
        'clhSoort
        '
        Me.clhSoort.Text = "Soort"
        Me.clhSoort.Width = 80
        '
        'clhMaxAantal
        '
        Me.clhMaxAantal.Text = "Maximum aantal"
        Me.clhMaxAantal.Width = 100
        '
        'lvwGevondenAlbums
        '
        Me.lvwGevondenAlbums.BackColor = System.Drawing.Color.White
        Me.lvwGevondenAlbums.Columns.AddRange(New System.Windows.Forms.ColumnHeader() {Me.cmhAlbum, Me.cmHJaar})
        Me.lvwGevondenAlbums.Cursor = System.Windows.Forms.Cursors.Default
        Me.lvwGevondenAlbums.Enabled = False
        Me.lvwGevondenAlbums.FullRowSelect = True
        Me.lvwGevondenAlbums.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable
        Me.lvwGevondenAlbums.Location = New System.Drawing.Point(488, 112)
        Me.lvwGevondenAlbums.MultiSelect = False
        Me.lvwGevondenAlbums.Name = "lvwGevondenAlbums"
        Me.lvwGevondenAlbums.Size = New System.Drawing.Size(256, 200)
        Me.lvwGevondenAlbums.Sorting = System.Windows.Forms.SortOrder.Ascending
        Me.lvwGevondenAlbums.TabIndex = 22
        Me.lvwGevondenAlbums.View = System.Windows.Forms.View.Details
        '
        'cmhAlbum
        '
        Me.cmhAlbum.Text = "AlbumNaam"
        Me.cmhAlbum.Width = 170
        '
        'cmHJaar
        '
        Me.cmHJaar.Text = "Productiejaar"
        Me.cmHJaar.Width = 80
        '
        'PictureBox1
        '
        Me.PictureBox1.Image = CType(resources.GetObject("PictureBox1.Image"), System.Drawing.Image)
        Me.PictureBox1.Location = New System.Drawing.Point(0, 0)
        Me.PictureBox1.Name = "PictureBox1"
        Me.PictureBox1.Size = New System.Drawing.Size(776, 88)
        Me.PictureBox1.TabIndex = 23
        Me.PictureBox1.TabStop = False
        '
        'frmLocatieZoeken
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(776, 334)
        Me.Controls.Add(Me.PictureBox1)
        Me.Controls.Add(Me.lvwGevondenAlbums)
        Me.Controls.Add(Me.lvwLocatiesZoeken)
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
        Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
        Me.MaximizeBox = False
        Me.Name = "frmLocatieZoeken"
        Me.Text = "Zoeken op locatie"
        Me.ResumeLayout(False)

    End Sub

#End Region

#Region "Zoeken op Locatie"

    Private Sub frmLocatieZoeken_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
        listviewopvullen()
    End Sub

    Private Sub listviewopvullen()
        'de locaties worden in een lvw gestoken
        lvwLocatiesZoeken.Items.Clear()

        Dim arlLocaties As ArrayList
        arlLocaties = clsLocatieDA.GetLocaties

        For Each oLocatie As clsLocatie In arlLocaties

            Dim olitm As ListViewItem

            olitm = New ListViewItem

            olitm.Text = oLocatie.Rek
            olitm.SubItems.Add(oLocatie.Vak)
            olitm.SubItems.Add(oLocatie.Schap)
            olitm.SubItems.Add(oLocatie.Soort)
            olitm.SubItems.Add(oLocatie.MaxAantal)
            lvwLocatiesZoeken.Items.Add(olitm)
        Next
    End Sub

    Private Sub lvwLocatiesZoeken_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles lvwLocatiesZoeken.SelectedIndexChanged
        albumszoeken()
    End Sub

    Private Sub albumszoeken()
        'zoeken per locatie op een of meerdere albums
        Dim iId As Integer
        Dim sGevondenId As String
        Dim olitm As ListViewItem
        Dim oLocatie As clsLocatie
        Dim arlLocaties As ArrayList
        For Each oItem As ListViewItem In lvwLocatiesZoeken.SelectedItems
            iId = oItem.Index + 1
            arlLocaties = clsLocatieDA.GetId(iId)

        Next

        lvwGevondenAlbums.Items.Clear()

        Dim arlAlbums As ArrayList
        arlAlbums = clsAlbumDA.GetAlbums

        For Each oAlbum As clsAlbum In arlAlbums

            If oAlbum.LocatieId = iId Then
                Dim olitm2 As ListViewItem
                olitm2 = New ListViewItem
                olitm2.Text = oAlbum.AlbumNaam
                olitm2.SubItems.Add(oAlbum.ProductieJaar)
                lvwGevondenAlbums.Items.Add(olitm2)
            End If

        Next

    End Sub

#End Region


End Class
