Initial commit
This commit is contained in:
@@ -0,0 +1,466 @@
|
||||
Imports System
|
||||
Imports System.Data
|
||||
Imports System.Data.SqlTypes
|
||||
Imports System.Data.SqlClient
|
||||
Imports DevComponents
|
||||
Imports DropDownControls
|
||||
|
||||
Public Class clsMassnahmeplan
|
||||
Inherits DB.clsMassnahmeplan
|
||||
|
||||
#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 Verantwortung As New DataTable
|
||||
Dim stammdaten As New DB.clsStammdaten
|
||||
Dim SpaltenTitel As New Utils.Tabellenspalte
|
||||
|
||||
Dim Definition_Massnahmeplan As New DataTable
|
||||
Dim clsDefinition_Massnahmeplan As New DB.clsDefinition_massnahmeplan
|
||||
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")
|
||||
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_Massnahmeplan.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.iMassnahmeplanNr = 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("Massnahmeplan")
|
||||
db.Dispose()
|
||||
|
||||
Me.cpMainConnectionProvider = Globals.conn
|
||||
Me.iMassnahmeplanNr = 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("massnahmeplan")
|
||||
db.Dispose()
|
||||
Me.iMassnahmeplanNr = 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.iMassnahmeplanNr.Value
|
||||
End Function
|
||||
|
||||
Public Function Get_massnahmeplan(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_massnahmenplan"
|
||||
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, "massnahmeplan", 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_massnahmeplan"
|
||||
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, "massnahmeplan", 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_Massnahmeplan(ByVal Key As Integer, ByRef cb As CheckedListBox)
|
||||
Me.Definition_Massnahmeplan.Rows.Clear()
|
||||
Try
|
||||
Dim connection As New SqlConnection()
|
||||
Dim da As New SqlDataAdapter("", connection)
|
||||
Dim sqlcmd As New SqlCommand
|
||||
|
||||
sqlcmd.CommandText = "sp_get_definition_Massnahmeplan"
|
||||
sqlcmd.Parameters.Add(New SqlParameter("@massnahmeplannr", 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_Massnahmeplan)
|
||||
|
||||
For Each r As DataRow In Definition_Massnahmeplan.Rows
|
||||
cb.Items.Add(r.Item("Bezeichnung"), True)
|
||||
Next
|
||||
'cb.DataSource = Definition_massnahmeplan
|
||||
'cb.ValueMember = "Definition_massnahmeplanNr"
|
||||
'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 massnahmeplannr As Integer, DefinitionNr As Integer, nodetext As String, ByRef chkcb As CheckedListBox)
|
||||
For Each r As DataRow In Me.Definition_Massnahmeplan.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_Massnahmeplan.NewRow
|
||||
dr.Item(1) = DefinitionNr
|
||||
dr.Item(2) = massnahmeplannr
|
||||
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_Massnahmeplan.Rows.Add(dr)
|
||||
chkcb.Items.Add(nodetext + " | " + dr.Item(3).ToString, True)
|
||||
|
||||
End Function
|
||||
|
||||
Public Function Get_Definition_massnahmeplan(ByVal Key As Integer, ByRef tree As AdvTree.AdvTree)
|
||||
Me.Definition_Massnahmeplan.Rows.Clear()
|
||||
Try
|
||||
Dim connection As New SqlConnection()
|
||||
Dim da As New SqlDataAdapter("", connection)
|
||||
Dim sqlcmd As New SqlCommand
|
||||
|
||||
sqlcmd.CommandText = "sp_get_definition_massnahmeplan"
|
||||
sqlcmd.Parameters.Add(New SqlParameter("@massnahmeplannr", 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_Massnahmeplan)
|
||||
Set_Zuordnungnodes(Definition_Massnahmeplan, 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 Massnahmeplannr As Integer, DefinitionNr As Integer, nodetext As String, ByRef tree As AdvTree.AdvTree)
|
||||
For Each r As DataRow In Me.Definition_Massnahmeplan.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_Massnahmeplan.NewRow
|
||||
dr.Item(0) = Format(Now, "ddhhmmss")
|
||||
dr.Item(1) = DefinitionNr
|
||||
dr.Item(2) = Massnahmeplannr
|
||||
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_Massnahmeplan.Rows.Add(dr)
|
||||
|
||||
Set_Zuordnungnodes(Definition_Massnahmeplan, 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_Massnahmeplan.Rows
|
||||
If r.Item(0) = ID Then
|
||||
r(4) = Aktiv
|
||||
r(3) = gueltig
|
||||
End If
|
||||
Next
|
||||
End Sub
|
||||
|
||||
Public Function Save_Definition_massnahmeplan(ByRef tree As AdvTree.AdvTree)
|
||||
|
||||
clsDefinition_Massnahmeplan.sConnectionString = Globals.sConnectionString
|
||||
For Each n As AdvTree.Node In tree.Nodes
|
||||
For Each r As DataRow In Definition_Massnahmeplan.Rows
|
||||
If r(0) = n.Tag Then
|
||||
If r(0) > 100000 Then
|
||||
clsDefinition_Massnahmeplan.iDefinitionNr = New SqlInt32(CType(r(1), Int32))
|
||||
clsDefinition_Massnahmeplan.imassnahmeplanNr = New SqlInt32(CType(r(2), Int32))
|
||||
clsDefinition_Massnahmeplan.daGueltig_Bis = New SqlDateTime(CType(r(3), DateTime))
|
||||
clsDefinition_Massnahmeplan.daErstellt_am = New SqlDateTime(CType(Now, DateTime))
|
||||
clsDefinition_Massnahmeplan.daMutiert_am = New SqlDateTime(CType(Now, DateTime))
|
||||
clsDefinition_Massnahmeplan.bAktiv = New SqlBoolean(CType(True, Boolean))
|
||||
clsDefinition_Massnahmeplan.iMutierer = New SqlInt32(CType(Globals.clsmitarbeiter.iMitarbeiternr.Value, Int32))
|
||||
conn.OpenConnection()
|
||||
clsDefinition_Massnahmeplan.Insert()
|
||||
conn.CloseConnection(True)
|
||||
Else
|
||||
clsDefinition_Massnahmeplan.iDefinition_massnahmeplanNr = New SqlInt32(CType(r(0), Int32))
|
||||
clsDefinition_Massnahmeplan.cpMainConnectionProvider = Globals.conn
|
||||
clsDefinition_Massnahmeplan.SelectOne()
|
||||
Dim tn1 As New AdvTree.Node
|
||||
tn1 = n.Nodes(0)
|
||||
If tn1.Tag <> clsDefinition_Massnahmeplan.bAktiv.Value Or tn1.Text <> clsDefinition_Massnahmeplan.daGueltig_Bis.Value Then
|
||||
clsDefinition_Massnahmeplan.iDefinition_massnahmeplanNr = New SqlInt32(CType(r(0), Int32))
|
||||
clsDefinition_Massnahmeplan.cpMainConnectionProvider = Globals.conn
|
||||
clsDefinition_Massnahmeplan.SelectOne()
|
||||
clsDefinition_Massnahmeplan.iDefinitionNr = New SqlInt32(CType(r(1), Int32))
|
||||
clsDefinition_Massnahmeplan.imassnahmeplanNr = New SqlInt32(CType(r(2), Int32))
|
||||
clsDefinition_Massnahmeplan.daGueltig_Bis = New SqlDateTime(CType(r(3), DateTime))
|
||||
clsDefinition_Massnahmeplan.daErstellt_am = New SqlDateTime(CType(Now, DateTime))
|
||||
clsDefinition_Massnahmeplan.daMutiert_am = New SqlDateTime(CType(Now, DateTime))
|
||||
clsDefinition_Massnahmeplan.bAktiv = New SqlBoolean(CType(tn1.Tag, Boolean))
|
||||
clsDefinition_Massnahmeplan.iMutierer = New SqlInt32(CType(Globals.clsmitarbeiter.iMitarbeiternr.Value, Int32))
|
||||
conn.OpenConnection()
|
||||
clsDefinition_Massnahmeplan.Update()
|
||||
conn.CloseConnection(True)
|
||||
End If
|
||||
|
||||
|
||||
End If
|
||||
End If
|
||||
|
||||
Next
|
||||
Next
|
||||
|
||||
End Function
|
||||
|
||||
End Class
|
||||
Binary file not shown.
@@ -0,0 +1,343 @@
|
||||
Imports C1.Win.C1TrueDBGrid
|
||||
Imports System
|
||||
Imports System.Data
|
||||
Imports System.Data.SqlTypes
|
||||
Imports System.Data.SqlClient
|
||||
Imports System.Windows.Forms
|
||||
|
||||
Namespace TKB.Auswertung
|
||||
Public Class clsAuswertung
|
||||
|
||||
Private Auswertungen As New DataSet
|
||||
Private Mitarbeiter_Auswerungsparameter As New DB.clsMitarbeiter_Auswertungsparameter
|
||||
Public AuswertungParameter As New DataTable
|
||||
Public Auswertung As New DB.clsAuswertung
|
||||
Public MitarbeiterAuswertungsparameter As New DataTable
|
||||
Dim sheader1 As String
|
||||
Property TitelZeile1() As String
|
||||
Get
|
||||
Return sheader1
|
||||
End Get
|
||||
Set(ByVal value As String)
|
||||
sheader1 = value
|
||||
End Set
|
||||
End Property
|
||||
Dim sheader2 As String
|
||||
Property TitelZeile2() As String
|
||||
Get
|
||||
Return sheader2
|
||||
End Get
|
||||
Set(ByVal value As String)
|
||||
sheader2 = value
|
||||
End Set
|
||||
End Property
|
||||
Dim scparamcollection As New Collection
|
||||
Property ParamCollection() As Collection
|
||||
Get
|
||||
Return scparamcollection
|
||||
End Get
|
||||
Set(ByVal value As Collection)
|
||||
scparamcollection = value
|
||||
End Set
|
||||
End Property
|
||||
Dim mFullparam As String
|
||||
Property FullParam() As String
|
||||
Get
|
||||
Return mFullparam
|
||||
End Get
|
||||
Set(ByVal value As String)
|
||||
mFullparam = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Public Sub Get_Auswertungen(ByRef tree As TreeView)
|
||||
Read_Auswertungen()
|
||||
Load_Treeview(Auswertungen, tree)
|
||||
End Sub
|
||||
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' Auswertungen, für welche der User berechtigt ist, auslesen
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
''' <remarks></remarks>
|
||||
Private Function Read_Auswertungen() As DataTable
|
||||
Dim scmCmdToExecute As SqlCommand = New SqlCommand()
|
||||
Dim dtToReturn As DataTable = New DataTable()
|
||||
Dim sdaAdapter As SqlDataAdapter = New SqlDataAdapter(scmCmdToExecute)
|
||||
scmCmdToExecute.CommandText = "dbo.sp_Auswertung_Get_Auswertungen"
|
||||
scmCmdToExecute.CommandType = CommandType.StoredProcedure
|
||||
scmCmdToExecute.Connection = Globals.conn.scoDBConnection
|
||||
Try
|
||||
scmCmdToExecute.Parameters.Add(New SqlParameter("@mitarbeiternr", SqlDbType.Int, 4, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, Globals.Mitarbeiternr))
|
||||
sdaAdapter.Fill(dtToReturn)
|
||||
Auswertungen.Tables.Clear()
|
||||
Auswertungen.Tables.Add(dtToReturn)
|
||||
Catch ex As Exception
|
||||
Throw New Exception("clsAuswertung::" & scmCmdToExecute.CommandText & "::Error occured." & ex.Message, ex)
|
||||
Finally
|
||||
scmCmdToExecute.Dispose()
|
||||
sdaAdapter.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("id"), _
|
||||
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
|
||||
For Each oDataRow In oDS.Tables(0).Rows
|
||||
If Not oDataRow.IsNull("Parentid") Then
|
||||
If oDataRow.Item("Parentid") = 0 Then
|
||||
Dim oNode As New TreeNode()
|
||||
oNode.Text = oDataRow("Bezeichnung").ToString()
|
||||
oNode.Tag = oDataRow("auswertungnr").ToString
|
||||
oNode.ToolTipText = oDataRow("Beschreibung").ToString
|
||||
oNode.ImageIndex = 0
|
||||
oNode.SelectedImageIndex = 0
|
||||
oNode.StateImageIndex = 0
|
||||
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("Auswertungnr").ToString()
|
||||
If oChildRow("Auswertungnr") = 0 Then
|
||||
oChildNode.ImageIndex = 0
|
||||
oChildNode.SelectedImageIndex = 0
|
||||
oChildNode.StateImageIndex = 0
|
||||
oChildNode.ToolTipText = oChildRow("Beschreibung").ToString
|
||||
Else
|
||||
oChildNode.ImageIndex = 1
|
||||
oChildNode.SelectedImageIndex = 1
|
||||
oChildNode.StateImageIndex = 1
|
||||
oChildNode.ToolTipText = oChildRow("Beschreibung").ToString
|
||||
End If
|
||||
oNode.Nodes.Add(oChildNode)
|
||||
RecursivelyLoadTree(oChildRow, oChildNode)
|
||||
Next oChildRow
|
||||
End Sub
|
||||
|
||||
Public Function Get_Auswertung(ByVal Auswertungnr As Integer) As Boolean
|
||||
Try
|
||||
Me.Auswertung.iAuswertungNr = New SqlInt32(CType(Auswertungnr, Int32))
|
||||
Me.Auswertung.cpMainConnectionProvider = Globals.conn
|
||||
Me.Auswertung.SelectOne()
|
||||
Me.AuswertungParameter = Get_Auswertungsparameter(Me.Auswertung.iAuswertungNr.Value)
|
||||
Me.MitarbeiterAuswertungsparameter = Me.Get_MAParameter(Me.Auswertung.iAuswertungNr.Value)
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
Return False
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function Get_Auswertungsparameter(ByVal Auswertungnr As Integer) As DataTable
|
||||
Dim scmCmdToExecute As SqlCommand = New SqlCommand()
|
||||
Dim dtToReturn As DataTable = New DataTable()
|
||||
Dim sdaAdapter As SqlDataAdapter = New SqlDataAdapter(scmCmdToExecute)
|
||||
scmCmdToExecute.CommandText = "dbo.sp_rpt_get_auswertungparameter"
|
||||
scmCmdToExecute.CommandType = CommandType.StoredProcedure
|
||||
scmCmdToExecute.Connection = conn.scoDBConnection
|
||||
Try
|
||||
scmCmdToExecute.Parameters.Add(New SqlParameter("@Auswertungnr", SqlDbType.VarChar, 50, ParameterDirection.Input, True, 0, 0, "", DataRowVersion.Proposed, Auswertungnr))
|
||||
sdaAdapter.Fill(dtToReturn)
|
||||
Return dtToReturn
|
||||
Catch ex As Exception
|
||||
' // some error occured. Bubble it to caller and encapsulate Exception object
|
||||
Throw New Exception("frmAuswertung::" & scmCmdToExecute.CommandText & "::Error occured." & ex.Message, ex)
|
||||
Finally
|
||||
scmCmdToExecute.Dispose()
|
||||
sdaAdapter.Dispose()
|
||||
End Try
|
||||
|
||||
End Function
|
||||
|
||||
Public Function get_rptparam_values(ByVal sp As String) As DataTable
|
||||
Dim scmCmdToExecute As SqlCommand = New SqlCommand()
|
||||
Dim dtToReturn As DataTable = New DataTable()
|
||||
Dim sdaAdapter As SqlDataAdapter = New SqlDataAdapter(scmCmdToExecute)
|
||||
scmCmdToExecute.CommandText = sp
|
||||
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("frmAuswertung::" & scmCmdToExecute.CommandText & "::Error occured." & ex.Message, ex)
|
||||
Finally
|
||||
scmCmdToExecute.Dispose()
|
||||
sdaAdapter.Dispose()
|
||||
End Try
|
||||
|
||||
End Function
|
||||
|
||||
Public Function Get_Auswertungsdaten(ByVal sql As String, ByVal sqlwhere As String, ByVal sqltype As String) As DataSet
|
||||
Dim scmCmdToExecute As SqlCommand = New SqlCommand()
|
||||
Dim dtToReturn As DataSet = New DataSet()
|
||||
Dim sdaAdapter As SqlDataAdapter = New SqlDataAdapter(scmCmdToExecute)
|
||||
scmCmdToExecute.CommandText = sql
|
||||
Select Case UCase(sqltype)
|
||||
Case "SQL"
|
||||
If sqlwhere <> "" Then sql = sql + " where " + sqlwhere
|
||||
'gaga
|
||||
Case "VIEW"
|
||||
If sqlwhere <> "" Then sql = sql + " where " + sqlwhere
|
||||
Case "SP"
|
||||
scmCmdToExecute.CommandType = CommandType.StoredProcedure
|
||||
scmCmdToExecute.Parameters.Add(New SqlParameter("@sqlwhere", SqlDbType.VarChar, 1024, ParameterDirection.Input, True, 0, 0, "", DataRowVersion.Proposed, sqlwhere))
|
||||
End Select
|
||||
scmCmdToExecute.Connection = conn.scoDBConnection
|
||||
Try
|
||||
'scmCmdToExecute.Parameters.Add(New SqlParameter("@Rolle", SqlDbType.VarChar, 50, ParameterDirection.Output, True, 0, 0, "", DataRowVersion.Proposed, ""))
|
||||
sdaAdapter.Fill(dtToReturn)
|
||||
Return dtToReturn
|
||||
Catch ex As Exception
|
||||
' // some error occured. Bubble it to caller and encapsulate Exception object
|
||||
Throw New Exception("frmAuswertung::" & scmCmdToExecute.CommandText & "::Error occured." & ex.Message, ex)
|
||||
Finally
|
||||
scmCmdToExecute.Dispose()
|
||||
sdaAdapter.Dispose()
|
||||
End Try
|
||||
|
||||
End Function
|
||||
Public Function Get_Auswertungsdaten(ByVal sp As String, ByVal sqlwhere As String, ByVal txp As Boolean) As DataTable
|
||||
|
||||
Dim con As New SqlConnection(Get_TXP_Connection)
|
||||
Dim scmCmdToExecute As SqlCommand = New SqlCommand()
|
||||
Dim dtToReturn As DataTable = New DataTable()
|
||||
Dim sdaAdapter As SqlDataAdapter = New SqlDataAdapter(scmCmdToExecute)
|
||||
scmCmdToExecute.CommandText = sp
|
||||
scmCmdToExecute.CommandType = CommandType.StoredProcedure
|
||||
scmCmdToExecute.Connection = con
|
||||
scmCmdToExecute.CommandTimeout = 30000
|
||||
|
||||
Try
|
||||
scmCmdToExecute.Parameters.Add(New SqlParameter("@sqlwhere", SqlDbType.VarChar, 1024, ParameterDirection.Input, True, 0, 0, "", DataRowVersion.Proposed, sqlwhere))
|
||||
sdaAdapter.Fill(dtToReturn)
|
||||
Return dtToReturn
|
||||
Catch ex As Exception
|
||||
' // some error occured. Bubble it to caller and encapsulate Exception object
|
||||
Throw New Exception("frmAuswertung::" & scmCmdToExecute.CommandText & "::Error occured." & ex.Message, ex)
|
||||
Finally
|
||||
con.Close()
|
||||
scmCmdToExecute.Dispose()
|
||||
sdaAdapter.Dispose()
|
||||
con.Dispose()
|
||||
End Try
|
||||
|
||||
End Function
|
||||
|
||||
Private Function Get_TXP_Connection() As String
|
||||
Dim sCstr As String = ""
|
||||
Dim txpfile As System.IO.File
|
||||
Dim txpread As System.IO.StreamReader
|
||||
txpread = txpfile.OpenText(Application.StartupPath + "\TXPConn.cfg")
|
||||
sCstr = txpread.ReadLine
|
||||
sCstr = Crypto.DecryptText(sCstr, "HutterundMueller")
|
||||
sCstr = Left(sCstr, Len(sCstr) - 1)
|
||||
txpread.Close()
|
||||
|
||||
Return sCstr
|
||||
End Function
|
||||
Public Function Save_MAParameter(ByVal auswertungnr As Integer, ByVal Bezeichnung As String, ByVal Parameter As String, ByVal Titel1 As String, ByVal Titel2 As String, ByVal PrintParam As Boolean, ByVal sqlwhere As String)
|
||||
Me.Mitarbeiter_Auswerungsparameter.cpMainConnectionProvider = Globals.conn
|
||||
Me.Mitarbeiter_Auswerungsparameter.iAuswertungnr = New SqlInt32(CType(auswertungnr, Int32))
|
||||
Me.Mitarbeiter_Auswerungsparameter.iMitarbeiternr = New SqlInt32(CType(Globals.Mitarbeiternr, Int32))
|
||||
Me.Mitarbeiter_Auswerungsparameter.sBeschreibung = New SqlString(CType(Bezeichnung, String))
|
||||
Me.Mitarbeiter_Auswerungsparameter.sParameterdaten = New SqlString(CType(Parameter, String))
|
||||
Me.Mitarbeiter_Auswerungsparameter.sTitelzeile1 = New SqlString(CType(Titel1, String))
|
||||
Me.Mitarbeiter_Auswerungsparameter.sTitelzeile2 = New SqlString(CType(Titel2, String))
|
||||
Me.Mitarbeiter_Auswerungsparameter.sSQLWhere = New SqlString(CType(sqlwhere, String))
|
||||
If PrintParam = True Then
|
||||
Me.Mitarbeiter_Auswerungsparameter.bParamPrint = New SqlBoolean(CType(True, Boolean))
|
||||
Else
|
||||
Me.Mitarbeiter_Auswerungsparameter.bParamPrint = New SqlBoolean(CType(False, Boolean))
|
||||
End If
|
||||
Globals.conn.OpenConnection()
|
||||
Me.Mitarbeiter_Auswerungsparameter.Insert()
|
||||
Globals.conn.CloseConnection(True)
|
||||
Me.MitarbeiterAuswertungsparameter = Me.Get_MAParameter(auswertungnr)
|
||||
End Function
|
||||
|
||||
|
||||
Public Function Get_MAParameter(ByVal Auswertungnr As Integer) As DataTable
|
||||
Dim scmCmdToExecute As SqlCommand = New SqlCommand()
|
||||
Dim dtToReturn As DataTable = New DataTable()
|
||||
Dim sdaAdapter As SqlDataAdapter = New SqlDataAdapter(scmCmdToExecute)
|
||||
scmCmdToExecute.CommandText = "dbo.sp_mitarbeiter_auswertungparamter_selectall"
|
||||
scmCmdToExecute.CommandType = CommandType.StoredProcedure
|
||||
scmCmdToExecute.Connection = conn.scoDBConnection
|
||||
Try
|
||||
scmCmdToExecute.Parameters.Add(New SqlParameter("@mitarbeiternr", SqlDbType.Int, 4, ParameterDirection.Input, True, 0, 0, "", DataRowVersion.Proposed, Globals.Mitarbeiternr))
|
||||
scmCmdToExecute.Parameters.Add(New SqlParameter("@Auswertungnr", SqlDbType.Int, 4, ParameterDirection.Input, True, 0, 0, "", DataRowVersion.Proposed, Auswertungnr))
|
||||
sdaAdapter.Fill(dtToReturn)
|
||||
Return dtToReturn
|
||||
Catch ex As Exception
|
||||
' // some error occured. Bubble it to caller and encapsulate Exception object
|
||||
Throw New Exception("frmAuswertung::" & scmCmdToExecute.CommandText & "::Error occured." & ex.Message, ex)
|
||||
Finally
|
||||
scmCmdToExecute.Dispose()
|
||||
sdaAdapter.Dispose()
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function Delete_Parameter(ByVal AuswertungParameterNr As Integer)
|
||||
Me.Mitarbeiter_Auswerungsparameter.iMitarbeiter_AuswertungsparameterNr = New SqlInt32(CType(AuswertungParameterNr, Int32))
|
||||
Me.Mitarbeiter_Auswerungsparameter.cpMainConnectionProvider = Globals.conn
|
||||
Globals.conn.OpenConnection()
|
||||
Me.Mitarbeiter_Auswerungsparameter.Delete()
|
||||
Globals.conn.CloseConnection(True)
|
||||
Me.MitarbeiterAuswertungsparameter = Me.Get_MAParameter(Me.Auswertung.iAuswertungNr.Value)
|
||||
End Function
|
||||
|
||||
|
||||
End Class
|
||||
|
||||
End Namespace
|
||||
Reference in New Issue
Block a user