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.
403 lines
15 KiB
403 lines
15 KiB
Imports System.ComponentModel
|
|
Imports System.Reflection
|
|
Imports System
|
|
Imports System.Data
|
|
Imports System.Data.SqlTypes
|
|
Imports System.Data.SqlClient
|
|
|
|
Public Class DataClass
|
|
|
|
Dim m_connectionstring As String
|
|
Property ConnectionString As String
|
|
Get
|
|
ConnectionString = m_connectionstring
|
|
End Get
|
|
Set(value As String)
|
|
m_connectionstring = value
|
|
Update_Connectionstring()
|
|
End Set
|
|
End Property
|
|
|
|
Dim m_Mitarbeiternr As Integer
|
|
Property Mitarbeiternr As Integer
|
|
Get
|
|
Mitarbeiternr = m_Mitarbeiternr
|
|
End Get
|
|
Set(value As Integer)
|
|
m_Mitarbeiternr = value
|
|
Update_Mitarbeiter()
|
|
End Set
|
|
End Property
|
|
|
|
|
|
Public Enum Struktur_Selectiontype
|
|
Berechtigung = 0
|
|
Organisation = 1
|
|
Personal = 2
|
|
Plattform = 3
|
|
Server = 4
|
|
Verwaltungdurch = 5
|
|
Verwaltungmit = 6
|
|
End Enum
|
|
|
|
|
|
Sub New()
|
|
|
|
End Sub
|
|
|
|
Sub Update_Connectionstring()
|
|
Globals.sConnectionString = Me.ConnectionString
|
|
Globals.conn.sConnectionString = Me.ConnectionString
|
|
End Sub
|
|
|
|
Public Sub Update_Mitarbeiter()
|
|
Globals.Mitarbeiternr = Me.Mitarbeiternr
|
|
End Sub
|
|
|
|
Public Shared Function CreateNew(ByVal ClassName As String) As Object
|
|
Dim objType As System.Type
|
|
Dim objConstructor As Reflection.ConstructorInfo
|
|
If ClassName Is Nothing Then Throw New ArgumentNullException(ClassName)
|
|
objType = System.Type.GetType(ClassName)
|
|
If objType Is Nothing Then Throw New Exception("Unknown Type " & ClassName)
|
|
Dim objParams() As System.Type = {}
|
|
objConstructor = objType.GetConstructor(objParams)
|
|
If objConstructor Is Nothing Then Throw New Exception("No default constructor for " & objType.FullName)
|
|
Return objConstructor.Invoke(objParams)
|
|
End Function
|
|
|
|
Public Sub CreateNew(ByVal ClassName As String, ByRef Obj As Object)
|
|
Dim objType As System.Type
|
|
Dim objConstructor As Reflection.ConstructorInfo
|
|
If ClassName Is Nothing Then Throw New ArgumentNullException(ClassName)
|
|
objType = System.Type.GetType(ClassName)
|
|
If objType Is Nothing Then Throw New Exception("Unknown Type " & ClassName)
|
|
Dim objParams() As System.Type = {}
|
|
objConstructor = objType.GetConstructor(objParams)
|
|
If objConstructor Is Nothing Then Throw New Exception("No default constructor for " & objType.FullName)
|
|
Obj = objConstructor.Invoke(objParams)
|
|
End Sub
|
|
|
|
Public Function Get_Selectiontype(ByVal type As String) As _DataClass.DataClass.Struktur_Selectiontype
|
|
Select Case type
|
|
Case "Berechtigung"
|
|
Return Struktur_Selectiontype.Berechtigung
|
|
Case "Organisation"
|
|
Return Struktur_Selectiontype.Organisation
|
|
Case "Funktionstelle"
|
|
Return Struktur_Selectiontype.Organisation
|
|
Case "Personal"
|
|
Return Struktur_Selectiontype.Personal
|
|
Case "Plattform"
|
|
Return Struktur_Selectiontype.Plattform
|
|
Case "Server"
|
|
Return Struktur_Selectiontype.Server
|
|
Case "Verwaltung durch", "VerwaltungDurch"
|
|
Return Struktur_Selectiontype.Verwaltungdurch
|
|
Case "Verwaltung mit", "VerwaltungMit"
|
|
Return Struktur_Selectiontype.Verwaltungmit
|
|
End Select
|
|
End Function
|
|
|
|
Public Function Get_SelectionTypeText(ByVal Type As _DataClass.DataClass.Struktur_Selectiontype) As String
|
|
Select Case Type
|
|
Case _DataClass.DataClass.Struktur_Selectiontype.Berechtigung
|
|
Return "Berechtigung"
|
|
Case _DataClass.DataClass.Struktur_Selectiontype.Organisation
|
|
Return "Funktionstelle"
|
|
Case _DataClass.DataClass.Struktur_Selectiontype.Personal
|
|
Return "Personal"
|
|
Case _DataClass.DataClass.Struktur_Selectiontype.Plattform
|
|
Return "Plattform"
|
|
Case _DataClass.DataClass.Struktur_Selectiontype.Server
|
|
Return "Server"
|
|
Case _DataClass.DataClass.Struktur_Selectiontype.Verwaltungdurch
|
|
Return "VerwaltungDurch"
|
|
Case _DataClass.DataClass.Struktur_Selectiontype.Verwaltungmit
|
|
Return "VerwaltungMit"
|
|
End Select
|
|
End Function
|
|
|
|
Public Function Get_Beziehungen(ByVal Type As String, ByVal Keyvalue As Integer) As DataTable
|
|
Dim objekt As New DB.clsObjekt
|
|
objekt.cpMainConnectionProvider = Globals.conn
|
|
Dim dt As New DataTable
|
|
dt = objekt.SelectAll
|
|
For Each dr As DataRow In dt.Rows
|
|
If dr.Item("Aktiv") = True And ((dr.Item("Bezeichnung") = Type Or dr.Item("Beschreibung") = Type)) Then
|
|
Dim clsbeziehungen As New db.clsBeziehungen
|
|
Return clsbeziehungen.Get_Beziehungen(dr.Item("Stored_Proc_Beziehungen"), Keyvalue)
|
|
End If
|
|
Next
|
|
End Function
|
|
|
|
Private Function Get_Data_BezExcelExport(ByVal Type As String, ByVal Keyvalue As Integer) As DataTable
|
|
Dim objekt As New DB.clsObjekt
|
|
objekt.cpMainConnectionProvider = Globals.conn
|
|
Dim dt As New DataTable
|
|
dt = objekt.SelectAll
|
|
For Each dr As DataRow In dt.Rows
|
|
If dr.Item("Aktiv") = True And (dr.Item("Bezeichnung") = Type Or dr.Item("Beschreibung") = Type) Then
|
|
Dim clsbeziehungen As New DB.clsBeziehungen
|
|
Return clsbeziehungen.Get_Beziehungen(dr.Item("Stored_Proc_Beziehungen"), Keyvalue, 1)
|
|
End If
|
|
Next
|
|
End Function
|
|
|
|
Public Function Get_Data_for_ExcelExport(ByVal Type As String, ByVal Keyvalue As Integer) As DataTable
|
|
Dim dt As New DataTable
|
|
Dim dr As New DataTable
|
|
|
|
dr.Columns.Add("Key", System.Type.GetType("System.Int32"))
|
|
dr.Columns.Add("M_Bezeichnung", System.Type.GetType("System.String"))
|
|
dr.Columns.Add("M_Beschreibung", System.Type.GetType("System.String"))
|
|
|
|
Select Case Get_Selectiontype(Type)
|
|
Case 1 'Organisation
|
|
'dr.Columns.Add("Funktionsstelle", System.Type.GetType("System.String"))
|
|
dr.Columns.Add("Funktionsnummer", System.Type.GetType("System.Int32"))
|
|
Case 0 'BERECHTIGUNG
|
|
Case 3 'PLATTFORM
|
|
Case 2 'PERSONAL
|
|
dr.Columns.Add("UserID", System.Type.GetType("System.String"))
|
|
dr.Columns.Add("Name", System.Type.GetType("System.String"))
|
|
Case 4 'SERVER
|
|
Case 5 'VERWALTUNGDURCH
|
|
Case 6 'VERWALTUNGMIT
|
|
End Select
|
|
|
|
dr.Columns.Add("ID", System.Type.GetType("System.Int32"))
|
|
dr.Columns.Add("Sequenz", System.Type.GetType("System.Int32"))
|
|
dr.Columns.Add("Bezeichnung", System.Type.GetType("System.String"))
|
|
dr.Columns.Add("Beschreibung", System.Type.GetType("System.String"))
|
|
dr.Columns.Add("Typ", System.Type.GetType("System.String"))
|
|
dr.Columns.Add("Zusatz", System.Type.GetType("System.String"))
|
|
|
|
Dim DBObject As New Object
|
|
Me.CreateNew("_DataClass.db." + Type, DBObject)
|
|
DBObject.get_data(Keyvalue)
|
|
|
|
dt = Get_Data_BezExcelExport(Type, Keyvalue)
|
|
|
|
For Each r In dt.Rows
|
|
Dim daten As DataRow = dr.NewRow
|
|
daten("ID") = r("ID")
|
|
daten("Bezeichnung") = r("Bezeichnung")
|
|
daten("Beschreibung") = r("Beschreibung")
|
|
daten("Sequenz") = r("Sequenz")
|
|
daten("Typ") = r("Typ")
|
|
daten("Key") = DBObject.Get_Keyvalue
|
|
daten("M_Bezeichnung") = DBObject.sbezeichnung.ToString
|
|
daten("M_Beschreibung") = DBObject.sbeschreibung.ToString
|
|
Try
|
|
daten("Zusatz") = r("Zusatz")
|
|
|
|
Catch ex As Exception
|
|
|
|
End Try
|
|
|
|
Select Case Get_Selectiontype(Type)
|
|
Case 1 'Organisation
|
|
daten("Funktionsnummer") = DBObject.sFunktionsstelle.ToString
|
|
'daten("Funktionsnummer") = DBObject.sFunktionsnummer.ToString
|
|
Case 0 'BERECHTIGUNG
|
|
Case 3 'PLATTFORM
|
|
Case 2 'PERSONAL
|
|
daten("UserID") = DBObject.stgnummer.ToString
|
|
daten("Name") = DBObject.sname.ToString
|
|
Case 4 'SERVER
|
|
Case 5 'VERWALTUNGDURCH
|
|
Case 6 'VERWALTUNGMIT
|
|
End Select
|
|
|
|
Try
|
|
If r("Aktiv") = True Then dr.Rows.Add(daten)
|
|
Catch ex As Exception
|
|
dr.Rows.Add(daten)
|
|
End Try
|
|
|
|
|
|
Next
|
|
Select Case Get_Selectiontype(Type)
|
|
Case 1 'Organisation
|
|
dr.Columns("M_Bezeichnung").ColumnName = "Funktionsstelle"
|
|
Case Else
|
|
|
|
End Select
|
|
Return dr
|
|
|
|
|
|
|
|
End Function
|
|
|
|
Public Function Get_Stammdaten(ByVal Tabelle As String, ByVal orderby As String) As DataTable
|
|
Dim selectcommand As New SqlCommand
|
|
Dim connection As New SqlConnection()
|
|
Dim da As New SqlDataAdapter("", connection)
|
|
Dim ds As New DataSet
|
|
selectcommand.CommandText = "sp_get_stammdaten"
|
|
selectcommand.Parameters.Add("@Mitarbeiternr", SqlDbType.Int, 4)
|
|
selectcommand.Parameters.Add("@Tabelle", SqlDbType.VarChar, 255)
|
|
selectcommand.Parameters.Add("@Orderby", SqlDbType.VarChar, 255)
|
|
selectcommand.Parameters(0).Value = Globals.Mitarbeiternr
|
|
selectcommand.Parameters(1).Value = Tabelle
|
|
selectcommand.Parameters(2).Value = orderby
|
|
|
|
selectcommand.CommandType = CommandType.StoredProcedure
|
|
selectcommand.Connection = connection
|
|
Try
|
|
connection.ConnectionString = Globals.sConnectionString
|
|
connection.Open()
|
|
da.SelectCommand = selectcommand
|
|
da.Fill(ds)
|
|
Return ds.Tables(0)
|
|
Catch ex As Exception
|
|
MsgBox(ex.Message)
|
|
Finally
|
|
connection.Close()
|
|
da.Dispose()
|
|
ds.Dispose()
|
|
selectcommand.Dispose()
|
|
End Try
|
|
End Function
|
|
|
|
Public Function Get_Aktive_Funktionsstellen() As DataTable
|
|
Dim fs As New db.Funktionstelle
|
|
Return fs.Get_aktive_Funktionsstellen
|
|
End Function
|
|
|
|
Public Function Get_Aktives_Personal() As DataTable
|
|
Dim fs As New db.Personal
|
|
Return fs.Get_aktives_Personal
|
|
End Function
|
|
|
|
Public Function Update_Temporaer_Berechtigung(beschreibung As String, unterlagen As String, bearbeiter As String, kontakt As String, termin As String, keyvalue As Integer, ByVal Datatype As Integer, Optional kontaktid As Integer = 0, Optional kontaktidsd As Integer = 0)
|
|
Dim selectcommand As New SqlCommand
|
|
Dim connection As New SqlConnection()
|
|
Dim da As New SqlDataAdapter("", connection)
|
|
Dim ds As New DataSet
|
|
selectcommand.CommandText = "sp_set_Temporaerberechtigung"
|
|
selectcommand.Parameters.Add("@Beschreibung", SqlDbType.VarChar, 1024)
|
|
selectcommand.Parameters.Add("@Unterlagen", SqlDbType.VarChar, 1024)
|
|
selectcommand.Parameters.Add("@Bearbeiter", SqlDbType.VarChar, 1024)
|
|
selectcommand.Parameters.Add("@Kontkat", SqlDbType.VarChar, 1024)
|
|
selectcommand.Parameters.Add("@Termin", SqlDbType.DateTime)
|
|
selectcommand.Parameters.Add("@KeyValue", SqlDbType.Int, 4)
|
|
selectcommand.Parameters.Add("@Mitarbeiternr", SqlDbType.Int, 4)
|
|
selectcommand.Parameters.Add("@Datatype", SqlDbType.Int, 4)
|
|
selectcommand.Parameters.Add("@Kontaktid", SqlDbType.Int, 4)
|
|
selectcommand.Parameters.Add("@KontaktidSD", SqlDbType.Int, 4)
|
|
|
|
selectcommand.Parameters(0).Value = beschreibung
|
|
selectcommand.Parameters(1).Value = unterlagen
|
|
selectcommand.Parameters(2).Value = bearbeiter
|
|
selectcommand.Parameters(3).Value = kontakt
|
|
selectcommand.Parameters(4).Value = termin
|
|
selectcommand.Parameters(5).Value = keyvalue
|
|
selectcommand.Parameters(6).Value = Globals.Mitarbeiternr
|
|
selectcommand.Parameters(7).Value = Datatype
|
|
selectcommand.Parameters(8).Value = kontaktid
|
|
selectcommand.Parameters(9).Value = kontaktidsd
|
|
|
|
selectcommand.CommandType = CommandType.StoredProcedure
|
|
selectcommand.Connection = connection
|
|
Try
|
|
connection.ConnectionString = Globals.sConnectionString
|
|
connection.Open()
|
|
da.SelectCommand = selectcommand
|
|
da.Fill(ds)
|
|
Catch ex As Exception
|
|
MsgBox(ex.Message)
|
|
Finally
|
|
connection.Close()
|
|
da.Dispose()
|
|
ds.Dispose()
|
|
selectcommand.Dispose()
|
|
End Try
|
|
|
|
End Function
|
|
|
|
Public Function Get_Temporaer_Berechtigung(ByVal Keyvalue As Integer) As DataTable
|
|
Dim selectcommand As New SqlCommand
|
|
Dim connection As New SqlConnection()
|
|
Dim da As New SqlDataAdapter("", connection)
|
|
Dim ds As New DataSet
|
|
selectcommand.CommandText = "sp_get_Temporaerberechtigung"
|
|
selectcommand.Parameters.Add("@KeyValue", SqlDbType.Int, 4)
|
|
selectcommand.Parameters(0).Value = Keyvalue
|
|
|
|
selectcommand.CommandType = CommandType.StoredProcedure
|
|
selectcommand.Connection = connection
|
|
Try
|
|
connection.ConnectionString = Globals.sConnectionString
|
|
connection.Open()
|
|
da.SelectCommand = selectcommand
|
|
da.Fill(ds)
|
|
Return ds.Tables(0)
|
|
Catch ex As Exception
|
|
MsgBox(ex.Message)
|
|
Finally
|
|
connection.Close()
|
|
da.Dispose()
|
|
ds.Dispose()
|
|
selectcommand.Dispose()
|
|
End Try
|
|
|
|
End Function
|
|
|
|
Public Function Get_Temp_Berechtgungen() As DataTable
|
|
Dim selectcommand As New SqlCommand
|
|
Dim connection As New SqlConnection()
|
|
Dim da As New SqlDataAdapter("", connection)
|
|
Dim ds As New DataSet
|
|
selectcommand.CommandText = "sp_get_Tempberechtigung"
|
|
|
|
selectcommand.CommandType = CommandType.StoredProcedure
|
|
selectcommand.Connection = connection
|
|
Try
|
|
connection.ConnectionString = Globals.sConnectionString
|
|
connection.Open()
|
|
da.SelectCommand = selectcommand
|
|
da.Fill(ds)
|
|
Return ds.Tables(0)
|
|
Catch ex As Exception
|
|
MsgBox(ex.Message)
|
|
Finally
|
|
connection.Close()
|
|
da.Dispose()
|
|
ds.Dispose()
|
|
selectcommand.Dispose()
|
|
End Try
|
|
End Function
|
|
|
|
Public Function Delete_temp_Berechtigung(ByVal keyvalue As Integer, mitarbeiternr As Integer)
|
|
Dim selectcommand As New SqlCommand
|
|
Dim connection As New SqlConnection()
|
|
Dim da As New SqlDataAdapter("", connection)
|
|
Dim ds As New DataSet
|
|
selectcommand.CommandText = "sp_delete_Tempberechtigung"
|
|
selectcommand.Parameters.Add("@KeyValue", SqlDbType.Int, 4)
|
|
selectcommand.Parameters.Add("@Mitarbeiternr", SqlDbType.Int, 4)
|
|
selectcommand.Parameters(0).Value = keyvalue
|
|
selectcommand.Parameters(1).Value = mitarbeiternr
|
|
selectcommand.CommandType = CommandType.StoredProcedure
|
|
selectcommand.Connection = connection
|
|
Try
|
|
connection.ConnectionString = Globals.sConnectionString
|
|
connection.Open()
|
|
da.SelectCommand = selectcommand
|
|
da.Fill(ds)
|
|
Catch ex As Exception
|
|
MsgBox(ex.Message)
|
|
Finally
|
|
connection.Close()
|
|
da.Dispose()
|
|
ds.Dispose()
|
|
selectcommand.Dispose()
|
|
End Try
|
|
|
|
End Function
|
|
|
|
|
|
End Class
|