Imports System.Data.SqlClient Imports System.Data.SqlTypes Namespace DB Public Class clsMyFunktionsstelle Inherits DB.clsFunktionstelle #Region "Deklarationen" Public daten As New DataTable Public Neuer_Datensatz As Boolean = False Public Mitarbeiterdaten As New DataTable Dim mMutierer As String Property MutiererText() As String Get Return mMutierer End Get Set(ByVal value As String) mMutierer = value End Set End Property #End Region Sub New() End Sub Public Overloads Sub dispose() MyBase.Dispose() Try Catch End Try End Sub ''' ''' Mutierer auslesen ''' ''' ''' Public Function Get_Mutierer(ByVal nr As Integer) As String Dim ma As New DB.clsMitarbeiter Dim dt As New DataTable Dim Retvalue As String ma.cpMainConnectionProvider = Globals.conn ma.iMitarbeiternr = New SqlInt32(CType(nr, Int32)) dt = ma.SelectOne() If dt.Rows.Count = 0 Then Retvalue = ("{" + nr.ToString + "}") Else Retvalue = ma.sName.ToString + " " + ma.sVorname.ToString + ", " + ma.sTgnummer.ToString End If ma.Dispose() dt.Dispose() Return Retvalue End Function Public Function Get_Parent() As String Dim f As New clsFunktionstelle Try f.cpMainConnectionProvider = Globals.conn f.iFunktionstelleNr = New SqlInt32(CType(Me.iParentID.Value, String)) f.SelectOne() Return f.sBezeichnung.Value Catch Return "" Finally f.Dispose() End Try End Function Public Function Get_Mitarbeiterdaten() Dim scmCmdToExecute As SqlCommand = New SqlCommand() scmCmdToExecute.CommandText = "dbo.sp_get_FunktionstelleMitarbeiter" scmCmdToExecute.CommandType = CommandType.StoredProcedure Dim dtToReturn As DataTable = New DataTable Dim sdaAdapter As SqlDataAdapter = New SqlDataAdapter(scmCmdToExecute) ' // Use base class' connection object scmCmdToExecute.Connection = m_scoMainConnection Try scmCmdToExecute.Parameters.Add(New SqlParameter("@Funktionstellenr", SqlDbType.Int, 4, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, Me.iFunktionstelleNr.Value)) If m_bMainConnectionIsCreatedLocal Then m_scoMainConnection.Open() Else If m_cpMainConnectionProvider.bIsTransactionPending Then scmCmdToExecute.Transaction = m_cpMainConnectionProvider.stCurrentTransaction End If End If sdaAdapter.Fill(dtToReturn) Return dtToReturn Catch ex As Exception Throw New Exception("_FunktionenDetail::sp_get_FunktionstelleMitarbeiter::Error occured.", ex) Finally If m_bMainConnectionIsCreatedLocal Then m_scoMainConnection.Close() End If scmCmdToExecute.Dispose() sdaAdapter.Dispose() End Try End Function Public Function Get_Beziehungen() Dim scmCmdToExecute As SqlCommand = New SqlCommand() scmCmdToExecute.CommandText = "dbo.sp_get_funktionstelle_beziehungen" scmCmdToExecute.CommandType = CommandType.StoredProcedure Dim dtToReturn As DataTable = New DataTable Dim sdaAdapter As SqlDataAdapter = New SqlDataAdapter(scmCmdToExecute) ' // Use base class' connection object scmCmdToExecute.Connection = m_scoMainConnection Try scmCmdToExecute.Parameters.Add(New SqlParameter("@Funktionstellenr", SqlDbType.Int, 4, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, Me.iFunktionstelleNr.Value)) If m_bMainConnectionIsCreatedLocal Then m_scoMainConnection.Open() Else If m_cpMainConnectionProvider.bIsTransactionPending Then scmCmdToExecute.Transaction = m_cpMainConnectionProvider.stCurrentTransaction End If End If sdaAdapter.Fill(dtToReturn) Return dtToReturn Catch ex As Exception Throw New Exception("_FunktionenDetail::sp_get_funktionstelle_beziehungen::Error occured.", ex) Finally If m_bMainConnectionIsCreatedLocal Then m_scoMainConnection.Close() End If scmCmdToExecute.Dispose() sdaAdapter.Dispose() End Try End Function Public Function Get_Data(ByVal Nr As Integer) Me.cpMainConnectionProvider = Globals.conn Me.iFunktionstelleNr = New SqlInt32(CType(Nr, Int32)) Globals.conn.OpenConnection() Me.daten = Me.SelectOne() Globals.conn.CloseConnection(True) Try Catch ex As Exception End Try Me.MutiererText = Get_Mutierer(Me.iMutierer.Value) End Function Public Function Save_Data() As Integer Me.cpMainConnectionProvider = Globals.conn Me.iMutierer = New SqlInt32(CType(Globals.Mitarbeiternr, Int32)) Me.daMutiert_am = New SqlDateTime(CType(Now, DateTime)) Globals.conn.OpenConnection() Me.Update() Globals.conn.CloseConnection(True) Me.Neuer_Datensatz = False End Function Public Function Create_Copy(Optional ByVal Basenr As Integer = 0) As Integer If Basenr <> 0 Then Get_Data(Basenr) End If Dim db As New DB.clsMyKey_Tabelle db.cpMainConnectionProvider = Globals.conn Dim newkey = db.get_dbkey("Funktionstelle") db.Dispose() Me.cpMainConnectionProvider = Globals.conn Me.iFunktionstelleNr = New SqlInt32(CType(newkey, Int32)) Me.daErstellt_am = New SqlDateTime(CType(Now, DateTime)) Me.daMutiert_am = New SqlDateTime(CType(Now, DateTime)) Me.iMutierer = New SqlInt32(CType(Globals.Mitarbeiternr, Int32)) Globals.conn.OpenConnection() Me.Insert() Globals.conn.CloseConnection(True) Me.Neuer_Datensatz = True Return newkey End Function ''' ''' Löschen eines Datensatzes erstellen. ''' ''' Ursprungs-Person: Ist dieser Wert nicht 0, werden die Daten mit BaseNr zuerst gelesen ''' ''' Public Function Delete_Thema(Optional ByVal Basenr As Integer = 0) As Integer If Basenr <> 0 Then Get_Data(Basenr) End If Me.cpMainConnectionProvider = Globals.conn Me.bAktiv = New SqlBoolean(CType(False, Boolean)) Me.daMutiert_am = New SqlDateTime(CType(Now, DateTime)) Me.iMutierer = New SqlInt32(CType(Globals.Mitarbeiternr, Int32)) Globals.conn.OpenConnection() Me.Update() Globals.conn.CloseConnection(True) Me.Neuer_Datensatz = False End Function Public Overloads Function Delete(Optional ByVal Basenr As Integer = 0) As Integer If Basenr <> 0 Then Get_Data(Basenr) End If Me.cpMainConnectionProvider = Globals.conn Globals.conn.OpenConnection() MyBase.Delete() Globals.conn.CloseConnection(True) Me.Neuer_Datensatz = False End Function ''' ''' Neue Person einfügen ''' ''' ''' Public Function Add_New() As Integer Dim db As New DB.clsMyKey_Tabelle db.cpMainConnectionProvider = Globals.conn Dim newkey = db.get_dbkey("Funktionstelle") db.Dispose() Me.iFunktionstelleNr = New SqlInt32(CType(newkey, Int32)) Me.sBeschreibung = New SqlString(CType("", String)) Me.sBezeichnung = New SqlString(CType("", String)) Me.sFunktionsnummer = New SqlInt32(CType(1, Int32)) Me.sFunktionsstelle = New SqlString(CType(0, String)) Me.bAktiv = New SqlBoolean(CType(True, Boolean)) Me.daErstellt_am = New SqlDateTime(CType(Now, DateTime)) Me.daMutiert_am = New SqlDateTime(CType(Now, DateTime)) Me.iMutierer = New SqlInt32(CType(Globals.Mitarbeiternr, Int32)) Me.iCID = New SqlInt32(CType(0, Integer)) Me.cpMainConnectionProvider = Globals.conn Globals.conn.OpenConnection() Me.Insert() Globals.conn.CloseConnection(True) Me.Neuer_Datensatz = True Return newkey End Function End Class End Namespace