Initial commit
This commit is contained in:
11
_MyBeziehungen/Klassen/Globals.vb
Normal file
11
_MyBeziehungen/Klassen/Globals.vb
Normal file
@@ -0,0 +1,11 @@
|
||||
Module Globals
|
||||
Public Spaltendaten As New DataTable
|
||||
Public sConnectionString As String
|
||||
Public conn As New DB.clsConnectionProvider
|
||||
Public ConnectionFileName As String = ""
|
||||
Public Mitarbeiternr As Integer
|
||||
Public TmpFilepath As String
|
||||
Public SecurityDaten As New DataSet
|
||||
Public Objekt As New DataTable
|
||||
Public WithEvents Generic_Event_Handler As New _Generic_Event_Handler.Generic_Event_Handler
|
||||
End Module
|
||||
826
_MyBeziehungen/Klassen/MySecurity.vb
Normal file
826
_MyBeziehungen/Klassen/MySecurity.vb
Normal file
@@ -0,0 +1,826 @@
|
||||
Imports C1.Win.C1TrueDBGrid
|
||||
Imports System
|
||||
Imports System.Data
|
||||
Imports System.Data.SqlTypes
|
||||
Imports System.Data.SqlClient
|
||||
Namespace Utils
|
||||
''' <summary>
|
||||
''' Formular-Security-Objekte auslesen und auf DB schreiben bzw. Formular-Security zur Laufzeit setzen
|
||||
''' </summary>
|
||||
''' <remarks></remarks>
|
||||
|
||||
Public Class MySecurity
|
||||
|
||||
Dim SecurityData As DataSet = Globals.SecurityDaten
|
||||
Dim connection As New SqlConnection()
|
||||
Dim da As New SqlDataAdapter("", connection)
|
||||
|
||||
Dim IntForm As Object
|
||||
Dim ctlcol As New Collection
|
||||
Dim formname As String = ""
|
||||
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' Formularsecurity setzen
|
||||
''' </summary>
|
||||
''' <param name="f">Aktuelles Formular</param>
|
||||
''' <returns></returns>
|
||||
''' <remarks></remarks>
|
||||
Public Function Set_Form_Security(ByRef f As Object)
|
||||
IntForm = f
|
||||
formname = f.Name
|
||||
'Load form DB
|
||||
Load_Data(f.Name)
|
||||
'Load FormObjects
|
||||
Me.ctlcol.Clear()
|
||||
formname = f.Name
|
||||
For Each ctl As Control In f.Controls
|
||||
Objectanalysis(ctl)
|
||||
' AddHandler ctl.HelpRequested, AddressOf Object_MouseDown
|
||||
'ctl.ContextMenuStrip = Globals.TTContextMenuStrip
|
||||
'AddHandler ctl.KeyDown, AddressOf Object_MouseDown
|
||||
Next
|
||||
Set_Security()
|
||||
|
||||
End Function
|
||||
|
||||
Public Function Set_Menu_Security(ByRef f As Form, ByRef menu As ToolStripMenuItem, ByVal Menuname As String)
|
||||
IntForm = f
|
||||
formname = f.Name
|
||||
Load_Data(f.Name)
|
||||
Me.ctlcol.Clear()
|
||||
formname = f.Name
|
||||
Dim ctl As Object = menu
|
||||
Dim typ As System.Type = ctl.GetType
|
||||
ctlcol.Add(New MyFormControls(ctl, formname, typ.Name, Menuname, ctl.Name))
|
||||
|
||||
Set_Security()
|
||||
'If Globals.Set_ToolTips = True Then
|
||||
' tt.Edit_ToolTips(f, ctlcol)
|
||||
'Else
|
||||
' tt.Set_ToolTips(f)
|
||||
'End If
|
||||
|
||||
End Function
|
||||
|
||||
|
||||
Public Function Set_Form_Readonly(ByRef f As Form)
|
||||
IntForm = f
|
||||
Me.formname = f.Name
|
||||
Load_Data(f.Name)
|
||||
Me.ctlcol.Clear()
|
||||
For Each ctl As Control In f.Controls
|
||||
Objectanalysis_readonly(ctl)
|
||||
Next
|
||||
End Function
|
||||
Public Function Set_Form_Default(ByRef f As Form)
|
||||
IntForm = f
|
||||
Me.formname = f.Name
|
||||
Load_Data(f.Name)
|
||||
Me.ctlcol.Clear()
|
||||
For Each ctl As Control In f.Controls
|
||||
Objectanalysis_default(ctl)
|
||||
Next
|
||||
End Function
|
||||
|
||||
Private Function Objectanalysis_readonly(ByRef ctl As Object) As String
|
||||
Dim typ As System.Type = ctl.GetType
|
||||
Select Case LCase(typ.Name)
|
||||
Case "splitcontainer"
|
||||
ctlcol.Add(New MyFormControls(ctl, formname, typ.Name, ctl.Name, ""))
|
||||
Dim tmpsplit As SplitContainer = ctl
|
||||
For Each ctrl As Object In tmpsplit.Panel1.Controls
|
||||
Objectanalysis_readonly(ctrl)
|
||||
Next
|
||||
For Each ctrl As Object In tmpsplit.Panel2.Controls
|
||||
Objectanalysis_readonly(ctrl)
|
||||
Next
|
||||
Case "tabcontrol", "clsmytabcontrol"
|
||||
ctlcol.Add(New MyFormControls(ctl, formname, typ.Name, ctl.Name, ""))
|
||||
Dim tmptabcontrol As TabControl = ctl
|
||||
For Each ctl In tmptabcontrol.TabPages
|
||||
Objectanalysis_readonly(ctl)
|
||||
Next
|
||||
Case "tabpage"
|
||||
Dim tmptabpage As TabPage = ctl
|
||||
ctlcol.Add(New MyFormControls(ctl, formname, typ.Name, ctl.Name, tmptabpage.Parent.Name, 1))
|
||||
|
||||
For Each ctl In tmptabpage.Controls
|
||||
Objectanalysis_readonly(ctl)
|
||||
Next
|
||||
Case "groupbox"
|
||||
ctlcol.Add(New MyFormControls(ctl, formname, typ.Name, ctl.Name, ""))
|
||||
Dim tmptabpage As GroupBox = ctl
|
||||
For Each ctl In tmptabpage.Controls
|
||||
Objectanalysis_readonly(ctl)
|
||||
Next
|
||||
Case "panel"
|
||||
ctlcol.Add(New MyFormControls(ctl, formname, typ.Name, ctl.Name, ""))
|
||||
Dim tmppanel As Panel = ctl
|
||||
For Each ctl In tmppanel.Controls
|
||||
Objectanalysis_readonly(ctl)
|
||||
Next
|
||||
Case "textbox"
|
||||
Dim x As TextBox = ctl
|
||||
x.BackColor = Color.LightGray
|
||||
x.ForeColor = Color.Black
|
||||
x.ReadOnly = True
|
||||
Case "maskedtextbox"
|
||||
Dim x As MaskedTextBox = ctl
|
||||
x.BackColor = Color.LightGray
|
||||
x.ForeColor = Color.Black
|
||||
x.ReadOnly = True
|
||||
Case "combobox"
|
||||
Dim x As ComboBox = ctl
|
||||
x.Enabled = False
|
||||
x.BackColor = Color.LightGray
|
||||
x.ForeColor = Color.Black
|
||||
Case "checkbox"
|
||||
Dim x As CheckBox = ctl
|
||||
x.Enabled = False
|
||||
Case "radiobutton"
|
||||
Dim x As RadioButton = ctl
|
||||
x.Enabled = False
|
||||
Case "comboboxtree"
|
||||
Dim x As Object = ctl
|
||||
x.enabled = False
|
||||
x.BackColor = Color.LightGray
|
||||
x.ForeColor = Color.Black
|
||||
Case "richtextbox"
|
||||
Dim x As Object = ctl
|
||||
x.BackColor = Color.LightGray
|
||||
x.ForeColor = Color.Black
|
||||
x.ReadOnly = True
|
||||
Case "button"
|
||||
Dim x As Button = ctl
|
||||
x.Enabled = False
|
||||
Case "listbox"
|
||||
Dim x As Object = ctl
|
||||
ctl.enabled = False
|
||||
Case "checkedlistbox"
|
||||
Dim x As Object = ctl
|
||||
ctl.enabled = False
|
||||
Case "datetimepicker"
|
||||
Dim x As Object = ctl
|
||||
ctl.enabled = False
|
||||
|
||||
Case Else
|
||||
End Select
|
||||
End Function
|
||||
|
||||
Private Function Objectanalysis_default(ByRef ctl As Object) As String
|
||||
Dim typ As System.Type = ctl.GetType
|
||||
Select Case LCase(typ.Name)
|
||||
Case "splitcontainer"
|
||||
ctlcol.Add(New MyFormControls(ctl, formname, typ.Name, ctl.Name, ""))
|
||||
Dim tmpsplit As SplitContainer = ctl
|
||||
For Each ctrl As Object In tmpsplit.Panel1.Controls
|
||||
Objectanalysis_default(ctrl)
|
||||
Next
|
||||
For Each ctrl As Object In tmpsplit.Panel2.Controls
|
||||
Objectanalysis_default(ctrl)
|
||||
Next
|
||||
Case "tabcontrol", "clsmytabcontrol"
|
||||
ctlcol.Add(New MyFormControls(ctl, formname, typ.Name, ctl.Name, ""))
|
||||
Dim tmptabcontrol As TabControl = ctl
|
||||
For Each ctl In tmptabcontrol.TabPages
|
||||
Objectanalysis_default(ctl)
|
||||
Next
|
||||
Case "tabpage"
|
||||
Dim tmptabpage As TabPage = ctl
|
||||
ctlcol.Add(New MyFormControls(ctl, formname, typ.Name, ctl.Name, tmptabpage.Parent.Name, 1))
|
||||
For Each ctl In tmptabpage.Controls
|
||||
Objectanalysis_default(ctl)
|
||||
Next
|
||||
Case "groupbox"
|
||||
ctlcol.Add(New MyFormControls(ctl, formname, typ.Name, ctl.Name, ""))
|
||||
Dim tmptabpage As GroupBox = ctl
|
||||
For Each ctl In tmptabpage.Controls
|
||||
Objectanalysis_default(ctl)
|
||||
Next
|
||||
Case "panel"
|
||||
ctlcol.Add(New MyFormControls(ctl, formname, typ.Name, ctl.Name, ""))
|
||||
Dim tmppanel As Panel = ctl
|
||||
For Each ctl In tmppanel.Controls
|
||||
Objectanalysis_default(ctl)
|
||||
Next
|
||||
Case "textbox"
|
||||
Dim x As TextBox = ctl
|
||||
x.BackColor = Color.White
|
||||
x.ForeColor = Color.Black
|
||||
x.Enabled = True
|
||||
Case "maskedtextbox"
|
||||
Dim x As MaskedTextBox = ctl
|
||||
x.BackColor = Color.White
|
||||
x.ForeColor = Color.Black
|
||||
x.Enabled = True
|
||||
Case "combobox"
|
||||
Dim x As ComboBox = ctl
|
||||
x.Enabled = True
|
||||
x.BackColor = Color.White
|
||||
x.ForeColor = Color.Black
|
||||
|
||||
Case "checkbox"
|
||||
Dim x As CheckBox = ctl
|
||||
x.Enabled = True
|
||||
Case "radiobutton"
|
||||
Dim x As RadioButton = ctl
|
||||
x.Enabled = True
|
||||
Case "comboboxtree"
|
||||
Dim x As Object = ctl
|
||||
x.enabled = True
|
||||
x.BackColor = Color.White
|
||||
x.ForeColor = Color.Black
|
||||
Case "richtextbox"
|
||||
Dim x As Object = ctl
|
||||
x.BackColor = Color.White
|
||||
x.ForeColor = Color.Black
|
||||
x.readonly = True
|
||||
Case "button"
|
||||
Dim x As Button = ctl
|
||||
x.Enabled = True
|
||||
Case "listbox"
|
||||
Dim x As Object = ctl
|
||||
ctl.enabled = True
|
||||
Case "checkedlistbox"
|
||||
Dim x As Object = ctl
|
||||
ctl.enabled = True
|
||||
Case "datetimepicker"
|
||||
Dim x As Object = ctl
|
||||
ctl.enabled = True
|
||||
Case Else
|
||||
End Select
|
||||
End Function
|
||||
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' Daten ab Datenbank laden
|
||||
''' </summary>
|
||||
''' <remarks></remarks>
|
||||
Private Sub Load_Data(ByVal Formname As String)
|
||||
Try
|
||||
'xxx
|
||||
If SecurityData.Tables.Count > 0 Then
|
||||
SecurityData.Tables.Clear()
|
||||
End If
|
||||
' Exit Sub
|
||||
Catch ex As Exception
|
||||
End Try
|
||||
SecurityData.Tables.Clear()
|
||||
Dim sqlcmd As New SqlCommand
|
||||
|
||||
sqlcmd.CommandText = "dbo.my_security_get_data"
|
||||
sqlcmd.Parameters.Add("@FormName", SqlDbType.VarChar, 255)
|
||||
sqlcmd.Parameters.Add("@Mitarbeiternr", SqlDbType.Int, 4)
|
||||
sqlcmd.Parameters(0).Value = Formname
|
||||
sqlcmd.Parameters(1).Value = Globals.Mitarbeiternr
|
||||
|
||||
sqlcmd.CommandType = CommandType.StoredProcedure
|
||||
sqlcmd.Connection = connection
|
||||
Try
|
||||
connection.ConnectionString = Globals.sConnectionString
|
||||
connection.Open()
|
||||
da.SelectCommand = sqlcmd
|
||||
da.Fill(SecurityData, "SecurityTable")
|
||||
Globals.SecurityDaten.Tables.Add(SecurityData.Tables(0).Copy)
|
||||
Catch ex As Exception
|
||||
Finally
|
||||
connection.Close()
|
||||
da.Dispose()
|
||||
sqlcmd.Dispose()
|
||||
End Try
|
||||
End Sub
|
||||
''' <summary>
|
||||
''' Prüft die DB-Einträge mit den Formcontrols und bei Übereinstimmung werden die Security-Einstellungen gesetzt
|
||||
''' </summary>
|
||||
''' <remarks></remarks>
|
||||
Private Sub Set_Security()
|
||||
Dim i As Integer
|
||||
For i = 0 To Me.SecurityData.Tables(0).Rows.Count - 1
|
||||
Dim SecurityObject As String = Me.SecurityData.Tables(0).Rows(i).Item("SecurityObject")
|
||||
Dim SecurityObjectitem As String = Me.SecurityData.Tables(0).Rows(i).Item("SecurityObjectItem")
|
||||
Dim read_only As Boolean = Me.SecurityData.Tables(0).Rows(i).Item("readonly")
|
||||
Dim invisible As Boolean = Me.SecurityData.Tables(0).Rows(i).Item("invisible")
|
||||
Dim ii As Integer
|
||||
For ii = 1 To ctlcol.Count
|
||||
Dim secobj As MyFormControls = ctlcol(ii)
|
||||
If secobj.MySecurityObject = SecurityObject And secobj.MySecurityObjectItem = SecurityObjectitem Then
|
||||
Set_Preferences(secobj.MyControl, read_only, invisible, SecurityObjectitem)
|
||||
End If
|
||||
Next
|
||||
Next
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' Security-Einstellungen setzen
|
||||
''' </summary>
|
||||
''' <param name="obj">Betroffenes Objeckt (Menuitem, Conrol usw.)</param>
|
||||
''' <param name="read_only">Readonly ja/nein</param>
|
||||
''' <param name="invisible">Sichtbar ja/nein</param>
|
||||
''' <param name="SecurityObjectItem">Name des Unterobjektes - wird für die Spalteneinstellungen von C1TruedbGrids verwendet</param>
|
||||
''' <remarks></remarks>
|
||||
Private Sub Set_Preferences(ByRef obj As Object, ByVal read_only As Boolean, ByVal invisible As Boolean, ByVal SecurityObjectItem As String)
|
||||
Dim objtype As System.Type = obj.GetType
|
||||
Select Case LCase(objtype.Name)
|
||||
Case "button"
|
||||
Dim ctl As Button = obj
|
||||
If read_only Then ctl.Enabled = False
|
||||
If invisible Then
|
||||
ctl.Visible = False
|
||||
ctl.Enabled = False
|
||||
End If
|
||||
Case "toolstripmenuitem"
|
||||
Dim ctl As ToolStripMenuItem = obj
|
||||
If read_only Then ctl.Enabled = False
|
||||
If invisible Then
|
||||
ctl.Visible = False
|
||||
ctl.Enabled = False
|
||||
End If
|
||||
Case "textbox", "label", "combobox", "checkbox", "toolstripbutton", "panel", "datetimepicker"
|
||||
If read_only Then obj.Enabled = False
|
||||
If invisible Then obj.Visible = False
|
||||
Case "richtextbox"
|
||||
If read_only Then obj.Enabled = False
|
||||
Try
|
||||
obj.readonly = True
|
||||
obj.enabled = True
|
||||
Catch ex As Exception
|
||||
End Try
|
||||
If invisible Then obj.Visible = False
|
||||
Case "tabpage"
|
||||
If invisible Then
|
||||
Dim tbp As TabPage = obj
|
||||
For Each x As MyFormControls In Me.ctlcol
|
||||
If x.MySecurityObject = tbp.Parent.Name Then
|
||||
Dim tb As TabControl = x.MyControl
|
||||
tb.TabPages.Remove(tbp)
|
||||
Exit Sub
|
||||
End If
|
||||
Next
|
||||
End If
|
||||
'20100406 - TabPageHandling
|
||||
If read_only Then
|
||||
'obj.enabled = False
|
||||
For Each CTLX As Control In obj.CONTROLS
|
||||
Me.Objectanalysis_readonly(CTLX)
|
||||
Next
|
||||
End If
|
||||
Case "c1truedbgrid"
|
||||
Dim ctl As C1TrueDBGrid = obj
|
||||
If SecurityObjectItem = "" Then
|
||||
If read_only Then ctl.Enabled = False
|
||||
If invisible Then obj.Visible = False
|
||||
Else
|
||||
If read_only Then ctl.Splits(0).DisplayColumns(SecurityObjectItem).Locked = True
|
||||
If invisible Then ctl.Splits(0).DisplayColumns(SecurityObjectItem).Visible = False
|
||||
End If
|
||||
|
||||
End Select
|
||||
End Sub
|
||||
|
||||
|
||||
#Region "Read Objects from Form and save to Database"
|
||||
Dim tmpmenuname As String
|
||||
''' <summary>
|
||||
''' Alle Controls des Formulars zusammensuchen und auf der DB speichern
|
||||
''' </summary>
|
||||
''' <param name="f">Betroffenes Formular</param>
|
||||
''' <returns></returns>
|
||||
''' <remarks></remarks>
|
||||
|
||||
Public Function List_Form_Controls(ByRef f As Object)
|
||||
Me.ctlcol.Clear()
|
||||
formname = f.Name
|
||||
For Each ctl As Control In f.Controls
|
||||
Objectanalysis(ctl)
|
||||
Next
|
||||
Dim i As Integer
|
||||
For i = 1 To ctlcol.Count
|
||||
Dim secobj As MyFormControls = ctlcol(i)
|
||||
secobj.Write_Object_to_DB()
|
||||
Next
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' Sämtliche Controls vom Formular auslesen
|
||||
''' </summary>
|
||||
''' <param name="ctl"></param>
|
||||
''' <returns></returns>
|
||||
''' <remarks></remarks>
|
||||
Private Function Objectanalysis(ByRef ctl As Object) As String
|
||||
Dim typ As System.Type = ctl.GetType
|
||||
Select Case LCase(typ.Name)
|
||||
Case "menustrip"
|
||||
ctlcol.Add(New MyFormControls(ctl, formname, typ.Name, ctl.Name, ""))
|
||||
tmpmenuname = ctl.name
|
||||
ReadMenu(ctl)
|
||||
Case "contextmenustrip"
|
||||
ctlcol.Add(New MyFormControls(ctl, formname, typ.Name, ctl.Name, ""))
|
||||
tmpmenuname = ctl.name
|
||||
ReadContextMenu(ctl)
|
||||
Case "toolstrip"
|
||||
ctlcol.Add(New MyFormControls(ctl, formname, typ.Name, ctl.Name, ""))
|
||||
Dim tmptoolstrop As ToolStrip = ctl
|
||||
Try
|
||||
Dim ic As Integer
|
||||
For ic = 0 To tmptoolstrop.Items.Count - 1
|
||||
Try
|
||||
Dim subobj As ToolStripButton
|
||||
subobj = tmptoolstrop.Items(ic)
|
||||
ctlcol.Add(New MyFormControls(subobj, formname, typ.Name, ctl.Name, subobj.Name, 1))
|
||||
Catch ex As Exception
|
||||
|
||||
End Try
|
||||
|
||||
Next
|
||||
'For Each subobj As ToolStripButton In tmptoolstrop.Items
|
||||
'ctlcol.Add(New MyFormControls(subobj, formname, typ.Name, ctl.Name, subobj.Name, 1))
|
||||
'Next
|
||||
Catch
|
||||
End Try
|
||||
Case "splitcontainer"
|
||||
ctlcol.Add(New MyFormControls(ctl, formname, typ.Name, ctl.Name, ""))
|
||||
Dim tmpsplit As SplitContainer = ctl
|
||||
For Each ctrl As Object In tmpsplit.Panel1.Controls
|
||||
Objectanalysis(ctrl)
|
||||
Next
|
||||
For Each ctrl As Object In tmpsplit.Panel2.Controls
|
||||
Objectanalysis(ctrl)
|
||||
Next
|
||||
Case "tabcontrol", "clsmytabcontrol"
|
||||
ctlcol.Add(New MyFormControls(ctl, formname, typ.Name, ctl.Name, ""))
|
||||
Dim tmptabcontrol As TabControl = ctl
|
||||
For Each ctl In tmptabcontrol.TabPages
|
||||
Objectanalysis(ctl)
|
||||
Next
|
||||
Case "tabpage"
|
||||
Dim tmptabpage As TabPage = ctl
|
||||
ctlcol.Add(New MyFormControls(ctl, formname, typ.Name, ctl.Name, tmptabpage.Parent.Name, 1))
|
||||
|
||||
For Each ctl In tmptabpage.Controls
|
||||
Objectanalysis(ctl)
|
||||
Next
|
||||
Case "groupbox"
|
||||
ctlcol.Add(New MyFormControls(ctl, formname, typ.Name, ctl.Name, ""))
|
||||
Dim tmptabpage As GroupBox = ctl
|
||||
For Each ctl In tmptabpage.Controls
|
||||
Objectanalysis(ctl)
|
||||
Next
|
||||
Case "panel"
|
||||
ctlcol.Add(New MyFormControls(ctl, formname, typ.Name, ctl.Name, ""))
|
||||
Dim tmppanel As Panel = ctl
|
||||
For Each ctl In tmppanel.Controls
|
||||
Objectanalysis(ctl)
|
||||
Next
|
||||
Case "c1truedbgrid"
|
||||
ctlcol.Add(New MyFormControls(ctl, formname, typ.Name, ctl.Name, ""))
|
||||
Dim ctrl As C1TrueDBGrid = ctl
|
||||
Dim i As Integer
|
||||
For i = 0 To ctrl.Columns.Count - 1
|
||||
ctlcol.Add(New MyFormControls(ctl, formname, typ.Name, ctl.Name, ctrl.Columns(i).Caption, 0, ctrl.Columns(i).Caption))
|
||||
Next
|
||||
Try
|
||||
If ctrl.ContextMenuStrip.Name <> "" Then
|
||||
Dim x As ContextMenuStrip = ctrl.ContextMenuStrip
|
||||
Objectanalysis(x)
|
||||
End If
|
||||
Catch ex As Exception
|
||||
|
||||
End Try
|
||||
For Each xctl As Object In ctrl.Controls
|
||||
Objectanalysis(xctl)
|
||||
Next
|
||||
Case "treeview"
|
||||
ctlcol.Add(New MyFormControls(ctl, formname, typ.Name, ctl.Name, ""))
|
||||
Dim ctrl As TreeView = ctl
|
||||
Try
|
||||
|
||||
If ctrl.ContextMenuStrip.Name <> "" Then
|
||||
Dim x As ContextMenuStrip = ctrl.ContextMenuStrip
|
||||
Objectanalysis(x)
|
||||
End If
|
||||
|
||||
Catch ex As Exception
|
||||
|
||||
End Try
|
||||
|
||||
Case Else
|
||||
If ctl.name = "TreeStruktur" Then
|
||||
End If
|
||||
ctlcol.Add(New MyFormControls(ctl, formname, typ.Name, ctl.Name, ""))
|
||||
End Select
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' Auslesen von MenuItems
|
||||
''' </summary>
|
||||
''' <param name="x"></param>
|
||||
''' <returns></returns>
|
||||
''' <remarks></remarks>
|
||||
'''
|
||||
Dim level As Integer = 0
|
||||
Private Function ReadMenu(ByRef x As Object)
|
||||
Dim tmpmnu As MenuStrip = x
|
||||
level = 0
|
||||
For Each xx As Object In tmpmnu.Items
|
||||
Dim objtype As System.Type = xx.GetType
|
||||
If LCase(objtype.Name) = "toolstripmenuitem" Then
|
||||
ctlcol.Add(New MyFormControls(xx, formname, "menustrip", tmpmenuname, xx.Name, level))
|
||||
get_all_menus(xx)
|
||||
End If
|
||||
Next
|
||||
End Function
|
||||
''' <summary>
|
||||
''' Auslesen von ContextMenuItems
|
||||
''' </summary>
|
||||
''' <param name="x"></param>
|
||||
''' <returns></returns>
|
||||
''' <remarks></remarks>
|
||||
'''
|
||||
|
||||
Private Function ReadContextMenu(ByRef x As Object)
|
||||
Dim tmpmnu As ContextMenuStrip = x
|
||||
level = 0
|
||||
Try
|
||||
For Each xx As Object In tmpmnu.Items
|
||||
Dim objtype As System.Type = xx.GetType
|
||||
If LCase(objtype.Name) = "toolstripmenuitem" Then
|
||||
ctlcol.Add(New MyFormControls(xx, formname, "menustrip", tmpmenuname, xx.Name, level))
|
||||
get_all_menus(xx)
|
||||
End If
|
||||
' ctlcol.Add(New MyFormControls(xx, formname, "contextmenustrip", tmpmenuname, xx.Name, level))
|
||||
' get_all_menus(xx)
|
||||
Next
|
||||
Catch ex As Exception
|
||||
End Try
|
||||
End Function
|
||||
''' <summary>
|
||||
''' Auslesen von Menu-Subitems
|
||||
''' </summary>
|
||||
''' <param name="xx"></param>
|
||||
''' <returns></returns>
|
||||
''' <remarks></remarks>
|
||||
Private Function get_all_menus(ByRef xx As ToolStripMenuItem)
|
||||
level = level + 1
|
||||
For Each subobj As Object In xx.DropDownItems
|
||||
If LCase(subobj.GetType.Name) = "toolstripmenuitem" Then
|
||||
ctlcol.Add(New MyFormControls(subobj, formname, "menustrip", tmpmenuname, subobj.Name, level))
|
||||
get_all_menus(subobj)
|
||||
End If
|
||||
Next
|
||||
level = level - 1
|
||||
End Function
|
||||
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' Prüft, ob das Security-Objekt bereits auf der DB vorhanden ist
|
||||
''' </summary>
|
||||
''' <param name="securityform">Formular</param>
|
||||
''' <param name="securityobjecttype">Objekttyp</param>
|
||||
''' <param name="securityobject">Objektname</param>
|
||||
''' <param name="securityobjectitem">Objektitem</param>
|
||||
''' <returns></returns>
|
||||
''' <remarks></remarks>
|
||||
Private Function Objexists(ByVal securityform As String, ByVal securityobjecttype As String, ByVal securityobject As String, ByVal securityobjectitem As String) As Boolean
|
||||
Dim scmCmdToExecute As SqlCommand = New SqlCommand()
|
||||
scmCmdToExecute.CommandText = "dbo.[my_security_check_entry]"
|
||||
scmCmdToExecute.CommandType = CommandType.StoredProcedure
|
||||
scmCmdToExecute.Connection = conn.scoDBConnection
|
||||
Try
|
||||
scmCmdToExecute.Parameters.Add(New SqlParameter("@form", SqlDbType.VarChar, 255, ParameterDirection.Input, True, 0, 0, "", DataRowVersion.Proposed, securityform))
|
||||
scmCmdToExecute.Parameters.Add(New SqlParameter("@objecttype", SqlDbType.VarChar, 255, ParameterDirection.Input, True, 0, 0, "", DataRowVersion.Proposed, securityobjecttype))
|
||||
scmCmdToExecute.Parameters.Add(New SqlParameter("@object", SqlDbType.VarChar, 255, ParameterDirection.Input, True, 0, 0, "", DataRowVersion.Proposed, securityobject))
|
||||
scmCmdToExecute.Parameters.Add(New SqlParameter("@objectitem", SqlDbType.VarChar, 255, ParameterDirection.Input, True, 0, 0, "", DataRowVersion.Proposed, securityobjectitem))
|
||||
scmCmdToExecute.Parameters.Add(New SqlParameter("@objexists", SqlDbType.Int, 4, ParameterDirection.Output, True, 0, 0, "", DataRowVersion.Proposed, 0))
|
||||
scmCmdToExecute.Connection.Open()
|
||||
scmCmdToExecute.ExecuteNonQuery()
|
||||
If scmCmdToExecute.Parameters("@objexists").Value > 0 Then
|
||||
Return True
|
||||
Else
|
||||
Return False
|
||||
End If
|
||||
Catch ex As Exception
|
||||
Finally
|
||||
scmCmdToExecute.Connection.Close()
|
||||
End Try
|
||||
End Function
|
||||
|
||||
#End Region
|
||||
|
||||
#Region "ScreenDoku"
|
||||
|
||||
Public Function Print_Screen(ByRef ctl As Control)
|
||||
saveasbitmap(ctl, ctl.Name)
|
||||
End Function
|
||||
Public Function Generate_HTML()
|
||||
saveasbitmap(Me.IntForm, "testform")
|
||||
'Exit Function
|
||||
'Dim x As MyFormControls
|
||||
'For Each x In ctlcol
|
||||
' Try
|
||||
' saveasbitmap(x.MyControl, x.MyFormname & "_" & x.MySecurityObject & "_" & x.MySecurityObjectItem)
|
||||
' If x.MySecurityObjecttype = "ToolStrip" And x.MySecurityObjectItem = "" Then
|
||||
' Dim gaga As ToolStrip = x.MyControl
|
||||
' For Each c As ToolStripButton In gaga.Items
|
||||
' Dim xxx As Control = CType(c, Control)
|
||||
|
||||
' xxx = CType(c, Control)
|
||||
' saveasbitmap(xxx, "xxx")
|
||||
' Next
|
||||
' End If
|
||||
' Catch ex As Exception
|
||||
' MsgBox(ex.Message)
|
||||
' End Try
|
||||
'Next
|
||||
End Function
|
||||
|
||||
Public Function saveasbitmap(ByRef ctl As Control, ByVal filename As String)
|
||||
Dim g As Graphics = ctl.CreateGraphics
|
||||
Dim b As New Bitmap(ctl.Width, ctl.Height)
|
||||
ctl.DrawToBitmap(b, New Rectangle(0, 0, ctl.Width, ctl.Height))
|
||||
'b.Save("E:\Software-Projekte\Vertragsverwaltung\Screens\" & filename & ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg)
|
||||
End Function
|
||||
|
||||
|
||||
#End Region
|
||||
|
||||
#Region "Dataobject"
|
||||
Function Check_DataObjectReadonly(Objectname) As Boolean
|
||||
Dim i As Integer = 0
|
||||
Load_Data("DataObject")
|
||||
Dim dv As New DataView(SecurityData.Tables(0), "SecurityForm='DataObject' and SecurityObjectType='" + Objectname + "'", "", DataViewRowState.CurrentRows)
|
||||
For Each row As DataRowView In dv
|
||||
i = i + 1
|
||||
Next
|
||||
If i > 0 Then Return True Else Return False
|
||||
|
||||
End Function
|
||||
|
||||
#End Region
|
||||
End Class
|
||||
''' <summary>
|
||||
''' Klasse für ein Control-Objekt
|
||||
''' </summary>
|
||||
''' <remarks></remarks>
|
||||
Public Class MyFormControls
|
||||
|
||||
Public MyControl As Object
|
||||
Public MyFormname As String
|
||||
Public MySecurityObjecttype As String
|
||||
Public MySecurityObject As String
|
||||
Public MySecurityObjectItem As String
|
||||
Public MyDescription As String
|
||||
Public MyLevel As Integer
|
||||
|
||||
''' <summary>
|
||||
''' Neue Instanz erstellen
|
||||
''' </summary>
|
||||
''' <param name="ctl">Control-Objekt</param>
|
||||
''' <param name="Formname">Betroffenes Formular</param>
|
||||
''' <param name="securityobjecttype">Objekttyp</param>
|
||||
''' <param name="Securityobject">Objektname</param>
|
||||
''' <param name="SecurityObjectItem">Unterobjekt (z.B. bei Menus, Spalten von C1TrueDBGrids)</param>
|
||||
''' <remarks></remarks>
|
||||
Sub New(ByVal ctl As Object, ByVal Formname As String, ByVal securityobjecttype As String, ByVal Securityobject As String, ByVal SecurityObjectItem As String, Optional ByVal level As Integer = 0, Optional ByVal desc As String = "")
|
||||
MyControl = ctl
|
||||
MySecurityObjecttype = securityobjecttype
|
||||
MyFormname = Formname
|
||||
MySecurityObject = Securityobject
|
||||
MySecurityObjectItem = SecurityObjectItem
|
||||
If desc = "" Then
|
||||
MyDescription = Get_Description(ctl)
|
||||
Else
|
||||
MyDescription = desc
|
||||
End If
|
||||
Try
|
||||
MyDescription = MyDescription.Replace("&", "")
|
||||
Catch ex As Exception
|
||||
End Try
|
||||
MyLevel = level
|
||||
End Sub
|
||||
|
||||
Private Function Get_Description(ByRef ctl As Object) As String
|
||||
Dim typ As System.Type = ctl.GetType
|
||||
Select Case LCase(typ.Name)
|
||||
Case "menustrip", "toolstripmenuitem", "toolstrip", "toolstripbutton", "contextmenustrip", "tabpage", "c1truedbgrid", "label"
|
||||
Return ctl.Text
|
||||
Case Else
|
||||
Return ctl.Name
|
||||
End Select
|
||||
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' Schreibt einen Datnsatz in die Tabelle SecurityObjects
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
''' <remarks></remarks>
|
||||
Public Function Write_Object_to_DB()
|
||||
If Objexists() Then Exit Function
|
||||
Dim sectbl As New DB.clsSecurityObject
|
||||
Dim dbkey As New DB.clsMyKey_Tabelle
|
||||
dbkey.cpMainConnectionProvider = Globals.conn
|
||||
Dim newkey As Integer = dbkey.get_dbkey("SecurityObject")
|
||||
|
||||
sectbl.cpMainConnectionProvider = Globals.conn
|
||||
conn.OpenConnection()
|
||||
sectbl.iSecurityObjectNr = New SqlInt32(CType(newkey, Int32))
|
||||
sectbl.sSecurityForm = New SqlString(CType(MyFormname, String))
|
||||
sectbl.sSecurityObjectType = New SqlString(CType(Me.MySecurityObjecttype, String))
|
||||
sectbl.sSecurityObject = New SqlString(CType(Me.MySecurityObject, String))
|
||||
sectbl.sSecurityObjectItem = New SqlString(CType(Me.MySecurityObjectItem, String))
|
||||
sectbl.bAktiv = New SqlBoolean(CType(True, Boolean))
|
||||
sectbl.daErstellt_am = New SqlDateTime(CType(Now, DateTime))
|
||||
sectbl.daMutiert_am = New SqlDateTime(CType(Now, DateTime))
|
||||
sectbl.sSecurityObjectDescriotion = New SqlString(CType(Me.MyDescription, String))
|
||||
sectbl.iLevel = New SqlInt32(CType(Me.MyLevel, Int32))
|
||||
sectbl.iMutierer = New SqlInt32(CType(Globals.Mitarbeiternr, Int32))
|
||||
sectbl.iMandantnr = New SqlInt32(CType(Globals.Mitarbeiternr, Int32))
|
||||
sectbl.Insert()
|
||||
conn.CloseConnection(True)
|
||||
sectbl.Dispose()
|
||||
dbkey.Dispose()
|
||||
End Function
|
||||
|
||||
|
||||
''' <summary>
|
||||
'''Prüft, ob das Security-Objekt bereits auf der DB vorhanden ist
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
''' <remarks></remarks>
|
||||
Private Function Objexists() As Boolean
|
||||
Dim scmCmdToExecute As SqlCommand = New SqlCommand()
|
||||
scmCmdToExecute.CommandText = "dbo.[my_security_check_entry]"
|
||||
scmCmdToExecute.CommandType = CommandType.StoredProcedure
|
||||
scmCmdToExecute.Connection = conn.scoDBConnection
|
||||
Try
|
||||
scmCmdToExecute.Parameters.Add(New SqlParameter("@form", SqlDbType.VarChar, 255, ParameterDirection.Input, True, 0, 0, "", DataRowVersion.Proposed, Me.MyFormname))
|
||||
scmCmdToExecute.Parameters.Add(New SqlParameter("@objecttype", SqlDbType.VarChar, 255, ParameterDirection.Input, True, 0, 0, "", DataRowVersion.Proposed, Me.MySecurityObjecttype))
|
||||
scmCmdToExecute.Parameters.Add(New SqlParameter("@object", SqlDbType.VarChar, 255, ParameterDirection.Input, True, 0, 0, "", DataRowVersion.Proposed, Me.MySecurityObject))
|
||||
scmCmdToExecute.Parameters.Add(New SqlParameter("@objectitem", SqlDbType.VarChar, 255, ParameterDirection.Input, True, 0, 0, "", DataRowVersion.Proposed, Me.MySecurityObjectItem))
|
||||
scmCmdToExecute.Parameters.Add(New SqlParameter("@objexists", SqlDbType.Int, 4, ParameterDirection.Output, True, 0, 0, "", DataRowVersion.Proposed, 0))
|
||||
scmCmdToExecute.Connection.Open()
|
||||
scmCmdToExecute.ExecuteNonQuery()
|
||||
If scmCmdToExecute.Parameters("@objexists").Value > 0 Then
|
||||
Return True
|
||||
Else
|
||||
Return False
|
||||
End If
|
||||
Catch ex As Exception
|
||||
Finally
|
||||
scmCmdToExecute.Connection.Close()
|
||||
End Try
|
||||
End Function
|
||||
|
||||
|
||||
End Class
|
||||
|
||||
Public Class ControlsCollection
|
||||
Private Shared m_controls As Collection
|
||||
Public Sub New(ByVal myForm As Form)
|
||||
m_controls = New Collection
|
||||
'create a control walker to get
|
||||
'all controls on the form
|
||||
Dim aControlWalker As New ControlWalker(myForm)
|
||||
End Sub
|
||||
'This property returns the collection of all controls
|
||||
'on the form
|
||||
ReadOnly Property Controls() As Collection
|
||||
Get
|
||||
Return m_controls
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public Function FindControl(ByVal ctlname As String) As Boolean
|
||||
Dim i As Integer
|
||||
For i = 1 To Me.m_controls.Count
|
||||
Dim ctl As Control = m_controls(i)
|
||||
If UCase(ctl.Name) = UCase(ctlname) Then MsgBox("found")
|
||||
Next
|
||||
End Function
|
||||
Private Class ControlWalker
|
||||
' This class recursively walks through all controls
|
||||
' in a container, and all containers contained in
|
||||
' this container, visiting all controls throughout
|
||||
' the hierarchy
|
||||
Private mContainer As Object
|
||||
Public Sub New(ByVal Container As Object)
|
||||
Dim cControl As Control
|
||||
If Container.haschildren Then
|
||||
For Each cControl In Container.controls
|
||||
'add this control to the controls collection
|
||||
m_controls.Add(cControl)
|
||||
If cControl.HasChildren Then
|
||||
'This control has children, create another
|
||||
'ControlWalk go visit each of them
|
||||
Dim cWalker As New ControlWalker(cControl)
|
||||
End If
|
||||
Next cControl
|
||||
End If
|
||||
End Sub
|
||||
End Class
|
||||
End Class
|
||||
End Namespace
|
||||
432
_MyBeziehungen/Klassen/MySpalten.vb
Normal file
432
_MyBeziehungen/Klassen/MySpalten.vb
Normal file
@@ -0,0 +1,432 @@
|
||||
Imports System
|
||||
Imports System.Data
|
||||
Imports System.Data.SqlTypes
|
||||
Imports System.Data.SqlClient
|
||||
'*
|
||||
' Object MyspaltenTitel
|
||||
'
|
||||
' Dieses Objekt liest die Daten aus der Tabelle Spalten und speichert diese in spaltendaten
|
||||
' Die Daten werden für die Spaltenbezeichnung der C1Datagrids verwendet
|
||||
'
|
||||
' Autor: Stefan Hutter
|
||||
' Datum: 2.12.2002
|
||||
'*
|
||||
Imports C1.Win.C1TrueDBGrid
|
||||
Namespace Utils
|
||||
|
||||
Public Class Tabellenspalte
|
||||
Private m_table As String
|
||||
Private m_field As String
|
||||
Private m_spaltenname As String
|
||||
Private m_locked As Boolean
|
||||
Private m_Width As Integer
|
||||
Private m_Order As Integer
|
||||
Private m_alsHacken As Boolean
|
||||
Private m_tiptext As String
|
||||
Private m_numberformat As String
|
||||
|
||||
Property ColWith() As Integer
|
||||
Get
|
||||
Return m_Width
|
||||
End Get
|
||||
Set(ByVal Value As Integer)
|
||||
m_Width = Value
|
||||
End Set
|
||||
End Property
|
||||
Property Order() As Integer
|
||||
Get
|
||||
Return m_Order
|
||||
End Get
|
||||
Set(ByVal Value As Integer)
|
||||
m_Order = Value
|
||||
End Set
|
||||
End Property
|
||||
Property Tabelle() As String
|
||||
Get
|
||||
Return m_table
|
||||
End Get
|
||||
Set(ByVal Value As String)
|
||||
m_table = Value
|
||||
End Set
|
||||
End Property
|
||||
Property Feld() As String
|
||||
Get
|
||||
Return m_field
|
||||
End Get
|
||||
Set(ByVal Value As String)
|
||||
m_field = Value
|
||||
End Set
|
||||
End Property
|
||||
Property spaltenname() As String
|
||||
Get
|
||||
Return m_spaltenname
|
||||
End Get
|
||||
Set(ByVal Value As String)
|
||||
m_spaltenname = Value
|
||||
End Set
|
||||
End Property
|
||||
Property locked() As Boolean
|
||||
Get
|
||||
Return m_locked
|
||||
End Get
|
||||
Set(ByVal Value As Boolean)
|
||||
m_locked = Value
|
||||
End Set
|
||||
End Property
|
||||
Property AlsHacken() As Boolean
|
||||
Get
|
||||
Return m_alsHacken
|
||||
End Get
|
||||
Set(ByVal Value As Boolean)
|
||||
m_alsHacken = Value
|
||||
End Set
|
||||
End Property
|
||||
Property TipText() As String
|
||||
Get
|
||||
Return m_tiptext
|
||||
End Get
|
||||
Set(ByVal Value As String)
|
||||
m_tiptext = Value
|
||||
End Set
|
||||
End Property
|
||||
Property Numberformat() As String
|
||||
Get
|
||||
Return m_numberformat
|
||||
End Get
|
||||
Set(ByVal value As String)
|
||||
m_numberformat = value
|
||||
End Set
|
||||
End Property
|
||||
Public Sub New()
|
||||
|
||||
End Sub
|
||||
Public Sub New(ByRef daten As Object, ByRef tablename As String, ByRef ds As DataSet)
|
||||
Spaltentitel_aktualisieren(daten, tablename, ds)
|
||||
End Sub
|
||||
Public Function getspalte()
|
||||
Try
|
||||
Dim myspalten As New MySpaltenTitel()
|
||||
myspalten.getspalte(Me.Tabelle, Me.Feld, Me.spaltenname, Me.locked, Me.ColWith, Me.Order, Me.AlsHacken, Me.TipText, Me.Numberformat)
|
||||
Catch ex As Exception
|
||||
MsgBox(ex.Message)
|
||||
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function Spaltentitel_aktualisieren(ByRef daten As Object, ByRef tablename As String, ByRef ds As DataSet)
|
||||
Dim anzcols As Integer
|
||||
Dim i As Integer
|
||||
Dim s As String
|
||||
anzcols = daten.Splits(0).DisplayColumns.Count
|
||||
Me.Tabelle = tablename
|
||||
For i = 0 To daten.Columns.Count - 1
|
||||
s = daten.Columns(i).DataField
|
||||
Me.Feld = s
|
||||
Me.getspalte()
|
||||
daten.Columns(i).Caption = Me.spaltenname
|
||||
|
||||
If Me.ColWith = 0 Then
|
||||
daten.Splits(0).DisplayColumns(i).Width = 0
|
||||
daten.Splits(0).DisplayColumns(i).Visible = False
|
||||
Else
|
||||
daten.Splits(0).DisplayColumns(i).Width = Me.ColWith
|
||||
End If
|
||||
|
||||
If Me.locked Then
|
||||
daten.Splits(0).DisplayColumns(i).Locked = True
|
||||
End If
|
||||
|
||||
If Me.AlsHacken Then
|
||||
daten.Columns(i).ValueItems.Presentation = C1.Win.C1TrueDBGrid.PresentationEnum.CheckBox
|
||||
End If
|
||||
|
||||
'Präsentation von aktiv
|
||||
If LCase(daten.Columns(i).DataField) = "aktiv" Then
|
||||
daten.Columns(i).ValueItems.Presentation = C1.Win.C1TrueDBGrid.PresentationEnum.CheckBox
|
||||
daten.Columns(i).ValueItems.DefaultItem = True
|
||||
daten.Columns(i).DefaultValue = True
|
||||
daten.Columns(i).FilterText = True
|
||||
'Dim items As C1.Win.C1TrueDBGrid.ValueItems = daten.Columns("aktiv").ValueItems
|
||||
'items.Values.Clear()
|
||||
'items.Values.Add(New C1.Win.C1TrueDBGrid.ValueItem("False", False)) ' unchecked
|
||||
'items.Values.Add(New C1.Win.C1TrueDBGrid.ValueItem("True", True)) ' checked
|
||||
'items.Values.Add(New C1.Win.C1TrueDBGrid.ValueItem("", "INDETERMINATE")) ' indeterminate state
|
||||
|
||||
|
||||
End If
|
||||
Select Case LCase(daten.Columns(i).DataField)
|
||||
Case "erstellt_am", "erstelltam"
|
||||
daten.Columns(i).DefaultValue = Now
|
||||
End Select
|
||||
If daten.Columns(i).DataType.Name = "DateTime" Then
|
||||
daten.Columns(i).NumberFormat = "dd.MM.yyyy HH:mm:ss"
|
||||
End If
|
||||
If Me.Numberformat <> "" Then
|
||||
daten.columns(i).numberformat = Me.Numberformat
|
||||
End If
|
||||
Next
|
||||
ColumnOrder(tablename, daten)
|
||||
daten.HeadingStyle.WrapText = False
|
||||
End Function
|
||||
|
||||
Public Function Spaltentitel_aktualisieren(ByRef daten As Object, ByRef tablename As String, ByRef dt As DataTable, Optional ByVal Aktiv_Spalte_True_Setzen As Boolean = True)
|
||||
Dim anzcols As Integer
|
||||
Dim i As Integer
|
||||
Dim t As New DataTable()
|
||||
Dim s As String
|
||||
anzcols = daten.Splits(0).DisplayColumns.Count
|
||||
t = dt
|
||||
Me.Tabelle = tablename
|
||||
For i = 0 To daten.Columns.Count - 1
|
||||
s = daten.Columns(i).DataField
|
||||
'If s = "ApplikationNr" Then
|
||||
' MsgBox("Hallo")
|
||||
|
||||
'End If
|
||||
Me.Feld = s
|
||||
Me.getspalte()
|
||||
daten.Columns(i).Caption = Me.spaltenname
|
||||
|
||||
If Me.ColWith = 0 Then
|
||||
daten.Splits(0).DisplayColumns(i).Width = 0
|
||||
daten.Splits(0).DisplayColumns(i).Visible = False
|
||||
Else
|
||||
daten.Splits(0).DisplayColumns(i).Width = Me.ColWith
|
||||
End If
|
||||
|
||||
If Me.locked Then
|
||||
daten.Splits(0).DisplayColumns(i).Locked = True
|
||||
End If
|
||||
|
||||
If Me.AlsHacken Then
|
||||
daten.Columns(i).ValueItems.Presentation = C1.Win.C1TrueDBGrid.PresentationEnum.CheckBox
|
||||
End If
|
||||
|
||||
'Präsentation von aktiv
|
||||
If LCase(daten.Columns(i).DataField) = "aktiv" And Aktiv_Spalte_True_Setzen = True Then
|
||||
daten.Columns(i).ValueItems.Presentation = C1.Win.C1TrueDBGrid.PresentationEnum.CheckBox
|
||||
daten.Columns(i).ValueItems.DefaultItem = True
|
||||
daten.Columns(i).DefaultValue = True
|
||||
daten.Columns(i).FilterText = True
|
||||
End If
|
||||
Select Case LCase(daten.Columns(i).DataField)
|
||||
Case "erstellt_am", "erstelltam"
|
||||
daten.Columns(i).DefaultValue = Now
|
||||
End Select
|
||||
If daten.Columns(i).DataType.Name = "DateTime" Then
|
||||
daten.Columns(i).NumberFormat = "dd.MM.yyyy HH:mm:ss"
|
||||
End If
|
||||
If Me.Numberformat <> "" Then
|
||||
daten.columns(i).numberformat = Me.Numberformat
|
||||
End If
|
||||
Next
|
||||
ColumnOrder(tablename, daten)
|
||||
daten.HeadingStyle.WrapText = False
|
||||
End Function
|
||||
|
||||
Public Function Spaltentitel_aktualisieren_Optionaler_Aktiv_Filer(ByRef daten As Object, ByRef tablename As String, ByRef dt As DataTable, Optional ByVal Aktiv_Filter As String = "")
|
||||
Dim anzcols As Integer
|
||||
Dim i As Integer
|
||||
Dim t As New DataTable()
|
||||
Dim s As String
|
||||
anzcols = daten.Splits(0).DisplayColumns.Count
|
||||
t = dt
|
||||
Me.Tabelle = tablename
|
||||
For i = 0 To daten.Columns.Count - 1
|
||||
s = daten.Columns(i).DataField
|
||||
|
||||
Me.Feld = s
|
||||
Me.getspalte()
|
||||
If Me.spaltenname = "" Then
|
||||
daten.Splits(0).DisplayColumns(i).Width = 0
|
||||
Else
|
||||
daten.Columns(i).Caption = Me.spaltenname
|
||||
|
||||
If Me.ColWith = 0 Then
|
||||
daten.Splits(0).DisplayColumns(i).Width = 0
|
||||
daten.Splits(0).DisplayColumns(i).Visible = False
|
||||
Else
|
||||
daten.Splits(0).DisplayColumns(i).Width = Me.ColWith
|
||||
End If
|
||||
|
||||
If Me.locked Then
|
||||
daten.Splits(0).DisplayColumns(i).Locked = True
|
||||
End If
|
||||
|
||||
If Me.AlsHacken Then
|
||||
daten.Columns(i).ValueItems.Presentation = C1.Win.C1TrueDBGrid.PresentationEnum.CheckBox
|
||||
End If
|
||||
|
||||
'Präsentation von aktiv
|
||||
If LCase(daten.Columns(i).DataField) = "aktiv" And Aktiv_Filter <> "" Then
|
||||
daten.Columns(i).ValueItems.Presentation = C1.Win.C1TrueDBGrid.PresentationEnum.CheckBox
|
||||
daten.Columns(i).ValueItems.DefaultItem = True
|
||||
daten.Columns(i).DefaultValue = True
|
||||
daten.Columns(i).FilterText = Aktiv_Filter
|
||||
End If
|
||||
Select Case LCase(daten.Columns(i).DataField)
|
||||
Case "erstellt_am", "erstelltam"
|
||||
daten.Columns(i).DefaultValue = Now
|
||||
End Select
|
||||
If daten.Columns(i).DataType.Name = "DateTime" Then
|
||||
daten.Columns(i).NumberFormat = "dd.MM.yyyy HH:mm:ss"
|
||||
End If
|
||||
If Me.Numberformat <> "" Then
|
||||
daten.columns(i).numberformat = Me.Numberformat
|
||||
End If
|
||||
End If
|
||||
Next
|
||||
ColumnOrder(tablename, daten)
|
||||
daten.HeadingStyle.WrapText = False
|
||||
End Function
|
||||
''' <summary>
|
||||
''' Sortierung der in der DB-Tabelle Spalaten festgelegten Reihenfolge
|
||||
''' </summary>
|
||||
''' <param name="Tablename"></param>
|
||||
''' <param name="Data"></param>
|
||||
''' <returns></returns>
|
||||
''' <remarks></remarks>
|
||||
Public Function ColumnOrder(ByVal Tablename As String, ByRef Data As C1TrueDBGrid)
|
||||
Dim spaltendata As DataTable = Globals.Spaltendaten
|
||||
Dim dv() As DataRow
|
||||
Dim dr As DataRow
|
||||
Dim dc As New Collection
|
||||
dv = spaltendata.Select("Tabelle='" & Tablename & "'", "Reihenfolge desc, Eintragnr")
|
||||
For Each c As C1DisplayColumn In Data.Splits(0).DisplayColumns
|
||||
dc.Add(c)
|
||||
Next
|
||||
While Data.Splits(0).DisplayColumns.Count > 0
|
||||
Data.Splits(0).DisplayColumns.RemoveAt(0)
|
||||
End While
|
||||
|
||||
For Each dr In dv
|
||||
For Each e As C1DisplayColumn In dc
|
||||
If e.Name = dr.Item(3) Then
|
||||
Data.Splits(0).DisplayColumns.Insert(0, e)
|
||||
End If
|
||||
Next
|
||||
Next
|
||||
|
||||
End Function
|
||||
End Class
|
||||
|
||||
Public Class MySpaltenTitel
|
||||
Private spaltendata As DataTable = Globals.Spaltendaten
|
||||
Sub New()
|
||||
load_data()
|
||||
End Sub
|
||||
|
||||
Sub dispose()
|
||||
spaltendata.Dispose()
|
||||
Me.dispose()
|
||||
End Sub
|
||||
|
||||
Public Function getspalte(ByVal tabelle As String, ByVal feld As String, ByRef spaltenname As String, ByRef locked As Boolean, _
|
||||
ByRef colwidth As Integer, ByRef order As Integer, ByRef alshacken As Boolean, ByRef tiptext As String, ByRef numberformat As String)
|
||||
If spaltendata.Rows.Count = 0 Then load_data()
|
||||
Dim dv() As DataRow
|
||||
Dim dr As DataRow
|
||||
dv = spaltendata.Select("Tabelle='" & tabelle & "' and tabellenspalte='" & feld & "'", "Reihenfolge, Eintragnr")
|
||||
If dv.Length = 0 Then
|
||||
spaltenname = ""
|
||||
locked = True
|
||||
colwidth = 0
|
||||
order = 0
|
||||
alshacken = False
|
||||
tiptext = ""
|
||||
numberformat = ""
|
||||
End If
|
||||
For Each dr In dv
|
||||
spaltenname = dr.Item(3)
|
||||
locked = dr.Item(4)
|
||||
colwidth = dr.Item(6)
|
||||
order = dr.Item(7)
|
||||
alshacken = dr.Item(5)
|
||||
tiptext = dr.Item(8)
|
||||
numberformat = dr.Item(14).ToString
|
||||
Next
|
||||
'Dim i As Integer
|
||||
'For i = 0 To spaltendata.Rows.Count - 1
|
||||
|
||||
' If UCase(spaltendata.Rows(i).Item(1)) = UCase(tabelle) And UCase(spaltendata.Rows(i).Item(2)) = UCase(feld) Then
|
||||
' spaltenname = spaltendata.Rows(i).Item(3)
|
||||
' locked = spaltendata.Rows(i).Item(4)
|
||||
' colwidth = spaltendata.Rows(i).Item(6)
|
||||
' order = spaltendata.Rows(i).Item(7)
|
||||
' alshacken = spaltendata.Rows(i).Item(5)
|
||||
' tiptext = spaltendata.Rows(i).Item(8)
|
||||
' Exit Function
|
||||
' End If
|
||||
'Next
|
||||
|
||||
End Function
|
||||
|
||||
Public Sub load_data()
|
||||
If Me.spaltendata.Rows.Count > 0 Then Exit Sub
|
||||
Dim spalten As New Utils.clsSpalten()
|
||||
spaltendata.Rows.Clear()
|
||||
spalten.cpMainConnectionProvider = conn
|
||||
spaltendata = spalten.Select_All_Aktiv
|
||||
Globals.Spaltendaten = spaltendata
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
Public Class clsSpalten
|
||||
Inherits DB.clsSpalten
|
||||
''' <summary>
|
||||
''' Purpose: SelectAll method. This method will Select all rows from the table.
|
||||
''' </summary>
|
||||
''' <returns>DataTable object if succeeded, otherwise an Exception is thrown. </returns>
|
||||
''' <remarks>
|
||||
''' Properties set after a succesful call of this method:
|
||||
''' <UL>
|
||||
''' <LI>iErrorCode</LI>
|
||||
'''</UL>
|
||||
''' </remarks>
|
||||
Public Function Select_All_Aktiv() As DataTable
|
||||
Dim scmCmdToExecute As SqlCommand = New SqlCommand()
|
||||
scmCmdToExecute.CommandText = "dbo.[pr_spalten_SelectAll_Aktiv]"
|
||||
scmCmdToExecute.CommandType = CommandType.StoredProcedure
|
||||
Dim dtToReturn As DataTable = New DataTable("spalten")
|
||||
Dim sdaAdapter As SqlDataAdapter = New SqlDataAdapter(scmCmdToExecute)
|
||||
|
||||
' // Use base class' connection object
|
||||
scmCmdToExecute.Connection = m_scoMainConnection
|
||||
|
||||
Try
|
||||
scmCmdToExecute.Parameters.Add(New SqlParameter("@iErrorCode", SqlDbType.Int, 4, ParameterDirection.Output, True, 10, 0, "", DataRowVersion.Proposed, m_iErrorCode))
|
||||
|
||||
If m_bMainConnectionIsCreatedLocal Then
|
||||
' // Open connection.
|
||||
m_scoMainConnection.Open()
|
||||
Else
|
||||
If m_cpMainConnectionProvider.bIsTransactionPending Then
|
||||
scmCmdToExecute.Transaction = m_cpMainConnectionProvider.stCurrentTransaction
|
||||
End If
|
||||
End If
|
||||
|
||||
' // Execute query.
|
||||
sdaAdapter.Fill(dtToReturn)
|
||||
m_iErrorCode = New SqlInt32(CType(scmCmdToExecute.Parameters.Item("@iErrorCode").Value, SqlInt32))
|
||||
|
||||
If Not m_iErrorCode.Equals(New SqlInt32(0)) Then
|
||||
' // Throw error.
|
||||
Throw New Exception("Stored Procedure 'pr_spalten_SelectAll' reported the ErrorCode: " & m_iErrorCode.ToString())
|
||||
End If
|
||||
|
||||
Return dtToReturn
|
||||
Catch ex As Exception
|
||||
' // some error occured. Bubble it to caller and encapsulate Exception object
|
||||
Throw New Exception("clsSpalten::SelectAll::Error occured.", ex)
|
||||
Finally
|
||||
If m_bMainConnectionIsCreatedLocal Then
|
||||
' // Close connection.
|
||||
m_scoMainConnection.Close()
|
||||
End If
|
||||
scmCmdToExecute.Dispose()
|
||||
sdaAdapter.Dispose()
|
||||
End Try
|
||||
End Function
|
||||
|
||||
End Class
|
||||
End Namespace
|
||||
630
_MyBeziehungen/Klassen/clsSpalten.vb
Normal file
630
_MyBeziehungen/Klassen/clsSpalten.vb
Normal file
@@ -0,0 +1,630 @@
|
||||
' ///////////////////////////////////////////////////////////////////////////
|
||||
' // Description: Data Access class for the table 'spalten'
|
||||
' // Generated by LLBLGen v1.21.2003.712 Final on: Dienstag, 1. Januar 2013, 13:15:45
|
||||
' // Because the Base Class already implements IDispose, this class doesn't.
|
||||
' ///////////////////////////////////////////////////////////////////////////
|
||||
Imports System
|
||||
Imports System.Data
|
||||
Imports System.Data.SqlTypes
|
||||
Imports System.Data.SqlClient
|
||||
|
||||
Namespace db
|
||||
''' <summary>
|
||||
''' Purpose: Data Access class for the table 'spalten'.
|
||||
''' </summary>
|
||||
Public Class clsSpalten
|
||||
Inherits clsDBInteractionBase
|
||||
|
||||
#Region " Class Member Declarations "
|
||||
|
||||
Private m_bReadonly, m_bAlsHacken, m_bAktiv As SqlBoolean
|
||||
Private m_daErstellt_am, m_daMutiert_am As SqlDateTime
|
||||
Private m_iMandantnr, m_iMutierer, m_iReihenfolge, m_iEintragnr, m_iBreite As SqlInt32
|
||||
Private m_sTabelle, m_sNumberFormat, m_sTiptext, m_sSpalte, m_sTabellenspalte As SqlString
|
||||
|
||||
#End Region
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' Purpose: Class constructor.
|
||||
''' </summary>
|
||||
Public Sub New()
|
||||
' // Nothing for now.
|
||||
End Sub
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' Purpose: Insert method. This method will insert one new row into the database.
|
||||
''' </summary>
|
||||
''' <returns>True if succeeded, otherwise an Exception is thrown. </returns>
|
||||
''' <remarks>
|
||||
''' Properties needed for this method:
|
||||
''' <UL>
|
||||
''' <LI>iEintragnr</LI>
|
||||
''' <LI>sTabelle. May be SqlString.Null</LI>
|
||||
''' <LI>sTabellenspalte. May be SqlString.Null</LI>
|
||||
''' <LI>sSpalte. May be SqlString.Null</LI>
|
||||
''' <LI>bReadonly</LI>
|
||||
''' <LI>bAlsHacken</LI>
|
||||
''' <LI>iBreite. May be SqlInt32.Null</LI>
|
||||
''' <LI>iReihenfolge. May be SqlInt32.Null</LI>
|
||||
''' <LI>sTiptext. May be SqlString.Null</LI>
|
||||
''' <LI>bAktiv</LI>
|
||||
''' <LI>daErstellt_am. May be SqlDateTime.Null</LI>
|
||||
''' <LI>daMutiert_am. May be SqlDateTime.Null</LI>
|
||||
''' <LI>iMutierer. May be SqlInt32.Null</LI>
|
||||
''' <LI>iMandantnr. May be SqlInt32.Null</LI>
|
||||
''' <LI>sNumberFormat. May be SqlString.Null</LI>
|
||||
''' </UL>
|
||||
''' Properties set after a succesful call of this method:
|
||||
''' <UL>
|
||||
''' <LI>iErrorCode</LI>
|
||||
'''</UL>
|
||||
''' </remarks>
|
||||
Overrides Public Function Insert() As Boolean
|
||||
Dim scmCmdToExecute As SqlCommand = New SqlCommand()
|
||||
scmCmdToExecute.CommandText = "dbo.[pr_spalten_Insert]"
|
||||
scmCmdToExecute.CommandType = CommandType.StoredProcedure
|
||||
|
||||
' // Use base class' connection object
|
||||
scmCmdToExecute.Connection = m_scoMainConnection
|
||||
|
||||
Try
|
||||
scmCmdToExecute.Parameters.Add(New SqlParameter("@ieintragnr", SqlDbType.Int, 4, ParameterDirection.Input, False, 10, 0, "", DataRowVersion.Proposed, m_iEintragnr))
|
||||
scmCmdToExecute.Parameters.Add(New SqlParameter("@stabelle", SqlDbType.VarChar, 255, ParameterDirection.Input, True, 0, 0, "", DataRowVersion.Proposed, m_sTabelle))
|
||||
scmCmdToExecute.Parameters.Add(New SqlParameter("@stabellenspalte", SqlDbType.VarChar, 255, ParameterDirection.Input, True, 0, 0, "", DataRowVersion.Proposed, m_sTabellenspalte))
|
||||
scmCmdToExecute.Parameters.Add(New SqlParameter("@sspalte", SqlDbType.VarChar, 255, ParameterDirection.Input, True, 0, 0, "", DataRowVersion.Proposed, m_sSpalte))
|
||||
scmCmdToExecute.Parameters.Add(New SqlParameter("@bReadonly", SqlDbType.Bit, 1, ParameterDirection.Input, False, 0, 0, "", DataRowVersion.Proposed, m_bReadonly))
|
||||
scmCmdToExecute.Parameters.Add(New SqlParameter("@balsHacken", SqlDbType.Bit, 1, ParameterDirection.Input, False, 0, 0, "", DataRowVersion.Proposed, m_bAlsHacken))
|
||||
scmCmdToExecute.Parameters.Add(New SqlParameter("@iBreite", SqlDbType.Int, 4, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, m_iBreite))
|
||||
scmCmdToExecute.Parameters.Add(New SqlParameter("@iReihenfolge", SqlDbType.Int, 4, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, m_iReihenfolge))
|
||||
scmCmdToExecute.Parameters.Add(New SqlParameter("@stiptext", SqlDbType.VarChar, 255, ParameterDirection.Input, True, 0, 0, "", DataRowVersion.Proposed, m_sTiptext))
|
||||
scmCmdToExecute.Parameters.Add(New SqlParameter("@baktiv", SqlDbType.Bit, 1, ParameterDirection.Input, False, 0, 0, "", DataRowVersion.Proposed, m_bAktiv))
|
||||
scmCmdToExecute.Parameters.Add(New SqlParameter("@daerstellt_am", SqlDbType.DateTime, 8, ParameterDirection.Input, True, 0, 0, "", DataRowVersion.Proposed, m_daErstellt_am))
|
||||
scmCmdToExecute.Parameters.Add(New SqlParameter("@damutiert_am", SqlDbType.DateTime, 8, ParameterDirection.Input, True, 0, 0, "", DataRowVersion.Proposed, m_daMutiert_am))
|
||||
scmCmdToExecute.Parameters.Add(New SqlParameter("@imutierer", SqlDbType.Int, 4, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, m_iMutierer))
|
||||
scmCmdToExecute.Parameters.Add(New SqlParameter("@imandantnr", SqlDbType.Int, 4, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, m_iMandantnr))
|
||||
scmCmdToExecute.Parameters.Add(New SqlParameter("@sNumberFormat", SqlDbType.VarChar, 255, ParameterDirection.Input, True, 0, 0, "", DataRowVersion.Proposed, m_sNumberFormat))
|
||||
scmCmdToExecute.Parameters.Add(new SqlParameter("@iErrorCode", SqlDbType.Int, 4, ParameterDirection.Output, True, 10, 0, "", DataRowVersion.Proposed, m_iErrorCode))
|
||||
|
||||
If m_bMainConnectionIsCreatedLocal Then
|
||||
' // Open connection.
|
||||
m_scoMainConnection.Open()
|
||||
Else
|
||||
If m_cpMainConnectionProvider.bIsTransactionPending Then
|
||||
scmCmdToExecute.Transaction = m_cpMainConnectionProvider.stCurrentTransaction
|
||||
End If
|
||||
End If
|
||||
|
||||
' // Execute query.
|
||||
m_iRowsAffected = scmCmdToExecute.ExecuteNonQuery()
|
||||
m_iErrorCode = New SqlInt32(CType(scmCmdToExecute.Parameters.Item("@iErrorCode").Value, SqlInt32))
|
||||
|
||||
If Not m_iErrorCode.Equals(New SqlInt32(LLBLError.AllOk)) Then
|
||||
' // Throw error.
|
||||
Throw New Exception("Stored Procedure 'pr_spalten_Insert' reported the ErrorCode: " & m_iErrorCode.ToString())
|
||||
End If
|
||||
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
' // some error occured. Bubble it to caller and encapsulate Exception object
|
||||
Throw New Exception("clsSpalten::Insert::Error occured.", ex)
|
||||
Finally
|
||||
If m_bMainConnectionIsCreatedLocal Then
|
||||
' // Close connection.
|
||||
m_scoMainConnection.Close()
|
||||
End If
|
||||
scmCmdToExecute.Dispose()
|
||||
End Try
|
||||
End Function
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' Purpose: Update method. This method will Update one existing row in the database.
|
||||
''' </summary>
|
||||
''' <returns>True if succeeded, otherwise an Exception is thrown. </returns>
|
||||
''' <remarks>
|
||||
''' Properties needed for this method:
|
||||
''' <UL>
|
||||
''' <LI>iEintragnr</LI>
|
||||
''' <LI>sTabelle. May be SqlString.Null</LI>
|
||||
''' <LI>sTabellenspalte. May be SqlString.Null</LI>
|
||||
''' <LI>sSpalte. May be SqlString.Null</LI>
|
||||
''' <LI>bReadonly</LI>
|
||||
''' <LI>bAlsHacken</LI>
|
||||
''' <LI>iBreite. May be SqlInt32.Null</LI>
|
||||
''' <LI>iReihenfolge. May be SqlInt32.Null</LI>
|
||||
''' <LI>sTiptext. May be SqlString.Null</LI>
|
||||
''' <LI>bAktiv</LI>
|
||||
''' <LI>daErstellt_am. May be SqlDateTime.Null</LI>
|
||||
''' <LI>daMutiert_am. May be SqlDateTime.Null</LI>
|
||||
''' <LI>iMutierer. May be SqlInt32.Null</LI>
|
||||
''' <LI>iMandantnr. May be SqlInt32.Null</LI>
|
||||
''' <LI>sNumberFormat. May be SqlString.Null</LI>
|
||||
''' </UL>
|
||||
''' Properties set after a succesful call of this method:
|
||||
''' <UL>
|
||||
''' <LI>iErrorCode</LI>
|
||||
'''</UL>
|
||||
''' </remarks>
|
||||
Overrides Public Function Update() As Boolean
|
||||
Dim scmCmdToExecute As SqlCommand = New SqlCommand()
|
||||
scmCmdToExecute.CommandText = "dbo.[pr_spalten_Update]"
|
||||
scmCmdToExecute.CommandType = CommandType.StoredProcedure
|
||||
|
||||
' // Use base class' connection object
|
||||
scmCmdToExecute.Connection = m_scoMainConnection
|
||||
|
||||
Try
|
||||
scmCmdToExecute.Parameters.Add(New SqlParameter("@ieintragnr", SqlDbType.Int, 4, ParameterDirection.Input, False, 10, 0, "", DataRowVersion.Proposed, m_iEintragnr))
|
||||
scmCmdToExecute.Parameters.Add(New SqlParameter("@stabelle", SqlDbType.VarChar, 255, ParameterDirection.Input, True, 0, 0, "", DataRowVersion.Proposed, m_sTabelle))
|
||||
scmCmdToExecute.Parameters.Add(New SqlParameter("@stabellenspalte", SqlDbType.VarChar, 255, ParameterDirection.Input, True, 0, 0, "", DataRowVersion.Proposed, m_sTabellenspalte))
|
||||
scmCmdToExecute.Parameters.Add(New SqlParameter("@sspalte", SqlDbType.VarChar, 255, ParameterDirection.Input, True, 0, 0, "", DataRowVersion.Proposed, m_sSpalte))
|
||||
scmCmdToExecute.Parameters.Add(New SqlParameter("@bReadonly", SqlDbType.Bit, 1, ParameterDirection.Input, False, 0, 0, "", DataRowVersion.Proposed, m_bReadonly))
|
||||
scmCmdToExecute.Parameters.Add(New SqlParameter("@balsHacken", SqlDbType.Bit, 1, ParameterDirection.Input, False, 0, 0, "", DataRowVersion.Proposed, m_bAlsHacken))
|
||||
scmCmdToExecute.Parameters.Add(New SqlParameter("@iBreite", SqlDbType.Int, 4, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, m_iBreite))
|
||||
scmCmdToExecute.Parameters.Add(New SqlParameter("@iReihenfolge", SqlDbType.Int, 4, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, m_iReihenfolge))
|
||||
scmCmdToExecute.Parameters.Add(New SqlParameter("@stiptext", SqlDbType.VarChar, 255, ParameterDirection.Input, True, 0, 0, "", DataRowVersion.Proposed, m_sTiptext))
|
||||
scmCmdToExecute.Parameters.Add(New SqlParameter("@baktiv", SqlDbType.Bit, 1, ParameterDirection.Input, False, 0, 0, "", DataRowVersion.Proposed, m_bAktiv))
|
||||
scmCmdToExecute.Parameters.Add(New SqlParameter("@daerstellt_am", SqlDbType.DateTime, 8, ParameterDirection.Input, True, 0, 0, "", DataRowVersion.Proposed, m_daErstellt_am))
|
||||
scmCmdToExecute.Parameters.Add(New SqlParameter("@damutiert_am", SqlDbType.DateTime, 8, ParameterDirection.Input, True, 0, 0, "", DataRowVersion.Proposed, m_daMutiert_am))
|
||||
scmCmdToExecute.Parameters.Add(New SqlParameter("@imutierer", SqlDbType.Int, 4, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, m_iMutierer))
|
||||
scmCmdToExecute.Parameters.Add(New SqlParameter("@imandantnr", SqlDbType.Int, 4, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, m_iMandantnr))
|
||||
scmCmdToExecute.Parameters.Add(New SqlParameter("@sNumberFormat", SqlDbType.VarChar, 255, ParameterDirection.Input, True, 0, 0, "", DataRowVersion.Proposed, m_sNumberFormat))
|
||||
scmCmdToExecute.Parameters.Add(new SqlParameter("@iErrorCode", SqlDbType.Int, 4, ParameterDirection.Output, True, 10, 0, "", DataRowVersion.Proposed, m_iErrorCode))
|
||||
|
||||
If m_bMainConnectionIsCreatedLocal Then
|
||||
' // Open connection.
|
||||
m_scoMainConnection.Open()
|
||||
Else
|
||||
If m_cpMainConnectionProvider.bIsTransactionPending Then
|
||||
scmCmdToExecute.Transaction = m_cpMainConnectionProvider.stCurrentTransaction
|
||||
End If
|
||||
End If
|
||||
|
||||
' // Execute query.
|
||||
m_iRowsAffected = scmCmdToExecute.ExecuteNonQuery()
|
||||
m_iErrorCode = New SqlInt32(CType(scmCmdToExecute.Parameters.Item("@iErrorCode").Value, SqlInt32))
|
||||
|
||||
If Not m_iErrorCode.Equals(New SqlInt32(LLBLError.AllOk)) Then
|
||||
' // Throw error.
|
||||
Throw New Exception("Stored Procedure 'pr_spalten_Update' reported the ErrorCode: " & m_iErrorCode.ToString())
|
||||
End If
|
||||
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
' // some error occured. Bubble it to caller and encapsulate Exception object
|
||||
Throw New Exception("clsSpalten::Update::Error occured.", ex)
|
||||
Finally
|
||||
If m_bMainConnectionIsCreatedLocal Then
|
||||
' // Close connection.
|
||||
m_scoMainConnection.Close()
|
||||
End If
|
||||
scmCmdToExecute.Dispose()
|
||||
End Try
|
||||
End Function
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' Purpose: Delete method. This method will Delete one existing row in the database, based on the Primary Key.
|
||||
''' </summary>
|
||||
''' <returns>True if succeeded, otherwise an Exception is thrown. </returns>
|
||||
''' <remarks>
|
||||
''' Properties needed for this method:
|
||||
''' <UL>
|
||||
''' <LI>iEintragnr</LI>
|
||||
''' </UL>
|
||||
''' Properties set after a succesful call of this method:
|
||||
''' <UL>
|
||||
''' <LI>iErrorCode</LI>
|
||||
'''</UL>
|
||||
''' </remarks>
|
||||
Overrides Public Function Delete() As Boolean
|
||||
Dim scmCmdToExecute As SqlCommand = New SqlCommand()
|
||||
scmCmdToExecute.CommandText = "dbo.[pr_spalten_Delete]"
|
||||
scmCmdToExecute.CommandType = CommandType.StoredProcedure
|
||||
|
||||
' // Use base class' connection object
|
||||
scmCmdToExecute.Connection = m_scoMainConnection
|
||||
|
||||
Try
|
||||
scmCmdToExecute.Parameters.Add(New SqlParameter("@ieintragnr", SqlDbType.Int, 4, ParameterDirection.Input, False, 10, 0, "", DataRowVersion.Proposed, m_iEintragnr))
|
||||
scmCmdToExecute.Parameters.Add(new SqlParameter("@iErrorCode", SqlDbType.Int, 4, ParameterDirection.Output, True, 10, 0, "", DataRowVersion.Proposed, m_iErrorCode))
|
||||
|
||||
If m_bMainConnectionIsCreatedLocal Then
|
||||
' // Open connection.
|
||||
m_scoMainConnection.Open()
|
||||
Else
|
||||
If m_cpMainConnectionProvider.bIsTransactionPending Then
|
||||
scmCmdToExecute.Transaction = m_cpMainConnectionProvider.stCurrentTransaction
|
||||
End If
|
||||
End If
|
||||
|
||||
' // Execute query.
|
||||
m_iRowsAffected = scmCmdToExecute.ExecuteNonQuery()
|
||||
m_iErrorCode = New SqlInt32(CType(scmCmdToExecute.Parameters.Item("@iErrorCode").Value, SqlInt32))
|
||||
|
||||
If Not m_iErrorCode.Equals(New SqlInt32(LLBLError.AllOk)) Then
|
||||
' // Throw error.
|
||||
Throw New Exception("Stored Procedure 'pr_spalten_Delete' reported the ErrorCode: " & m_iErrorCode.ToString())
|
||||
End If
|
||||
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
' // some error occured. Bubble it to caller and encapsulate Exception object
|
||||
Throw New Exception("clsSpalten::Delete::Error occured.", ex)
|
||||
Finally
|
||||
If m_bMainConnectionIsCreatedLocal Then
|
||||
' // Close connection.
|
||||
m_scoMainConnection.Close()
|
||||
End If
|
||||
scmCmdToExecute.Dispose()
|
||||
End Try
|
||||
End Function
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' Purpose: Select method. This method will Select one existing row from the database, based on the Primary Key.
|
||||
''' </summary>
|
||||
''' <returns>DataTable object if succeeded, otherwise an Exception is thrown. </returns>
|
||||
''' <remarks>
|
||||
''' Properties needed for this method:
|
||||
''' <UL>
|
||||
''' <LI>iEintragnr</LI>
|
||||
''' </UL>
|
||||
''' Properties set after a succesful call of this method:
|
||||
''' <UL>
|
||||
''' <LI>iErrorCode</LI>
|
||||
''' <LI>iEintragnr</LI>
|
||||
''' <LI>sTabelle</LI>
|
||||
''' <LI>sTabellenspalte</LI>
|
||||
''' <LI>sSpalte</LI>
|
||||
''' <LI>bReadonly</LI>
|
||||
''' <LI>bAlsHacken</LI>
|
||||
''' <LI>iBreite</LI>
|
||||
''' <LI>iReihenfolge</LI>
|
||||
''' <LI>sTiptext</LI>
|
||||
''' <LI>bAktiv</LI>
|
||||
''' <LI>daErstellt_am</LI>
|
||||
''' <LI>daMutiert_am</LI>
|
||||
''' <LI>iMutierer</LI>
|
||||
''' <LI>iMandantnr</LI>
|
||||
''' <LI>sNumberFormat</LI>
|
||||
'''</UL>
|
||||
''' Will fill all properties corresponding with a field in the table with the value of the row selected.
|
||||
''' </remarks>
|
||||
Overrides Public Function SelectOne() As DataTable
|
||||
Dim scmCmdToExecute As SqlCommand = New SqlCommand()
|
||||
scmCmdToExecute.CommandText = "dbo.[pr_spalten_SelectOne]"
|
||||
scmCmdToExecute.CommandType = CommandType.StoredProcedure
|
||||
Dim dtToReturn As DataTable = new DataTable("spalten")
|
||||
Dim sdaAdapter As SqlDataAdapter = new SqlDataAdapter(scmCmdToExecute)
|
||||
|
||||
' // Use base class' connection object
|
||||
scmCmdToExecute.Connection = m_scoMainConnection
|
||||
|
||||
Try
|
||||
scmCmdToExecute.Parameters.Add(new SqlParameter("@ieintragnr", SqlDbType.Int, 4, ParameterDirection.Input, False, 10, 0, "", DataRowVersion.Proposed, m_iEintragnr))
|
||||
scmCmdToExecute.Parameters.Add(new SqlParameter("@iErrorCode", SqlDbType.Int, 4, ParameterDirection.Output, True, 10, 0, "", DataRowVersion.Proposed, m_iErrorCode))
|
||||
|
||||
If m_bMainConnectionIsCreatedLocal Then
|
||||
' // Open connection.
|
||||
m_scoMainConnection.Open()
|
||||
Else
|
||||
If m_cpMainConnectionProvider.bIsTransactionPending Then
|
||||
scmCmdToExecute.Transaction = m_cpMainConnectionProvider.stCurrentTransaction
|
||||
End If
|
||||
End If
|
||||
|
||||
' // Execute query.
|
||||
sdaAdapter.Fill(dtToReturn)
|
||||
m_iErrorCode = New SqlInt32(CType(scmCmdToExecute.Parameters.Item("@iErrorCode").Value, SqlInt32))
|
||||
|
||||
If Not m_iErrorCode.Equals(New SqlInt32(LLBLError.AllOk)) Then
|
||||
' // Throw error.
|
||||
Throw New Exception("Stored Procedure 'pr_spalten_SelectOne' reported the ErrorCode: " & m_iErrorCode.ToString())
|
||||
End If
|
||||
|
||||
If dtToReturn.Rows.Count > 0 Then
|
||||
m_iEintragnr = New SqlInt32(CType(dtToReturn.Rows(0)("eintragnr"), Integer))
|
||||
If dtToReturn.Rows(0)("tabelle") Is System.DBNull.Value Then
|
||||
m_sTabelle = SqlString.Null
|
||||
Else
|
||||
m_sTabelle = New SqlString(CType(dtToReturn.Rows(0)("tabelle"), String))
|
||||
End If
|
||||
If dtToReturn.Rows(0)("tabellenspalte") Is System.DBNull.Value Then
|
||||
m_sTabellenspalte = SqlString.Null
|
||||
Else
|
||||
m_sTabellenspalte = New SqlString(CType(dtToReturn.Rows(0)("tabellenspalte"), String))
|
||||
End If
|
||||
If dtToReturn.Rows(0)("spalte") Is System.DBNull.Value Then
|
||||
m_sSpalte = SqlString.Null
|
||||
Else
|
||||
m_sSpalte = New SqlString(CType(dtToReturn.Rows(0)("spalte"), String))
|
||||
End If
|
||||
m_bReadonly = New SqlBoolean(CType(dtToReturn.Rows(0)("Readonly"), Boolean))
|
||||
m_bAlsHacken = New SqlBoolean(CType(dtToReturn.Rows(0)("alsHacken"), Boolean))
|
||||
If dtToReturn.Rows(0)("Breite") Is System.DBNull.Value Then
|
||||
m_iBreite = SqlInt32.Null
|
||||
Else
|
||||
m_iBreite = New SqlInt32(CType(dtToReturn.Rows(0)("Breite"), Integer))
|
||||
End If
|
||||
If dtToReturn.Rows(0)("Reihenfolge") Is System.DBNull.Value Then
|
||||
m_iReihenfolge = SqlInt32.Null
|
||||
Else
|
||||
m_iReihenfolge = New SqlInt32(CType(dtToReturn.Rows(0)("Reihenfolge"), Integer))
|
||||
End If
|
||||
If dtToReturn.Rows(0)("tiptext") Is System.DBNull.Value Then
|
||||
m_sTiptext = SqlString.Null
|
||||
Else
|
||||
m_sTiptext = New SqlString(CType(dtToReturn.Rows(0)("tiptext"), String))
|
||||
End If
|
||||
m_bAktiv = New SqlBoolean(CType(dtToReturn.Rows(0)("aktiv"), Boolean))
|
||||
If dtToReturn.Rows(0)("erstellt_am") Is System.DBNull.Value Then
|
||||
m_daErstellt_am = SqlDateTime.Null
|
||||
Else
|
||||
m_daErstellt_am = New SqlDateTime(CType(dtToReturn.Rows(0)("erstellt_am"), Date))
|
||||
End If
|
||||
If dtToReturn.Rows(0)("mutiert_am") Is System.DBNull.Value Then
|
||||
m_daMutiert_am = SqlDateTime.Null
|
||||
Else
|
||||
m_daMutiert_am = New SqlDateTime(CType(dtToReturn.Rows(0)("mutiert_am"), Date))
|
||||
End If
|
||||
If dtToReturn.Rows(0)("mutierer") Is System.DBNull.Value Then
|
||||
m_iMutierer = SqlInt32.Null
|
||||
Else
|
||||
m_iMutierer = New SqlInt32(CType(dtToReturn.Rows(0)("mutierer"), Integer))
|
||||
End If
|
||||
If dtToReturn.Rows(0)("mandantnr") Is System.DBNull.Value Then
|
||||
m_iMandantnr = SqlInt32.Null
|
||||
Else
|
||||
m_iMandantnr = New SqlInt32(CType(dtToReturn.Rows(0)("mandantnr"), Integer))
|
||||
End If
|
||||
If dtToReturn.Rows(0)("NumberFormat") Is System.DBNull.Value Then
|
||||
m_sNumberFormat = SqlString.Null
|
||||
Else
|
||||
m_sNumberFormat = New SqlString(CType(dtToReturn.Rows(0)("NumberFormat"), String))
|
||||
End If
|
||||
End If
|
||||
Return dtToReturn
|
||||
Catch ex As Exception
|
||||
' // some error occured. Bubble it to caller and encapsulate Exception object
|
||||
Throw New Exception("clsSpalten::SelectOne::Error occured.", ex)
|
||||
Finally
|
||||
If m_bMainConnectionIsCreatedLocal Then
|
||||
' // Close connection.
|
||||
m_scoMainConnection.Close()
|
||||
End If
|
||||
scmCmdToExecute.Dispose()
|
||||
sdaAdapter.Dispose()
|
||||
End Try
|
||||
End Function
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' Purpose: SelectAll method. This method will Select all rows from the table.
|
||||
''' </summary>
|
||||
''' <returns>DataTable object if succeeded, otherwise an Exception is thrown. </returns>
|
||||
''' <remarks>
|
||||
''' Properties set after a succesful call of this method:
|
||||
''' <UL>
|
||||
''' <LI>iErrorCode</LI>
|
||||
'''</UL>
|
||||
''' </remarks>
|
||||
Overrides Public Function SelectAll() As DataTable
|
||||
Dim scmCmdToExecute As SqlCommand = New SqlCommand()
|
||||
scmCmdToExecute.CommandText = "dbo.[pr_spalten_SelectAll]"
|
||||
scmCmdToExecute.CommandType = CommandType.StoredProcedure
|
||||
Dim dtToReturn As DataTable = new DataTable("spalten")
|
||||
Dim sdaAdapter As SqlDataAdapter = new SqlDataAdapter(scmCmdToExecute)
|
||||
|
||||
' // Use base class' connection object
|
||||
scmCmdToExecute.Connection = m_scoMainConnection
|
||||
|
||||
Try
|
||||
scmCmdToExecute.Parameters.Add(new SqlParameter("@iErrorCode", SqlDbType.Int, 4, ParameterDirection.Output, True, 10, 0, "", DataRowVersion.Proposed, m_iErrorCode))
|
||||
|
||||
If m_bMainConnectionIsCreatedLocal Then
|
||||
' // Open connection.
|
||||
m_scoMainConnection.Open()
|
||||
Else
|
||||
If m_cpMainConnectionProvider.bIsTransactionPending Then
|
||||
scmCmdToExecute.Transaction = m_cpMainConnectionProvider.stCurrentTransaction
|
||||
End If
|
||||
End If
|
||||
|
||||
' // Execute query.
|
||||
sdaAdapter.Fill(dtToReturn)
|
||||
m_iErrorCode = New SqlInt32(CType(scmCmdToExecute.Parameters.Item("@iErrorCode").Value, SqlInt32))
|
||||
|
||||
If Not m_iErrorCode.Equals(New SqlInt32(LLBLError.AllOk)) Then
|
||||
' // Throw error.
|
||||
Throw New Exception("Stored Procedure 'pr_spalten_SelectAll' reported the ErrorCode: " & m_iErrorCode.ToString())
|
||||
End If
|
||||
|
||||
Return dtToReturn
|
||||
Catch ex As Exception
|
||||
' // some error occured. Bubble it to caller and encapsulate Exception object
|
||||
Throw New Exception("clsSpalten::SelectAll::Error occured.", ex)
|
||||
Finally
|
||||
If m_bMainConnectionIsCreatedLocal Then
|
||||
' // Close connection.
|
||||
m_scoMainConnection.Close()
|
||||
End If
|
||||
scmCmdToExecute.Dispose()
|
||||
sdaAdapter.Dispose()
|
||||
End Try
|
||||
End Function
|
||||
|
||||
|
||||
#Region " Class Property Declarations "
|
||||
|
||||
Public Property [iEintragnr]() As SqlInt32
|
||||
Get
|
||||
Return m_iEintragnr
|
||||
End Get
|
||||
Set(ByVal Value As SqlInt32)
|
||||
Dim iEintragnrTmp As SqlInt32 = Value
|
||||
If iEintragnrTmp.IsNull Then
|
||||
Throw New ArgumentOutOfRangeException("iEintragnr", "iEintragnr can't be NULL")
|
||||
End If
|
||||
m_iEintragnr = Value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
|
||||
Public Property [sTabelle]() As SqlString
|
||||
Get
|
||||
Return m_sTabelle
|
||||
End Get
|
||||
Set(ByVal Value As SqlString)
|
||||
m_sTabelle = Value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
|
||||
Public Property [sTabellenspalte]() As SqlString
|
||||
Get
|
||||
Return m_sTabellenspalte
|
||||
End Get
|
||||
Set(ByVal Value As SqlString)
|
||||
m_sTabellenspalte = Value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
|
||||
Public Property [sSpalte]() As SqlString
|
||||
Get
|
||||
Return m_sSpalte
|
||||
End Get
|
||||
Set(ByVal Value As SqlString)
|
||||
m_sSpalte = Value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
|
||||
Public Property [bReadonly]() As SqlBoolean
|
||||
Get
|
||||
Return m_bReadonly
|
||||
End Get
|
||||
Set(ByVal Value As SqlBoolean)
|
||||
Dim bReadonlyTmp As SqlBoolean = Value
|
||||
If bReadonlyTmp.IsNull Then
|
||||
Throw New ArgumentOutOfRangeException("bReadonly", "bReadonly can't be NULL")
|
||||
End If
|
||||
m_bReadonly = Value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
|
||||
Public Property [bAlsHacken]() As SqlBoolean
|
||||
Get
|
||||
Return m_bAlsHacken
|
||||
End Get
|
||||
Set(ByVal Value As SqlBoolean)
|
||||
Dim bAlsHackenTmp As SqlBoolean = Value
|
||||
If bAlsHackenTmp.IsNull Then
|
||||
Throw New ArgumentOutOfRangeException("bAlsHacken", "bAlsHacken can't be NULL")
|
||||
End If
|
||||
m_bAlsHacken = Value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
|
||||
Public Property [iBreite]() As SqlInt32
|
||||
Get
|
||||
Return m_iBreite
|
||||
End Get
|
||||
Set(ByVal Value As SqlInt32)
|
||||
m_iBreite = Value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
|
||||
Public Property [iReihenfolge]() As SqlInt32
|
||||
Get
|
||||
Return m_iReihenfolge
|
||||
End Get
|
||||
Set(ByVal Value As SqlInt32)
|
||||
m_iReihenfolge = Value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
|
||||
Public Property [sTiptext]() As SqlString
|
||||
Get
|
||||
Return m_sTiptext
|
||||
End Get
|
||||
Set(ByVal Value As SqlString)
|
||||
m_sTiptext = Value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
|
||||
Public Property [bAktiv]() As SqlBoolean
|
||||
Get
|
||||
Return m_bAktiv
|
||||
End Get
|
||||
Set(ByVal Value As SqlBoolean)
|
||||
Dim bAktivTmp As SqlBoolean = Value
|
||||
If bAktivTmp.IsNull Then
|
||||
Throw New ArgumentOutOfRangeException("bAktiv", "bAktiv can't be NULL")
|
||||
End If
|
||||
m_bAktiv = Value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
|
||||
Public Property [daErstellt_am]() As SqlDateTime
|
||||
Get
|
||||
Return m_daErstellt_am
|
||||
End Get
|
||||
Set(ByVal Value As SqlDateTime)
|
||||
m_daErstellt_am = Value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
|
||||
Public Property [daMutiert_am]() As SqlDateTime
|
||||
Get
|
||||
Return m_daMutiert_am
|
||||
End Get
|
||||
Set(ByVal Value As SqlDateTime)
|
||||
m_daMutiert_am = Value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
|
||||
Public Property [iMutierer]() As SqlInt32
|
||||
Get
|
||||
Return m_iMutierer
|
||||
End Get
|
||||
Set(ByVal Value As SqlInt32)
|
||||
m_iMutierer = Value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
|
||||
Public Property [iMandantnr]() As SqlInt32
|
||||
Get
|
||||
Return m_iMandantnr
|
||||
End Get
|
||||
Set(ByVal Value As SqlInt32)
|
||||
m_iMandantnr = Value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
|
||||
Public Property [sNumberFormat]() As SqlString
|
||||
Get
|
||||
Return m_sNumberFormat
|
||||
End Get
|
||||
Set(ByVal Value As SqlString)
|
||||
m_sNumberFormat = Value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
#End Region
|
||||
|
||||
End Class
|
||||
End Namespace
|
||||
Reference in New Issue
Block a user