Imports wrd = Microsoft.Office.Interop.Word
Imports mediatheek.Data
Imports Mediatheek.DataAcces



Public Class frmLocatieRapport
    Inherits System.Windows.Forms.Form


    Dim mLocatie As clsLocatie
    Dim miAantalKeerChanged As Integer
    Dim msCboTekst As String

#Region " Windows Form Designer generated code "

    Public Sub New(ByVal sLocatieID As String)
        MyBase.New()
        InitializeComponent()
        mLocatie = clsLocatieDA.GetLocatieByID(sLocatieID).Item(0)
        msCboTekst = mLocatie.ToString
        MyBase.Text = "Rapport voor " & "Rek: " & mLocatie.Rek & " Vak: " & mLocatie.Vak & " Schap: " & mLocatie.Schap
    End Sub


    Public Sub New()
        MyBase.New()
        InitializeComponent()
        msCboTekst = "Kies een locatie."
        chbVoorAlleLocaties.Enabled = False
        btnRapport.Enabled = False
        MyBase.Text = "Rapport voor locaties"
    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 gpbRapportKeuzes As System.Windows.Forms.GroupBox
    Friend WithEvents btnRapport As System.Windows.Forms.Button
    Friend WithEvents chbVoorAlleLocaties As System.Windows.Forms.CheckBox
    Friend WithEvents chbAlbumsPerLocatie As System.Windows.Forms.CheckBox
    Friend WithEvents cboLocaties As System.Windows.Forms.ComboBox
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents sfdLocatieRapport As System.Windows.Forms.SaveFileDialog
    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(frmLocatieRapport))
        Me.sfdLocatieRapport = New System.Windows.Forms.SaveFileDialog
        Me.gpbRapportKeuzes = New System.Windows.Forms.GroupBox
        Me.Label1 = New System.Windows.Forms.Label
        Me.cboLocaties = New System.Windows.Forms.ComboBox
        Me.btnRapport = New System.Windows.Forms.Button
        Me.chbVoorAlleLocaties = New System.Windows.Forms.CheckBox
        Me.chbAlbumsPerLocatie = New System.Windows.Forms.CheckBox
        Me.PictureBox1 = New System.Windows.Forms.PictureBox
        Me.gpbRapportKeuzes.SuspendLayout()
        Me.SuspendLayout()
        '
        'sfdLocatieRapport
        '
        Me.sfdLocatieRapport.Filter = "Word Documenten (*.doc)|*.doc"
        Me.sfdLocatieRapport.Title = "Album Rapport opslaan als..."
        '
        'gpbRapportKeuzes
        '
        Me.gpbRapportKeuzes.Controls.Add(Me.Label1)
        Me.gpbRapportKeuzes.Controls.Add(Me.cboLocaties)
        Me.gpbRapportKeuzes.Controls.Add(Me.btnRapport)
        Me.gpbRapportKeuzes.Controls.Add(Me.chbVoorAlleLocaties)
        Me.gpbRapportKeuzes.Controls.Add(Me.chbAlbumsPerLocatie)
        Me.gpbRapportKeuzes.Location = New System.Drawing.Point(64, 80)
        Me.gpbRapportKeuzes.Name = "gpbRapportKeuzes"
        Me.gpbRapportKeuzes.Size = New System.Drawing.Size(320, 120)
        Me.gpbRapportKeuzes.TabIndex = 0
        Me.gpbRapportKeuzes.TabStop = False
        '
        'Label1
        '
        Me.Label1.Location = New System.Drawing.Point(16, 24)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(48, 23)
        Me.Label1.TabIndex = 3
        Me.Label1.Text = "Locatie:"
        '
        'cboLocaties
        '
        Me.cboLocaties.Location = New System.Drawing.Point(64, 24)
        Me.cboLocaties.Name = "cboLocaties"
        Me.cboLocaties.Size = New System.Drawing.Size(240, 21)
        Me.cboLocaties.TabIndex = 2
        '
        'btnRapport
        '
        Me.btnRapport.Location = New System.Drawing.Point(224, 56)
        Me.btnRapport.Name = "btnRapport"
        Me.btnRapport.Size = New System.Drawing.Size(75, 56)
        Me.btnRapport.TabIndex = 1
        Me.btnRapport.Text = "Rapport"
        '
        'chbVoorAlleLocaties
        '
        Me.chbVoorAlleLocaties.Location = New System.Drawing.Point(16, 88)
        Me.chbVoorAlleLocaties.Name = "chbVoorAlleLocaties"
        Me.chbVoorAlleLocaties.Size = New System.Drawing.Size(192, 24)
        Me.chbVoorAlleLocaties.TabIndex = 0
        Me.chbVoorAlleLocaties.Text = "Deze informatie voor alle locaties"
        '
        'chbAlbumsPerLocatie
        '
        Me.chbAlbumsPerLocatie.Location = New System.Drawing.Point(16, 56)
        Me.chbAlbumsPerLocatie.Name = "chbAlbumsPerLocatie"
        Me.chbAlbumsPerLocatie.Size = New System.Drawing.Size(192, 24)
        Me.chbAlbumsPerLocatie.TabIndex = 0
        Me.chbAlbumsPerLocatie.Text = "Albums weergeven bij de locatie"
        '
        '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(440, 72)
        Me.PictureBox1.TabIndex = 1
        Me.PictureBox1.TabStop = False
        '
        'frmLocatieRapport
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(432, 213)
        Me.Controls.Add(Me.PictureBox1)
        Me.Controls.Add(Me.gpbRapportKeuzes)
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
        Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
        Me.MaximizeBox = False
        Me.Name = "frmLocatieRapport"
        Me.gpbRapportKeuzes.ResumeLayout(False)
        Me.ResumeLayout(False)

    End Sub

#End Region

#Region "Events"

    Private Sub chbVoorAlleLocaties_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chbVoorAlleLocaties.CheckedChanged
        If chbVoorAlleLocaties.Checked Then
            MyBase.Text = "Rapport voor alle locaties"
        ElseIf chbVoorAlleLocaties.Checked = False Then
            MyBase.Text = "Rapport voor " & mLocatie.ToString
        End If
    End Sub

    Private Sub cboLocaties_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboLocaties.SelectedIndexChanged


        If miAantalKeerChanged > 0 Then
            chbVoorAlleLocaties.Enabled = True
            btnRapport.Enabled = True
            'deze code zodat bij opvullen de eerste item niet vanzelf als gekozen locatie word gezet
            mLocatie = cboLocaties.SelectedItem
            MyBase.Text = "Rapport voor " & "Rek: " & mLocatie.Rek & " Vak: " & mLocatie.Vak & " Schap: " & mLocatie.Schap
        End If
        miAantalKeerChanged += 1

    End Sub

    Private Sub frmLocatieRapport_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim arlLocaties As ArrayList
        arlLocaties = clsLocatieDA.GetLocaties
        cboLocaties.DataSource = arlLocaties
        cboLocaties.Text = msCboTekst
    End Sub

    Private Sub btnRapport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRapport.Click

        Rapport()

    End Sub

#End Region

    Private Sub Rapport()
        'algemeen object
        Dim oData As Object

        Dim arlLocaties As ArrayList
        arlLocaties = clsLocatieDA.GetLocaties

        If chbVoorAlleLocaties.Checked = True Then
            oData = arlLocaties
        ElseIf chbVoorAlleLocaties.Checked = False Then
            oData = mLocatie
        End If

        clsFichegenerator.LocatieRapport(oData, chbAlbumsPerLocatie.Checked)

    End Sub


End Class
