|
|
Imports System
|
|
|
Imports System.Data
|
|
|
Imports System.Data.SqlTypes
|
|
|
Imports System.Data.SqlClient
|
|
|
Imports C1.Win.C1TrueDBGrid
|
|
|
Namespace TKB.VV.DMS
|
|
|
|
|
|
Public Class clsDok
|
|
|
Inherits TKB.VV.DB.clsDokument
|
|
|
|
|
|
#Region "Deklarationen"
|
|
|
Private Dokumenttyp As New TKB.VV.DB.clsDokumenttyp
|
|
|
Public Dokumenttypdaten As DataTable
|
|
|
Private DocMgmt As New TKB.VV.Utils.MyDocMgmt
|
|
|
Public Dokumente As New DataTable
|
|
|
Public Neuer_Datensatz As Boolean = False
|
|
|
Private Stammdaten As New TKB.VV.Stammdaten.clsStammdaten
|
|
|
|
|
|
#End Region
|
|
|
|
|
|
|
|
|
''' <summary>
|
|
|
''' Dokument laden
|
|
|
''' </summary>
|
|
|
''' <param name="Nr">PersonNr</param>
|
|
|
''' <returns></returns>
|
|
|
''' <remarks></remarks>
|
|
|
|
|
|
Public Function Get_Dokument(ByVal Nr As Integer)
|
|
|
Me.cpMainConnectionProvider = Globals.conn
|
|
|
Me.iDokumentNr = New SqlInt32(CType(Nr, Int32))
|
|
|
Globals.conn.OpenConnection()
|
|
|
Me.SelectOne()
|
|
|
Globals.conn.CloseConnection(True)
|
|
|
End Function
|
|
|
''' <summary>
|
|
|
''' Person sichern
|
|
|
''' </summary>
|
|
|
''' <returns></returns>
|
|
|
''' <remarks></remarks>
|
|
|
Public Function Save_Data() As Integer
|
|
|
Me.cpMainConnectionProvider = Globals.conn
|
|
|
Me.daMutiert_am = New SqlDateTime(CType(Now, DateTime))
|
|
|
Me.iMutierer = New SqlInt32(CType(Globals.clsmitarbeiter.iMitarbeiternr.Value, Int32))
|
|
|
Globals.conn.OpenConnection()
|
|
|
Me.Update()
|
|
|
Globals.conn.CloseConnection(True)
|
|
|
Me.Neuer_Datensatz = False
|
|
|
Return Me.iDokumentNr.Value
|
|
|
End Function
|
|
|
''' <summary>
|
|
|
''' Kopie eines Datensatzes erstellen.
|
|
|
''' </summary>
|
|
|
''' <param name="Basenr">Ursprungs-Person: Ist dieser Wert nicht 0, werden die Daten mit BaseNr zuerst gelesen</param>
|
|
|
''' <returns></returns>
|
|
|
''' <remarks></remarks>
|
|
|
Public Function Create_Copy(Optional ByVal Basenr As Integer = 0) As Integer
|
|
|
If Basenr <> 0 Then
|
|
|
Get_Dokument(Basenr)
|
|
|
End If
|
|
|
Dim db As New TKB.VV.DB.clsMyKey_Tabelle
|
|
|
db.cpMainConnectionProvider = Globals.conn
|
|
|
Dim newkey = db.get_dbkey("Dokument")
|
|
|
db.Dispose()
|
|
|
|
|
|
Me.cpMainConnectionProvider = Globals.conn
|
|
|
Me.iDokumentNr = 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.clsmitarbeiter.iMitarbeiternr.Value, Int32))
|
|
|
Globals.conn.OpenConnection()
|
|
|
Me.Insert()
|
|
|
Globals.conn.CloseConnection(True)
|
|
|
Me.Neuer_Datensatz = True
|
|
|
Return newkey
|
|
|
End Function
|
|
|
''' <summary>
|
|
|
''' Datensatz inaktivieren
|
|
|
''' </summary>
|
|
|
''' <param name="Basenr">Ursprungs-Person: Ist dieser Wert nicht 0, werden die Daten mit BaseNr zuerst gelesen</param>
|
|
|
''' <returns></returns>
|
|
|
''' <remarks></remarks>
|
|
|
Public Function Delete_Dokument(Optional ByVal Basenr As Integer = 0) As Integer
|
|
|
If Basenr <> 0 Then
|
|
|
Get_Dokument(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.clsmitarbeiter.iMitarbeiternr.Value, Int32))
|
|
|
Globals.conn.OpenConnection()
|
|
|
Me.Update()
|
|
|
Globals.conn.CloseConnection(True)
|
|
|
Me.Neuer_Datensatz = False
|
|
|
End Function
|
|
|
''' <summary>
|
|
|
''' Datensatz physisch l<>schen
|
|
|
''' </summary>
|
|
|
''' <param name="Basenr">Ursprungs-Person: Ist dieser Wert nicht 0, werden die Daten mit BaseNr zuerst gelesen</param>
|
|
|
''' <returns></returns>
|
|
|
''' <remarks></remarks>
|
|
|
Public Overloads Function Delete(Optional ByVal Basenr As Integer = 0) As Integer
|
|
|
If Basenr <> 0 Then
|
|
|
Get_Dokument(Basenr)
|
|
|
End If
|
|
|
Me.cpMainConnectionProvider = Globals.conn
|
|
|
Globals.conn.OpenConnection()
|
|
|
MyBase.Delete()
|
|
|
Globals.conn.CloseConnection(True)
|
|
|
Me.Neuer_Datensatz = False
|
|
|
End Function
|
|
|
''' <summary>
|
|
|
''' Neue Person einf<6E>gen
|
|
|
''' </summary>
|
|
|
''' <returns></returns>
|
|
|
''' <remarks></remarks>
|
|
|
Public Function Add_New(ByVal Elementnr As Integer, ByVal doktype As Integer) As Integer
|
|
|
Dim db As New TKB.VV.DB.clsMyKey_Tabelle
|
|
|
db.cpMainConnectionProvider = Globals.conn
|
|
|
Dim newkey = db.get_dbkey("Dokument")
|
|
|
db.Dispose()
|
|
|
Me.iDokumentNr = New SqlInt32(CType(newkey, Int32))
|
|
|
Me.iKeyValue = New SqlInt32(CType(Elementnr, Int32))
|
|
|
Me.iDokType = New SqlInt32(CType(doktype, Int32))
|
|
|
Me.iDokumenttypNr = New SqlInt32(CType(1, Int32))
|
|
|
Me.sBezeichnung = New SqlString(CType("", String))
|
|
|
Me.sBeschreibung = New SqlString(CType("", String))
|
|
|
Me.sFilename = New SqlString(CType("", String))
|
|
|
Me.sOriginalFilename_incl_Path = New SqlString(CType("", String))
|
|
|
Me.sVersion = New SqlString(CType("", String))
|
|
|
Me.daVersionsdatum = New SqlDateTime(CType(SqlDateTime.Null, DateTime))
|
|
|
|
|
|
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.clsmitarbeiter.iMitarbeiternr.Value, Int32))
|
|
|
|
|
|
Me.iSecurityLevelNr = New SqlInt32(CType(0, Int32))
|
|
|
Me.cpMainConnectionProvider = Globals.conn
|
|
|
Globals.conn.OpenConnection()
|
|
|
Me.Insert()
|
|
|
Globals.conn.CloseConnection(True)
|
|
|
Me.Neuer_Datensatz = True
|
|
|
Return newkey
|
|
|
End Function
|
|
|
|
|
|
''' <summary>
|
|
|
''' Dokumenttypen laden und in der Datatable Dokumenttypdaten bereit stellen
|
|
|
''' </summary>
|
|
|
''' <returns></returns>
|
|
|
''' <remarks></remarks>
|
|
|
Public Function Get_Dokumenttypen() As DataTable
|
|
|
Me.Dokumenttyp.cpMainConnectionProvider = Globals.conn
|
|
|
Me.Dokumenttypdaten = Stammdaten.Get_Stammdaten("Dokumenttyp", "Bezeichnung")
|
|
|
End Function
|
|
|
''' <summary>
|
|
|
''' Datei im Dokument speichern
|
|
|
''' </summary>
|
|
|
''' <param name="DokumentNr"></param>
|
|
|
''' <param name="Filename"></param>
|
|
|
''' <returns></returns>
|
|
|
''' <remarks></remarks>
|
|
|
Public Function Save_File(ByVal DokumentNr As Integer, ByVal Filename As String) As Boolean
|
|
|
If Filename = "" Then Return True
|
|
|
If Me.DocMgmt.Save_Document(DokumentNr, Filename) = False Then
|
|
|
Return False
|
|
|
Else
|
|
|
Return True
|
|
|
End If
|
|
|
End Function
|
|
|
|
|
|
Public Function Show_Doc(ByVal dokumentnr As Integer)
|
|
|
Me.DocMgmt.Show_Document(dokumentnr)
|
|
|
End Function
|
|
|
|
|
|
Public Function Get_Dokumente(ByVal Keyvalue As Integer, ByVal Doktype As Integer) As DataTable
|
|
|
Dim scmCmdToExecute As SqlCommand = New SqlCommand()
|
|
|
Dim dtToReturn As DataTable = New DataTable()
|
|
|
Dim sdaAdapter As SqlDataAdapter = New SqlDataAdapter(scmCmdToExecute)
|
|
|
scmCmdToExecute.CommandText = "dbo.sp_get_dokumente"
|
|
|
scmCmdToExecute.CommandType = CommandType.StoredProcedure
|
|
|
scmCmdToExecute.Connection = conn.scoDBConnection
|
|
|
Try
|
|
|
scmCmdToExecute.Parameters.Add(New SqlParameter("@keyvalue", SqlDbType.VarChar, 255, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, Keyvalue))
|
|
|
scmCmdToExecute.Parameters.Add(New SqlParameter("@doktype", SqlDbType.Int, 4, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, Doktype))
|
|
|
scmCmdToExecute.Parameters.Add(New SqlParameter("@mitarbeiternr", SqlDbType.Int, 4, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, Globals.clsmitarbeiter.iMitarbeiternr.Value))
|
|
|
sdaAdapter.Fill(dtToReturn)
|
|
|
Return dtToReturn
|
|
|
Catch ex As Exception
|
|
|
Throw New Exception("clsDok::" & scmCmdToExecute.CommandText & "::Error occured." & ex.Message, ex)
|
|
|
Finally
|
|
|
scmCmdToExecute.Dispose()
|
|
|
sdaAdapter.Dispose()
|
|
|
End Try
|
|
|
End Function
|
|
|
|
|
|
Public Function Exists_Testdrehbuch(ByVal Applikationnr As Integer) As Integer
|
|
|
Dim tmpdata As New DataTable
|
|
|
tmpdata = Get_Dokumente(Applikationnr, 2)
|
|
|
If tmpdata.Rows.Count = 0 Then
|
|
|
tmpdata.Dispose()
|
|
|
Return -1
|
|
|
Else
|
|
|
Return tmpdata.Rows(0).Item("Dokumentnr")
|
|
|
tmpdata.Dispose()
|
|
|
End If
|
|
|
End Function
|
|
|
|
|
|
|
|
|
#Region "Dokumentablageorte"
|
|
|
Public Dokumentablageort As TKB.VV.Sysadmin.DomainTable
|
|
|
|
|
|
Public Function Get_Ablageorte(ByVal c1data As C1TrueDBGrid, ByVal Dokumentnr As Integer)
|
|
|
Dokumentablageort = New TKB.VV.Sysadmin.DomainTable("Dokumentablageort", Str(Dokumentnr), Globals.clsmitarbeiter.iMitarbeiternr.Value)
|
|
|
c1data.DataSource = Dokumentablageort.Tabledata
|
|
|
c1data.DataMember = Dokumentablageort.Tabledata.Tables(0).TableName
|
|
|
End Function
|
|
|
|
|
|
#End Region
|
|
|
|
|
|
|
|
|
End Class
|
|
|
End Namespace
|
|
|
|
|
|
|