Imports System.Windows.Forms

Public Class _FRReporting
    Dim m_connectionstring As String

#Region "Properties"
    Public Property ConnectionString() As String
        Get
            ConnectionString = m_connectionstring
        End Get
        Set(ByVal Value As String)
            If m_connectionstring <> Value Then
                m_connectionstring = Value
                Globals.sConnectionString = m_connectionstring
                Globals.conn.sConnectionString = m_connectionstring
            End If
        End Set
    End Property


    Dim m_Mitarbeiternr As Integer
    Public Property Mitarbeiternr As Integer
        Get
            Mitarbeiternr = m_Mitarbeiternr
        End Get
        Set(value As Integer)
            If m_Mitarbeiternr <> value Then
                m_Mitarbeiternr = value
                Globals.Mitarbeiternr = m_Mitarbeiternr
            End If
        End Set
    End Property

    Dim m_TempFilePath As String
    Public Property TempFilePath As String
        Get
            TempFilePath = m_TempFilePath
        End Get
        Set(value As String)
            If m_TempFilePath <> value Then
                m_TempFilePath = value
                Globals.TmpFilepath = m_TempFilePath
            End If
        End Set
    End Property

    Sub New()

    End Sub
#End Region


    Public Function ReportSelect(ByVal Parentform As Form)
        Dim f As New FrmReportSelect
        f.MdiParent = Parentform
        f.Show()
    End Function

    Public Function DefaultReport(ByVal auswertungnr As Integer, param As String, ByVal ParamValue As String, Optional Parent As Object = Nothing)
        Dim f As New FrmReportSelect
        f.MdiParent = Parent
        f.Show()
        f.TreeAuswertungen.SelectedNode = FindNode(f.TreeAuswertungen.Nodes, auswertungnr, "")
        f.cbparam1.Text = param
        f.cbop1.Text = "="
        f.cbvalue1.Text = ParamValue
        f.showreport()
        f.Close()
    End Function

    Public Function FindNode(ByVal _nodeCollection As TreeNodeCollection, ByVal SearchVal As Integer, ByVal SearchString As String) As TreeNode
        Dim tmpNode As TreeNode
        For Each _child As TreeNode In _nodeCollection
            If _child.Tag = SearchVal Then

                Return _child
            End If
            ' If InStr(UCase(_child.Text), UCase(SearchString)) > 0 Then
            ' Return _child
            ' End If
            tmpNode = FindNode(_child.Nodes, SearchVal, SearchString)
            If Not tmpNode Is Nothing Then
                Return tmpNode
            End If
        Next
        Return Nothing
    End Function

    Public Function Print_Report_With_Data(ByVal auswertungnr As Integer, param As String, ByVal ParamValue As String, Optional Parent As Object = Nothing, Optional data As DataSet = Nothing, Optional design As Boolean = True, Optional Export_Direct_as_PDF As Boolean = False)
        Dim f As New FrmReportSelect
        Try
            f.MdiParent = Parent

        Catch ex As Exception

        End Try

        If Export_Direct_as_PDF = True Then
            f.Visible = False
            f.Height = 0
            f.WindowState = FormWindowState.Minimized
        End If
        f.Show()
        f.showreport_withdata(data, auswertungnr, design, Export_Direct_as_PDF)
        f.Close()

    End Function


End Class
