99 lines
3.3 KiB
Plaintext
99 lines
3.3 KiB
Plaintext
Imports System.Data.SQLite
|
|
Imports System
|
|
Imports System.IO
|
|
Imports System.Data
|
|
Imports System.Diagnostics
|
|
|
|
Public Class DocMgMt
|
|
Dim Opt As New clsAllgemein
|
|
|
|
|
|
Public Function Save_RptDatei(ByVal Auswertungnr As Integer, ByVal AuswertungName As String) As String
|
|
Dim filename As String = AuswertungName
|
|
Dim Connection As New SQLiteConnection()
|
|
Dim DA As New SQLiteDataAdapter("select * from Report where Reportnr = " & Str(Auswertungnr), Connection)
|
|
Dim cb As SQLiteCommandBuilder = New SQLiteCommandBuilder(DA)
|
|
Dim ds As New DataSet()
|
|
Dim fs As New FileStream(filename, FileMode.OpenOrCreate, FileAccess.Read)
|
|
Dim mydata(fs.Length) As Byte
|
|
fs.Read(mydata, 0, fs.Length)
|
|
fs.Close()
|
|
Try
|
|
Connection.ConnectionString = My.Settings.LPConnectionString
|
|
Connection.Open()
|
|
DA.Fill(ds, "RptFile")
|
|
Dim myRow As DataRow
|
|
If ds.Tables(0).Rows.Count = 0 Then
|
|
MsgBox("Datei kann nicht gespeichert werden.", MsgBoxStyle.Critical)
|
|
Exit Function
|
|
Else
|
|
myRow = ds.Tables(0).Rows(0)
|
|
myRow.Item(2) = mydata
|
|
'myRow.Item(3) = mydata
|
|
'myRow.Item(5) = Now
|
|
'myRow.Item(6) = 1
|
|
DA.Update(ds, "RptFile")
|
|
End If
|
|
Catch ex As Exception
|
|
MsgBox(ex.Message)
|
|
Return False
|
|
End Try
|
|
fs = Nothing
|
|
cb = Nothing
|
|
ds = Nothing
|
|
DA = Nothing
|
|
Connection.Close()
|
|
Connection = Nothing
|
|
Return RptName(AuswertungName)
|
|
End Function
|
|
|
|
Public Function RptName(ByVal path As String) As String
|
|
Dim i As Integer
|
|
Dim file As String = path
|
|
i = InStrRev(file.Trim, "\")
|
|
If i = 0 Then
|
|
Return file.Trim
|
|
Else
|
|
Return Right(file.Trim, Len(file.Trim) - i)
|
|
End If
|
|
End Function
|
|
|
|
Public Function Get_RptDatei(ByVal Auswertungnr As String, Optional ByVal fname As String = "") As String
|
|
Dim pfad As String = Opt.Get_Option(1)
|
|
Dim connection As New SQLiteConnection()
|
|
Dim DA As New SQLiteDataAdapter("select * from Report where Reportnr = " & Str(Auswertungnr), connection)
|
|
Dim CB As SQLiteCommandBuilder = New SQLiteCommandBuilder(DA)
|
|
Dim ds As New DataSet()
|
|
Dim Filename As String = ""
|
|
Try
|
|
connection.ConnectionString = My.Settings.LPConnectionString
|
|
connection.Open()
|
|
DA.Fill(ds, "RptFile")
|
|
Dim myRow As DataRow
|
|
myRow = ds.Tables(0).Rows(0)
|
|
Dim MyData() As Byte
|
|
Filename = pfad + "\" + myRow.Item(1).ToString + ".frx"
|
|
If fname <> "" Then
|
|
Filename = fname
|
|
End If
|
|
MyData = myRow.Item(2)
|
|
Dim K As Long
|
|
K = UBound(MyData)
|
|
Dim fs As New FileStream(Filename, FileMode.OpenOrCreate, FileAccess.Write)
|
|
fs.Write(MyData, 0, K)
|
|
fs.Close()
|
|
fs = Nothing
|
|
Catch ex As Exception
|
|
Return ""
|
|
End Try
|
|
CB = Nothing
|
|
ds = Nothing
|
|
DA = Nothing
|
|
connection.Close()
|
|
connection = Nothing
|
|
Return filename
|
|
End Function
|
|
|
|
|
|
End Class
|