Initial commit
This commit is contained in:
@@ -0,0 +1,757 @@
|
||||
Imports System.Data.SqlTypes
|
||||
Imports System.Data.SqlClient
|
||||
Imports DevComponents
|
||||
|
||||
Public Class clsVorgabe
|
||||
Inherits DB.clsVorgabe
|
||||
|
||||
|
||||
#Region "Deklarationen"
|
||||
Public daten As New DataTable
|
||||
Public Neuer_Datensatz As Boolean = False
|
||||
Public Mitarbeiterdaten As New DataTable
|
||||
|
||||
Dim stammdaten As New DB.clsStammdaten
|
||||
Dim SpaltenTitel As New Utils.Tabellenspalte
|
||||
|
||||
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()
|
||||
MyBase.New()
|
||||
End Sub
|
||||
|
||||
Public Overloads Sub dispose()
|
||||
MyBase.Dispose()
|
||||
Try
|
||||
Me.stammdaten = Nothing
|
||||
Catch
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' Mutierer auslesen
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
''' <remarks></remarks>
|
||||
Public Function Get_Mutierer(ByVal nr As Integer) As String
|
||||
Try
|
||||
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
|
||||
Catch
|
||||
Return ""
|
||||
End Try
|
||||
|
||||
End Function
|
||||
|
||||
|
||||
Public Function Get_Data(ByVal Nr As Integer)
|
||||
Me.cpMainConnectionProvider = Globals.conn
|
||||
Me.iVorgabeID = New SqlInt32(CType(Nr, Int32))
|
||||
Globals.conn.OpenConnection()
|
||||
Me.daten = Me.SelectOne()
|
||||
Globals.conn.CloseConnection(True)
|
||||
Try
|
||||
Me.MutiererText = Get_Mutierer(Me.iMutierer.Value)
|
||||
Catch ex As Exception
|
||||
Me.MutiererText = ""
|
||||
|
||||
End Try
|
||||
|
||||
End Function
|
||||
|
||||
Public Function Save_Data() As Integer
|
||||
Me.cpMainConnectionProvider = Globals.conn
|
||||
Me.iMutierer = New SqlInt32(CType(Globals.clsmitarbeiter.iMitarbeiternr, 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("Vorgabe")
|
||||
db.Dispose()
|
||||
|
||||
Me.cpMainConnectionProvider = Globals.conn
|
||||
Me.iVorgabeID = 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, Int32))
|
||||
Globals.conn.OpenConnection()
|
||||
Me.Insert()
|
||||
Globals.conn.CloseConnection(True)
|
||||
Me.Neuer_Datensatz = True
|
||||
Return newkey
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' Löschen 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 Delete_Data(Optional ByVal Basenr As Integer = 0) As Integer
|
||||
If Basenr <> 0 Then
|
||||
Get_Data(Basenr)
|
||||
End If
|
||||
If bAktiv.Value = False Then Exit Function
|
||||
|
||||
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, 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
|
||||
|
||||
''' <summary>
|
||||
''' Neue Person einfügen
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
''' <remarks></remarks>
|
||||
Public Function Add_New() As Integer
|
||||
Dim db As New DB.clsMyKey_Tabelle
|
||||
db.cpMainConnectionProvider = Globals.conn
|
||||
Dim newkey = db.get_dbkey("Vorgabe")
|
||||
db.Dispose()
|
||||
Me.iVorgabeID = New SqlInt32(CType(newkey, Int32))
|
||||
Me.iParentID = New SqlInt32(CType(0, Int32))
|
||||
Me.sBezeichnung = New SqlString(CType("", String))
|
||||
Me.sBeschreibung = New SqlString(CType("", String))
|
||||
Me.sKapitelNr = New SqlString(CType("", String))
|
||||
Me.sKapitelNr = New SqlString(CType("", String))
|
||||
Me.sDefinition = New SqlString(CType("", String))
|
||||
Me.sErgaenzungen = New SqlString(CType("", 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.clsmitarbeiter.iMitarbeiternr, Int32))
|
||||
Me.cpMainConnectionProvider = Globals.conn
|
||||
Try
|
||||
Globals.conn.OpenConnection()
|
||||
Me.Insert()
|
||||
Globals.conn.CloseConnection(True)
|
||||
Catch ex As Exception
|
||||
MsgBox(ex.Message)
|
||||
End Try
|
||||
Me.Neuer_Datensatz = True
|
||||
Return Me.iVorgabeID.Value
|
||||
End Function
|
||||
|
||||
|
||||
End Class
|
||||
|
||||
Public Class clsVorgabeTree
|
||||
|
||||
#Region "Deklarationen"
|
||||
|
||||
Dim treedata As New DataSet
|
||||
|
||||
Dim TreeaufbauSuche As Boolean = False
|
||||
Dim TreeaufbauNr As Integer = 0
|
||||
Dim FoundNode As Integer = 0
|
||||
Dim Searchstring As String = ""
|
||||
Public Treesearch As New AdvTree.AdvTree
|
||||
Dim SpaltenTitel As New Utils.Tabellenspalte
|
||||
|
||||
Dim m_imagelist As ImageList
|
||||
Property imagelist As ImageList
|
||||
Get
|
||||
Return m_imagelist
|
||||
End Get
|
||||
Set(value As ImageList)
|
||||
m_imagelist = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Dim m_pruefplannr As Integer
|
||||
Property Pruefplannr As Integer
|
||||
Get
|
||||
Return m_pruefplannr
|
||||
End Get
|
||||
Set(value As Integer)
|
||||
m_pruefplannr = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Dim m_Tree_from_Pruefplan As Boolean = False
|
||||
Property Tree_From_Pruefplan As Boolean
|
||||
Get
|
||||
Return m_Tree_from_Pruefplan
|
||||
End Get
|
||||
Set(value As Boolean)
|
||||
m_Tree_from_Pruefplan = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Dim m_tree_from_massnahmeplan As Boolean = False
|
||||
Property Tree_from_Massnahmeplan As Boolean
|
||||
Get
|
||||
Return m_tree_from_massnahmeplan
|
||||
End Get
|
||||
Set(value As Boolean)
|
||||
m_tree_from_massnahmeplan = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
#End Region
|
||||
|
||||
#Region "Tree"
|
||||
|
||||
Public Sub Load_Treeview(ByRef tree As DevComponents.AdvTree.AdvTree)
|
||||
tree.Nodes.Clear()
|
||||
TreeaufbauNr = -1
|
||||
If Me.Tree_From_Pruefplan = True Then
|
||||
load_treedata_pruefplan
|
||||
Else
|
||||
If Me.Tree_from_Massnahmeplan = True Then
|
||||
Load_Treedata_Massnahmeplan()
|
||||
Else
|
||||
Load_Treedata("")
|
||||
|
||||
End If
|
||||
|
||||
End If
|
||||
If Not (treedata Is Nothing) Then
|
||||
Dim oView As DataView = treedata.Tables(0).DefaultView
|
||||
Dim oTable As DataTable = oView.Table
|
||||
Dim oDS As DataSet = New DataSet()
|
||||
oDS.Tables.Add(oTable.Copy())
|
||||
|
||||
If oDS.Relations.Contains("SelfRefenceRelation") = False Then
|
||||
oDS.Relations.Add("SelfRefenceRelation",
|
||||
oDS.Tables(0).Columns("id"),
|
||||
oDS.Tables(0).Columns("Parentid"))
|
||||
End If
|
||||
oTable.Dispose()
|
||||
oTable = Nothing
|
||||
|
||||
LoadTreeView(oDS, tree)
|
||||
oDS.Dispose()
|
||||
oDS = Nothing
|
||||
tree.ExpandAll()
|
||||
End If
|
||||
End Sub
|
||||
|
||||
|
||||
|
||||
|
||||
Public Sub Search_Eintraege(ByRef tree As DevComponents.AdvTree.AdvTree, Searchstring As String)
|
||||
tree.Nodes.Clear()
|
||||
TreeaufbauNr = -1
|
||||
Load_Treedata(Searchstring)
|
||||
If Not (treedata Is Nothing) Then
|
||||
Dim oView As DataView = treedata.Tables(0).DefaultView
|
||||
Dim oTable As DataTable = oView.Table
|
||||
Dim oDS As DataSet = New DataSet()
|
||||
oDS.Tables.Add(oTable.Copy())
|
||||
|
||||
If oDS.Relations.Contains("SelfRefenceRelation") = False Then
|
||||
oDS.Relations.Add("SelfRefenceRelation",
|
||||
oDS.Tables(0).Columns("id"),
|
||||
oDS.Tables(0).Columns("Parentid"))
|
||||
End If
|
||||
oTable.Dispose()
|
||||
oTable = Nothing
|
||||
|
||||
LoadTreeView(oDS, tree)
|
||||
oDS.Dispose()
|
||||
oDS = Nothing
|
||||
tree.ExpandAll()
|
||||
End If
|
||||
End Sub
|
||||
|
||||
|
||||
|
||||
|
||||
Public Function Load_Treedata(ByVal datatype As String) As DataTable
|
||||
treedata.Tables.Clear()
|
||||
Dim selectcommand As New SqlCommand
|
||||
Dim connection As New SqlConnection()
|
||||
Dim da As New SqlDataAdapter("", connection)
|
||||
|
||||
selectcommand.CommandText = "sp_get_vorgabetree"
|
||||
selectcommand.Parameters.Add("@Root", SqlDbType.VarChar)
|
||||
selectcommand.Parameters(0).Value = datatype
|
||||
selectcommand.CommandType = CommandType.StoredProcedure
|
||||
selectcommand.Connection = connection
|
||||
Try
|
||||
connection.ConnectionString = Globals.sConnectionString
|
||||
connection.Open()
|
||||
da.SelectCommand = selectcommand
|
||||
da.Fill(treedata, "Tree")
|
||||
If treedata_for_search.Rows.Count < 1 Then
|
||||
For Each c As DataColumn In treedata.Tables(0).Columns
|
||||
If c.ColumnName = "ErweiterteSuche" Then
|
||||
Dim dc As New DataColumn
|
||||
dc.ColumnName = "ErweiterteSuche"
|
||||
dc.DataType = System.Type.GetType("System.String")
|
||||
dc.DefaultValue = " "
|
||||
Try
|
||||
Globals.treedata_for_search.Columns.Add(dc)
|
||||
Catch
|
||||
End Try
|
||||
Else
|
||||
Try
|
||||
Globals.treedata_for_search.Columns.Add(c.ColumnName)
|
||||
Catch
|
||||
End Try
|
||||
End If
|
||||
Next
|
||||
End If
|
||||
For Each row As DataRow In treedata.Tables(0).Rows
|
||||
Globals.treedata_for_search.ImportRow(row)
|
||||
Next
|
||||
Catch ex As Exception
|
||||
MsgBox(ex.Message)
|
||||
Finally
|
||||
connection.Close()
|
||||
da.Dispose()
|
||||
selectcommand.Dispose()
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function Load_Treedata_Pruefplan() As DataTable
|
||||
treedata.Tables.Clear()
|
||||
Dim selectcommand As New SqlCommand
|
||||
Dim connection As New SqlConnection()
|
||||
Dim da As New SqlDataAdapter("", connection)
|
||||
|
||||
selectcommand.CommandText = "sp_get_vorgabetree_pruefplan"
|
||||
selectcommand.Parameters.Add("@Root", SqlDbType.VarChar)
|
||||
selectcommand.Parameters(0).Value = Me.Pruefplannr
|
||||
selectcommand.CommandType = CommandType.StoredProcedure
|
||||
selectcommand.Connection = connection
|
||||
Try
|
||||
connection.ConnectionString = Globals.sConnectionString
|
||||
connection.Open()
|
||||
da.SelectCommand = selectcommand
|
||||
da.Fill(treedata, "Tree")
|
||||
If treedata_for_search.Rows.Count < 1 Then
|
||||
For Each c As DataColumn In treedata.Tables(0).Columns
|
||||
If c.ColumnName = "ErweiterteSuche" Then
|
||||
Dim dc As New DataColumn
|
||||
dc.ColumnName = "ErweiterteSuche"
|
||||
dc.DataType = System.Type.GetType("System.String")
|
||||
dc.DefaultValue = " "
|
||||
Try
|
||||
Globals.treedata_for_search.Columns.Add(dc)
|
||||
Catch
|
||||
End Try
|
||||
Else
|
||||
Try
|
||||
Globals.treedata_for_search.Columns.Add(c.ColumnName)
|
||||
Catch
|
||||
End Try
|
||||
End If
|
||||
Next
|
||||
End If
|
||||
For Each row As DataRow In treedata.Tables(0).Rows
|
||||
Globals.treedata_for_search.ImportRow(row)
|
||||
Next
|
||||
Catch ex As Exception
|
||||
MsgBox(ex.Message)
|
||||
Finally
|
||||
connection.Close()
|
||||
da.Dispose()
|
||||
selectcommand.Dispose()
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function Load_Treedata_Massnahmeplan() As DataTable
|
||||
treedata.Tables.Clear()
|
||||
Dim selectcommand As New SqlCommand
|
||||
Dim connection As New SqlConnection()
|
||||
Dim da As New SqlDataAdapter("", connection)
|
||||
|
||||
selectcommand.CommandText = "sp_get_vorgabetree_massnahmeplan"
|
||||
selectcommand.Parameters.Add("@Root", SqlDbType.VarChar)
|
||||
selectcommand.Parameters(0).Value = Me.Pruefplannr
|
||||
selectcommand.CommandType = CommandType.StoredProcedure
|
||||
selectcommand.Connection = connection
|
||||
Try
|
||||
connection.ConnectionString = Globals.sConnectionString
|
||||
connection.Open()
|
||||
da.SelectCommand = selectcommand
|
||||
da.Fill(treedata, "Tree")
|
||||
If treedata_for_search.Rows.Count < 1 Then
|
||||
For Each c As DataColumn In treedata.Tables(0).Columns
|
||||
If c.ColumnName = "ErweiterteSuche" Then
|
||||
Dim dc As New DataColumn
|
||||
dc.ColumnName = "ErweiterteSuche"
|
||||
dc.DataType = System.Type.GetType("System.String")
|
||||
dc.DefaultValue = " "
|
||||
Try
|
||||
Globals.treedata_for_search.Columns.Add(dc)
|
||||
Catch
|
||||
End Try
|
||||
Else
|
||||
Try
|
||||
Globals.treedata_for_search.Columns.Add(c.ColumnName)
|
||||
Catch
|
||||
End Try
|
||||
End If
|
||||
Next
|
||||
End If
|
||||
For Each row As DataRow In treedata.Tables(0).Rows
|
||||
Globals.treedata_for_search.ImportRow(row)
|
||||
Next
|
||||
Catch ex As Exception
|
||||
MsgBox(ex.Message)
|
||||
Finally
|
||||
connection.Close()
|
||||
da.Dispose()
|
||||
selectcommand.Dispose()
|
||||
End Try
|
||||
End Function
|
||||
Protected Function GetAllNodes(ByVal treestruktur As DevComponents.AdvTree.AdvTree) As List(Of TreeNode)
|
||||
|
||||
Dim allNodes As List(Of TreeNode) = New List(Of TreeNode)()
|
||||
|
||||
' start recursion for each root node of the treeview
|
||||
For i As Integer = 0 To treestruktur.Nodes.Count - 1
|
||||
GetAllNodes(treestruktur.Nodes(i), allNodes)
|
||||
Next
|
||||
|
||||
Return allNodes
|
||||
|
||||
End Function
|
||||
|
||||
Protected Sub GetAllNodes(ByVal subRoot As DevComponents.AdvTree.Node, ByVal allNodes As List(Of TreeNode))
|
||||
|
||||
' check for null (this can be removed since within th
|
||||
If (subRoot Is Nothing) Then
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
' add subroot
|
||||
Dim r As DataRow
|
||||
r = treedata_for_search.NewRow
|
||||
r.Item(0) = subRoot.Tag
|
||||
Try
|
||||
r.Item(1) = subRoot.Parent.Tag
|
||||
Catch
|
||||
r.Item(1) = 0
|
||||
End Try
|
||||
|
||||
r.Item(2) = subRoot.Text
|
||||
r.Item(3) = subRoot.ImageIndex
|
||||
treedata_for_search.Rows.Add(r)
|
||||
'allNodes.Add(subRoot)
|
||||
' add all it's children
|
||||
For i As Integer = 0 To subRoot.Nodes.Count - 1
|
||||
GetAllNodes(subRoot.Nodes(i), allNodes)
|
||||
Next
|
||||
|
||||
|
||||
End Sub
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' Tree aufbauen
|
||||
''' </summary>
|
||||
''' <param name="oDS"></param>
|
||||
''' <param name="oTreeview"></param>
|
||||
''' <remarks></remarks>
|
||||
Private Sub LoadTreeView(ByVal oDS As DataSet, ByRef oTreeview As DevComponents.AdvTree.AdvTree)
|
||||
'Dim oTreeView As TreeView = New TreeView()
|
||||
Dim oDataRow As DataRow
|
||||
For Each oDataRow In oDS.Tables(0).Rows
|
||||
If Not oDataRow.IsNull("Parentid") Then
|
||||
If oDataRow.Item("Parentid") = 0 Then
|
||||
'If oDataRow.IsNull("Parentid") Then
|
||||
Dim oNode As New DevComponents.AdvTree.Node
|
||||
oNode.Text = Trim(oDataRow("Bezeichnung").ToString())
|
||||
Try
|
||||
'oNode.ToolTipText = Trim(oDataRow("ErweiterteSuche").ToString)
|
||||
Catch
|
||||
End Try
|
||||
oNode.Tag = oDataRow("id").ToString
|
||||
oNode.ImageIndex = oDataRow("ImageIndex")
|
||||
oTreeview.Nodes.Add(oNode)
|
||||
RecursivelyLoadTree(oDataRow, oNode)
|
||||
End If
|
||||
End If
|
||||
Next oDataRow
|
||||
oDS.Dispose()
|
||||
oDS = Nothing
|
||||
End Sub
|
||||
''' <summary>
|
||||
''' Child-Nodes hinzufügen
|
||||
''' </summary>
|
||||
''' <param name="oDataRow"></param>
|
||||
''' <param name="oNode"></param>
|
||||
''' <remarks></remarks>
|
||||
Private Sub RecursivelyLoadTree(ByVal oDataRow As DataRow, ByRef oNode As DevComponents.AdvTree.Node)
|
||||
Dim oChildRow As DataRow
|
||||
For Each oChildRow In oDataRow.GetChildRows("SelfRefenceRelation")
|
||||
Dim oChildNode As New DevComponents.AdvTree.Node
|
||||
oChildNode.Text = Trim(oChildRow("Bezeichnung").ToString())
|
||||
oChildNode.Tag = oChildRow("id").ToString()
|
||||
oChildNode.ImageIndex = oChildRow("ImageIndex")
|
||||
|
||||
oNode.Nodes.Add(oChildNode)
|
||||
RecursivelyLoadTree(oChildRow, oChildNode)
|
||||
Next oChildRow
|
||||
End Sub
|
||||
Public Function FindNode(ByVal _nodeCollection As AdvTree.NodeCollection, ByVal SearchVal As Integer, ByVal SearchString As String) As AdvTree.Node
|
||||
Dim tmpNode As AdvTree.Node
|
||||
For Each _child As AdvTree.Node In _nodeCollection
|
||||
If _child.Tag = SearchVal Then
|
||||
|
||||
Return _child
|
||||
End If
|
||||
' If InStr(UCase(_child.Text), UCase(SearchString)) > 0 Then
|
||||
' Return _child
|
||||
' End If
|
||||
tmpNode = FindNode(_child.Nodes, SearchVal, SearchString)
|
||||
If Not tmpNode Is Nothing Then
|
||||
Return tmpNode
|
||||
End If
|
||||
Next
|
||||
Return Nothing
|
||||
End Function
|
||||
|
||||
|
||||
Public Function Init_Search()
|
||||
FoundNode = 0
|
||||
Searchstring = ""
|
||||
Me.Treesearch.Nodes.Clear()
|
||||
End Function
|
||||
|
||||
Public Function SearchNode(ByRef tree As AdvTree.AdvTree, ByVal SearchString As String) As AdvTree.Node
|
||||
'Return tree.FindNodeByCellText(SearchString)
|
||||
|
||||
Me.Treesearch.Nodes.Clear()
|
||||
Dim dv As New DataView(treedata_for_search, "", "id,sortkey", DataViewRowState.CurrentRows)
|
||||
For Each rowView As DataRowView In dv
|
||||
Dim dr As DataRow = rowView.Row
|
||||
'InStr(UCase(SearchString), UCase(dr.Item("Bezeichnung")))
|
||||
If InStr(Trim(UCase(dr.Item("Bezeichnung"))), Trim(UCase(SearchString))) > 0 Then
|
||||
Dim tn As New AdvTree.Node
|
||||
tn.Text = dr.Item("Bezeichnung")
|
||||
tn.Tag = dr.Item("id")
|
||||
Treesearch.Nodes.Add(tn)
|
||||
End If
|
||||
Next
|
||||
Return FindFirst(tree)
|
||||
End Function
|
||||
|
||||
Public Function FindFirst(ByRef Tree As AdvTree.AdvTree) As AdvTree.Node
|
||||
Try
|
||||
If Me.Treesearch.Nodes.Count > 0 Then Me.Treesearch.SelectedNode = Me.Treesearch.Nodes(0)
|
||||
Return FindNode(Tree.Nodes, Treesearch.SelectedNode.Tag, "")
|
||||
Catch
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function FindNextNode(ByRef tree As AdvTree.AdvTree) As AdvTree.Node
|
||||
Try
|
||||
Treesearch.SelectedNode = Treesearch.SelectedNode.NextNode
|
||||
If Treesearch.SelectedNode Is Nothing Then
|
||||
Return FindFirst(tree)
|
||||
End If
|
||||
Return Me.FindNode(tree.Nodes, Treesearch.SelectedNode.Tag, "")
|
||||
Catch ex As Exception
|
||||
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function FindPrevNode(ByRef tree As AdvTree.AdvTree) As AdvTree.Node
|
||||
Try
|
||||
Treesearch.SelectedNode = Treesearch.SelectedNode.PrevNode
|
||||
If Treesearch.SelectedNode Is Nothing Then
|
||||
Return FindLastNode(tree)
|
||||
End If
|
||||
Return Me.FindNode(tree.Nodes, Treesearch.SelectedNode.Tag, "")
|
||||
Catch ex As Exception
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function FindLastNode(ByRef tree As AdvTree.AdvTree) As AdvTree.Node
|
||||
Try
|
||||
Treesearch.SelectedNode = Treesearch.Nodes(Treesearch.Nodes.Count - 1)
|
||||
Return Me.FindNode(tree.Nodes, Treesearch.SelectedNode.Tag, "")
|
||||
Catch ex As Exception
|
||||
End Try
|
||||
|
||||
End Function
|
||||
Public Function Get_Eintraege(ByRef c1daten As C1.Win.C1TrueDBGrid.C1TrueDBGrid, ByVal Key As Integer)
|
||||
Try
|
||||
Dim ds As New DataSet
|
||||
Dim connection As New SqlConnection()
|
||||
Dim da As New SqlDataAdapter("", connection)
|
||||
Dim sqlcmd As New SqlCommand
|
||||
|
||||
sqlcmd.CommandText = "sp_get_Vorgaben"
|
||||
sqlcmd.Parameters.Add(New SqlParameter("@key", SqlDbType.Int, 4, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, Key))
|
||||
sqlcmd.CommandType = CommandType.StoredProcedure
|
||||
sqlcmd.Connection = connection
|
||||
Try
|
||||
connection.ConnectionString = Globals.sConnectionString
|
||||
connection.Open()
|
||||
da.SelectCommand = sqlcmd
|
||||
da.Fill(ds, "Datatable1")
|
||||
c1daten.DataSource = Nothing
|
||||
c1daten.DataSource = ds.Tables(0)
|
||||
c1daten.DataMember = ds.Tables(0).TableName
|
||||
|
||||
SpaltenTitel.Spaltentitel_aktualisieren(c1daten, "Vorgabe", ds.Tables(0))
|
||||
Catch ex As Exception
|
||||
MsgBox(ex.Message)
|
||||
Finally
|
||||
connection.Close()
|
||||
da.Dispose()
|
||||
sqlcmd.Dispose()
|
||||
End Try
|
||||
Catch ex As Exception
|
||||
MsgBox(ex.Message)
|
||||
End Try
|
||||
End Function
|
||||
|
||||
|
||||
|
||||
|
||||
#End Region
|
||||
|
||||
#Region "ComboboxFilter"
|
||||
Public Sub Refresh_Filter(ByRef cbx As ToolStripComboBox)
|
||||
Dim s As String
|
||||
s = cbx.SelectedText.ToString
|
||||
cbx.Items.Clear()
|
||||
cbx.Items.Add("-- Alle --")
|
||||
For Each r As DataRow In treedata.Tables(0).Rows
|
||||
Try
|
||||
If r("Parentid") = 0 Then
|
||||
cbx.Items.Add(r("bezeichnung"))
|
||||
End If
|
||||
Catch
|
||||
End Try
|
||||
|
||||
Next
|
||||
If s <> "" Then cbx.Text = s
|
||||
End Sub
|
||||
#End Region
|
||||
|
||||
'#Region "Suche"
|
||||
' Public Function Init_Search()
|
||||
' FoundNode = 0
|
||||
' Searchstring = ""
|
||||
' Me.Treesearch.Nodes.Clear()
|
||||
' End Function
|
||||
|
||||
' Public Function SearchNode(ByRef tree As AdvTree.AdvTree, ByVal SearchString As String) As AdvTree.Node
|
||||
' 'Return tree.FindNodeByCellText(SearchString)
|
||||
|
||||
' Me.Treesearch.Nodes.Clear()
|
||||
' For Each dr As DataRow In treedata_for_search.Rows
|
||||
' 'InStr(UCase(SearchString), UCase(dr.Item("Bezeichnung")))
|
||||
' If InStr(UCase(dr.Item("Bezeichnung")), UCase(SearchString)) > 0 Or InStr(UCase(dr.Item("ErweiterteSuche")), UCase(SearchString)) > 0 Then
|
||||
' Dim tn As New AdvTree.Node
|
||||
' tn.Text = dr.Item("Bezeichnung")
|
||||
' tn.Tag = dr.Item("id")
|
||||
' Treesearch.Nodes.Add(tn)
|
||||
' End If
|
||||
' Next
|
||||
' Return FindFirst(tree)
|
||||
' End Function
|
||||
|
||||
' Public Function FindFirst(ByRef Tree As AdvTree.AdvTree) As AdvTree.Node
|
||||
' Try
|
||||
' If Me.Treesearch.Nodes.Count > 0 Then Me.Treesearch.SelectedNode = Me.Treesearch.Nodes(0)
|
||||
' Return FindNode(Tree.Nodes, Treesearch.SelectedNode.Tag, "")
|
||||
' Catch
|
||||
' End Try
|
||||
' End Function
|
||||
|
||||
|
||||
|
||||
' Public Function FindNextNode(ByRef tree As AdvTree.AdvTree) As AdvTree.Node
|
||||
' Try
|
||||
' Treesearch.SelectedNode = Treesearch.SelectedNode.NextNode
|
||||
' If Treesearch.SelectedNode Is Nothing Then
|
||||
' Return FindFirst(tree)
|
||||
' End If
|
||||
' Return Me.FindNode(tree.Nodes, Treesearch.SelectedNode.Tag, "")
|
||||
' Catch ex As Exception
|
||||
|
||||
' End Try
|
||||
' End Function
|
||||
|
||||
' Public Function FindPrevNode(ByRef tree As AdvTree.AdvTree) As AdvTree.Node
|
||||
' Try
|
||||
' Treesearch.SelectedNode = Treesearch.SelectedNode.PrevNode
|
||||
' If Treesearch.SelectedNode Is Nothing Then
|
||||
' Return FindLastNode(tree)
|
||||
' End If
|
||||
' Return Me.FindNode(tree.Nodes, Treesearch.SelectedNode.Tag, "")
|
||||
' Catch ex As Exception
|
||||
' End Try
|
||||
' End Function
|
||||
|
||||
' Public Function FindLastNode(ByRef tree As AdvTree.AdvTree) As AdvTree.Node
|
||||
' Try
|
||||
' Treesearch.SelectedNode = Treesearch.Nodes(Treesearch.Nodes.Count - 1)
|
||||
' Return Me.FindNode(tree.Nodes, Treesearch.SelectedNode.Tag, "")
|
||||
' Catch ex As Exception
|
||||
' End Try
|
||||
|
||||
' End Function
|
||||
|
||||
' Public Function Get_DBObjektname(ByVal type As Integer) As String
|
||||
' For Each dr As DataRow In Globals.Objekt.Rows
|
||||
' If dr.Item("Objektnr") = type Then
|
||||
' Return dr.Item("DBOBject")
|
||||
' Exit For
|
||||
' End If
|
||||
' Next
|
||||
' End Function
|
||||
|
||||
|
||||
|
||||
'#End Region
|
||||
|
||||
|
||||
|
||||
End Class
|
||||
@@ -0,0 +1,425 @@
|
||||
Imports C1.Win.C1TrueDBGrid
|
||||
Imports System
|
||||
Imports System.IO
|
||||
Imports System.Data
|
||||
Imports System.Data.SqlTypes
|
||||
Imports System.Data.SqlClient
|
||||
Imports System.Diagnostics
|
||||
|
||||
'
|
||||
Namespace Utils
|
||||
''' <summary>
|
||||
''' Klasse für das Speichern bzw. Auslesen von Image-Dateien in der Datenbank
|
||||
''' </summary>
|
||||
''' <remarks>
|
||||
''' Es werden folgende Datebanktabellen berücksichtigt:
|
||||
''' <list type="bullet">
|
||||
''' <item>
|
||||
''' <description>Dokument Attribut DocImage</description></item>
|
||||
''' <item>
|
||||
''' <description>Profile Attribut V_Uebersicht (Profillayout des C1TrueDBGrids der
|
||||
''' Vertragsübersicht|Vertragselemente</description></item></list>
|
||||
''' </remarks>
|
||||
''' <includesource>yes</includesource>
|
||||
Public Class MyDocMgmt
|
||||
''' <summary>
|
||||
''' Grid-Layoutfile speichern
|
||||
''' </summary>
|
||||
''' <param name="c1data">C1Truedbgrind, von welchem das Layout gespeichert werden soll</param>
|
||||
''' <param name="GriddNo">Nummer des Grids: 1=Vertragsübersicht...</param>
|
||||
''' <returns></returns>
|
||||
''' <remarks></remarks>
|
||||
Public Function Save_LayoutFile(ByRef c1data As C1TrueDBGrid, ByVal GridNo As Integer, ByVal Profilnr As Integer) As Boolean
|
||||
Dim filename As String = Globals.TmpFilepath(+Trim(Str(Profilnr)) + Trim(Str(GridNo)) + ".lyt")
|
||||
c1data.SaveLayout(filename)
|
||||
|
||||
Dim Connection As New SqlConnection()
|
||||
Dim DA As New SqlDataAdapter("select * from profil where profilnr = " & Str(Profilnr), Connection)
|
||||
'mitarbeiternr=" + Str(Globals.clsmitarbeiter.iMitarbeiternr.Value)
|
||||
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
|
||||
fs.Read(mydata, 0, fs.Length)
|
||||
fs.Close()
|
||||
Try
|
||||
Connection.ConnectionString = Globals.sConnectionString
|
||||
Connection.Open()
|
||||
DA.Fill(ds, "profil")
|
||||
Dim myRow As DataRow
|
||||
If ds.Tables(0).Rows.Count = 0 Then
|
||||
' Neues Profil sepeichern
|
||||
myRow = ds.Tables(0).NewRow
|
||||
myRow.Item(1) = Globals.Mitarbeiternr
|
||||
myRow.Item(2) = ""
|
||||
Select Case GridNo
|
||||
Case 1
|
||||
myRow.Item(3) = mydata
|
||||
End Select
|
||||
ds.Tables(0).Rows.Add(myRow)
|
||||
DA.Update(ds, "profil")
|
||||
Else
|
||||
myRow = ds.Tables(0).Rows(0)
|
||||
Select Case GridNo
|
||||
Case 1
|
||||
myRow.Item(3) = mydata
|
||||
End Select
|
||||
DA.Update(ds, "profil")
|
||||
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 True
|
||||
|
||||
End Function
|
||||
|
||||
Private Function Get_Layoutfile_from_db(ByVal filename As String, ByVal GridNo As Integer, ByVal Profilnr As Integer) As Boolean
|
||||
'Exit Function
|
||||
Dim connection As New SqlConnection()
|
||||
Dim da As New SqlDataAdapter("Select * From profil where profilnr=" & Str(Profilnr), connection)
|
||||
'mitarbeiternr=" + Str(Globals.clsmitarbeiter.iMitarbeiternr.Value)
|
||||
Dim CB As SqlCommandBuilder = New SqlCommandBuilder(da)
|
||||
Dim ds As New DataSet()
|
||||
Try
|
||||
connection.ConnectionString = Globals.sConnectionString
|
||||
connection.Open()
|
||||
da.Fill(ds, "docs")
|
||||
Dim myRow As DataRow
|
||||
myRow = ds.Tables(0).Rows(0)
|
||||
Dim MyData() As Byte
|
||||
Select Case GridNo
|
||||
Case 1
|
||||
MyData = myRow.Item(3)
|
||||
|
||||
End Select
|
||||
|
||||
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
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
Return False
|
||||
End Try
|
||||
CB = Nothing
|
||||
ds = Nothing
|
||||
da = Nothing
|
||||
connection.Close()
|
||||
connection = Nothing
|
||||
Return True
|
||||
End Function
|
||||
|
||||
Public Function Get_Layout(ByRef c1data As C1TrueDBGrid, ByVal GridNo As Integer, ByVal Profilnr As Integer) As Boolean
|
||||
Dim filename As String = Globals.TmpFilepath + Trim(Str(Profilnr)) + Trim(Str(GridNo)) + ".lyt"
|
||||
If File.Exists(filename) Then
|
||||
c1data.LoadLayout(filename)
|
||||
Return True
|
||||
End If
|
||||
If Get_Layoutfile_from_db(filename, GridNo, Profilnr) Then
|
||||
c1data.LoadLayout(filename)
|
||||
Return True
|
||||
End If
|
||||
Return False
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' Dokument in der Tabelle Dokument speichern
|
||||
''' </summary>
|
||||
''' <param name="Dokumentnr">Nummer des Dokument-Datensatzes</param>
|
||||
''' <param name="Filename">Zu speichender Dateiname</param>
|
||||
''' <returns></returns>
|
||||
''' <remarks></remarks>
|
||||
|
||||
Public Function Save_Document(ByVal Dokumentnr As Integer, ByVal Filename As String) As Boolean
|
||||
Dim Connection As New SqlConnection()
|
||||
Dim DA As New SqlDataAdapter("select * from dokument where dokumentnr =" + Str(Dokumentnr), 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
|
||||
fs.Read(mydata, 0, fs.Length)
|
||||
fs.Close()
|
||||
Try
|
||||
Connection.ConnectionString = Globals.sConnectionString
|
||||
Connection.Open()
|
||||
DA.Fill(ds, "Dokument")
|
||||
Dim myRow As DataRow
|
||||
If ds.Tables(0).Rows.Count = 0 Then
|
||||
Return False
|
||||
Else
|
||||
myRow = ds.Tables(0).Rows(0)
|
||||
myRow.Item(16) = mydata
|
||||
DA.Update(ds, "Dokument")
|
||||
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 True
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' Liest das Dokument aus der DB und speichert dieses unter einem temporären Filenamen ab
|
||||
''' </summary>
|
||||
''' <param name="DokumentNr"></param>
|
||||
''' <returns></returns>
|
||||
''' <remarks></remarks>
|
||||
Public Function Get_Dokument(ByVal DokumentNr As Integer) As String
|
||||
Dim Filename As String = Globals.TmpFilepath
|
||||
If Right(Filename, 1) <> "\" Then Filename = Filename + "\"
|
||||
|
||||
Dim connection As New SqlConnection()
|
||||
Dim da As New SqlDataAdapter("Select * From Dokument where DokumentNr=" + Str(DokumentNr), connection)
|
||||
Dim CB As SqlCommandBuilder = New SqlCommandBuilder(da)
|
||||
Dim ds As New DataSet()
|
||||
Try
|
||||
connection.ConnectionString = Globals.sConnectionString
|
||||
connection.Open()
|
||||
da.Fill(ds, "Dokument")
|
||||
Dim myRow As DataRow
|
||||
myRow = ds.Tables(0).Rows(0)
|
||||
Select Case myRow.Item("Speichertypnr")
|
||||
Case 1
|
||||
Dim MyData() As Byte
|
||||
MyData = myRow.Item(16)
|
||||
|
||||
Dim K As Long
|
||||
K = UBound(MyData)
|
||||
Filename = Filename + myRow.Item(6)
|
||||
Dim fs As New FileStream(Filename, FileMode.OpenOrCreate, FileAccess.Write)
|
||||
fs.Write(MyData, 0, K)
|
||||
fs.Close()
|
||||
fs = Nothing
|
||||
Case 2
|
||||
Filename = myRow.Item("OriginalFilename_incl_Path")
|
||||
Case 3
|
||||
Filename = myRow.Item("OriginalFilename_incl_Path")
|
||||
Case Else
|
||||
Filename = myRow.Item("OriginalFilename_incl_Path")
|
||||
End Select
|
||||
|
||||
Catch ex As Exception
|
||||
MsgBox(ex.Message, MsgBoxStyle.Critical)
|
||||
Return ""
|
||||
Finally
|
||||
connection.Close()
|
||||
connection = Nothing
|
||||
End Try
|
||||
CB = Nothing
|
||||
ds = Nothing
|
||||
da = Nothing
|
||||
Return Filename
|
||||
End Function
|
||||
|
||||
Public Function Show_Document(ByVal Dokumentnr As Integer) As Boolean
|
||||
Dim tmpfilename As String = Me.Get_Dokument(Dokumentnr)
|
||||
If tmpfilename <> "" Then
|
||||
OpenSystemFile(tmpfilename)
|
||||
Return True
|
||||
End If
|
||||
Return False
|
||||
End Function
|
||||
|
||||
Public Function OpenSystemFile(ByVal sFileName As String) As Boolean
|
||||
If Len(sFileName) > 0 Then
|
||||
System.Diagnostics.Process.Start(sFileName)
|
||||
'
|
||||
' ShellExecute(GetDesktopWindow(), vbNullString, sFileName, vbNullString, vbNullString, vbNormalFocus)
|
||||
Return True
|
||||
End If
|
||||
End Function
|
||||
|
||||
Public Function Save_RptDatei(ByVal Auswertungnr As Integer, ByVal AuswertungName As String) As String
|
||||
Dim filename As String = AuswertungName
|
||||
Dim Connection As New SqlConnection()
|
||||
Dim DA As New SqlDataAdapter("select * from AuswertungRptDatei where AuswertungDateiNr = " & Str(Auswertungnr), 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
|
||||
fs.Read(mydata, 0, fs.Length)
|
||||
fs.Close()
|
||||
Try
|
||||
Connection.ConnectionString = Globals.sConnectionString
|
||||
Connection.Open()
|
||||
DA.Fill(ds, "RptFile")
|
||||
Dim myRow As DataRow
|
||||
If ds.Tables(0).Rows.Count = 0 Then
|
||||
' Neues Datei speichern
|
||||
myRow = ds.Tables(0).NewRow
|
||||
myRow.Item(0) = Auswertungnr
|
||||
myRow.Item(1) = AuswertungName
|
||||
myRow.Item(2) = RptName(AuswertungName)
|
||||
myRow.Item(3) = mydata
|
||||
myRow.Item(4) = Now
|
||||
myRow.Item(5) = Now
|
||||
myRow.Item(6) = Globals.Mitarbeiternr
|
||||
ds.Tables(0).Rows.Add(myRow)
|
||||
DA.Update(ds, "RptFile")
|
||||
Else
|
||||
myRow = ds.Tables(0).Rows(0)
|
||||
myRow.Item(1) = AuswertungName
|
||||
myRow.Item(2) = RptName(AuswertungName)
|
||||
myRow.Item(3) = mydata
|
||||
myRow.Item(5) = Now
|
||||
myRow.Item(6) = Globals.Mitarbeiternr
|
||||
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 connection As New SqlConnection()
|
||||
Dim DA As New SqlDataAdapter("select * from AuswertungRptDatei where AuswertungDateiNr = " & Str(Auswertungnr), connection)
|
||||
Dim CB As SqlCommandBuilder = New SqlCommandBuilder(DA)
|
||||
Dim ds As New DataSet()
|
||||
Dim Filename As String = ""
|
||||
Try
|
||||
connection.ConnectionString = Globals.sConnectionString
|
||||
connection.Open()
|
||||
DA.Fill(ds, "RptFile")
|
||||
Dim myRow As DataRow
|
||||
myRow = ds.Tables(0).Rows(0)
|
||||
Dim MyData() As Byte
|
||||
Filename = Globals.TmpFilepath + "\" + myRow.Item(2).ToString
|
||||
If fname <> "" Then
|
||||
Filename = fname
|
||||
End If
|
||||
MyData = myRow.Item(3)
|
||||
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
|
||||
|
||||
Public Function Save_Architekturfile(ByVal Applikationnr As Integer, ByVal iFilename As String)
|
||||
Dim filename As String = iFilename
|
||||
Dim Connection As New SqlConnection()
|
||||
Dim DA As New SqlDataAdapter("select * from ApplikationArchitektur where applikationnr = " & Str(Applikationnr), 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
|
||||
fs.Read(mydata, 0, fs.Length)
|
||||
fs.Close()
|
||||
Try
|
||||
Connection.ConnectionString = Globals.sConnectionString
|
||||
Connection.Open()
|
||||
DA.Fill(ds, "RptFile")
|
||||
Dim myRow As DataRow
|
||||
If ds.Tables(0).Rows.Count = 0 Then
|
||||
' Neues Datei speichern
|
||||
myRow = ds.Tables(0).NewRow
|
||||
myRow.Item(0) = Applikationnr
|
||||
myRow.Item(1) = mydata
|
||||
' myRow.Item(4) = Now
|
||||
' myRow.Item(5) = Now
|
||||
' myRow.Item(6) = Globals.clsmitarbeiter.iMitarbeiternr.Value
|
||||
ds.Tables(0).Rows.Add(myRow)
|
||||
DA.Update(ds, "RptFile")
|
||||
Else
|
||||
myRow = ds.Tables(0).Rows(0)
|
||||
myRow.Item(1) = mydata
|
||||
' myRow.Item(2) = RptName(AuswertungName)
|
||||
' myRow.Item(3) = mydata
|
||||
' myRow.Item(5) = Now
|
||||
' myRow.Item(6) = Globals.clsmitarbeiter.iMitarbeiternr.Value
|
||||
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
|
||||
End Function
|
||||
|
||||
Public Function Get_Architekturfile(ByVal Applikationnr As String, Optional ByVal fname As String = "") As String
|
||||
Dim connection As New SqlConnection()
|
||||
Dim DA As New SqlDataAdapter("select * from ApplikationArchitektur where applikationnr = " & Str(Applikationnr), connection)
|
||||
Dim CB As SqlCommandBuilder = New SqlCommandBuilder(DA)
|
||||
Dim ds As New DataSet()
|
||||
Dim Filename As String = ""
|
||||
Try
|
||||
connection.ConnectionString = Globals.sConnectionString
|
||||
connection.Open()
|
||||
DA.Fill(ds, "RptFile")
|
||||
Dim myRow As DataRow
|
||||
myRow = ds.Tables(0).Rows(0)
|
||||
Dim MyData() As Byte
|
||||
Filename = Globals.TmpFilepath + "\architekturfile.xml"
|
||||
If fname <> "" Then
|
||||
Filename = fname
|
||||
End If
|
||||
MyData = myRow.Item(1)
|
||||
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
|
||||
|
||||
End Namespace
|
||||
Reference in New Issue
Block a user