Update 20241215
This commit is contained in:
64
VBFileManagement/Class1.vb
Normal file
64
VBFileManagement/Class1.vb
Normal file
@@ -0,0 +1,64 @@
|
||||
Imports System.Data.SqlClient
|
||||
Imports System.Data.SqlTypes
|
||||
Imports System.IO
|
||||
Public Class VBFileManagement
|
||||
Public Function Update_Vorlage(filename As String, vorlageid As String, connectionstring As String, manr As Integer)
|
||||
Dim IntFilename As String
|
||||
Dim Connection As New SqlConnection()
|
||||
Dim DA As New SqlDataAdapter("select * from office_vorlage_datei where office_vorlage_dateinr = " + Str(vorlageid), Connection)
|
||||
Dim cb As SqlCommandBuilder = New SqlCommandBuilder(DA)
|
||||
Dim ds As New DataSet()
|
||||
Dim fs As New FileStream(filename, FileMode.OpenOrCreate, FileAccess.Read)
|
||||
Dim mydata(fs.Length) As Byte
|
||||
Dim fi As New IO.FileInfo(filename)
|
||||
IntFilename = (fi.Name)
|
||||
Try
|
||||
fs.Read(mydata, 0, fs.Length)
|
||||
fs.Close()
|
||||
|
||||
Connection.ConnectionString = connectionstring
|
||||
Connection.Open()
|
||||
DA.Fill(ds, "docs")
|
||||
Dim myRow As DataRow
|
||||
If ds.Tables(0).Rows.Count = 0 Then
|
||||
' Neues Dokument speichern
|
||||
myRow = ds.Tables(0).NewRow
|
||||
myRow.Item(0) = vorlageid
|
||||
myRow.Item(1) = 0
|
||||
myRow.Item(2) = mydata
|
||||
myRow.Item(3) = 1
|
||||
myRow.Item(4) = Now
|
||||
myRow.Item(5) = manr
|
||||
myRow.Item(6) = 0
|
||||
myRow.Item(7) = System.DBNull.Value
|
||||
myRow.Item(8) = 0
|
||||
myRow.Item(10) = IntFilename
|
||||
ds.Tables(0).Rows.Add(myRow)
|
||||
DA.Update(ds, "docs")
|
||||
Else
|
||||
'Bestehendes Dokument sichenr
|
||||
myRow = ds.Tables(0).Rows(0)
|
||||
myRow.Item(2) = mydata
|
||||
myRow.Item(3) = 1
|
||||
myRow.Item(4) = Now
|
||||
myRow.Item(5) = manr
|
||||
myRow.Item(6) = 0
|
||||
myRow.Item(7) = System.DBNull.Value
|
||||
myRow.Item(8) = 0
|
||||
myRow.Item(10) = IntFilename
|
||||
DA.Update(ds, "docs")
|
||||
End If
|
||||
Catch ex As Exception
|
||||
|
||||
MsgBox(ex.Message)
|
||||
End Try
|
||||
fs = Nothing
|
||||
cb = Nothing
|
||||
ds = Nothing
|
||||
DA = Nothing
|
||||
|
||||
Connection.Close()
|
||||
Connection = Nothing
|
||||
End Function
|
||||
|
||||
End Class
|
||||
Reference in New Issue
Block a user