Merge branch 'master' of http://scmadmin@172.24.11.74:90/scm/git/RecordOrganizer
This commit is contained in:
@@ -49,6 +49,28 @@
|
||||
|
||||
' +++ Public Functions +++
|
||||
|
||||
Public Shared Function GetParentRecordId(RecordId As Integer) As Integer
|
||||
Try
|
||||
Dim parentId = ClassDatabase.Execute_Scalar("SELECT RECORD1_ID FROM TBPMO_RECORD_CONNECT WHERE RECORD2_ID = " & RecordId)
|
||||
If IsNothing(parentId) Then
|
||||
Return 0
|
||||
Else
|
||||
Return parentId
|
||||
End If
|
||||
Catch ex As Exception
|
||||
MsgBox("Error in GetFormId:" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Shared Function GetFormId(RecordId As Integer) As Integer
|
||||
Try
|
||||
Dim FormId = ClassDatabase.Execute_Scalar("SELECT FORM_ID FROM VWPMO_VALUES WHERE RECORD_ID = " & RecordId)
|
||||
Return FormId
|
||||
Catch ex As Exception
|
||||
MsgBox("Error in GetFormId:" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Shared Function GetControlGuid(name As String)
|
||||
Try
|
||||
Dim sql = "SELECT GUID FROM TBPMO_CONTROL WHERE UPPER(NAME) = UPPER('" & name & "')"
|
||||
|
||||
@@ -2,9 +2,10 @@
|
||||
Imports System.Text.RegularExpressions
|
||||
|
||||
Public Class ClassRecordView
|
||||
Public RecordId As Integer
|
||||
|
||||
Private DTControls As DataTable
|
||||
Private DTValues As DataTable
|
||||
Private RecordId As Integer
|
||||
Private FormId As Integer
|
||||
Private Panel As Panel
|
||||
|
||||
@@ -23,8 +24,11 @@ Public Class ClassRecordView
|
||||
''' </summary>
|
||||
Public Sub LoadRecord(recordId As Integer)
|
||||
Me.RecordId = recordId
|
||||
Me.LoadControls(Me.Panel)
|
||||
Me.LoadControls()
|
||||
Me.LoadValues(Me.Panel.Controls)
|
||||
Me.PreventControlValueChanges()
|
||||
|
||||
JUMP_RECORD_ID = 0
|
||||
End Sub
|
||||
|
||||
#Region "Helper Functions"
|
||||
@@ -94,16 +98,29 @@ Public Class ClassRecordView
|
||||
End Function
|
||||
|
||||
Private Function ReplaceStaticPlaceholders(sqlcommand As String) As String
|
||||
If (New Regex(STATIC_PATTERN).IsMatch(sqlcommand)) Then
|
||||
Try
|
||||
If (New Regex(STATIC_PATTERN).IsMatch(sqlcommand)) Then
|
||||
|
||||
sqlcommand = sqlcommand _
|
||||
.Replace("@RECORD_ID", Me.RecordId) _
|
||||
.Replace("@RECORDID", Me.RecordId)
|
||||
' TODO: Add more placeholders
|
||||
Dim FormId As Integer = ClassControlCommands.GetFormId(Me.RecordId)
|
||||
Dim ParentRecordId As Integer = ClassControlCommands.GetParentRecordId(Me.RecordId)
|
||||
|
||||
End If
|
||||
sqlcommand = sqlcommand _
|
||||
.Replace("@RECORD_ID", Me.RecordId) _
|
||||
.Replace("@RECORDID", Me.RecordId) _
|
||||
.Replace("@FORM_ID", FormId) _
|
||||
.Replace("@ENTITY_ID", FormId)
|
||||
|
||||
Return sqlcommand
|
||||
If ParentRecordId > 0 Then
|
||||
sqlcommand = sqlcommand _
|
||||
.Replace("@PARENTRECORDID", ParentRecordId) _
|
||||
.Replace("@PARENTRECORD_ID", ParentRecordId)
|
||||
End If
|
||||
|
||||
End If
|
||||
Return sqlcommand
|
||||
Catch ex As Exception
|
||||
Return sqlcommand
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Private Function LoadSQLList(props As ControlProps) As DataTable
|
||||
@@ -156,7 +173,7 @@ Public Class ClassRecordView
|
||||
|
||||
#End Region
|
||||
|
||||
Private Sub LoadControls(panel As Panel)
|
||||
Private Sub LoadControls()
|
||||
Dim controls As New List(Of Control)
|
||||
DTControls = ClassDatabase.Return_Datatable(String.Format("SELECT * FROM VWPMO_CONTROL_SCREEN WHERE FORM_ID = {0}", GetFormId()))
|
||||
|
||||
@@ -183,6 +200,8 @@ Public Class ClassRecordView
|
||||
control = LoadCheckBox(props)
|
||||
Case "Radiobutton"
|
||||
control = LoadRadioButton(props)
|
||||
Case "Picturebox"
|
||||
control = LoadPictureBox(props)
|
||||
End Select
|
||||
|
||||
If control IsNot Nothing Then
|
||||
@@ -190,8 +209,24 @@ Public Class ClassRecordView
|
||||
End If
|
||||
Next
|
||||
|
||||
panel.Controls.Clear()
|
||||
panel.Controls.AddRange(controls.ToArray())
|
||||
Me.Panel.Controls.Clear()
|
||||
Me.Panel.Controls.AddRange(controls.ToArray())
|
||||
End Sub
|
||||
|
||||
Private Sub PreventControlValueChanges()
|
||||
|
||||
For Each c As Control In Me.Panel.Controls
|
||||
Dim type As String = DirectCast(c.Tag, ControlProps).Type
|
||||
|
||||
If type = "CheckedListBox" Then
|
||||
Dim checklistbox = DirectCast(c, CheckedListBoxControl)
|
||||
AddHandler checklistbox.ItemChecking, Sub(sender As Object, e As DevExpress.XtraEditors.Controls.ItemCheckingEventArgs)
|
||||
e.Cancel = True
|
||||
End Sub
|
||||
End If
|
||||
|
||||
Next
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub LoadValues(controlCollection As Control.ControlCollection)
|
||||
@@ -203,13 +238,14 @@ Public Class ClassRecordView
|
||||
|
||||
For Each control As Control In controls
|
||||
Dim controlId As Integer = DirectCast(control.Tag, ControlProps).Id
|
||||
Dim controlType As String = DirectCast(control.Tag, ControlProps).Type
|
||||
|
||||
Dim values As List(Of Object) = (From row In DTValues.AsEnumerable()
|
||||
Where row.Item("CONTROL_ID") = controlId
|
||||
Select row.Item("VALUE")).ToList()
|
||||
|
||||
' Wenn kein Wert existiert, keinen Wert laden
|
||||
If values.Count = 0 Then
|
||||
If values.Count = 0 And Not controlType = "Picturebox" Then
|
||||
Continue For
|
||||
Else
|
||||
LoadValue(control, values)
|
||||
@@ -222,8 +258,6 @@ Public Class ClassRecordView
|
||||
Dim value = Nothing
|
||||
If values.Count > 0 Then
|
||||
value = values(0)
|
||||
Else
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
Select Case controlType
|
||||
@@ -235,24 +269,27 @@ Public Class ClassRecordView
|
||||
Case "Combobox"
|
||||
DirectCast(control, TextBox).Text = value.ToString()
|
||||
Case "Datepicker"
|
||||
Dim dtp As TextBox = DirectCast(control, TextBox)
|
||||
Try
|
||||
DirectCast(control, TextBox).Text = DateTime.Parse(value).ToShortDateString()
|
||||
dtp.Text = DateTime.Parse(value).ToShortDateString()
|
||||
Catch ex As Exception
|
||||
|
||||
dtp.text = "Invalid Date"
|
||||
End Try
|
||||
|
||||
Case "Checkbox"
|
||||
Dim checkbox = DirectCast(control, CheckBox)
|
||||
Try
|
||||
DirectCast(control, CheckBox).Checked = Boolean.Parse(value)
|
||||
checkbox.Checked = Boolean.Parse(value)
|
||||
Catch ex As Exception
|
||||
DirectCast(control, CheckBox).Checked = False
|
||||
checkbox.Checked = False
|
||||
End Try
|
||||
|
||||
Case "RadioButton"
|
||||
Dim radio = DirectCast(control, RadioButton)
|
||||
Try
|
||||
DirectCast(control, RadioButton).Checked = Boolean.Parse(value)
|
||||
radio.Checked = Boolean.Parse(value)
|
||||
Catch ex As Exception
|
||||
DirectCast(control, RadioButton).Checked = False
|
||||
radio.Checked = False
|
||||
End Try
|
||||
|
||||
Case "Datagridview"
|
||||
@@ -260,17 +297,17 @@ Public Class ClassRecordView
|
||||
Dim datagridview As ListBoxControl = DirectCast(control, ListBoxControl)
|
||||
datagridview.Items.AddRange(values.ToArray())
|
||||
Catch ex As Exception
|
||||
|
||||
' Keine Items hinzufügen
|
||||
End Try
|
||||
|
||||
|
||||
Case "ListBox"
|
||||
Try
|
||||
Dim listbox As ListBoxControl = DirectCast(control, ListBoxControl)
|
||||
listbox.Items.AddRange(values.ToArray())
|
||||
Catch ex As Exception
|
||||
|
||||
' Keine Items hinzufügen
|
||||
End Try
|
||||
|
||||
|
||||
Case "CheckedListBox"
|
||||
Try
|
||||
Dim checkedlist As CheckedListBoxControl = DirectCast(control, CheckedListBoxControl)
|
||||
@@ -290,9 +327,25 @@ Public Class ClassRecordView
|
||||
End While
|
||||
Next
|
||||
Catch ex As Exception
|
||||
|
||||
' Keine Items anchecken
|
||||
End Try
|
||||
Case "Picturebox"
|
||||
Try
|
||||
Dim pb As PictureBox = DirectCast(control, PictureBox)
|
||||
Dim controlId As Integer = DirectCast(control.Tag, ControlProps).Id
|
||||
Dim sql = String.Format("SELECT IMG FROM TBPMO_CONTROL_IMAGE WHERE RECORD_ID = {0} AND CONTROL_ID = {1}", Me.RecordId, controlId)
|
||||
Dim bimg() As Byte = ClassDatabase.Execute_Scalar(sql)
|
||||
|
||||
If Not IsNothing(bimg) Then
|
||||
Dim img As Bitmap = ByteArrayToBitmap(bimg)
|
||||
|
||||
pb.BackgroundImage = img
|
||||
pb.BackgroundImageLayout = ImageLayout.Zoom
|
||||
End If
|
||||
Catch ex As Exception
|
||||
' Kein Bild laden
|
||||
MsgBox(ex.Message)
|
||||
End Try
|
||||
|
||||
End Select
|
||||
|
||||
End Sub
|
||||
@@ -303,24 +356,26 @@ Public Class ClassRecordView
|
||||
Public Name As String
|
||||
Public Type As String
|
||||
Public Caption As String
|
||||
|
||||
' Position/Size Props
|
||||
Public X As Integer
|
||||
Public Y As Integer
|
||||
Public Height As Integer
|
||||
Public Width As Integer
|
||||
|
||||
' Font/Color Props
|
||||
Public FontColor As Color
|
||||
Public FontSize As Integer
|
||||
Public FontStyle As FontStyle
|
||||
Public FontFamily As String
|
||||
Public Font As Font
|
||||
|
||||
Public BackColor As Color
|
||||
|
||||
' Flag Props
|
||||
Public IsRequired As Boolean
|
||||
Public IsReadOnly As Boolean
|
||||
Public IsMultiline As Boolean
|
||||
|
||||
' Data Props
|
||||
Public SqlCommand1 As String
|
||||
Public SqlCommand2 As String
|
||||
@@ -339,7 +394,8 @@ Public Class ClassRecordView
|
||||
label.Text = props.Caption
|
||||
label.Font = props.Font
|
||||
label.ForeColor = props.FontColor
|
||||
label.BackColor = props.BackColor
|
||||
'label.BackColor = props.BackColor
|
||||
label.BackColor = Color.White
|
||||
label.AutoSize = True
|
||||
|
||||
props = LoadDataSource(props)
|
||||
@@ -364,7 +420,8 @@ Public Class ClassRecordView
|
||||
textbox.BorderStyle = BorderStyle.FixedSingle
|
||||
textbox.Font = props.Font
|
||||
textbox.ForeColor = props.FontColor
|
||||
textbox.BackColor = props.BackColor
|
||||
'textbox.BackColor = props.BackColor
|
||||
textbox.BackColor = Color.White
|
||||
textbox.ReadOnly = True
|
||||
|
||||
Return textbox
|
||||
@@ -377,7 +434,8 @@ Public Class ClassRecordView
|
||||
combo.BorderStyle = BorderStyle.FixedSingle
|
||||
combo.Font = props.Font
|
||||
combo.ForeColor = props.FontColor
|
||||
combo.BackColor = props.BackColor
|
||||
'combo.BackColor = props.BackColor
|
||||
combo.BackColor = Color.White
|
||||
combo.ReadOnly = True
|
||||
|
||||
Return combo
|
||||
@@ -390,7 +448,8 @@ Public Class ClassRecordView
|
||||
dtp.BorderStyle = BorderStyle.FixedSingle
|
||||
dtp.Font = props.Font
|
||||
dtp.ForeColor = props.FontColor
|
||||
dtp.BackColor = props.BackColor
|
||||
'dtp.BackColor = props.BackColor
|
||||
dtp.BackColor = Color.White
|
||||
dtp.ReadOnly = True
|
||||
|
||||
Return dtp
|
||||
@@ -400,7 +459,7 @@ Public Class ClassRecordView
|
||||
Dim check As CheckBox = SetBaseProps(New CheckBox, props)
|
||||
|
||||
check.Text = props.Caption
|
||||
check.Enabled = False
|
||||
check.AutoCheck = False
|
||||
|
||||
Return check
|
||||
End Function
|
||||
@@ -409,7 +468,7 @@ Public Class ClassRecordView
|
||||
Dim radio As RadioButton = SetBaseProps(New RadioButton, props)
|
||||
|
||||
radio.Text = props.Caption
|
||||
radio.Enabled = False
|
||||
radio.AutoCheck = False
|
||||
|
||||
Return radio
|
||||
End Function
|
||||
@@ -431,6 +490,10 @@ Public Class ClassRecordView
|
||||
|
||||
props = LoadDataSource(props)
|
||||
|
||||
If Not IsNothing(props.StaticList) Then
|
||||
checklistbox.DataSource = props.StaticList
|
||||
End If
|
||||
|
||||
If Not IsNothing(props.DataSource) Then
|
||||
If props.DataSource.GetType() Is GetType(DataTable) Then
|
||||
Dim dt As DataTable = props.DataSource
|
||||
@@ -451,5 +514,13 @@ Public Class ClassRecordView
|
||||
Return checklistbox
|
||||
End Function
|
||||
|
||||
Private Function LoadPictureBox(props As ControlProps) As PictureBox
|
||||
Dim pb As PictureBox = SetBaseProps(New PictureBox, props)
|
||||
|
||||
pb.BorderStyle = BorderStyle.FixedSingle
|
||||
|
||||
Return pb
|
||||
End Function
|
||||
|
||||
#End Region
|
||||
End Class
|
||||
|
||||
@@ -30,6 +30,7 @@ Public Class frmRecordView
|
||||
Public hIcon As IntPtr
|
||||
Public hProcess As IntPtr
|
||||
End Structure
|
||||
|
||||
Private Sub frmRecordView_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
||||
If USER_LANGUAGE <> "de-DE" Then
|
||||
Me.Text = "Detailview Record"
|
||||
@@ -38,6 +39,10 @@ Public Class frmRecordView
|
||||
End If
|
||||
recordView = New ClassRecordView(pnlDetails)
|
||||
recordView.LoadRecord(JUMP_RECORD_ID)
|
||||
|
||||
'Titel updaten
|
||||
Me.Text &= " " + recordView.RecordId.ToString()
|
||||
|
||||
RUN_WDSEARCH_GRID()
|
||||
Load_Tasks()
|
||||
End Sub
|
||||
|
||||
Reference in New Issue
Block a user