'''Verwaltung und logik von Dokumentarten
Public Class Dokumentart
#Region "Members"
Private _dokumentartNr As Integer
Private _bezeichnung As String
Private _parentId As Integer
Private _sort As Integer
Private _imageIndex As Integer
Private _imageIndexOpen As Integer
Private _beschreibung As String
Private _mandantNr As Integer 'nicht implementiert
Private _sprache As Integer 'nicht implementiert
Private _aktiv As Boolean
Private _erstelltAm As DateTime
Private _mutiertAm As DateTime
Private _mutiererId As Integer
Private _coldApplication As String
Private _coldBezeichnung As String
#End Region
#Region "Constructors"
Public Sub New()
'leere instanz erstellen
End Sub
Public Sub New(ByVal dokumentartNr As Integer)
'instanz von db laden
Dim ds As New DataSet()
DataAccess.Dokumentart.GetDokumentart(ds, dokumentartNr)
LoadData(ds)
End Sub
'''neue dokumentart in db erstellen und laden
Public Sub New(ByVal bezeichnung As String, ByVal parentId As Integer, ByVal sort As Integer, _
ByVal imageIndex As Integer, ByVal imageIndexOpen As Integer, ByVal beschreibung As String, _
ByVal aktiv As Boolean, ByVal coldApplication As String, ByVal coldBezeichnung As String, ByVal mutiererId As Integer)
_bezeichnung = bezeichnung
_parentId = parentId
_sort = sort
_imageIndex = imageIndex
_imageIndexOpen = imageIndexOpen
_beschreibung = beschreibung
_aktiv = aktiv
_coldApplication = coldApplication
_coldBezeichnung = coldBezeichnung
Save(mutiererId)
End Sub
#End Region
#Region "Private Functions"
'''lädt die daten vom ds in die member der klasse
'''
Private Sub LoadData(ByRef ds As DataSet)
Try
If Common.Tools.ValidateDS(ds) Then
_dokumentartNr = NullHandler.CToInt32(ds.Tables(0).Rows(0)("dokumentartNr"))
_bezeichnung = NullHandler.CToString(ds.Tables(0).Rows(0)("bezeichnung"))
_parentId = NullHandler.CToInt32(ds.Tables(0).Rows(0)("parentId"))
_sort = NullHandler.CToInt32(ds.Tables(0).Rows(0)("sort"))
_imageIndex = NullHandler.CToInt32(ds.Tables(0).Rows(0)("imageIndex"))
_imageIndexOpen = NullHandler.CToInt32(ds.Tables(0).Rows(0)("imageIndexOpen"))
_beschreibung = NullHandler.CToString(ds.Tables(0).Rows(0)("beschreibung"))
_mandantNr = NullHandler.CToInt32(ds.Tables(0).Rows(0)("mandantNr"))
_sprache = NullHandler.CToInt32(ds.Tables(0).Rows(0)("sprache"))
_aktiv = Common.Tools.CToBool(ds.Tables(0).Rows(0)("aktiv")) 'no null support, wird auf 0 gesetzt
_erstelltAm = NullHandler.CToDateTime(ds.Tables(0).Rows(0)("erstellt_am"))
_mutiertAm = NullHandler.CToDateTime(ds.Tables(0).Rows(0)("mutiert_am"))
_mutiererId = NullHandler.CToInt32(ds.Tables(0).Rows(0)("mutierer"))
_coldApplication = NullHandler.CToString(ds.Tables(0).Rows(0)("coldApplication"))
_coldBezeichnung = NullHandler.CToString(ds.Tables(0).Rows(0)("coldBezeichnung"))
End If
Catch ex As Exception
TKBLib.Errorhandling.TraceHelper.Msg("EDOKALib.BF.Dokumentart.LoadData", ex.Message + " " + ex.StackTrace, TraceLevel.Error)
Throw ex
End Try
End Sub
#End Region
#Region "Public Functions"
'''speichert eine dokumentart (insert und update)
Public Function Save(ByVal mutierer As Integer)
Try
Dim err As Integer
If _dokumentartNr = 0 Then 'create new
err = DataAccess.Dokumentart.Add(_dokumentartNr, _bezeichnung, _parentId, _sort, _imageIndex, _
_imageIndexOpen, _beschreibung, _mandantNr, _sprache, _aktiv, mutierer, _coldApplication, _
_coldBezeichnung)
Else 'save existing
err = DataAccess.Dokumentart.Update(_dokumentartNr, _bezeichnung, _parentId, _sort, _imageIndex, _
_imageIndexOpen, _beschreibung, _mandantNr, _sprache, _aktiv, mutierer, _coldApplication, _
_coldBezeichnung)
End If
If err <> 0 Then
Throw New DokumentartException(Meldungstext.GetInhaltById(40000))
End If
'refresh data
Dim ds As New DataSet()
DataAccess.Dokumentart.GetDokumentart(ds, _dokumentartNr)
LoadData(ds)
Catch ex As Exception
TKBLib.Errorhandling.TraceHelper.Msg("EDOKALib.BF.Dokumentart.Save", ex.Message + " " + ex.StackTrace, TraceLevel.Error)
Throw ex
End Try
End Function
Public Function Delete(ByVal mutierer As Integer)
Try
_aktiv = False
Save(mutierer)
Catch ex As Exception
TKBLib.Errorhandling.TraceHelper.Msg("EDOKA", ex.Message + " " + ex.StackTrace, TraceLevel.Error)
Throw ex
End Try
End Function
#End Region
#Region "Properties"
Public ReadOnly Property DokumentartNr() As Integer
Get
Return _dokumentartNr
End Get
End Property
Public Property Bezeichnung() As String
Get
Return _bezeichnung
End Get
Set(ByVal Value As String)
_bezeichnung = Value
End Set
End Property
Public Property ParentId() As Integer
Get
Return ParentId
End Get
Set(ByVal Value As Integer)
ParentId = Value
End Set
End Property
Public Property Sort() As Integer
Get
Return _sort
End Get
Set(ByVal Value As Integer)
_sort = Value
End Set
End Property
Public Property ImageIndex() As Integer
Get
Return _imageIndex
End Get
Set(ByVal Value As Integer)
_imageIndex = Value
End Set
End Property
Public Property ImageIndexOpen() As Integer
Get
Return _imageIndexOpen
End Get
Set(ByVal Value As Integer)
_imageIndexOpen = Value
End Set
End Property
Public Property Beschreibung() As String
Get
Return _beschreibung
End Get
Set(ByVal Value As String)
_beschreibung = Value
End Set
End Property
Public Property Aktiv() As Boolean
Get
Return _aktiv
End Get
Set(ByVal Value As Boolean)
_aktiv = Value
End Set
End Property
Public Property ErstelltAm() As DateTime
Get
Return _erstelltAm
End Get
Set(ByVal Value As DateTime)
_erstelltAm = Value
End Set
End Property
Public Property MutiertAm() As DateTime
Get
Return _mutiertAm
End Get
Set(ByVal Value As DateTime)
_mutiertAm = Value
End Set
End Property
Public Property MutiererId() As Integer
Get
Return _mutiererId
End Get
Set(ByVal Value As Integer)
_mutiererId = Value
End Set
End Property
Public Property ColdApplication() As String
Get
Return _coldApplication
End Get
Set(ByVal Value As String)
_coldApplication = Value
End Set
End Property
Public Property ColdBezeichnung() As String
Get
Return _coldBezeichnung
End Get
Set(ByVal Value As String)
_coldBezeichnung = Value
End Set
End Property
#End Region
End Class
'''Diese Klasse behandelt eine DokumentArt spezifische Ausnahme
Public Class DokumentartException
Inherits Exception
Dim _message As String
Public Sub New(ByVal message As String)
_message = message
End Sub
Public Overrides ReadOnly Property Message() As String
Get
Return _message
End Get
End Property
End Class