This commit is contained in:
SchreiberM
2016-01-20 15:46:59 +01:00
9 changed files with 222 additions and 138 deletions

View File

@@ -165,7 +165,7 @@
Public Shared Function UpdateControl(control As Control, properties As Object)
Try
' Nach Typ den Update Befehl anpassen
Dim CurrentType As String = control.GetType.Name
Dim type As String = control.GetType.Name
Dim SQL As String
Dim NAME As String
@@ -181,6 +181,21 @@
Dim SHOW_COLUMN As Integer
Dim STATIC_LIST As String
' So sollte diese Funktion später mal aussehen :(
'Select Case type
' Case "TextBox"
' NAME = properties.Name
' MULTILINE = ClassConverter.BoolToInt(properties.Multiline)
' COL_NAME = ClassConverter.ToStringOrDefault(properties.ColumnTitle)
' DEFAULTVALUE = ClassConverter.ToStringOrDefault(properties.DefaultValue)
' SHOW_COLUMN = ClassConverter.BoolToInt(properties.ShowColumn)
' FORMAT_TYPE = properties.Format.ToString()
' REQUIRED = ClassConverter.BoolToInt(properties.IsRequired)
' READ_ONLY = ClassConverter.BoolToInt(properties.IsReadOnly)
' SQLCommand = ClassConverter.SQLValueToString(properties.SQLCommand)
'End Select
NAME = properties.Name
If propExists(properties, "Multiline") Then
@@ -195,34 +210,36 @@
COL_NAME = String.Empty
End If
If CurrentType = "RadioButton" AndAlso propExistsWithType(properties, "DefaultValue", GetType(Boolean)) Then
If type = "RadioButton" Then
DEFAULTVALUE = properties.DefaultValue
ElseIf CurrentType = "CheckBox" AndAlso propExistsWithType(properties, "DefaultValue", GetType(Boolean)) Then
ElseIf type = "CheckBox" Then
DEFAULTVALUE = properties.DefaultValue
ElseIf propExists(properties, "DefaultValue") Then
ElseIf type = "CheckBox" Then
DEFAULTVALUE = properties.DefaultValue
Else
DEFAULTVALUE = ""
ElseIf type = "ComboBox" Then
DEFAULTVALUE = properties.DefaultValue
ElseIf type = "DateEdit" Then
DEFAULTVALUE = ClassConverter.ToDateTimePickerOptionsOrDefault(properties.DefaultValue)
End If
If CurrentType = "TextBox" OrElse
CurrentType = "ComboBox" OrElse
CurrentType = "CheckBox" OrElse
CurrentType = "RadioButton" OrElse
CurrentType = "CheckedListBoxControl" OrElse
CurrentType = "ListBoxControl" Then
If type = "TextBox" OrElse
type = "ComboBox" OrElse
type = "CheckBox" OrElse
type = "RadioButton" OrElse
type = "CheckedListBoxControl" OrElse
type = "ListBoxControl" Then
SHOW_COLUMN = BoolToInt(properties.ShowColumn)
Else
SHOW_COLUMN = BoolToInt(True)
End If
If CurrentType = "TextBox" AndAlso propExists(properties, "Format") Then
If type = "TextBox" AndAlso propExists(properties, "Format") Then
FORMAT_TYPE = properties.Format.ToString
ElseIf CurrentType = "ComboBox" AndAlso propExists(properties, "Format") Then
ElseIf type = "ComboBox" AndAlso propExists(properties, "Format") Then
FORMAT_TYPE = properties.Format.ToString
Else
FORMAT_TYPE = EnumFormat.String.ToString
FORMAT_TYPE = EnumFormatOptions.String.ToString
End If
If propExists(properties, "IsRequired") Then

View File

@@ -337,9 +337,9 @@ Public Class ClassControlCommandsUI
If CONTROL_ID <> -1 Then
CONTROL_VALUE = GetControlValue(ctrl)
End If
If TypeName(ctrl).ToString = "DateEdit" Then
CONTROL_VALUE = CDate(CONTROL_VALUE)
End If
'If TypeName(ctrl).ToString = "DateEdit" Then
' CONTROL_VALUE = CDate(CONTROL_VALUE)
'End If
'If CONTROL_ID = 489 Then
' Console.WriteLine(TypeName(ctrl))
'End If
@@ -514,7 +514,13 @@ Public Class ClassControlCommandsUI
Case "RadioButton"
Return DirectCast(ctrl, RadioButton).Checked.ToString()
Case "DateEdit"
Return DirectCast(ctrl, DevExpress.XtraEditors.DateEdit).DateTime.ToString("yyyy-MM-dd")
Dim Value = DirectCast(ctrl, DevExpress.XtraEditors.DateEdit).EditValue
If IsDBNull(Value) Then
Return ""
Else
Return DirectCast(ctrl, DevExpress.XtraEditors.DateEdit).DateTime.ToString("yyyy-MM-dd")
End If
Case "PictureBox"
'Return "PictureBox" 'Es ist egal was für ein String hier zurückgegeben wird, hauptsache nicht Nothing
Case "CheckedListBoxControl"
@@ -612,22 +618,19 @@ Public Class ClassControlCommandsUI
Try
Dim AddedWho = Environment.UserName
Dim FORMAT_TYPE As String = ClassDatabase.Execute_Scalar("SELECT FORMAT_TYPE FROM TBPMO_CONTROL WHERE GUID = " & ControlID)
Try
Select Case FORMAT_TYPE
Case "Currency"
If Not Value = String.Empty Then
Value = Decimal.Parse(Value, Globalization.NumberStyles.Currency).ToString
End If
Case "Decimal"
If Not Value = String.Empty Then
Value = Decimal.Parse(Value, Globalization.NumberStyles.Integer)
End If
Select Case FORMAT_TYPE
Case "Currency"
If Not Value = String.Empty Then
Value = Decimal.Parse(Value, Globalization.NumberStyles.Currency).ToString
End If
End Select
Catch ex As Exception
ClassLogger.Add("Unerwarteter Fehler in Insert ConvertValue to Format'" & FORMAT_TYPE & "': " & ex.Message, True)
End Try
Case "Decimal"
If Not Value = String.Empty Then
Value = Decimal.Parse(Value, Globalization.NumberStyles.Integer)
End If
End Select
Using conn As New SqlClient.SqlConnection(MyConnectionString)
Dim cmd As New SqlClient.SqlCommand("INSERT INTO TBPMO_CONTROL_VALUE (CONTROL_ID, RECORD_ID, VALUE, ADDED_WHO) VALUES (@CONTROL_ID, @RECORD_ID, @VALUE, @ADDED_WHO)", conn)
@@ -653,19 +656,15 @@ Public Class ClassControlCommandsUI
Try
Dim CHANGED_WHO = Environment.UserName
Dim FORMAT_TYPE As String = ClassDatabase.Execute_Scalar("SELECT FORMAT_TYPE FROM TBPMO_CONTROL WHERE GUID = " & ControlID)
Try
If Not Value = String.Empty Then
Select Case FORMAT_TYPE
Case "Currency"
Value = Decimal.Parse(Value, Globalization.NumberStyles.Currency).ToString
Case "Decimal"
Value = Decimal.Parse(Value, Globalization.NumberStyles.Integer)
End Select
End If
Catch ex As Exception
ClassLogger.Add("Unerwarteter Fehler in Update ConvertValue to Format'" & FORMAT_TYPE & "': " & ex.Message, True)
End Try
If Not Value = String.Empty Then
Select Case FORMAT_TYPE
Case "Currency"
Value = Decimal.Parse(Value, Globalization.NumberStyles.Currency).ToString
Case "Decimal"
Value = Decimal.Parse(Value, Globalization.NumberStyles.Integer)
End Select
End If
Using conn As New SqlClient.SqlConnection(MyConnectionString)
Dim cmd As New SqlClient.SqlCommand("UPDATE TBPMO_CONTROL_VALUE SET VALUE = @VALUE, CHANGED_WHO = @CHANGED_WHO WHERE CONTROL_ID = @CONTROL_ID AND RECORD_ID = @RECORD_ID", conn)
@@ -679,9 +678,6 @@ Public Class ClassControlCommandsUI
Return True
End Using
'Dim SQL As String = "UPDATE TBPMO_CONTROL_VALUE SET VALUE = '" & Value & "', CHANGED_WHO = '" & CHANGED_WHO & "' WHERE CONTROL_ID = " & ControlID & " AND RECORD_ID = " & RecordID
'Return ClassDatabase.Execute_non_Query(Sql, True)
Catch ex As Exception
ClassLogger.Add("Unerwarteter Fehler in UpdateControlValue: " & ex.Message, True)
Return False

View File

@@ -242,11 +242,11 @@ Module ClassControlProperties
<CategoryAttribute("Ansichtseinstellungen")>
<DescriptionAttribute("Gibt das Format des Textes an.")>
Public Property Format() As EnumFormat
Public Property Format() As EnumFormatOptions
Get
Return _format
End Get
Set(value As EnumFormat)
Set(value As EnumFormatOptions)
_format = value
End Set
End Property
@@ -267,15 +267,15 @@ Module ClassControlProperties
Private _master_data_id As Integer
Private _static_list As String
Private _format As EnumFormat
Private _format As EnumFormatOptions
<CategoryAttribute("Ansichtseinstellungen")>
<DescriptionAttribute("Gibt das Format des Textes an.")>
Public Property Format() As EnumFormat
Public Property Format() As EnumFormatOptions
Get
Return _format
End Get
Set(value As EnumFormat)
Set(value As EnumFormatOptions)
_format = value
End Set
End Property
@@ -304,6 +304,20 @@ Module ClassControlProperties
End Class
Public Class DateTimePickerProperties
Inherits InputControlProperties
Private _default_value As EnumDateTimePickerDefaultValueOptions = EnumDateTimePickerDefaultValueOptions.Empty
<CategoryAttribute("Sonstige Einstellungen")>
<DescriptionAttribute("Gibt den Standardwert dieses Elements an.")>
Public Overloads Property DefaultValue() As EnumDateTimePickerDefaultValueOptions
Get
Return _default_value
End Get
Set(value As EnumDateTimePickerDefaultValueOptions)
_default_value = value
End Set
End Property
End Class
Public Class CheckBoxProperties
Inherits InputControlProperties

View File

@@ -345,11 +345,25 @@ Public Class ClassControlValues
End If
Case GetType(DevExpress.XtraEditors.DateEdit)
Dim datepicker As DevExpress.XtraEditors.DateEdit = DirectCast(control, DevExpress.XtraEditors.DateEdit)
If IsDBNull(autoValue) OrElse autoValue = "" OrElse autoValue = "False" Then
autoValue = Now
Dim result As EnumDateTimePickerDefaultValueOptions = EnumDateTimePickerDefaultValueOptions.Empty
Dim success = [Enum].TryParse(Of EnumDateTimePickerDefaultValueOptions)(autoValue, result)
If success Then
If result = EnumDateTimePickerDefaultValueOptions.Empty Then
' DBNull.Value leert das DateEdit control.
autoValue = DBNull.Value
ElseIf result = EnumDateTimePickerDefaultValueOptions.CurrentDate Then
autoValue = Now
End If
Else
'Wenn der DefaultWert nicht gelesen werden konnte, DateEdit leeren
autoValue = DBNull.Value
End If
datepicker.DateTime = autoValue
' Mit EditValue kann man auch den angezeigten Wert leeren
'datepicker.DateTime = autoValue
datepicker.EditValue = autoValue
End Select
Catch ex As Exception
MsgBox("Unexpected Error in LoadDefaultValue:" & vbNewLine & ex.Message, MsgBoxStyle.Critical)

View File

@@ -1,38 +0,0 @@
Public Class ClassControlValuesConverter
Public Shared Function ToBooleanOrDefault(value As Object, Optional defaultValue As Boolean = False)
Try
If IsDBNull(value) OrElse value = "" Then
Return defaultValue
Else
Return Convert.ToBoolean(value)
End If
Catch ex As Exception
Return defaultValue
End Try
End Function
Public Shared Function ToStringOrDefault(value As Object, Optional defaultValue As String = "")
Try
If IsDBNull(value) OrElse String.IsNullOrEmpty(value) Then
Return defaultValue
Else
Return Convert.ToString(value)
End If
Catch ex As Exception
Return defaultValue
End Try
End Function
Public Shared Function ToIntOrDefault(value As Object, Optional defaultValue As Integer = 0)
Try
If IsDBNull(value) Then
Return defaultValue
Else
Return Convert.ToInt16(value)
End If
Catch ex As Exception
Return defaultValue
End Try
End Function
End Class

View File

@@ -0,0 +1,88 @@
Public Class ClassConverter
' ------------- STRING TO TYPE -------------
Public Shared Function ToBooleanOrDefault(value As Object, Optional defaultValue As Boolean = False)
Try
If IsDBNull(value) OrElse value = "" Then
Return defaultValue
Else
Return Convert.ToBoolean(value)
End If
Catch ex As Exception
Return defaultValue
End Try
End Function
Public Shared Function ToStringOrDefault(value As Object, Optional defaultValue As String = "")
Try
If IsDBNull(value) OrElse String.IsNullOrEmpty(value) Then
Return defaultValue
Else
Return Convert.ToString(value)
End If
Catch ex As Exception
Return defaultValue
End Try
End Function
Public Shared Function ToIntOrDefault(value As Object, Optional defaultValue As Integer = 0)
Try
If IsDBNull(value) Then
Return defaultValue
Else
Return Convert.ToInt16(value)
End If
Catch ex As Exception
Return defaultValue
End Try
End Function
' ------------- TYPE TO TYPE -------------
Public Shared Function BoolToInt(bool As Boolean)
Return IIf(bool, 1, 0)
End Function
Public Shared Function IntToBoolOrDefault(int As Integer, Optional defaultValue As Boolean = False)
If int = 0 Then
Return False
ElseIf int = 1 Then
Return True
Else
Return defaultValue
End If
End Function
' ------------- STRING TO ENUM -------------
Public Shared Function ToDateTimePickerOptionsOrDefault(value As String)
Try
If IsDBNull(value) OrElse String.IsNullOrEmpty(value) Then
Return EnumDateTimePickerDefaultValueOptions.Empty
Else
Dim result As EnumDateTimePickerDefaultValueOptions
Dim success = [Enum].TryParse(Of EnumDateTimePickerDefaultValueOptions)(value, result)
If success Then
Return result
Else
Return EnumDateTimePickerDefaultValueOptions.Empty
End If
End If
Catch ex As Exception
Return EnumDateTimePickerDefaultValueOptions.Empty
End Try
End Function
' ------------- TYPE TO STRING -------------
Public Shared Function SQLValueToString(value As SQLValue) As String
Dim cmd As String = value.Value
If cmd.Contains("'") Then
cmd = cmd.Replace("'", "''")
End If
Return cmd
End Function
End Class

View File

@@ -248,7 +248,7 @@
<ItemGroup>
<Compile Include="ClassControlLoader.vb" />
<Compile Include="ClassControlValueCache.vb" />
<Compile Include="ClassControlValuesConverter.vb" />
<Compile Include="ClassConverter.vb" />
<Compile Include="ClassFolderWatcher.vb" />
<Compile Include="ClassJumpRecord.vb" />
<Compile Include="ClassLicence.vb" />

View File

@@ -1,11 +1,16 @@
Module ModuleHelperMethods
Public Enum EnumFormat
Public Enum EnumFormatOptions
[String] = 0
Currency = 1
[Decimal] = 2
End Enum
Public Enum EnumDateTimePickerDefaultValueOptions
CurrentDate = 0
Empty = 1
End Enum
Public Function BoolToInt(bool As Boolean) As Integer
' Wandelt einen Boolean Wert in einen Int um
Return IIf(bool, 1, 0)

View File

@@ -23,6 +23,26 @@
End Try
End Sub
Public Sub LoadControlPropertiesNeu(ctrl As Control)
Try
'TODO: LoadControlProperties Neuschreiben!!!
Dim sql As String = String.Format("SELECT * FROM VWPMO_CONTROL_SCREEN WHERE CONTROL_ID = {0}", ctrl.Tag)
Dim dt As DataTable = ClassDatabase.Execute_Scalar(sql)
Dim props As Object = Nothing
Dim row As DataRow = Nothing
If dt.Rows.Count <> 1 Then
Exit Sub
End If
row = dt.Rows(0)
Catch ex As Exception
MsgBox("Error in loadcontrolproperties" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
End Try
End Sub
' ADDED 25.11
' Lade Control Eigenschaften und zeige diese an
' Wird von frmLevelDesigner aufgerufen
@@ -52,48 +72,32 @@
props.Caption = row.Item("CTRLSCR_CAPTION")
Case "Textbox"
props = New TextBoxProperties()
If Not IsDBNull(row.Item("CONTROL_DEF_VALUE")) Then
props.DefaultValue = row.Item("CONTROL_DEF_VALUE")
Else
props.DefaultValue = ""
End If
props.DefaultValue = ClassConverter.ToStringOrDefault(row.Item("CONTROL_DEF_VALUE"))
If Not IsDBNull(row.Item("CONTROL_FORMAT_TYPE")) Then
props.Format = DirectCast([Enum].Parse(GetType(EnumFormat), row.Item("CONTROL_FORMAT_TYPE")), Integer)
props.Format = DirectCast([Enum].Parse(GetType(EnumFormatOptions), row.Item("CONTROL_FORMAT_TYPE")), Integer)
Else
props.Format = "String"
End If
Case "Combobox"
props = New ComboBoxProperties()
props.MasterDataId = row.Item("CTRLSCR_MASTER_DATA_ID")
If Not IsDBNull(row.Item("CONTROL_DEF_VALUE")) Then
props.DefaultValue = row.Item("CONTROL_DEF_VALUE")
Else
props.DefaultValue = ""
End If
props.DefaultValue = ClassConverter.ToStringOrDefault(row.Item("CONTROL_DEF_VALUE"))
If Not IsDBNull(row.Item("CONTROL_FORMAT_TYPE")) Then
props.Format = DirectCast([Enum].Parse(GetType(EnumFormat), row.Item("CONTROL_FORMAT_TYPE")), Integer)
props.Format = DirectCast([Enum].Parse(GetType(EnumFormatOptions), row.Item("CONTROL_FORMAT_TYPE")), Integer)
Else
props.Format = "String"
End If
If Not IsDBNull(row.Item("CONTROL_STATIC_LIST")) Then
props.StaticList = row.Item("CONTROL_STATIC_LIST")
Else
props.StaticList = ""
End If
props.StaticList = ClassConverter.ToStringOrDefault(row.Item("CONTROL_STATIC_LIST"))
Case "Checkbox"
props = New CheckBoxProperties()
props.Caption = row.Item("CTRLSCR_CAPTION")
If IsDBNull(row.Item("CONTROL_DEF_VALUE")) Or row.Item("CONTROL_DEF_VALUE") = String.Empty Then
props.DefaultValue = False
Else
props.DefaultValue = row.Item("CONTROL_DEF_VALUE")
End If
props.DefaultValue = ClassConverter.ToBooleanOrDefault(row.Item("CONTROL_DEF_VALUE"))
Case "Datepicker"
props = New DateTimePickerProperties()
props.DefaultValue = ClassConverter.ToDateTimePickerOptionsOrDefault(row.Item("CONTROL_DEF_VALUE"))
Case "Datagridview"
props = New DataGridViewProperties()
Case "Groupbox"
@@ -105,33 +109,17 @@
Case "RadioButton"
props = New RadioButtonProperties()
props.Caption = row.Item("CTRLSCR_CAPTION")
props.DefaultValue = ClassControlValuesConverter.ToBooleanOrDefault(row.Item("CONTROL_DEF_VALUE"))
'If Not IsDBNull(row.Item("CONTROL_DEF_VALUE")) Then
' props.DefaultValue = row.Item("CONTROL_DEF_VALUE")
'Else
' props.DefaultValue = False
'End If
props.DefaultValue = ClassConverter.ToBooleanOrDefault(row.Item("CONTROL_DEF_VALUE"))
Case "F_AddAppointment"
props = New FunctionAddAppointment()
Case "F_AddFormData"
props = New FunctionAddFormData()
Case "CheckedListBox"
props = New ComboBoxProperties()
If Not IsDBNull(row.Item("CONTROL_STATIC_LIST")) Then
props.StaticList = row.Item("CONTROL_STATIC_LIST")
Else
props.StaticList = ""
End If
props.StaticList = ClassConverter.ToStringOrDefault(row.Item("CONTROL_STATIC_LIST"))
Case "ListBox"
props = New ComboBoxProperties()
If Not IsDBNull(row.Item("CONTROL_STATIC_LIST")) Then
props.StaticList = row.Item("CONTROL_STATIC_LIST")
Else
props.StaticList = ""
End If
props.StaticList = ClassConverter.ToStringOrDefault(row.Item("CONTROL_STATIC_LIST"))
Case Else
MsgBox("Unknown control type " & type, MsgBoxStyle.Exclamation, "Error in LoadControlProperties:")
End Select