Imports System.Data
Imports System.Data.SqlClient
'''Datenzugriff auf Tabelle team
Public Class Team
#Region "Public methods"
'''Gibt eine Liste mit allen Teams zurück
'''Das DataSet welches gefüllt werden soll
Overloads Shared Sub GetListe(ByRef ds As DataSet)
Dim sqlConn As New SqlConnection()
Dim sqlCmd As New SqlCommand()
Dim da As New SqlDataAdapter()
Try
sqlCmd.CommandText = "sp_ListTeams"
sqlCmd.CommandType = CommandType.StoredProcedure
sqlCmd.Connection = sqlConn
sqlConn.ConnectionString = Common.Datenbank.GetDSN()
sqlConn.Open()
da.SelectCommand = sqlCmd
da.Fill(ds, "TeamListe")
Catch ex As Exception
Throw ex
Finally
If sqlCmd Is Nothing Then
sqlCmd.Dispose()
End If
If sqlConn Is Nothing Then
sqlConn.Dispose()
End If
If da Is Nothing Then
da.Dispose()
End If
End Try
End Sub
'''Gibt eine Liste mit allen Teams denen ein Mitarbeiter zugewiesen ist zurück
'''Das DataSet welches gefüllt werden soll
Overloads Shared Sub GetListeByMitarbeiterNr(ByVal mitarbeiterNr As Integer, ByRef ds As DataSet)
Dim sqlConn As New SqlConnection()
Dim sqlCmd As New SqlCommand()
Dim da As New SqlDataAdapter()
Try
sqlCmd.CommandText = "sp_GetTeamsByMitarbeiterNr"
sqlCmd.CommandType = CommandType.StoredProcedure
sqlCmd.Connection = sqlConn
sqlCmd.Parameters.Add(New SqlParameter("@MitarbeiterNr", mitarbeiterNr))
sqlConn.ConnectionString = Common.Datenbank.GetDSN()
sqlConn.Open()
da.SelectCommand = sqlCmd
da.Fill(ds, "FunktionsgruppenListe")
Catch ex As Exception
Throw ex
Finally
If sqlCmd Is Nothing Then
sqlCmd.Dispose()
End If
If sqlConn Is Nothing Then
sqlConn.Dispose()
End If
If da Is Nothing Then
da.Dispose()
End If
End Try
End Sub
'''Gibt alle Details zur einem TeamMitarbeiter Verhältnis zurück
'''Die datenbank Nummer des TeamMitarbeiters (ID)
'''Das zu füllende DataSet
Overloads Shared Sub GetById(ByVal teamNr As Integer, ByRef ds As DataSet)
Dim sqlConn As New SqlConnection()
Dim sqlCmd As New SqlCommand()
Dim da As New SqlDataAdapter()
Try
sqlCmd.CommandText = "sp_GetTeamById"
sqlCmd.CommandType = CommandType.StoredProcedure
sqlCmd.Connection = sqlConn
sqlCmd.Parameters.Add(New SqlParameter("@TeamNr", teamNr))
sqlConn.ConnectionString = Common.Datenbank.GetDSN()
sqlConn.Open()
da.SelectCommand = sqlCmd
da.Fill(ds, "Team")
Catch ex As Exception
Throw ex
Finally
If sqlCmd Is Nothing Then
sqlCmd.Dispose()
End If
If sqlConn Is Nothing Then
sqlConn.Dispose()
End If
If da Is Nothing Then
da.Dispose()
End If
End Try
End Sub
#End Region
End Class