You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
420 lines
16 KiB
420 lines
16 KiB
Imports System
|
|
Imports System.Data
|
|
Imports System.Data.SqlTypes
|
|
Imports System.Data.SqlClient
|
|
Imports C1.Win.C1TrueDBGrid
|
|
Namespace TKB.VV.SLA
|
|
|
|
''' <summary>
|
|
''' Laden der Daten für die SLA-Katalogverwaltung
|
|
''' </summary>
|
|
''' <remarks></remarks>
|
|
Public Class clsSLAKatalogdaten
|
|
Inherits TKB.VV.Sysadmin.DomainTable
|
|
|
|
Sub New(ByVal tblname As String)
|
|
MyBase.New(tblname)
|
|
End Sub
|
|
|
|
Public Overrides Sub Load_Data()
|
|
Tabledata.Tables.Clear()
|
|
Dim selectcommand As New SqlCommand
|
|
Dim connection As New SqlConnection()
|
|
Dim da As New SqlDataAdapter("", connection)
|
|
|
|
selectcommand.CommandText = Me.Select_Proc & "_Level"
|
|
selectcommand.Parameters.Add("@Mitarbeiternr", SqlDbType.Int, 4)
|
|
selectcommand.Parameters.Add("@iErrorCode", SqlDbType.Int, 4)
|
|
selectcommand.Parameters(0).Value = Globals.clsmitarbeiter.iMitarbeiternr.Value
|
|
selectcommand.Parameters(1).Value = 0
|
|
|
|
selectcommand.CommandType = CommandType.StoredProcedure
|
|
selectcommand.Connection = connection
|
|
Try
|
|
connection.ConnectionString = Globals.sConnectionString
|
|
connection.Open()
|
|
da.SelectCommand = selectcommand
|
|
da.Fill(Tabledata, "Domaintable")
|
|
Catch ex As Exception
|
|
Finally
|
|
connection.Close()
|
|
da.Dispose()
|
|
selectcommand.Dispose()
|
|
End Try
|
|
End Sub
|
|
|
|
|
|
End Class
|
|
|
|
''' <summary>
|
|
''' TreeDatenklasse für den Servicekatalog-Tree
|
|
''' </summary>
|
|
''' <remarks></remarks>
|
|
'''
|
|
|
|
Public Class clsServiceKatalogTree
|
|
|
|
Dim Treedata As New DataSet
|
|
Public fnt_Strikeout As Font
|
|
Public fnt_normal As Font
|
|
''' <summary>
|
|
''' Laden der Treedaten und Tree aufbauen
|
|
''' </summary>
|
|
''' <param name="tree"></param>
|
|
''' <returns></returns>
|
|
''' <remarks></remarks>
|
|
Public Function Load_Tree(ByRef tree As TreeView, Optional ByVal CheckState As Integer = 0)
|
|
Load_Treedata(CheckState)
|
|
tree.Nodes.Clear()
|
|
Load_Treeview(Treedata, tree)
|
|
|
|
tree.ExpandAll()
|
|
End Function
|
|
''' <summary>
|
|
''' Treedaten ab Datenbank laden
|
|
''' </summary>
|
|
''' <returns></returns>
|
|
''' <remarks></remarks>
|
|
Private Function Load_Treedata(ByVal Checkstate) As DataTable
|
|
Treedata.Tables.Clear()
|
|
Dim selectcommand As New SqlCommand
|
|
Dim connection As New SqlConnection()
|
|
Dim da As New SqlDataAdapter("", connection)
|
|
|
|
selectcommand.CommandText = "my_servicekatalog_struktur"
|
|
selectcommand.Parameters.Add("@Mitarbeiternr", SqlDbType.Int, 4)
|
|
selectcommand.Parameters.Add("@CheckState", SqlDbType.Int, 4)
|
|
selectcommand.Parameters(0).Value = Globals.clsmitarbeiter.iMitarbeiternr.Value
|
|
selectcommand.Parameters(1).Value = Checkstate
|
|
|
|
selectcommand.CommandType = CommandType.StoredProcedure
|
|
selectcommand.Connection = connection
|
|
Try
|
|
connection.ConnectionString = Globals.sConnectionString
|
|
connection.Open()
|
|
da.SelectCommand = selectcommand
|
|
da.Fill(Treedata, "Tree")
|
|
Catch ex As Exception
|
|
Finally
|
|
connection.Close()
|
|
da.Dispose()
|
|
selectcommand.Dispose()
|
|
End Try
|
|
End Function
|
|
|
|
''' <summary>
|
|
''' Interne Relation aufbauen und Tree aufbauen
|
|
''' </summary>
|
|
''' <param name="oSourceData"></param>
|
|
''' <param name="tree"></param>
|
|
''' <remarks></remarks>
|
|
Private Sub Load_Treeview(ByVal oSourceData As DataSet, ByRef tree As TreeView)
|
|
If Not (oSourceData Is Nothing) Then
|
|
Dim oView As DataView = oSourceData.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("Servicekatalognr"), _
|
|
oDS.Tables(0).Columns("Parentid"))
|
|
End If
|
|
oTable.Dispose()
|
|
oTable = Nothing
|
|
LoadTreeView(oDS, tree)
|
|
oDS.Dispose()
|
|
oDS = Nothing
|
|
End If
|
|
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 TreeView)
|
|
'Dim oTreeView As TreeView = New TreeView()
|
|
Dim oDataRow As DataRow
|
|
fnt_Strikeout = New System.Drawing.Font(oTreeview.Font.FontFamily, oTreeview.Font.Size, FontStyle.Strikeout)
|
|
fnt_normal = New System.Drawing.Font(oTreeview.Font.FontFamily, oTreeview.Font.Size, FontStyle.Regular)
|
|
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 TreeNode()
|
|
oNode.Text = oDataRow("Bezeichnung").ToString()
|
|
oNode.Tag = oDataRow("Servicekatalognr").ToString
|
|
oNode.SelectedImageIndex = 0
|
|
oNode.StateImageIndex = 0
|
|
oNode.ImageIndex = 0
|
|
If oDataRow("Aktiv") = False Then
|
|
oNode.NodeFont = fnt_Strikeout
|
|
End If
|
|
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 TreeNode)
|
|
Dim oChildRow As DataRow
|
|
For Each oChildRow In oDataRow.GetChildRows("SelfRefenceRelation")
|
|
Dim oChildNode As New TreeNode()
|
|
oChildNode.Text = oChildRow("Bezeichnung").ToString()
|
|
oChildNode.Tag = oChildRow("Servicekatalognr").ToString()
|
|
If oChildRow("Aktiv") = False Then
|
|
oChildNode.NodeFont = fnt_Strikeout
|
|
End If
|
|
|
|
oNode.Nodes.Add(oChildNode)
|
|
RecursivelyLoadTree(oChildRow, oChildNode)
|
|
Next oChildRow
|
|
End Sub
|
|
''' <summary>
|
|
''' Images auf den Nodes des TreeVies setzen
|
|
''' </summary>
|
|
''' <param name="tree"></param>
|
|
''' <returns></returns>
|
|
''' <remarks></remarks>
|
|
Public Function Set_Images(ByRef tree As TreeView)
|
|
Dim tn As TreeNode
|
|
For Each tn In tree.Nodes
|
|
If tn.Nodes.Count > 0 Then
|
|
tn.ImageIndex = 0
|
|
tn.StateImageIndex = 0
|
|
tn.SelectedImageIndex = 0
|
|
Else
|
|
tn.ImageIndex = 1
|
|
tn.StateImageIndex = 1
|
|
tn.SelectedImageIndex = 1
|
|
End If
|
|
RecurseNodes(tn.Nodes)
|
|
Next
|
|
End Function
|
|
''' <summary>
|
|
''' Nodes rekursiv lesen
|
|
''' </summary>
|
|
''' <param name="Node"></param>
|
|
''' <returns></returns>
|
|
''' <remarks></remarks>
|
|
Private Function RecurseNodes(ByVal Node As TreeNodeCollection)
|
|
For Each tn As TreeNode In Node
|
|
If tn.Nodes.Count > 0 Then
|
|
tn.ImageIndex = 0
|
|
tn.StateImageIndex = 0
|
|
tn.SelectedImageIndex = 0
|
|
Else
|
|
tn.ImageIndex = 1
|
|
tn.StateImageIndex = 1
|
|
tn.SelectedImageIndex = 1
|
|
End If
|
|
RecurseNodes(tn.Nodes)
|
|
Next
|
|
End Function
|
|
|
|
End Class
|
|
|
|
Public Class clsServiceKatalogDaten
|
|
Inherits TKB.VV.DB.clsServiceKatalog
|
|
Public Vertragsbeziehungen As TKB.VV.Sysadmin.DomainTable
|
|
|
|
Public Function Insert_Katalogelement(ByVal Katalogname As String, ByVal parentid As String)
|
|
Dim dbkey As New TKB.VV.DB.clsMyKey_Tabelle
|
|
dbkey.cpMainConnectionProvider = Globals.conn
|
|
Dim newkey = dbkey.get_dbkey("Servicekatalog")
|
|
|
|
Me.iServiceKatalogNr = New SqlInt32(CType(newkey, Int32))
|
|
Me.iMandantnr = New SqlInt32(CType(Globals.clsmitarbeiter.iMandantnr.Value, Int32))
|
|
Me.iMutierer = New SqlInt32(CType(Globals.clsmitarbeiter.iMitarbeiternr.Value, Int32))
|
|
Me.daErstellt_am = New SqlDateTime(CType(Now, DateTime))
|
|
Me.daMutiert_am = New SqlDateTime(CType(Now, DateTime))
|
|
Me.bAktiv = New SqlBoolean(CType(True, Boolean))
|
|
Me.bExtern = New SqlBoolean(CType(False, Boolean))
|
|
Me.sBemerkung = New SqlString(CType("", String))
|
|
Me.sBezeichnung_intern = New SqlString(CType(Katalogname, String))
|
|
Me.sBezeichnung_extern = New SqlString(CType(Katalogname, String))
|
|
Me.iParentID = New SqlInt32(CType(parentid, Int32))
|
|
Me.iSecurityLevelNr = New SqlInt32(CType(0, Int32))
|
|
Me.cpMainConnectionProvider = Globals.conn
|
|
Globals.conn.OpenConnection()
|
|
Me.Insert()
|
|
Globals.conn.CloseConnection(True)
|
|
End Function
|
|
|
|
Public Function Save_Data()
|
|
Globals.conn.OpenConnection()
|
|
Me.Update()
|
|
Globals.conn.CloseConnection(True)
|
|
End Function
|
|
|
|
Public Function Get_Data(ByVal Servicekatalognr As Integer)
|
|
Me.cpMainConnectionProvider = Globals.conn
|
|
Globals.conn.OpenConnection()
|
|
Me.iServiceKatalogNr = New SqlInt32(CType(Servicekatalognr, Int32))
|
|
Me.SelectOne()
|
|
Globals.conn.CloseConnection(True)
|
|
End Function
|
|
|
|
Public Function Delete_Servicekatalog(Optional ByVal basenr As Integer = 0)
|
|
If basenr <> 0 Then
|
|
Get_Data(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)
|
|
End Function
|
|
|
|
''' <summary>
|
|
''' Services / Vertragsleistungen auslesen und dem Truedbgrid übergeben.
|
|
''' Ist im Feld Termin der Wert "01.01.1900" wird dieser durch NULL ersetzt
|
|
''' </summary>
|
|
''' <param name="c1data">TruedbGrid</param>
|
|
''' <param name="Vertragselementnr">Vertragselement, für welches die Dokumente ausgelesen werden</param>
|
|
''' <returns></returns>
|
|
''' <remarks></remarks>
|
|
Public Function Get_Vertragsbeziehungen(ByRef c1data As C1TrueDBGrid, ByVal ServiceKatalogNr As Integer)
|
|
Vertragsbeziehungen = New TKB.VV.Sysadmin.DomainTable("Vertragsleistung", 1, Trim(Str(ServiceKatalogNr)), Globals.clsmitarbeiter.iMitarbeiternr.Value)
|
|
Dim i As Integer = 0
|
|
c1data.DataSource = Vertragsbeziehungen.Tabledata
|
|
c1data.DataMember = Vertragsbeziehungen.Tabledata.Tables(0).TableName
|
|
End Function
|
|
|
|
End Class
|
|
|
|
''' <summary>
|
|
''' TreeDatenklasse für den Servicekatalog-Tree
|
|
''' </summary>
|
|
''' <remarks></remarks>
|
|
'''
|
|
Public Class clsServiceKatalogSLATree
|
|
Dim Treedata As New DataSet
|
|
''' <summary>
|
|
''' Laden der Treedaten und Tree aufbauen
|
|
''' </summary>
|
|
''' <param name="tree"></param>
|
|
''' <returns></returns>
|
|
''' <remarks></remarks>
|
|
Public Function Load_Tree(ByRef tree As TreeView)
|
|
tree.Enabled = False
|
|
Load_Treedata()
|
|
tree.Nodes.Clear()
|
|
LoadTreeView(Treedata, tree)
|
|
tree.ExpandAll()
|
|
tree.Enabled = True
|
|
End Function
|
|
''' <summary>
|
|
''' Treedaten ab Datenbank laden
|
|
''' </summary>
|
|
''' <returns></returns>
|
|
''' <remarks></remarks>
|
|
Private Function Load_Treedata() As DataTable
|
|
Dim selectcommand As New SqlCommand
|
|
Dim connection As New SqlConnection()
|
|
Dim da As New SqlDataAdapter("", connection)
|
|
|
|
selectcommand.CommandText = "my_servicekatalog_sla_struktur"
|
|
selectcommand.Parameters.Add("@Mitarbeiternr", SqlDbType.Int, 4)
|
|
selectcommand.Parameters(0).Value = Globals.clsmitarbeiter.iMitarbeiternr.Value
|
|
|
|
selectcommand.CommandType = CommandType.StoredProcedure
|
|
selectcommand.Connection = connection
|
|
Try
|
|
connection.ConnectionString = Globals.sConnectionString
|
|
connection.Open()
|
|
da.SelectCommand = selectcommand
|
|
da.Fill(Treedata, "Tree")
|
|
Catch ex As Exception
|
|
Finally
|
|
connection.Close()
|
|
da.Dispose()
|
|
selectcommand.Dispose()
|
|
End Try
|
|
End Function
|
|
|
|
Private Function LoadTreeView(ByVal ds As DataSet, ByRef tree As TreeView)
|
|
Dim sroot As String = ""
|
|
Dim tchild As New TreeNode
|
|
Dim tchild1 As New TreeNode
|
|
Dim i As Integer
|
|
For i = 0 To ds.Tables(0).Rows.Count - 1
|
|
If sroot <> ds.Tables(0).Rows(i).Item(1) Then
|
|
tchild = tree.Nodes.Add(ds.Tables(0).Rows(i).Item(1))
|
|
tchild.Tag = 0
|
|
sroot = ds.Tables(0).Rows(i).Item(1)
|
|
End If
|
|
tchild1 = tchild.Nodes.Add(ds.Tables(0).Rows(i).Item(2))
|
|
tchild1.Tag = ds.Tables(0).Rows(i).Item(0)
|
|
Next
|
|
End Function
|
|
|
|
Public Function Set_Images(ByRef tree As TreeView)
|
|
Dim tn As TreeNode
|
|
For Each tn In tree.Nodes
|
|
MsgBox(tn.Parent.Text)
|
|
If tn.Nodes.Count > 0 Then
|
|
tn.ImageIndex = 1
|
|
tn.SelectedImageIndex = 2
|
|
Else
|
|
tn.ImageIndex = 3
|
|
End If
|
|
RecurseNodes(tn.Nodes)
|
|
Next
|
|
End Function
|
|
|
|
Private Function RecurseNodes(ByVal Node As TreeNodeCollection)
|
|
For Each tn As TreeNode In Node
|
|
If tn.Nodes.Count > 0 Then
|
|
tn.ImageIndex = 1
|
|
tn.SelectedImageIndex = 2
|
|
Else
|
|
tn.ImageIndex = 3
|
|
End If
|
|
RecurseNodes(tn.Nodes)
|
|
Next
|
|
End Function
|
|
End Class
|
|
|
|
Public Class clsSLA
|
|
Inherits TKB.VV.DB.clsSLA
|
|
|
|
Overloads Sub dispose()
|
|
Me.dispose()
|
|
End Sub
|
|
|
|
Public Function SelectAll_Active() As DataTable
|
|
Dim scmCmdToExecute As SqlCommand = New SqlCommand()
|
|
Dim dtToReturn As DataTable = New DataTable()
|
|
Dim sdaAdapter As SqlDataAdapter = New SqlDataAdapter(scmCmdToExecute)
|
|
scmCmdToExecute.CommandText = "dbo.pr_sla_selectall_active"
|
|
scmCmdToExecute.CommandType = CommandType.StoredProcedure
|
|
scmCmdToExecute.Connection = conn.scoDBConnection
|
|
Try
|
|
sdaAdapter.Fill(dtToReturn)
|
|
Return dtToReturn
|
|
Catch ex As Exception
|
|
' // some error occured. Bubble it to caller and encapsulate Exception object
|
|
Throw New Exception("clsSlaKatalogDaten::SLA::" & scmCmdToExecute.CommandText & "::Error occured." & ex.Message, ex)
|
|
Finally
|
|
scmCmdToExecute.Dispose()
|
|
sdaAdapter.Dispose()
|
|
End Try
|
|
End Function
|
|
|
|
|
|
End Class
|
|
End Namespace
|