From 2e19d878e0821557c383e8a3411b56c5932f2463 Mon Sep 17 00:00:00 2001 From: Jonathan Jenne Date: Fri, 10 May 2019 15:31:03 +0200 Subject: [PATCH 1/7] importzugferdfiles: fix conversion error --- Jobs/EDMI/ZUGFeRD/ImportZUGFeRDFiles.vb | 9 ++++++++- Jobs/EDMI/ZUGFeRD/PropertyValues.vb | 15 ++------------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/Jobs/EDMI/ZUGFeRD/ImportZUGFeRDFiles.vb b/Jobs/EDMI/ZUGFeRD/ImportZUGFeRDFiles.vb index af954877..64faa339 100644 --- a/Jobs/EDMI/ZUGFeRD/ImportZUGFeRDFiles.vb +++ b/Jobs/EDMI/ZUGFeRD/ImportZUGFeRDFiles.vb @@ -288,12 +288,16 @@ Public Class ImportZUGFeRDFiles ToDictionary(Function(Item) Item.Key, Function(Item) Item.Value) + _logger.Debug("Found {0} default properties.", oDefaultProperties.Count) + ' PropertyMap items with `IsGrouped = True` are grouped by group scope Dim oGroupedProperties = args.PropertyMap. Where(Function(Item) Item.Value.IsGrouped = True). ToLookup(Function(Item) Item.Value.GroupScope, ' Lookup key is group scope Function(Item) Item) + _logger.Debug("Found {0} properties grouped in {1} group(s)", args.PropertyMap.Count - oDefaultProperties.Count, oGroupedProperties.Count) + ' Iterate through groups to get group scope and group items For Each oGroup In oGroupedProperties Dim oGroupScope = oGroup.Key @@ -355,7 +359,10 @@ Public Class ImportZUGFeRDFiles ' Iterate through default properties For Each Item As KeyValuePair(Of String, XmlItemProperty) In oDefaultProperties - Dim oPropertyValue As String = PropertyValues.GetPropValue(oDocument, Item.Key) + Dim oPropertyValueList As List(Of Object) = PropertyValues.GetPropValue(oDocument, Item.Key) + Dim oPropertyValue = oPropertyValueList. + DefaultIfEmpty(New List(Of Object) From {Nothing}). + First() Dim oPropertyDescription As String = Item.Value.Description If String.IsNullOrEmpty(oPropertyValue) Then diff --git a/Jobs/EDMI/ZUGFeRD/PropertyValues.vb b/Jobs/EDMI/ZUGFeRD/PropertyValues.vb index 369081bc..b8a03aa0 100644 --- a/Jobs/EDMI/ZUGFeRD/PropertyValues.vb +++ b/Jobs/EDMI/ZUGFeRD/PropertyValues.vb @@ -6,18 +6,7 @@ Public Class PropertyValues Private Shared _indexPattern = "\((\d+)\)" Private Shared _indexRegex As New Regex(_indexPattern) - Public Shared Function GetPropValues(Obj As Object, PropertyName As String) - Dim oResult As Object = GetPropValue(Obj, PropertyName) - - ' Wrap the result of `GetPropValue` in a list if a single Value is returned - If TypeOf oResult Is List(Of Object) Then - Return oResult - Else - Return New List(Of Object) From {oResult} - End If - End Function - - Public Shared Function GetPropValue(Obj As Object, PropertyName As String) + Public Shared Function GetPropValue(Obj As Object, PropertyName As String) As List(Of Object) Dim oNameParts As String() = PropertyName.Split("."c) If IsNothing(Obj) Then @@ -78,7 +67,7 @@ Public Class PropertyValues End If Next - Return Obj + Return New List(Of Object) From {Obj} End Function Private Shared Function GetIndex(Prop As String) As Integer From cc9ab1b0b0b3d1e8e31a06a2f7e12594d99db530 Mon Sep 17 00:00:00 2001 From: Jonathan Jenne Date: Fri, 10 May 2019 17:19:45 +0200 Subject: [PATCH 2/7] ImportZUGFeRD: fix shti --- DDZUGFeRDService/ThreadRunner.vb | 6 +++- Jobs/EDMI/ZUGFeRD/ImportZUGFeRDFiles.vb | 47 ++++++++++++++++++++----- Jobs/EDMI/ZUGFeRD/PropertyValues.vb | 6 ++-- 3 files changed, 46 insertions(+), 13 deletions(-) diff --git a/DDZUGFeRDService/ThreadRunner.vb b/DDZUGFeRDService/ThreadRunner.vb index 3d2601b4..45dbb8d5 100644 --- a/DDZUGFeRDService/ThreadRunner.vb +++ b/DDZUGFeRDService/ThreadRunner.vb @@ -163,11 +163,15 @@ Public Class ThreadRunner Dim tableName = row.Item("TABLE_NAME") Dim description = row.Item("DESCRIPTION") Dim isRequired = row.Item("IS_REQUIRED") + Dim isGrouped = row.Item("IS_GROUPED") + Dim groupScope = row.Item("GROUP_SCOPE") args.PropertyMap.Add(xmlPath, New XmlItemProperty() With { .Description = description, .TableName = tableName, - .IsRequired = isRequired + .IsRequired = isRequired, + .IsGrouped = isGrouped, + .GroupScope = groupScope }) Next diff --git a/Jobs/EDMI/ZUGFeRD/ImportZUGFeRDFiles.vb b/Jobs/EDMI/ZUGFeRD/ImportZUGFeRDFiles.vb index 64faa339..e04f4782 100644 --- a/Jobs/EDMI/ZUGFeRD/ImportZUGFeRDFiles.vb +++ b/Jobs/EDMI/ZUGFeRD/ImportZUGFeRDFiles.vb @@ -300,13 +300,15 @@ Public Class ImportZUGFeRDFiles ' Iterate through groups to get group scope and group items For Each oGroup In oGroupedProperties - Dim oGroupScope = oGroup.Key + Dim oGroupScope As String = oGroup.Key Dim oPropertyList As New Dictionary(Of XmlItemProperty, List(Of Object)) Dim oRowCount = 0 + _logger.Debug("Fetching Property values for group {0}.", oGroupScope) + ' get properties as a nested object, see `oPropertyList` For Each oProperty As KeyValuePair(Of String, XmlItemProperty) In oGroup - Dim oPropertyValues As List(Of Object) = PropertyValues.GetPropValues(oDocument, oProperty.Key) + Dim oPropertyValues As List(Of Object) = PropertyValues.GetPropValue(oDocument, oProperty.Key) oPropertyList.Add(oProperty.Value, oPropertyValues) @@ -316,6 +318,8 @@ Public Class ImportZUGFeRDFiles End If Next + _logger.Debug("Done Fetching Property values.") + ' Structure of oPropertyList ' [ # Propertyname # Row 1 # Row 2 ' PositionsMenge: [BilledQuantity1, BilledQuantity2, ...], @@ -323,23 +327,39 @@ Public Class ImportZUGFeRDFiles ' ... ' ] For oRowIndex = 0 To oRowCount - 1 + _logger.Debug("Processing row {0}", oRowIndex) + For Each oColumn As KeyValuePair(Of XmlItemProperty, List(Of Object)) In oPropertyList Dim oTableName As String = oColumn.Key.TableName Dim oPropertyDescription As String = oColumn.Key.Description Dim oPropertyValue = oColumn.Value.Item(oRowIndex) Dim oRowCounter = oRowIndex + 1 - If String.IsNullOrEmpty(oPropertyValue) Then + _logger.Debug("Processing property {0}.", oPropertyDescription) + + If TypeOf oPropertyValue Is List(Of Object) Then + Select Case oPropertyValue.Count + Case 0 + oPropertyValue = String.Empty + Case Else + Dim oList As List(Of Object) = DirectCast(oPropertyValue, List(Of Object)) + oPropertyValue = oList.Item(0) + End Select + End If + + If IsNothing(oPropertyValue) OrElse String.IsNullOrEmpty(oPropertyValue) Then If oColumn.Key.IsRequired Then - _logger.Warn("Property {0} is empty or not found. Continuing with Empty String.", oPropertyDescription) + _logger.Warn("Property {0} is empty or not found but was required. Continuing with Empty String.", oPropertyDescription) oMissingProperties.Add(oPropertyDescription) Else _logger.Warn("Property {0} is empty or not found. Continuing with Empty String.", oPropertyDescription) End If - oPropertyDescription = String.Empty + oPropertyValue = String.Empty End If + _logger.Debug("Property {0} has value {1}", oPropertyDescription, oPropertyValue) + Dim oCommand = $"INSERT INTO {oTableName} (REFERENCE_GUID, ITEM_DESCRIPTION, ITEM_VALUE, GROUP_COUNTER) VALUES ('{oFileGroupId}', '{oPropertyDescription}', '{oPropertyValue}', {oRowCounter})" _logger.Debug("Mapping Property {0} to value {1}. Will be inserted into table {2} with RowCounter {3}", oPropertyDescription, oPropertyValue, oTableName, oRowCounter) @@ -360,12 +380,21 @@ Public Class ImportZUGFeRDFiles ' Iterate through default properties For Each Item As KeyValuePair(Of String, XmlItemProperty) In oDefaultProperties Dim oPropertyValueList As List(Of Object) = PropertyValues.GetPropValue(oDocument, Item.Key) - Dim oPropertyValue = oPropertyValueList. - DefaultIfEmpty(New List(Of Object) From {Nothing}). - First() Dim oPropertyDescription As String = Item.Value.Description + Dim oPropertyValue As Object = Nothing + + If IsNothing(oPropertyValueList) Then + oPropertyValue = Nothing + ElseIf TypeOf oPropertyValueList Is List(Of Object) Then + Select Case oPropertyValueList.Count + Case 0 + oPropertyValue = Nothing + Case Else + oPropertyValue = oPropertyValueList.First() + End Select + End If - If String.IsNullOrEmpty(oPropertyValue) Then + If IsNothing(oPropertyValue) OrElse String.IsNullOrEmpty(oPropertyValue) Then If Item.Value.IsRequired Then _logger.Warn("Property {0} is empty but marked as required! Skipping.", oPropertyDescription) oMissingProperties.Add(oPropertyDescription) diff --git a/Jobs/EDMI/ZUGFeRD/PropertyValues.vb b/Jobs/EDMI/ZUGFeRD/PropertyValues.vb index b8a03aa0..b90aec42 100644 --- a/Jobs/EDMI/ZUGFeRD/PropertyValues.vb +++ b/Jobs/EDMI/ZUGFeRD/PropertyValues.vb @@ -10,7 +10,7 @@ Public Class PropertyValues Dim oNameParts As String() = PropertyName.Split("."c) If IsNothing(Obj) Then - Return Nothing + Return New List(Of Object) End If If oNameParts.Length = 1 Then @@ -31,11 +31,11 @@ Public Class PropertyValues Dim oInfo As PropertyInfo = oType.GetProperty(oPartName) If IsNothing(oInfo) Then - Return Nothing + Return New List(Of Object) End If If IsNothing(oInfo.GetValue(Obj, Nothing)) Then - Return Nothing + Return New List(Of Object) End If Obj = oInfo.GetValue(Obj, Nothing) From 83f026d38989660cd1ed3a98d1078c7d0bd9df3f Mon Sep 17 00:00:00 2001 From: Jonathan Jenne Date: Mon, 13 May 2019 12:37:01 +0200 Subject: [PATCH 3/7] WIP: Remove empty rows --- Jobs/EDMI/ZUGFeRD/ImportZUGFeRDFiles.vb | 28 ++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/Jobs/EDMI/ZUGFeRD/ImportZUGFeRDFiles.vb b/Jobs/EDMI/ZUGFeRD/ImportZUGFeRDFiles.vb index e04f4782..18007ebf 100644 --- a/Jobs/EDMI/ZUGFeRD/ImportZUGFeRDFiles.vb +++ b/Jobs/EDMI/ZUGFeRD/ImportZUGFeRDFiles.vb @@ -320,6 +320,32 @@ Public Class ImportZUGFeRDFiles _logger.Debug("Done Fetching Property values.") + + Dim oIndexesToRemove As New List(Of Integer) + + For oRowIndex = 0 To oRowCount - 1 + Dim oColumnIsEmpty = False + + For Each oRow In oPropertyList + Dim oValue As List(Of Object) = oRow.Value.Item(oRowIndex) + Dim oIsEmpty = oValue.Count = 0 + oColumnIsEmpty = oIsEmpty + + Console.WriteLine($"Value is empty: {oValue.Count = 0}") + Next + + If oColumnIsEmpty Then + oIndexesToRemove.Add(oRowIndex) + End If + + + + Console.WriteLine($"Column is empty: {oColumnIsEmpty}") + Next + + ' TODO: Remove Empty Rows by `oIndexesToRemove`! + + ' Structure of oPropertyList ' [ # Propertyname # Row 1 # Row 2 ' PositionsMenge: [BilledQuantity1, BilledQuantity2, ...], @@ -358,7 +384,7 @@ Public Class ImportZUGFeRDFiles oPropertyValue = String.Empty End If - _logger.Debug("Property {0} has value {1}", oPropertyDescription, oPropertyValue) + _logger.Debug("Property {0} has value '{1}'", oPropertyDescription, oPropertyValue) Dim oCommand = $"INSERT INTO {oTableName} (REFERENCE_GUID, ITEM_DESCRIPTION, ITEM_VALUE, GROUP_COUNTER) VALUES ('{oFileGroupId}', '{oPropertyDescription}', '{oPropertyValue}', {oRowCounter})" _logger.Debug("Mapping Property {0} to value {1}. Will be inserted into table {2} with RowCounter {3}", oPropertyDescription, oPropertyValue, oTableName, oRowCounter) From 58b65564fbf72a998e9c5a73d05df4615acb3e71 Mon Sep 17 00:00:00 2001 From: Jonathan Jenne Date: Mon, 13 May 2019 15:32:54 +0200 Subject: [PATCH 4/7] finish position import --- Jobs/EDMI/ZUGFeRD/ImportZUGFeRDFiles.vb | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Jobs/EDMI/ZUGFeRD/ImportZUGFeRDFiles.vb b/Jobs/EDMI/ZUGFeRD/ImportZUGFeRDFiles.vb index 18007ebf..3db28559 100644 --- a/Jobs/EDMI/ZUGFeRD/ImportZUGFeRDFiles.vb +++ b/Jobs/EDMI/ZUGFeRD/ImportZUGFeRDFiles.vb @@ -320,7 +320,6 @@ Public Class ImportZUGFeRDFiles _logger.Debug("Done Fetching Property values.") - Dim oIndexesToRemove As New List(Of Integer) For oRowIndex = 0 To oRowCount - 1 @@ -337,14 +336,19 @@ Public Class ImportZUGFeRDFiles If oColumnIsEmpty Then oIndexesToRemove.Add(oRowIndex) End If + Next + oIndexesToRemove = oIndexesToRemove. + OrderByDescending(Function(oIndex) oIndex). + ToList() - - Console.WriteLine($"Column is empty: {oColumnIsEmpty}") + For Each oIndex In oIndexesToRemove + For Each oRow In oPropertyList + oRow.Value.RemoveAt(oIndex) + Next Next - ' TODO: Remove Empty Rows by `oIndexesToRemove`! - + oRowCount -= oIndexesToRemove.Count ' Structure of oPropertyList ' [ # Propertyname # Row 1 # Row 2 From a1d6e0ff9b2d55252f9dd6280dacaefcbd5bea4d Mon Sep 17 00:00:00 2001 From: Jonathan Jenne Date: Mon, 13 May 2019 15:37:14 +0200 Subject: [PATCH 5/7] add comments --- Jobs/EDMI/ZUGFeRD/ImportZUGFeRDFiles.vb | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/Jobs/EDMI/ZUGFeRD/ImportZUGFeRDFiles.vb b/Jobs/EDMI/ZUGFeRD/ImportZUGFeRDFiles.vb index 3db28559..bcc54190 100644 --- a/Jobs/EDMI/ZUGFeRD/ImportZUGFeRDFiles.vb +++ b/Jobs/EDMI/ZUGFeRD/ImportZUGFeRDFiles.vb @@ -318,8 +318,10 @@ Public Class ImportZUGFeRDFiles End If Next + ' check for rows that are empty in every column + ' this happens when a grouped row is not filled + ' e.g. a row in a invoice that is just a note _logger.Debug("Done Fetching Property values.") - Dim oIndexesToRemove As New List(Of Integer) For oRowIndex = 0 To oRowCount - 1 @@ -327,10 +329,7 @@ Public Class ImportZUGFeRDFiles For Each oRow In oPropertyList Dim oValue As List(Of Object) = oRow.Value.Item(oRowIndex) - Dim oIsEmpty = oValue.Count = 0 - oColumnIsEmpty = oIsEmpty - - Console.WriteLine($"Value is empty: {oValue.Count = 0}") + oColumnIsEmpty = oValue.Count = 0 Next If oColumnIsEmpty Then @@ -338,16 +337,24 @@ Public Class ImportZUGFeRDFiles End If Next - oIndexesToRemove = oIndexesToRemove. - OrderByDescending(Function(oIndex) oIndex). - ToList() + _logger.Debug("Removing {0} empty rows.", oIndexesToRemove) + + + ' order indexes to remove descending to avoid indexOutOfRange errors + If oIndexesToRemove.Count > 0 Then + oIndexesToRemove = oIndexesToRemove. + OrderByDescending(Function(oIndex) oIndex). + ToList() + End If + ' now remove all empty rows. For Each oIndex In oIndexesToRemove For Each oRow In oPropertyList oRow.Value.RemoveAt(oIndex) Next Next + ' decrease row count by rows removed oRowCount -= oIndexesToRemove.Count ' Structure of oPropertyList From af4226b6821c85ab6cc18bb23e864fe690c804f0 Mon Sep 17 00:00:00 2001 From: Jonathan Jenne Date: Thu, 23 May 2019 11:00:29 +0200 Subject: [PATCH 6/7] disable button instead of hiding, remove empty values before saving, update dialog result handling --- Controls.LookupGrid/LookupControl.vbproj | 3 + Controls.LookupGrid/LookupControl2.resx | 123 ++++++++++++++++++ Controls.LookupGrid/LookupControl2.vb | 32 +++-- Controls.LookupGrid/frmLookupGrid.Designer.vb | 1 + Controls.LookupGrid/frmLookupGrid.vb | 2 +- 5 files changed, 148 insertions(+), 13 deletions(-) create mode 100644 Controls.LookupGrid/LookupControl2.resx diff --git a/Controls.LookupGrid/LookupControl.vbproj b/Controls.LookupGrid/LookupControl.vbproj index 9ebcc41b..42070850 100644 --- a/Controls.LookupGrid/LookupControl.vbproj +++ b/Controls.LookupGrid/LookupControl.vbproj @@ -151,6 +151,9 @@ LookupControl.vb + + LookupControl2.vb + VbMyResourcesResXFileCodeGenerator diff --git a/Controls.LookupGrid/LookupControl2.resx b/Controls.LookupGrid/LookupControl2.resx new file mode 100644 index 00000000..e5858cc2 --- /dev/null +++ b/Controls.LookupGrid/LookupControl2.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + False + + \ No newline at end of file diff --git a/Controls.LookupGrid/LookupControl2.vb b/Controls.LookupGrid/LookupControl2.vb index 54aa393d..95c502b4 100644 --- a/Controls.LookupGrid/LookupControl2.vb +++ b/Controls.LookupGrid/LookupControl2.vb @@ -22,7 +22,6 @@ Public Class LookupControl2 Return _SelectedValues End Get Set(value As List(Of String)) - _SelectedValues = value UpdateSelectedValues(value) End Set End Property @@ -31,19 +30,20 @@ Public Class LookupControl2 Return _ReadOnly End Get Set(value As Boolean) - SetButtonVisibility(Not value) + SetFormButtonEnabled(Not value) _ReadOnly = value End Set End Property Private ReadOnly _LookupFormButton As EditorButton + Private Const TAG_DROPDOWN = "openDropdown" Private Const TAG_BUTTON_LOOKUP_FORM = "openLookupForm" Private Const TEXT_NO_RECORDS = "Keine Datensätze ausgewählt" Private Const TEXT_ONE_RECORD = "Ein Datensatz ausgewählt" Private Const TEXT_N_RECORDS = "{0} Datensätze ausgewählt" - Private _SelectedValues As List(Of String) + Private _SelectedValues As New List(Of String) Private _ReadOnly As Boolean = False Shared Sub New() @@ -60,6 +60,7 @@ Public Class LookupControl2 .Tag = TAG_BUTTON_LOOKUP_FORM } + Properties.Buttons.Item(0).Tag = TAG_DROPDOWN Properties.Buttons.AddRange({_LookupFormButton}) AddHandler ButtonClick, AddressOf HandleButtonClick @@ -67,13 +68,23 @@ Public Class LookupControl2 AddHandler QueryPopUp, AddressOf HandleQueryPopup End Sub - Private Sub SetButtonVisibility(Visible As Boolean) + Private Sub SetFormButtonEnabled(Enabled As Boolean) Dim oButton As EditorButton = Properties.Buttons. Where(Function(b) b.Tag = TAG_BUTTON_LOOKUP_FORM). FirstOrDefault() If oButton IsNot Nothing Then - oButton.Visible = Visible + oButton.Enabled = Enabled + End If + End Sub + + Private Sub SetDropdownButtonEnabled(Enabled As Boolean) + Dim oButton As EditorButton = Properties.Buttons. + Where(Function(b) b.Tag = TAG_DROPDOWN). + FirstOrDefault() + + If oButton IsNot Nothing Then + oButton.Enabled = Enabled End If End Sub @@ -106,14 +117,7 @@ Public Class LookupControl2 If oResult = Windows.Forms.DialogResult.OK Then Dim oValues = oForm.SelectedValues - - UpdateSelectedValues(oValues) - SelectedValues = oValues - ElseIf oResult = Windows.Forms.DialogResult.Cancel Then - Dim oValues = New List(Of String) - UpdateSelectedValues(oValues) - SelectedValues = oValues End If End Using End Select @@ -124,6 +128,8 @@ Public Class LookupControl2 Exit Sub End If + Values.RemoveAll(Function(v) String.IsNullOrEmpty(v)) + If MultiSelect = True Then Properties.DataSource = Values @@ -140,6 +146,8 @@ Public Class LookupControl2 Text = Values.FirstOrDefault() EditValue = Nothing End If + + _SelectedValues = Values End Sub Private Function GetLookupForm() As frmLookupGrid diff --git a/Controls.LookupGrid/frmLookupGrid.Designer.vb b/Controls.LookupGrid/frmLookupGrid.Designer.vb index cc90e703..df89a0f1 100644 --- a/Controls.LookupGrid/frmLookupGrid.Designer.vb +++ b/Controls.LookupGrid/frmLookupGrid.Designer.vb @@ -69,6 +69,7 @@ Partial Class frmLookupGrid 'btnClear ' Me.btnClear.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.btnClear.DialogResult = System.Windows.Forms.DialogResult.OK Me.btnClear.Location = New System.Drawing.Point(236, 6) Me.btnClear.Name = "btnClear" Me.btnClear.Size = New System.Drawing.Size(136, 23) diff --git a/Controls.LookupGrid/frmLookupGrid.vb b/Controls.LookupGrid/frmLookupGrid.vb index 44517082..b186d83f 100644 --- a/Controls.LookupGrid/frmLookupGrid.vb +++ b/Controls.LookupGrid/frmLookupGrid.vb @@ -139,7 +139,7 @@ Public Class frmLookupGrid Private Sub btnClear_Click(sender As Object, e As EventArgs) Handles btnClear.Click SelectedValues = New List(Of String) - DialogResult = DialogResult.Cancel + DialogResult = DialogResult.OK Close() End Sub From 01b8b21dee44318cc042005b4b0e2dcb09364b37 Mon Sep 17 00:00:00 2001 From: Jonathan Jenne Date: Thu, 23 May 2019 11:00:44 +0200 Subject: [PATCH 7/7] update lookupcontrolgui --- LookupControlGui/Form1.Designer.vb | 122 ++++++++++++++++++++++++++++- LookupControlGui/Form1.resx | 36 +++++++++ LookupControlGui/Form1.vb | 17 ++-- 3 files changed, 168 insertions(+), 7 deletions(-) diff --git a/LookupControlGui/Form1.Designer.vb b/LookupControlGui/Form1.Designer.vb index 20e29cfc..825a143a 100644 --- a/LookupControlGui/Form1.Designer.vb +++ b/LookupControlGui/Form1.Designer.vb @@ -32,11 +32,43 @@ Partial Class Form1 Dim SerializableAppearanceObject6 As DevExpress.Utils.SerializableAppearanceObject = New DevExpress.Utils.SerializableAppearanceObject() Dim SerializableAppearanceObject7 As DevExpress.Utils.SerializableAppearanceObject = New DevExpress.Utils.SerializableAppearanceObject() Dim SerializableAppearanceObject8 As DevExpress.Utils.SerializableAppearanceObject = New DevExpress.Utils.SerializableAppearanceObject() + Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(Form1)) + Dim EditorButtonImageOptions3 As DevExpress.XtraEditors.Controls.EditorButtonImageOptions = New DevExpress.XtraEditors.Controls.EditorButtonImageOptions() + Dim SerializableAppearanceObject9 As DevExpress.Utils.SerializableAppearanceObject = New DevExpress.Utils.SerializableAppearanceObject() + Dim SerializableAppearanceObject10 As DevExpress.Utils.SerializableAppearanceObject = New DevExpress.Utils.SerializableAppearanceObject() + Dim SerializableAppearanceObject11 As DevExpress.Utils.SerializableAppearanceObject = New DevExpress.Utils.SerializableAppearanceObject() + Dim SerializableAppearanceObject12 As DevExpress.Utils.SerializableAppearanceObject = New DevExpress.Utils.SerializableAppearanceObject() + Dim EditorButtonImageOptions4 As DevExpress.XtraEditors.Controls.EditorButtonImageOptions = New DevExpress.XtraEditors.Controls.EditorButtonImageOptions() + Dim SerializableAppearanceObject13 As DevExpress.Utils.SerializableAppearanceObject = New DevExpress.Utils.SerializableAppearanceObject() + Dim SerializableAppearanceObject14 As DevExpress.Utils.SerializableAppearanceObject = New DevExpress.Utils.SerializableAppearanceObject() + Dim SerializableAppearanceObject15 As DevExpress.Utils.SerializableAppearanceObject = New DevExpress.Utils.SerializableAppearanceObject() + Dim SerializableAppearanceObject16 As DevExpress.Utils.SerializableAppearanceObject = New DevExpress.Utils.SerializableAppearanceObject() + Dim EditorButtonImageOptions5 As DevExpress.XtraEditors.Controls.EditorButtonImageOptions = New DevExpress.XtraEditors.Controls.EditorButtonImageOptions() + Dim SerializableAppearanceObject17 As DevExpress.Utils.SerializableAppearanceObject = New DevExpress.Utils.SerializableAppearanceObject() + Dim SerializableAppearanceObject18 As DevExpress.Utils.SerializableAppearanceObject = New DevExpress.Utils.SerializableAppearanceObject() + Dim SerializableAppearanceObject19 As DevExpress.Utils.SerializableAppearanceObject = New DevExpress.Utils.SerializableAppearanceObject() + Dim SerializableAppearanceObject20 As DevExpress.Utils.SerializableAppearanceObject = New DevExpress.Utils.SerializableAppearanceObject() + Dim EditorButtonImageOptions6 As DevExpress.XtraEditors.Controls.EditorButtonImageOptions = New DevExpress.XtraEditors.Controls.EditorButtonImageOptions() + Dim SerializableAppearanceObject21 As DevExpress.Utils.SerializableAppearanceObject = New DevExpress.Utils.SerializableAppearanceObject() + Dim SerializableAppearanceObject22 As DevExpress.Utils.SerializableAppearanceObject = New DevExpress.Utils.SerializableAppearanceObject() + Dim SerializableAppearanceObject23 As DevExpress.Utils.SerializableAppearanceObject = New DevExpress.Utils.SerializableAppearanceObject() + Dim SerializableAppearanceObject24 As DevExpress.Utils.SerializableAppearanceObject = New DevExpress.Utils.SerializableAppearanceObject() Me.Button1 = New System.Windows.Forms.Button() Me.LookupControl = New DigitalData.Controls.LookupGrid.LookupControl2() Me.LookupControl21View = New DevExpress.XtraGrid.Views.Grid.GridView() + Me.Label1 = New System.Windows.Forms.Label() + Me.LookupControl21 = New DigitalData.Controls.LookupGrid.LookupControl2() + Me.GridView1 = New DevExpress.XtraGrid.Views.Grid.GridView() + Me.Label2 = New System.Windows.Forms.Label() + Me.LookupControl22 = New DigitalData.Controls.LookupGrid.LookupControl2() + Me.GridView2 = New DevExpress.XtraGrid.Views.Grid.GridView() + Me.Label3 = New System.Windows.Forms.Label() CType(Me.LookupControl.Properties, System.ComponentModel.ISupportInitialize).BeginInit() CType(Me.LookupControl21View, System.ComponentModel.ISupportInitialize).BeginInit() + CType(Me.LookupControl21.Properties, System.ComponentModel.ISupportInitialize).BeginInit() + CType(Me.GridView1, System.ComponentModel.ISupportInitialize).BeginInit() + CType(Me.LookupControl22.Properties, System.ComponentModel.ISupportInitialize).BeginInit() + CType(Me.GridView2, System.ComponentModel.ISupportInitialize).BeginInit() Me.SuspendLayout() ' 'Button1 @@ -58,7 +90,7 @@ Partial Class Form1 Me.LookupControl.PreventDuplicates = False Me.LookupControl.Properties.Buttons.AddRange(New DevExpress.XtraEditors.Controls.EditorButton() {New DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo, "", -1, True, True, False, EditorButtonImageOptions1, New DevExpress.Utils.KeyShortcut(System.Windows.Forms.Keys.None), SerializableAppearanceObject1, SerializableAppearanceObject2, SerializableAppearanceObject3, SerializableAppearanceObject4, "", "openDropdown", Nothing, DevExpress.Utils.ToolTipAnchor.[Default]), New DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Ellipsis, "", -1, True, True, False, EditorButtonImageOptions2, New DevExpress.Utils.KeyShortcut(System.Windows.Forms.Keys.None), SerializableAppearanceObject5, SerializableAppearanceObject6, SerializableAppearanceObject7, SerializableAppearanceObject8, "", "openLookupForm", Nothing, DevExpress.Utils.ToolTipAnchor.[Default])}) Me.LookupControl.Properties.PopupView = Me.LookupControl21View - Me.LookupControl.SelectedValues = Nothing + Me.LookupControl.SelectedValues = CType(resources.GetObject("LookupControl.SelectedValues"), System.Collections.Generic.List(Of String)) Me.LookupControl.Size = New System.Drawing.Size(342, 20) Me.LookupControl.TabIndex = 3 ' @@ -69,21 +101,109 @@ Partial Class Form1 Me.LookupControl21View.OptionsSelection.EnableAppearanceFocusedCell = False Me.LookupControl21View.OptionsView.ShowGroupPanel = False ' + 'Label1 + ' + Me.Label1.AutoSize = True + Me.Label1.Location = New System.Drawing.Point(390, 15) + Me.Label1.Name = "Label1" + Me.Label1.Size = New System.Drawing.Size(91, 13) + Me.Label1.TabIndex = 4 + Me.Label1.Text = "Multiselect = True" + ' + 'LookupControl21 + ' + Me.LookupControl21.AllowAddNewValues = False + Me.LookupControl21.DataSource = Nothing + Me.LookupControl21.Location = New System.Drawing.Point(393, 89) + Me.LookupControl21.MultiSelect = True + Me.LookupControl21.Name = "LookupControl21" + Me.LookupControl21.PreventDuplicates = False + Me.LookupControl21.Properties.Buttons.AddRange(New DevExpress.XtraEditors.Controls.EditorButton() {New DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo, "", -1, True, True, False, EditorButtonImageOptions3, New DevExpress.Utils.KeyShortcut(System.Windows.Forms.Keys.None), SerializableAppearanceObject9, SerializableAppearanceObject10, SerializableAppearanceObject11, SerializableAppearanceObject12, "", "openDropdown", Nothing, DevExpress.Utils.ToolTipAnchor.[Default]), New DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Ellipsis, "", -1, True, True, False, EditorButtonImageOptions4, New DevExpress.Utils.KeyShortcut(System.Windows.Forms.Keys.None), SerializableAppearanceObject13, SerializableAppearanceObject14, SerializableAppearanceObject15, SerializableAppearanceObject16, "", "openLookupForm", Nothing, DevExpress.Utils.ToolTipAnchor.[Default])}) + Me.LookupControl21.Properties.PopupView = Me.GridView1 + Me.LookupControl21.SelectedValues = CType(resources.GetObject("LookupControl21.SelectedValues"), System.Collections.Generic.List(Of String)) + Me.LookupControl21.Size = New System.Drawing.Size(342, 20) + Me.LookupControl21.TabIndex = 3 + ' + 'GridView1 + ' + Me.GridView1.FocusRectStyle = DevExpress.XtraGrid.Views.Grid.DrawFocusRectStyle.RowFocus + Me.GridView1.Name = "GridView1" + Me.GridView1.OptionsSelection.EnableAppearanceFocusedCell = False + Me.GridView1.OptionsView.ShowGroupPanel = False + ' + 'Label2 + ' + Me.Label2.AutoSize = True + Me.Label2.Location = New System.Drawing.Point(390, 73) + Me.Label2.Name = "Label2" + Me.Label2.Size = New System.Drawing.Size(88, 13) + Me.Label2.TabIndex = 4 + Me.Label2.Text = "ReadOnly = True" + ' + 'LookupControl22 + ' + Me.LookupControl22.AllowAddNewValues = False + Me.LookupControl22.DataSource = Nothing + Me.LookupControl22.Location = New System.Drawing.Point(393, 147) + Me.LookupControl22.MultiSelect = False + Me.LookupControl22.Name = "LookupControl22" + Me.LookupControl22.PreventDuplicates = False + Me.LookupControl22.Properties.Buttons.AddRange(New DevExpress.XtraEditors.Controls.EditorButton() {New DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo, "", -1, True, True, False, EditorButtonImageOptions5, New DevExpress.Utils.KeyShortcut(System.Windows.Forms.Keys.None), SerializableAppearanceObject17, SerializableAppearanceObject18, SerializableAppearanceObject19, SerializableAppearanceObject20, "", "openDropdown", Nothing, DevExpress.Utils.ToolTipAnchor.[Default]), New DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Ellipsis, "", -1, True, True, False, EditorButtonImageOptions6, New DevExpress.Utils.KeyShortcut(System.Windows.Forms.Keys.None), SerializableAppearanceObject21, SerializableAppearanceObject22, SerializableAppearanceObject23, SerializableAppearanceObject24, "", "openLookupForm", Nothing, DevExpress.Utils.ToolTipAnchor.[Default])}) + Me.LookupControl22.Properties.DataSource = CType(resources.GetObject("LookupControl22.Properties.DataSource"), Object) + Me.LookupControl22.Properties.NullText = "Keine Datensätze ausgewählt" + Me.LookupControl22.Properties.PopupView = Me.GridView2 + Me.LookupControl22.SelectedValues = CType(resources.GetObject("LookupControl22.SelectedValues"), System.Collections.Generic.List(Of String)) + Me.LookupControl22.Size = New System.Drawing.Size(342, 20) + Me.LookupControl22.TabIndex = 3 + ' + 'GridView2 + ' + Me.GridView2.FocusRectStyle = DevExpress.XtraGrid.Views.Grid.DrawFocusRectStyle.RowFocus + Me.GridView2.Name = "GridView2" + Me.GridView2.OptionsSelection.EnableAppearanceFocusedCell = False + Me.GridView2.OptionsView.ShowGroupPanel = False + ' + 'Label3 + ' + Me.Label3.AutoSize = True + Me.Label3.Location = New System.Drawing.Point(390, 131) + Me.Label3.Name = "Label3" + Me.Label3.Size = New System.Drawing.Size(96, 13) + Me.Label3.TabIndex = 4 + Me.Label3.Text = "MultiSelect = False" + ' 'Form1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(800, 450) + Me.Controls.Add(Me.Label3) + Me.Controls.Add(Me.Label2) + Me.Controls.Add(Me.LookupControl22) + Me.Controls.Add(Me.Label1) + Me.Controls.Add(Me.LookupControl21) Me.Controls.Add(Me.LookupControl) Me.Controls.Add(Me.Button1) Me.Name = "Form1" Me.Text = "Form1" CType(Me.LookupControl.Properties, System.ComponentModel.ISupportInitialize).EndInit() CType(Me.LookupControl21View, System.ComponentModel.ISupportInitialize).EndInit() + CType(Me.LookupControl21.Properties, System.ComponentModel.ISupportInitialize).EndInit() + CType(Me.GridView1, System.ComponentModel.ISupportInitialize).EndInit() + CType(Me.LookupControl22.Properties, System.ComponentModel.ISupportInitialize).EndInit() + CType(Me.GridView2, System.ComponentModel.ISupportInitialize).EndInit() Me.ResumeLayout(False) + Me.PerformLayout() End Sub Friend WithEvents Button1 As Button Friend WithEvents LookupControl As DigitalData.Controls.LookupGrid.LookupControl2 Friend WithEvents LookupControl21View As DevExpress.XtraGrid.Views.Grid.GridView + Friend WithEvents Label1 As Label + Friend WithEvents LookupControl21 As DigitalData.Controls.LookupGrid.LookupControl2 + Friend WithEvents GridView1 As DevExpress.XtraGrid.Views.Grid.GridView + Friend WithEvents Label2 As Label + Friend WithEvents LookupControl22 As DigitalData.Controls.LookupGrid.LookupControl2 + Friend WithEvents GridView2 As DevExpress.XtraGrid.Views.Grid.GridView + Friend WithEvents Label3 As Label End Class diff --git a/LookupControlGui/Form1.resx b/LookupControlGui/Form1.resx index 1af7de15..fe049d32 100644 --- a/LookupControlGui/Form1.resx +++ b/LookupControlGui/Form1.resx @@ -117,4 +117,40 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + AAEAAAD/////AQAAAAAAAAAMAgAAAJoBbXNjb3JsaWIsIFZlcnNpb249NC4wLjAuMCwgQ3VsdHVyZT1u + ZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj1iNzdhNWM1NjE5MzRlMDg5XV0sIG1zY29ybGliLCBWZXJzaW9u + PTQuMC4wLjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49Yjc3YTVjNTYxOTM0ZTA4OQUB + AAAAMFN5c3RlbS5Db2xsZWN0aW9ucy5HZW5lcmljLkxpc3RgMVtbU3lzdGVtLlN0cmluZwMAAAAGX2l0 + ZW1zBV9zaXplCF92ZXJzaW9uBgAACAgCAAAACQMAAAAAAAAAAAAAABEDAAAAAAAAAAs= + + + + + AAEAAAD/////AQAAAAAAAAAMAgAAAJoBbXNjb3JsaWIsIFZlcnNpb249NC4wLjAuMCwgQ3VsdHVyZT1u + ZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj1iNzdhNWM1NjE5MzRlMDg5XV0sIG1zY29ybGliLCBWZXJzaW9u + PTQuMC4wLjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49Yjc3YTVjNTYxOTM0ZTA4OQUB + AAAAMFN5c3RlbS5Db2xsZWN0aW9ucy5HZW5lcmljLkxpc3RgMVtbU3lzdGVtLlN0cmluZwMAAAAGX2l0 + ZW1zBV9zaXplCF92ZXJzaW9uBgAACAgCAAAACQMAAAAAAAAAAAAAABEDAAAAAAAAAAs= + + + + + AAEAAAD/////AQAAAAAAAAAMAgAAAJoBbXNjb3JsaWIsIFZlcnNpb249NC4wLjAuMCwgQ3VsdHVyZT1u + ZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj1iNzdhNWM1NjE5MzRlMDg5XV0sIG1zY29ybGliLCBWZXJzaW9u + PTQuMC4wLjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49Yjc3YTVjNTYxOTM0ZTA4OQUB + AAAAMFN5c3RlbS5Db2xsZWN0aW9ucy5HZW5lcmljLkxpc3RgMVtbU3lzdGVtLlN0cmluZwMAAAAGX2l0 + ZW1zBV9zaXplCF92ZXJzaW9uBgAACAgCAAAACQMAAAAAAAAAAAAAABEDAAAAAAAAAAs= + + + + + AAEAAAD/////AQAAAAAAAAAMAgAAAJoBbXNjb3JsaWIsIFZlcnNpb249NC4wLjAuMCwgQ3VsdHVyZT1u + ZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj1iNzdhNWM1NjE5MzRlMDg5XV0sIG1zY29ybGliLCBWZXJzaW9u + PTQuMC4wLjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49Yjc3YTVjNTYxOTM0ZTA4OQUB + AAAAMFN5c3RlbS5Db2xsZWN0aW9ucy5HZW5lcmljLkxpc3RgMVtbU3lzdGVtLlN0cmluZwMAAAAGX2l0 + ZW1zBV9zaXplCF92ZXJzaW9uBgAACAgCAAAACQMAAAAAAAAAAAAAABEDAAAAAAAAAAs= + + \ No newline at end of file diff --git a/LookupControlGui/Form1.vb b/LookupControlGui/Form1.vb index ed7e82bb..036687f9 100644 --- a/LookupControlGui/Form1.vb +++ b/LookupControlGui/Form1.vb @@ -2,13 +2,22 @@ Private _Datasource As New List(Of String) From {"Foo", "bar", "baz", "quux"} Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load - Dim oDatatable = GetDatatable() Dim oSelectedValues = _Datasource.Take(1).ToList() LookupControl.DataSource = oDatatable LookupControl.SelectedValues = oSelectedValues - LookupControl.ReadOnly = True + LookupControl.ReadOnly = False + + LookupControl21.DataSource = oDatatable + LookupControl21.SelectedValues = oSelectedValues + LookupControl21.ReadOnly = True + + LookupControl22.DataSource = oDatatable + LookupControl22.SelectedValues = oSelectedValues + LookupControl22.ReadOnly = False + + LookupControl22.SelectedValues = New List(Of String) From {"", Nothing, "LOL"} End Sub Private Function GetDatatable() As DataTable @@ -27,8 +36,4 @@ Return oDatatable End Function - - Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click - LookupControl.ReadOnly = Not LookupControl.ReadOnly - End Sub End Class