You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
138 lines
4.9 KiB
138 lines
4.9 KiB
Imports System.Data.SqlClient
|
|
Imports System.Data.SqlDbType
|
|
Imports FastReport
|
|
|
|
Public Class Form1
|
|
Public Connectionstring
|
|
Dim dsreport As New DataSet
|
|
|
|
Dim ds As New DataSet
|
|
|
|
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
|
|
ds.ReadXml(Application.StartupPath + "\Applications.xml")
|
|
For Each r As DataRow In ds.Tables(0).Rows
|
|
Me.ToolStripComboBox2.Items.Add(r("Appname"))
|
|
Connectionstring = r("Connection")
|
|
Next
|
|
|
|
|
|
|
|
End Sub
|
|
|
|
|
|
Private Sub ToolStripComboBox1_Click(sender As System.Object, e As System.EventArgs) Handles ToolStripComboBox1.SelectedIndexChanged
|
|
For Each dr As DataRow In dsreport.Tables(0).Rows
|
|
If dr.Item(0) = ToolStripComboBox1.SelectedItem Then
|
|
Design_Report(dr.Item(1), dr.Item(2), dr.Item(3))
|
|
End If
|
|
Next
|
|
|
|
End Sub
|
|
|
|
Sub Design_Report(ByVal sql As String, ByVal sqltype As String, ByVal filename As String)
|
|
Dim ds As New DataSet
|
|
filename = Configuration.ConfigurationManager.AppSettings("Reportpfad") + "\" + filename
|
|
If sqltype = "SP" Then
|
|
ds = Get_Tabledata(sql, True, False)
|
|
Else
|
|
If sqltype = "SQL" Then
|
|
ds = Get_Tabledata(sql, False, True)
|
|
Else
|
|
ds = Get_Tabledata(sql, False, False)
|
|
End If
|
|
End If
|
|
|
|
Dim report As New Report
|
|
Try
|
|
If filename <> "" Then report.Load(filename)
|
|
report.RegisterData(ds)
|
|
report.GetDataSource("Daten").Enabled = True
|
|
report.SetParameterValue("Parcours", Get_Option(2))
|
|
report.SetParameterValue("Spruch", Get_Option(3))
|
|
report.Design()
|
|
report.Dispose()
|
|
Catch ex As Exception
|
|
MsgBox(ex.Message)
|
|
End Try
|
|
End Sub
|
|
|
|
Public Function Get_Tabledata(ByVal Tablename As String, Optional StoredProc As Boolean = False, Optional is_SQL_String As Boolean = False) As DataSet
|
|
Dim sqlconnect As New SqlConnection
|
|
Dim ds As New DataSet
|
|
ds.Tables.Clear()
|
|
sqlconnect.ConnectionString = Me.Connectionstring
|
|
sqlconnect.Open()
|
|
Dim da As New SqlDataAdapter("", sqlconnect)
|
|
Dim sqlcmd As New SqlCommand
|
|
sqlcmd.Connection = sqlconnect
|
|
If StoredProc = True Then
|
|
sqlcmd.CommandType = CommandType.StoredProcedure
|
|
sqlcmd.CommandText = Tablename
|
|
Else
|
|
sqlcmd.CommandType = CommandType.Text
|
|
sqlcmd.CommandText = "Select * from " + Tablename
|
|
End If
|
|
If is_SQL_String = True Then
|
|
sqlcmd.CommandText = Tablename
|
|
End If
|
|
' sqlcmd.CommandType = CommandType.StoredProcedure
|
|
' sqlcmd.CommandText = "Berufsliste"
|
|
da.SelectCommand = sqlcmd
|
|
da.Fill(ds, "Daten")
|
|
Return ds
|
|
End Function
|
|
|
|
Public Function Get_Option(ByVal onr As Integer) As String
|
|
Try
|
|
Dim sqlconnect As New SqlConnection
|
|
Dim ds As New DataSet
|
|
ds.Tables.Clear()
|
|
sqlconnect.ConnectionString = Me.Connectionstring
|
|
sqlconnect.Open()
|
|
Dim da As New SqlDataAdapter("", sqlconnect)
|
|
Dim sqlcmd As New SqlCommand
|
|
sqlcmd.Connection = sqlconnect
|
|
sqlcmd.CommandType = CommandType.Text
|
|
sqlcmd.CommandText = "Select * from optionen where optionnr=" + onr.ToString
|
|
da.SelectCommand = sqlcmd
|
|
da.Fill(ds, "Daten")
|
|
Return ds.Tables(0).Rows(0).Item("Inhalt")
|
|
Catch ex As Exception
|
|
Return ""
|
|
'MsgBox(ex.Message)
|
|
End Try
|
|
End Function
|
|
|
|
Private Sub ToolStripComboBox1_Click_1(sender As System.Object, e As System.EventArgs) Handles ToolStripComboBox1.Click
|
|
|
|
End Sub
|
|
|
|
Private Sub ToolStripComboBox2_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ToolStripComboBox2.SelectedIndexChanged
|
|
Me.TreeView1.Nodes.Clear()
|
|
|
|
For Each r As DataRow In ds.Tables(0).Rows
|
|
If r("Appname") = Me.ToolStripComboBox2.Text Then
|
|
dsreport.ReadXml(r("Path") + "\Auswertungen.xml")
|
|
For Each dr As DataRow In dsreport.Tables(0).Rows
|
|
Me.TreeView1.Nodes.Add(dr.Item(0))
|
|
Me.ToolStripComboBox1.Items.Add(dr.Item(0))
|
|
Next
|
|
End If
|
|
Next
|
|
End Sub
|
|
|
|
Private Sub TreeView1_AfterSelect(sender As Object, e As TreeViewEventArgs) Handles TreeView1.AfterSelect
|
|
For Each r As DataRow In ds.Tables(0).Rows
|
|
If r(0) = ToolStripComboBox2.Text Then
|
|
Connectionstring = r(2)
|
|
End If
|
|
Next
|
|
For Each dr As DataRow In dsreport.Tables(0).Rows
|
|
If dr.Item(0) = TreeView1.SelectedNode.Text Then
|
|
|
|
Design_Report(dr.Item(1), dr.Item(2), dr.Item(3))
|
|
End If
|
|
Next
|
|
End Sub
|
|
End Class
|