jj 18.05
This commit is contained in:
@@ -166,7 +166,8 @@ Public Class ClassControlBuilder
|
||||
If match.Success Then
|
||||
' DependingControlId bezeichnet das Control, das die Abhängigkeit enthält
|
||||
Dim dependingControlId As Integer = row.Item("GUID")
|
||||
Dim panel As Panel = DirectCast(control.Parent, Panel)
|
||||
'Dim panel As Panel = DirectCast(control.Parent, Panel)
|
||||
Dim panel As Panel = CtrlBuilder.MasterPanel
|
||||
' Über die Id das Control finden
|
||||
Dim dependingControl As Control = panel.Controls.OfType(Of Control)().Where(Function(c As Control)
|
||||
Return DirectCast(c.Tag, ClassControlMetadata).Id = dependingControlId
|
||||
|
||||
@@ -585,36 +585,79 @@ Public Class ClassControlValues
|
||||
#End Region
|
||||
|
||||
#Region "LoadDefaultValue"
|
||||
Public Shared Sub LoadDefaultValues(FormID As Integer, RecordID As Integer, controls As Control.ControlCollection, ParentRecordId As Integer, entity_ID As Integer)
|
||||
'' Zuerst alle Controls leeren
|
||||
ClearControlValues(controls)
|
||||
|
||||
Dim i = 0
|
||||
For Each control As Control In controls
|
||||
Public Shared Sub LoadDefaultValues(FormID As Integer, RecordID As Integer, controls As Control.ControlCollection, parentRecordID As Integer, EntityID As Integer)
|
||||
Try
|
||||
Dim sw As New Stopwatch()
|
||||
sw.Start()
|
||||
|
||||
Dim CONTROL_ID = DirectCast(control.Tag, ClassControlMetadata).Id ' GetControlID_for_Name(control.Name, FormID)
|
||||
If Not (TypeOf control Is Label) Then
|
||||
i += 1
|
||||
End If
|
||||
' Alle Controls leeren
|
||||
ClearControlValues(controls)
|
||||
|
||||
If TypeOf control Is GroupBox Then
|
||||
LoadDefaultValues(FormID, RecordID, DirectCast(control, GroupBox).Controls, ParentRecordId, entity_ID)
|
||||
End If
|
||||
' Alle Controls laden, die einen Default Value haben
|
||||
Dim SQL As String = String.Format("SELECT CONTROL_ID, CONTROL_DEF_VALUE, CONTROL_NAME FROM VWPMO_CONTROL_SCREEN WHERE FORM_ID = {0} AND CONTROL_DEF_VALUE <> '' " & _
|
||||
"UNION SELECT CONTROL_ID, CONTROL_SQLCOMMAND_1 AS CONTROL_DEF_VALUE, CONTROL_NAME FROM VWPMO_CONTROL_SCREEN where FORM_ID = {0} and CONTROL_SQLCOMMAND_1 <> '' AND CONTROL_SQLCOMMAND_1 NOT LIKE '%@%@%' AND CONTROL_SQLCOMMAND_1 LIKE '%@RECORD_ID%'", FormID)
|
||||
Dim DEFAULT_VALUE_DT As DataTable = ClassDatabase.Return_Datatable(SQL)
|
||||
|
||||
LoadDefaultValue(CONTROL_ID, RecordID, control, ParentRecordId, entity_ID)
|
||||
For Each row As DataRow In DEFAULT_VALUE_DT.Rows
|
||||
|
||||
Dim defaultValue = row.Item("CONTROL_DEF_VALUE")
|
||||
Dim controlId As Integer = row.Item("CONTROL_ID")
|
||||
Dim controlName As String = row.Item("CONTROL_NAME")
|
||||
|
||||
Dim control As Control = controls.Find(controlName, False)(0)
|
||||
|
||||
LoadDefaultValue(controlId, RecordID, control, parentRecordID, EntityID, defaultValue)
|
||||
|
||||
Next
|
||||
|
||||
|
||||
sw.Stop()
|
||||
Console.WriteLine("LoadDefaultValues took {0} milliseconds to load", sw.ElapsedMilliseconds)
|
||||
|
||||
'Den Focus auf das erste Steuerelement setzen
|
||||
If i = 1 Then
|
||||
control.Focus()
|
||||
End If
|
||||
|
||||
Next
|
||||
For Each c As Control In controls
|
||||
If Not TypeOf c Is Label Then
|
||||
c.Focus()
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
Catch ex As Exception
|
||||
MsgBox("Error in LoadDefaultValues: " & vbNewLine & ex.Message, MsgBoxStyle.Critical)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Public Shared Sub LoadDefaultValue(ControlID As Integer, RecordID As Integer, control As Control, ParentRecordId As Integer, entity_ID As Integer)
|
||||
|
||||
'Public Shared Sub LoadDefaultValues_(FormID As Integer, RecordID As Integer, controls As Control.ControlCollection, ParentRecordId As Integer, entity_ID As Integer)
|
||||
' '' Zuerst alle Controls leeren
|
||||
' ClearControlValues(controls)
|
||||
|
||||
' Dim i = 0
|
||||
' For Each control As Control In controls
|
||||
|
||||
' Dim CONTROL_ID = DirectCast(control.Tag, ClassControlMetadata).Id ' GetControlID_for_Name(control.Name, FormID)
|
||||
' If Not (TypeOf control Is Label) Then
|
||||
' i += 1
|
||||
' End If
|
||||
|
||||
' If TypeOf control Is GroupBox Then
|
||||
' LoadDefaultValues(FormID, RecordID, DirectCast(control, GroupBox).Controls, ParentRecordId, entity_ID)
|
||||
' End If
|
||||
|
||||
' 'LoadDefaultValue(CONTROL_ID, RecordID, control, ParentRecordId, entity_ID)
|
||||
|
||||
' 'Den Focus auf das erste Steuerelement setzen
|
||||
' If i = 1 Then
|
||||
' control.Focus()
|
||||
' End If
|
||||
|
||||
' Next
|
||||
'End Sub
|
||||
|
||||
Public Shared Sub LoadDefaultValue(ControlID As Integer, RecordID As Integer, control As Control, ParentRecordId As Integer, entity_ID As Integer, defaultValue As Object)
|
||||
Try
|
||||
Dim SQL = String.Format("SELECT CONTROL_DEF_VALUE FROM VWPMO_CONTROL_SCREEN WHERE CONTROL_ID = {0}", ControlID)
|
||||
Dim autoValue = ClassDatabase.Execute_Scalar(SQL)
|
||||
'Dim SQL = String.Format("SELECT CONTROL_DEF_VALUE FROM VWPMO_CONTROL_SCREEN WHERE CONTROL_ID = {0} and CONTROL_DEF_VALUE <> ''", ControlID)
|
||||
'Dim defaultValue = ClassDatabase.Execute_Scalar(SQL)
|
||||
|
||||
'Dim SQL = "SELECT * FROM VWPMO_CONTROL_SCREEN WHERE CONTROL_ID = " & ControlID
|
||||
'Dim DT As DataTable = ClassDatabase.Return_Datatable(SQL)
|
||||
@@ -626,84 +669,85 @@ Public Class ClassControlValues
|
||||
Console.WriteLine("obacht")
|
||||
End If
|
||||
Dim textbox As TextBox = DirectCast(control, TextBox)
|
||||
If IsDBNull(autoValue) Then
|
||||
If IsDBNull(defaultValue) Then
|
||||
textbox.Text = ""
|
||||
Else
|
||||
Dim vorgabe = autoValue
|
||||
Dim vorgabe = defaultValue
|
||||
'Wenn der Default Wert über einen Select kommt
|
||||
If vorgabe.ToString.ToLower.StartsWith("select") Then
|
||||
vorgabe = autoValue.Replace("@FORM_ID", CURRENT_FORM_ID)
|
||||
vorgabe = defaultValue.Replace("@FORM_ID", CURRENT_FORM_ID)
|
||||
vorgabe = vorgabe.Replace("@RECORD_ID", CURRENT_RECORD_ID)
|
||||
vorgabe = vorgabe.Replace("@RECORDID", CURRENT_RECORD_ID)
|
||||
vorgabe = vorgabe.Replace("@PARENTRECORD_ID", CURRENT_PARENT_ID)
|
||||
autoValue = ClassDatabase.Execute_Scalar(vorgabe.ToString, True)
|
||||
defaultValue = ClassDatabase.Execute_Scalar(vorgabe.ToString, True)
|
||||
If IsNothing(vorgabe) Then
|
||||
textbox.Text = ""
|
||||
End If
|
||||
End If
|
||||
textbox.Text = autoValue
|
||||
textbox.Text = defaultValue
|
||||
End If
|
||||
|
||||
Case GetType(CheckBox)
|
||||
Dim checkbox As CheckBox = DirectCast(control, CheckBox)
|
||||
checkbox.Checked = StrToBool(autoValue)
|
||||
checkbox.Checked = StrToBool(defaultValue)
|
||||
|
||||
Case GetType(RadioButton)
|
||||
Dim radio As RadioButton = DirectCast(control, RadioButton)
|
||||
radio.Checked = StrToBool(autoValue)
|
||||
radio.Checked = StrToBool(defaultValue)
|
||||
|
||||
Case GetType(CustomComboBox)
|
||||
|
||||
|
||||
Dim combobox As CustomComboBox = DirectCast(control, CustomComboBox)
|
||||
If IsDBNull(autoValue) Then
|
||||
If IsDBNull(defaultValue) Then
|
||||
combobox.SelectedIndex = -1
|
||||
Else
|
||||
combobox.SelectedIndex = combobox.FindStringExact(autoValue)
|
||||
combobox.SelectedIndex = combobox.FindStringExact(defaultValue)
|
||||
End If
|
||||
Case GetType(DevExpress.XtraEditors.DateEdit)
|
||||
Dim datepicker As DevExpress.XtraEditors.DateEdit = DirectCast(control, DevExpress.XtraEditors.DateEdit)
|
||||
|
||||
If IsDBNull(autoValue) Then
|
||||
autoValue = String.Empty
|
||||
If IsDBNull(defaultValue) Then
|
||||
defaultValue = String.Empty
|
||||
End If
|
||||
|
||||
Dim result As EnumDateTimePickerDefaultValueOptions = EnumDateTimePickerDefaultValueOptions.Empty
|
||||
Dim success = [Enum].TryParse(Of EnumDateTimePickerDefaultValueOptions)(autoValue, result)
|
||||
Dim success = [Enum].TryParse(Of EnumDateTimePickerDefaultValueOptions)(defaultValue, result)
|
||||
|
||||
If success Then
|
||||
If result = EnumDateTimePickerDefaultValueOptions.Empty Then
|
||||
' DBNull.Value leert das DateEdit control.
|
||||
autoValue = DBNull.Value
|
||||
defaultValue = DBNull.Value
|
||||
ElseIf result = EnumDateTimePickerDefaultValueOptions.CurrentDate Then
|
||||
autoValue = Now
|
||||
defaultValue = Now
|
||||
End If
|
||||
Else
|
||||
'Wenn der DefaultWert nicht gelesen werden konnte, DateEdit leeren
|
||||
autoValue = DBNull.Value
|
||||
defaultValue = DBNull.Value
|
||||
End If
|
||||
|
||||
' Mit EditValue kann man auch den angezeigten Wert leeren
|
||||
'datepicker.DateTime = autoValue
|
||||
datepicker.EditValue = autoValue
|
||||
datepicker.EditValue = defaultValue
|
||||
Case GetType(Label)
|
||||
Dim lbl As Label = DirectCast(control, Label)
|
||||
Dim CONNID = ClassDatabase.Execute_Scalar(String.Format("SELECT CONNECTION_ID_1 FROM TBPMO_CONTROL WHERE GUID = {0}", ControlID))
|
||||
Dim SQL_AUTOVALUE As String = ClassDatabase.Execute_Scalar(String.Format("SELECT SQL_COMMAND_1 FROM TBPMO_CONTROL WHERE GUID = {0}", ControlID))
|
||||
SQL_AUTOVALUE = ClassControlValues.ReplaceSqlCommandPlaceholders(SQL_AUTOVALUE, RecordID, ParentRecordId, entity_ID)
|
||||
'Dim SQL_AUTOVALUE As String = ClassDatabase.Execute_Scalar(String.Format("SELECT SQL_COMMAND_1 FROM TBPMO_CONTROL WHERE GUID = {0}", ControlID))
|
||||
defaultValue = ClassControlValues.ReplaceSqlCommandPlaceholders(defaultValue, RecordID, ParentRecordId, entity_ID)
|
||||
|
||||
If SQL_AUTOVALUE = "" Or IsDBNull(SQL_AUTOVALUE) Then
|
||||
|
||||
If defaultValue = "" Or IsDBNull(defaultValue) Then
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
If Not IsNothing(CONNID) Then
|
||||
autoValue = ClassDatabase.Execute_ScalarWithConnection(CONNID, SQL_AUTOVALUE)
|
||||
defaultValue = ClassDatabase.Execute_ScalarWithConnection(CONNID, defaultValue)
|
||||
Else
|
||||
autoValue = ClassDatabase.Execute_Scalar(SQL_AUTOVALUE, True)
|
||||
defaultValue = ClassDatabase.Execute_Scalar(defaultValue, True)
|
||||
End If
|
||||
' AutoValue = ClassDatabase.Execute_Scalar(SQL)
|
||||
|
||||
If Not IsNothing(autoValue) And Not IsDBNull(autoValue) Then
|
||||
lbl.Text = autoValue
|
||||
If Not IsNothing(defaultValue) And Not IsDBNull(defaultValue) Then
|
||||
lbl.Text = defaultValue
|
||||
End If
|
||||
|
||||
End Select
|
||||
|
||||
@@ -166,6 +166,7 @@ Public Class frmConstructor_Main
|
||||
Me.Cursor = Cursors.Default
|
||||
' Verhindert den Zeilenwechsel
|
||||
e.Cancel = True
|
||||
Exit Sub
|
||||
End Try
|
||||
End If
|
||||
|
||||
@@ -1333,7 +1334,9 @@ Public Class frmConstructor_Main
|
||||
CURRENT_RECORD_ID = NewRecordId
|
||||
RECORD_ID = NewRecordId
|
||||
SELECTED_RECORD_ID = NewRecordId
|
||||
|
||||
ClassControlValues.LoadDefaultValues(ENTITY_ID, SELECTED_RECORD_ID, pnlDetails.Controls, CURRENT_PARENT_ID, ENTITY_ID)
|
||||
|
||||
' Das StatusLabel aktualisieren
|
||||
Update_Record_Label(NewRecordId)
|
||||
' Im gegensatz zu EnableEditMode muss hier nur der save button enabled werden
|
||||
|
||||
Reference in New Issue
Block a user