Initial commit
This commit is contained in:
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 1.7 KiB |
@@ -0,0 +1,762 @@
|
||||
Imports System
|
||||
Imports System.Data
|
||||
Imports System.Data.SqlTypes
|
||||
Imports System.Data.SqlClient
|
||||
Imports DevComponents
|
||||
Imports DropDownControls
|
||||
|
||||
Public Class clspruefplan
|
||||
Inherits DB.clsPruefplan
|
||||
|
||||
#Region "Deklarationen"
|
||||
Public daten As New DataTable
|
||||
Public Neuer_Datensatz As Boolean = False
|
||||
Public Mitarbeiterdaten As New DataTable
|
||||
|
||||
Public Zeitpunkt As New DataTable
|
||||
Public Periodizitaet As New DataTable
|
||||
Public Prioritaet As New DataTable
|
||||
Public VerantwortungISI As New DataTable
|
||||
Public VerantwortungPlan As New DataTable
|
||||
Public Verantwortung As New DataTable
|
||||
Dim stammdaten As New DB.clsStammdaten
|
||||
Dim SpaltenTitel As New Utils.Tabellenspalte
|
||||
|
||||
Dim Definition_Pruefplan As New DataTable
|
||||
Dim clsDefinition_Pruefplan As New DB.clsDefinition_Pruefplan
|
||||
Public Terminierung As New DataTable
|
||||
|
||||
|
||||
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()
|
||||
Zeitpunkt = stammdaten.Get_Stammdaten("Zeitpunkt", "Beschreibung")
|
||||
Periodizitaet = stammdaten.Get_Stammdaten("Periodizitaet", "Bezeichnung")
|
||||
Prioritaet = stammdaten.Get_Stammdaten("Prioritaet", "Bezeichnung")
|
||||
VerantwortungISI = stammdaten.Get_Stammdaten("VerantwortungIsi", "Bezeichnung")
|
||||
Verantwortung = stammdaten.Get_Stammdaten("Verantwortung", "Bezeichnung")
|
||||
Terminierung = stammdaten.Get_Stammdaten("Terminierung", "Bezeichnung")
|
||||
VerantwortungPlan = stammdaten.Get_Stammdaten("VerantwortungIsi", "Bezeichnung")
|
||||
End Sub
|
||||
|
||||
|
||||
|
||||
Public Overloads Sub dispose()
|
||||
MyBase.Dispose()
|
||||
Try
|
||||
Me.Zeitpunkt.Dispose()
|
||||
Me.Periodizitaet.Dispose()
|
||||
Me.Prioritaet.Dispose()
|
||||
Me.VerantwortungISI.Dispose()
|
||||
Me.Verantwortung.Dispose()
|
||||
Me.stammdaten = Nothing
|
||||
Me.Definition_Pruefplan.Dispose()
|
||||
Me.VerantwortungPlan.Dispose()
|
||||
|
||||
|
||||
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.iPruefplanNr = 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("Pruefplan")
|
||||
db.Dispose()
|
||||
|
||||
Me.cpMainConnectionProvider = Globals.conn
|
||||
Me.iPruefplanNr = 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("Pruefplan")
|
||||
db.Dispose()
|
||||
Me.iPruefplanNr = New SqlInt32(CType(newkey, Int32))
|
||||
Me.daGueltig_Bis = New SqlDateTime(CType("31.12.2099", DateTime))
|
||||
Me.iPrioritaetNr = New SqlInt32(CType(0, Int32))
|
||||
Me.iPeriodizitaetNr = New SqlInt32(CType(0, Int32))
|
||||
Me.iZeitpunktNr = New SqlInt32(CType(0, Int32))
|
||||
Me.sBeschreibung = New SqlString(CType("", String))
|
||||
Me.sPruefgegenstand = New SqlString(CType("", String))
|
||||
Me.sHilfsmittel = New SqlString(CType("", String))
|
||||
Me.sMassnahmen = New SqlString(CType("", String))
|
||||
Me.iVerantwortungISINr = New SqlInt32(CType(0, Int32))
|
||||
Me.sBeschreibung = 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.daErstmals_am = New SqlDateTime(CType(DateAdd(DateInterval.Day, 1, Now), DateTime))
|
||||
Me.iTerminierungID = New SqlInt32(CType(0, 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.iPruefplanNr.Value
|
||||
End Function
|
||||
|
||||
Public Function Get_Pruefplan(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_pruefplan"
|
||||
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, "Pruefplan", 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
|
||||
|
||||
|
||||
Public Function Get_Eintraege(ByRef c1daten As C1.Win.C1TrueDBGrid.C1TrueDBGrid, ByVal Key As Integer, Optional Searchstring As String = "")
|
||||
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_pruefplan"
|
||||
sqlcmd.Parameters.Add(New SqlParameter("@key", SqlDbType.Int, 4, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, Key))
|
||||
sqlcmd.Parameters.Add(New SqlParameter("@Searchstring", SqlDbType.VarChar, 255, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, Searchstring))
|
||||
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, "Pruefplan", 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
|
||||
|
||||
Public Function Get_Definition_Pruefplan(ByVal Key As Integer, ByRef cb As CheckedListBox)
|
||||
Me.Definition_Pruefplan.Rows.Clear()
|
||||
Try
|
||||
Dim connection As New SqlConnection()
|
||||
Dim da As New SqlDataAdapter("", connection)
|
||||
Dim sqlcmd As New SqlCommand
|
||||
|
||||
sqlcmd.CommandText = "sp_get_definition_pruefplan"
|
||||
sqlcmd.Parameters.Add(New SqlParameter("@pruefplannr", 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(Me.Definition_Pruefplan)
|
||||
|
||||
For Each r As DataRow In Definition_Pruefplan.Rows
|
||||
cb.Items.Add(r.Item("Bezeichnung"), True)
|
||||
Next
|
||||
'cb.DataSource = Definition_Pruefplan
|
||||
'cb.ValueMember = "Definition_PruefplanNr"
|
||||
'cb.DisplayMember = "Bezeichnung"
|
||||
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
|
||||
|
||||
Public Function Add_new_Zuordnung(ByVal Pruefplannr As Integer, DefinitionNr As Integer, nodetext As String, ByRef chkcb As CheckedListBox)
|
||||
For Each r As DataRow In Me.Definition_Pruefplan.Rows
|
||||
If r.Item(1) = DefinitionNr Then
|
||||
MsgBox("Die Beziehung zu '" + nodetext + "' ist bereits vorhanden", vbExclamation)
|
||||
Exit Function
|
||||
End If
|
||||
Next
|
||||
Dim dr As DataRow = Me.Definition_Pruefplan.NewRow
|
||||
dr.Item(1) = DefinitionNr
|
||||
dr.Item(2) = Pruefplannr
|
||||
dr.Item(3) = "31.12.2099"
|
||||
dr.Item(4) = True
|
||||
dr.Item(5) = Now
|
||||
dr.Item(6) = Now
|
||||
dr.Item(7) = Globals.clsmitarbeiter.iMitarbeiternr.Value
|
||||
dr.Item(8) = nodetext
|
||||
Me.Definition_Pruefplan.Rows.Add(dr)
|
||||
chkcb.Items.Add(nodetext + " | " + dr.Item(3).ToString, True)
|
||||
|
||||
End Function
|
||||
|
||||
Public Function Get_Definition_Pruefplan(ByVal Key As Integer, ByRef tree As AdvTree.AdvTree)
|
||||
Me.Definition_Pruefplan.Rows.Clear()
|
||||
Try
|
||||
Dim connection As New SqlConnection()
|
||||
Dim da As New SqlDataAdapter("", connection)
|
||||
Dim sqlcmd As New SqlCommand
|
||||
|
||||
sqlcmd.CommandText = "sp_get_definition_pruefplan"
|
||||
sqlcmd.Parameters.Add(New SqlParameter("@pruefplannr", 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(Me.Definition_Pruefplan)
|
||||
Set_Zuordnungnodes(Definition_Pruefplan, tree)
|
||||
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
|
||||
Public Function Add_new_Zuordnung(ByVal Pruefplannr As Integer, DefinitionNr As Integer, nodetext As String, ByRef tree As AdvTree.AdvTree)
|
||||
For Each r As DataRow In Me.Definition_Pruefplan.Rows
|
||||
If r.Item(1) = DefinitionNr And (r(4) = True Or r(3) < Now) Then
|
||||
MsgBox("Die Beziehung zu '" + nodetext + "' ist bereits vorhanden", vbExclamation)
|
||||
Exit Function
|
||||
End If
|
||||
Next
|
||||
Dim dr As DataRow = Me.Definition_Pruefplan.NewRow
|
||||
dr.Item(0) = Format(Now, "ddhhmmss")
|
||||
dr.Item(1) = DefinitionNr
|
||||
dr.Item(2) = Pruefplannr
|
||||
dr.Item(3) = "31.12.2099"
|
||||
dr.Item(4) = True
|
||||
dr.Item(5) = Now
|
||||
dr.Item(6) = Now
|
||||
dr.Item(7) = Globals.clsmitarbeiter.iMitarbeiternr.Value
|
||||
dr.Item(8) = nodetext
|
||||
Me.Definition_Pruefplan.Rows.Add(dr)
|
||||
|
||||
Set_Zuordnungnodes(Definition_Pruefplan, tree)
|
||||
End Function
|
||||
|
||||
Sub Set_Zuordnungnodes(data As DataTable, ByRef tree As AdvTree.AdvTree)
|
||||
tree.Nodes.Clear()
|
||||
For Each r As DataRow In data.Rows
|
||||
Dim tn As New AdvTree.Node
|
||||
tn.Tag = r(0)
|
||||
tn.Text = r(8)
|
||||
tree.Nodes.Add(tn)
|
||||
Dim tn1 As New AdvTree.Node
|
||||
tn1.Text = r(3)
|
||||
tn1.Tag = r(4)
|
||||
tn.Nodes.Add(tn1)
|
||||
tn.ImageIndex = 0
|
||||
If r(3) < "31.12.2099" And r(3) > Now Then tn.ImageIndex = 3
|
||||
If r(3) < Now Then tn.ImageIndex = 2
|
||||
If r(4) = False Then tn.ImageIndex = 1
|
||||
|
||||
Next
|
||||
|
||||
End Sub
|
||||
|
||||
Public Sub Update_Zuordnung(ByVal ID As Integer, Aktiv As Boolean, gueltig As DateTime)
|
||||
For Each r As DataRow In Me.Definition_Pruefplan.Rows
|
||||
If r.Item(0) = ID Then
|
||||
r(4) = Aktiv
|
||||
r(3) = gueltig
|
||||
End If
|
||||
Next
|
||||
End Sub
|
||||
|
||||
Public Function Save_Definition_Pruefplan(ByRef tree As AdvTree.AdvTree)
|
||||
|
||||
clsDefinition_Pruefplan.sConnectionString = Globals.sConnectionString
|
||||
For Each n As AdvTree.Node In tree.Nodes
|
||||
For Each r As DataRow In Definition_Pruefplan.Rows
|
||||
If r(0) = n.Tag Then
|
||||
If r(0) > 100000 Then
|
||||
clsDefinition_Pruefplan.iDefinitionNr = New SqlInt32(CType(r(1), Int32))
|
||||
clsDefinition_Pruefplan.iPruefplanNr = New SqlInt32(CType(r(2), Int32))
|
||||
clsDefinition_Pruefplan.daGueltig_Bis = New SqlDateTime(CType(r(3), DateTime))
|
||||
clsDefinition_Pruefplan.daErstellt_am = New SqlDateTime(CType(Now, DateTime))
|
||||
clsDefinition_Pruefplan.daMutiert_am = New SqlDateTime(CType(Now, DateTime))
|
||||
clsDefinition_Pruefplan.bAktiv = New SqlBoolean(CType(True, Boolean))
|
||||
clsDefinition_Pruefplan.iMutierer = New SqlInt32(CType(Globals.clsmitarbeiter.iMitarbeiternr.Value, Int32))
|
||||
conn.OpenConnection()
|
||||
clsDefinition_Pruefplan.Insert()
|
||||
conn.CloseConnection(True)
|
||||
Else
|
||||
clsDefinition_Pruefplan.iDefinition_PruefplanNr = New SqlInt32(CType(r(0), Int32))
|
||||
clsDefinition_Pruefplan.cpMainConnectionProvider = Globals.conn
|
||||
clsDefinition_Pruefplan.SelectOne()
|
||||
Dim tn1 As New AdvTree.Node
|
||||
tn1 = n.Nodes(0)
|
||||
If tn1.Tag <> clsDefinition_Pruefplan.bAktiv.Value Or tn1.Text <> clsDefinition_Pruefplan.daGueltig_Bis.Value Then
|
||||
clsDefinition_Pruefplan.iDefinition_PruefplanNr = New SqlInt32(CType(r(0), Int32))
|
||||
clsDefinition_Pruefplan.cpMainConnectionProvider = Globals.conn
|
||||
clsDefinition_Pruefplan.SelectOne()
|
||||
clsDefinition_Pruefplan.iDefinitionNr = New SqlInt32(CType(r(1), Int32))
|
||||
clsDefinition_Pruefplan.iPruefplanNr = New SqlInt32(CType(r(2), Int32))
|
||||
clsDefinition_Pruefplan.daGueltig_Bis = New SqlDateTime(CType(r(3), DateTime))
|
||||
clsDefinition_Pruefplan.daErstellt_am = New SqlDateTime(CType(Now, DateTime))
|
||||
clsDefinition_Pruefplan.daMutiert_am = New SqlDateTime(CType(Now, DateTime))
|
||||
clsDefinition_Pruefplan.bAktiv = New SqlBoolean(CType(tn1.Tag, Boolean))
|
||||
clsDefinition_Pruefplan.iMutierer = New SqlInt32(CType(Globals.clsmitarbeiter.iMitarbeiternr.Value, Int32))
|
||||
conn.OpenConnection()
|
||||
clsDefinition_Pruefplan.Update()
|
||||
conn.CloseConnection(True)
|
||||
End If
|
||||
|
||||
|
||||
End If
|
||||
End If
|
||||
|
||||
Next
|
||||
Next
|
||||
|
||||
End Function
|
||||
|
||||
End Class
|
||||
|
||||
Public Class clsPlanTree
|
||||
|
||||
#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
|
||||
|
||||
#End Region
|
||||
|
||||
#Region "Tree"
|
||||
|
||||
Public Sub Load_Treeview(ByRef tree As DevComponents.AdvTree.AdvTree)
|
||||
tree.Nodes.Clear()
|
||||
TreeaufbauNr = -1
|
||||
Load_Treedata("")
|
||||
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_PruefplanStruktur"
|
||||
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
|
||||
|
||||
|
||||
|
||||
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()
|
||||
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
|
||||
|
||||
|
||||
|
||||
|
||||
#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
|
||||
|
||||
|
||||
|
||||
End Class
|
||||
Reference in New Issue
Block a user