add new lookupgrid

This commit is contained in:
Jonathan Jenne 2020-01-29 16:41:27 +01:00
parent edc2402f5e
commit c8e23e3ca0
3 changed files with 137 additions and 134 deletions

View File

@ -154,6 +154,9 @@
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\..\DDMonorepo\Controls.DocumentViewer\bin\Debug\DigitalData.Controls.DocumentViewer.dll</HintPath> <HintPath>..\..\DDMonorepo\Controls.DocumentViewer\bin\Debug\DigitalData.Controls.DocumentViewer.dll</HintPath>
</Reference> </Reference>
<Reference Include="DigitalData.Controls.LookupGrid">
<HintPath>..\..\DDMonorepo\Controls.LookupGrid\bin\Debug\DigitalData.Controls.LookupGrid.dll</HintPath>
</Reference>
<Reference Include="DigitalData.Modules.Config"> <Reference Include="DigitalData.Modules.Config">
<HintPath>..\..\DDMonorepo\Modules.Config\bin\Debug\DigitalData.Modules.Config.dll</HintPath> <HintPath>..\..\DDMonorepo\Modules.Config\bin\Debug\DigitalData.Modules.Config.dll</HintPath>
</Reference> </Reference>

View File

@ -531,140 +531,153 @@ Public Class frmIndex
Else Else
Dim table As DataTable = NewDataset.Tables(0) Dim table As DataTable = NewDataset.Tables(0)
If table.Rows.Count > 0 Then 'If table.Rows.Count > 0 Then
Dim columnCount = 1 ' Dim columnCount = 1
' Alle bis auf die erste Spalte der Tabelle entfernen ' ' Alle bis auf die erste Spalte der Tabelle entfernen
While (table.Columns.Count > columnCount) ' While (table.Columns.Count > columnCount)
table.Columns.RemoveAt(columnCount) ' table.Columns.RemoveAt(columnCount)
End While ' End While
'table.Columns.Item(0).ReadOnly = True ' 'table.Columns.Item(0).ReadOnly = True
If Multiselect Then ' If Multiselect Then
' Neue Spalte für Selektion einfügen ' ' Neue Spalte für Selektion einfügen
Dim selectedColumn As New DataColumn() With { ' Dim selectedColumn As New DataColumn() With {
.ColumnName = "SELECTED", ' .ColumnName = "SELECTED",
.DataType = GetType(Boolean), ' .DataType = GetType(Boolean),
.DefaultValue = False ' .DefaultValue = False
} ' }
table.Columns.Add(selectedColumn) ' table.Columns.Add(selectedColumn)
' Spalte an erste Stelle verschieben ' ' Spalte an erste Stelle verschieben
selectedColumn.SetOrdinal(0) ' selectedColumn.SetOrdinal(0)
End If ' End If
Const LOOKUP_NO_RECORDS As String = "Keine Datensätze ausgewählt" ' Const LOOKUP_NO_RECORDS As String = "Keine Datensätze ausgewählt"
Const LOOKUP_N_RECORDS As String = "{0} Datensätze ausgewählt" ' Const LOOKUP_N_RECORDS As String = "{0} Datensätze ausgewählt"
Const LOOKUP_CONTROL_HEIGHT As Integer = 24 ' Const LOOKUP_CONTROL_HEIGHT As Integer = 24
Dim lookupButton As New Button() ' Dim lookupButton As New Button()
lookupButton.Name = "btnLookup" & indexname ' lookupButton.Name = "btnLookup" & indexname
lookupButton.Location = New Point(311, y - 1) ' lookupButton.Location = New Point(311, y - 1)
lookupButton.Size = New Size(LOOKUP_CONTROL_HEIGHT, LOOKUP_CONTROL_HEIGHT) ' lookupButton.Size = New Size(LOOKUP_CONTROL_HEIGHT, LOOKUP_CONTROL_HEIGHT)
lookupButton.Image = My.Resources.gear_32xSM ' lookupButton.Image = My.Resources.gear_32xSM
pnlIndex.Controls.Add(lookupButton) ' pnlIndex.Controls.Add(lookupButton)
If Multiselect Then ' If Multiselect Then
Dim listbox As New ListBox() ' Dim listbox As New ListBox()
Dim gridLookup As New DevExpress.XtraEditors.GridLookUpEdit() ' Dim gridLookup As New DevExpress.XtraEditors.GridLookUpEdit()
gridLookup.Name = "cmbMulti" & indexname ' gridLookup.Name = "cmbMulti" & indexname
gridLookup.Font = New Font(gridLookup.Font.FontFamily, 10) ' gridLookup.Font = New Font(gridLookup.Font.FontFamily, 10)
gridLookup.Location = New Point(11, y) ' gridLookup.Location = New Point(11, y)
gridLookup.Size = New Size(300, LOOKUP_CONTROL_HEIGHT) ' gridLookup.Size = New Size(300, LOOKUP_CONTROL_HEIGHT)
' TODO: Hier noch die Vorbelegung für Vektor Indexe einfügen ' ' TODO: Hier noch die Vorbelegung für Vektor Indexe einfügen
gridLookup.Properties.PopupFormSize = New Size(gridLookup.Properties.PopupFormSize.Width, 100) ' gridLookup.Properties.PopupFormSize = New Size(gridLookup.Properties.PopupFormSize.Width, 100)
gridLookup.Properties.NullText = LOOKUP_NO_RECORDS ' gridLookup.Properties.NullText = LOOKUP_NO_RECORDS
If Vorgabe.Length > 0 Then ' If Vorgabe.Length > 0 Then
gridLookup.Properties.DataSource = New List(Of String) From {Vorgabe} ' gridLookup.Properties.DataSource = New List(Of String) From {Vorgabe}
gridLookup.Properties.NullText = String.Format(LOOKUP_N_RECORDS, 1) ' gridLookup.Properties.NullText = String.Format(LOOKUP_N_RECORDS, 1)
Else ' Else
gridLookup.Properties.DataSource = Nothing ' gridLookup.Properties.DataSource = Nothing
gridLookup.Properties.NullText = LOOKUP_NO_RECORDS ' gridLookup.Properties.NullText = LOOKUP_NO_RECORDS
End If ' End If
' Da das gridLookup ein Readonly Control sein soll, ' ' Da das gridLookup ein Readonly Control sein soll,
' sich aber trotzdem öffnen lassen soll, müssen wir so das setzen eines neuen Werts verhindern ' ' sich aber trotzdem öffnen lassen soll, müssen wir so das setzen eines neuen Werts verhindern
AddHandler gridLookup.EditValueChanging, Sub(sender As Object, e As ChangingEventArgs) ' AddHandler gridLookup.EditValueChanging, Sub(sender As Object, e As ChangingEventArgs)
e.Cancel = True ' e.Cancel = True
End Sub ' End Sub
With gridLookup.Properties.View ' With gridLookup.Properties.View
.OptionsBehavior.ReadOnly = True ' .OptionsBehavior.ReadOnly = True
.OptionsBehavior.Editable = False ' .OptionsBehavior.Editable = False
.OptionsView.ShowColumnHeaders = False ' .OptionsView.ShowColumnHeaders = False
End With ' End With
AddHandler lookupButton.Click, Sub() ' AddHandler lookupButton.Click, Sub()
Dim frm As New frmLookupGrid() ' Dim frm As New frmLookupGrid()
frm.MultiSelect = True ' frm.MultiSelect = True
frm.DataSource = table ' frm.DataSource = table
frm.AddNewValues = AddNewValues ' frm.AddNewValues = AddNewValues
frm.PreventDuplicates = PreventDuplicateValues ' frm.PreventDuplicates = PreventDuplicateValues
frm.StartPosition = FormStartPosition.Manual ' frm.StartPosition = FormStartPosition.Manual
frm.SelectedValues = gridLookup.Properties.DataSource ' frm.SelectedValues = gridLookup.Properties.DataSource
frm.Location = pnlIndex.PointToScreen(New Point(340, y)) ' frm.Location = pnlIndex.PointToScreen(New Point(340, y))
Dim result = frm.ShowDialog() ' Dim result = frm.ShowDialog()
If result = DialogResult.OK Then ' If result = DialogResult.OK Then
Dim values As List(Of String) = frm.SelectedValues ' Dim values As List(Of String) = frm.SelectedValues
gridLookup.Properties.DataSource = values ' gridLookup.Properties.DataSource = values
gridLookup.Properties.NullText = IIf(values.Count = 0, LOOKUP_NO_RECORDS, String.Format(LOOKUP_N_RECORDS, values.Count)) ' gridLookup.Properties.NullText = IIf(values.Count = 0, LOOKUP_NO_RECORDS, String.Format(LOOKUP_N_RECORDS, values.Count))
End If ' End If
End Sub ' End Sub
pnlIndex.Controls.Add(gridLookup) ' pnlIndex.Controls.Add(gridLookup)
Else ' Else
Dim textBox As New TextBox() ' Dim textBox As New TextBox()
textBox.Name = "cmbSingle" & indexname ' textBox.Name = "cmbSingle" & indexname
textBox.Font = New Font(textBox.Font.FontFamily, 9) ' textBox.Font = New Font(textBox.Font.FontFamily, 9)
textBox.Location = New Point(11, y) ' textBox.Location = New Point(11, y)
textBox.Size = New Size(300, LOOKUP_CONTROL_HEIGHT) ' textBox.Size = New Size(300, LOOKUP_CONTROL_HEIGHT)
textBox.ReadOnly = True ' textBox.ReadOnly = True
textBox.Text = Vorgabe ' textBox.Text = Vorgabe
AddHandler lookupButton.Click, Sub() ' AddHandler lookupButton.Click, Sub()
Dim frm As New frmLookupGrid() ' Dim frm As New frmLookupGrid()
frm.FormBorderStyle = FormBorderStyle.SizableToolWindow ' frm.FormBorderStyle = FormBorderStyle.SizableToolWindow
frm.MultiSelect = False ' frm.MultiSelect = False
frm.DataSource = table ' frm.DataSource = table
frm.AddNewValues = AddNewValues ' frm.AddNewValues = AddNewValues
frm.StartPosition = FormStartPosition.Manual ' frm.StartPosition = FormStartPosition.Manual
frm.SelectedValues = New List(Of String) From {textBox.Text} ' frm.SelectedValues = New List(Of String) From {textBox.Text}
frm.Location = pnlIndex.PointToScreen(New Point(340, y)) ' frm.Location = pnlIndex.PointToScreen(New Point(340, y))
Dim result = frm.ShowDialog() ' Dim result = frm.ShowDialog()
If result = DialogResult.OK Then ' If result = DialogResult.OK Then
Dim value = frm.SelectedValues.FirstOrDefault() ' Dim value = frm.SelectedValues.FirstOrDefault()
textBox.Text = value ' textBox.Text = value
End If ' End If
End Sub ' End Sub
pnlIndex.Controls.Add(textBox) ' pnlIndex.Controls.Add(textBox)
End If ' End If
' Für ergebnisse die kleiner/gleich MAX_COMBOBOX_ITEMS sind ' ' Für ergebnisse die kleiner/gleich MAX_COMBOBOX_ITEMS sind
' die normale ComboBox verwenden ' ' die normale ComboBox verwenden
' 'Die Standardcombobox anlegen ' ' 'Die Standardcombobox anlegen
' newCMB = addCombobox(indexname, y) ' ' newCMB = addCombobox(indexname, y)
' newCMB.DataSource = table ' ' newCMB.DataSource = table
' newCMB.DisplayMember = table.Columns(0).ColumnName ' ' newCMB.DisplayMember = table.Columns(0).ColumnName
' newCMB.AutoCompleteSource = AutoCompleteSource.ListItems ' ' newCMB.AutoCompleteSource = AutoCompleteSource.ListItems
' newCMB.AutoCompleteMode = AutoCompleteMode.Suggest ' ' newCMB.AutoCompleteMode = AutoCompleteMode.Suggest
' newCMB.DropDownHeight = (newCMB.ItemHeight + 0.2) * 25 ' ' newCMB.DropDownHeight = (newCMB.ItemHeight + 0.2) * 25
' If Vorgabe <> "" Then ' ' If Vorgabe <> "" Then
' newCMB.SelectedIndex = newCMB.FindStringExact(Vorgabe) ' ' newCMB.SelectedIndex = newCMB.FindStringExact(Vorgabe)
' newCMB.Text = Vorgabe ' ' newCMB.Text = Vorgabe
' Get_NextComboBoxResults(newCMB) ' ' Get_NextComboBoxResults(newCMB)
' End If ' ' End If
Else 'Else
'End If
Dim oControl As New DigitalData.Controls.LookupGrid.LookupControl2 With {
.DataSource = table,
.MultiSelect = Multiselect,
.AllowAddNewValues = AddNewValues,
.PreventDuplicates = PreventDuplicateValues,
.Location = New Point(11, y),
.Size = New Size(300, 27),
.Name = "cmbMulti" & indexname
}
pnlIndex.Controls.Add(oControl)
End If
If connectionString.Contains("Initial Catalog=") Then If connectionString.Contains("Initial Catalog=") Then
Try Try
adapter.Dispose() adapter.Dispose()
@ -928,41 +941,27 @@ Public Class frmIndex
End If End If
End If End If
End If End If
If ctrl.Name.StartsWith("cmbMulti") Then If ctrl.Name.StartsWith("cmbMulti") Then
Dim cmbMulti As DevExpress.XtraEditors.GridLookUpEdit = ctrl Dim oLookup = DirectCast(ctrl, DigitalData.Controls.LookupGrid.LookupControl2)
Dim values As List(Of String) = cmbMulti.Properties.DataSource Dim values As List(Of String) = oLookup.SelectedValues
If values.Count = 0 Then If values.Count = 0 Then
Dim optional_index As Boolean = ClassDatabase.Execute_Scalar("SELECT OPTIONAL FROM TBDD_INDEX_MAN WHERE DOK_ID = " & dokartid & " AND NAME = '" & Replace(cmbMulti.Name, "cmbMulti", "") & "'", MyConnectionString, True) Dim optional_index As Boolean = ClassDatabase.Execute_Scalar("SELECT OPTIONAL FROM TBDD_INDEX_MAN WHERE DOK_ID = " & dokartid & " AND NAME = '" & Replace(oLookup.Name, "cmbMulti", "") & "'", MyConnectionString, True)
If optional_index = False Then If optional_index = False Then
MsgBox("Bitte wählen Sie einen Wert aus der Combobox.", MsgBoxStyle.Exclamation) MsgBox("Bitte wählen Sie einen Wert aus der Combobox.", MsgBoxStyle.Exclamation)
cmbMulti.Focus() oLookup.Focus()
Return False Return False
Else Else
Indexwert_Postprocessing(Replace(cmbMulti.Name, "cmbMulti", ""), "") Indexwert_Postprocessing(Replace(oLookup.Name, "cmbMulti", ""), "")
result = True result = True
End If End If
Else Else
Dim vectorValue = String.Join(ClassConstants.VECTORSEPARATOR, values) Dim vectorValue = String.Join(ClassConstants.VECTORSEPARATOR, values)
Indexwert_Postprocessing(Replace(cmbMulti.Name, "cmbMulti", ""), vectorValue) Indexwert_Postprocessing(Replace(oLookup.Name, "cmbMulti", ""), vectorValue)
result = True
End If End If
'If cmbMulti.Text = "" Then
' Dim optional_index As Boolean = ClassDatabase.Execute_Scalar("SELECT OPTIONAL FROM TBDD_INDEX_MAN WHERE DOK_ID = " & dokartid & " AND NAME = '" & Replace(cmbMulti.Name, "cmbMulti", "") & "'", MyConnectionString, True)
' If optional_index = False Then
' MsgBox("Bitte wählen Sie einen Wert aus der Combobox.", MsgBoxStyle.Exclamation)
' cmbMulti.Focus()
' Return False
' Else
' Indexwert_Postprocessing(Replace(cmbMulti.Name, "cmbMulti", ""), "")
' result = True
' End If
'Else
' Indexwert_Postprocessing(Replace(cmbMulti.Name, "cmbMulti", ""), cmbMulti.Text)
' result = True
'End If
ElseIf ctrl.Name.StartsWith("cmbSingle") Then ElseIf ctrl.Name.StartsWith("cmbSingle") Then
Dim cmbSingle As TextBox = ctrl Dim cmbSingle As TextBox = ctrl

View File

@ -114,6 +114,7 @@
<File Id="Config" Name="DigitalData.Modules.Config.dll" Source="DigitalData.Modules.Config.dll" KeyPath="no" /> <File Id="Config" Name="DigitalData.Modules.Config.dll" Source="DigitalData.Modules.Config.dll" KeyPath="no" />
<File Id="DLLLicenseManager" Name="DLLLicenseManager.dll" Source="P:\Visual Studio Projekte\Bibliotheken\DLLLicenseManager.dll" KeyPath="no" /> <File Id="DLLLicenseManager" Name="DLLLicenseManager.dll" Source="P:\Visual Studio Projekte\Bibliotheken\DLLLicenseManager.dll" KeyPath="no" />
<File Id="DocumentViewer" Name="DigitalData.Controls.DocumentViewer.dll" Source="DigitalData.Controls.DocumentViewer.dll" KeyPath="no" /> <File Id="DocumentViewer" Name="DigitalData.Controls.DocumentViewer.dll" Source="DigitalData.Controls.DocumentViewer.dll" KeyPath="no" />
<File Id="LookupGrid" Name="DigitalData.Controls.LookupGrid.dll" Source="DigitalData.Controls.LookupGrid.dll" KeyPath="no" />
</Component> </Component>
<Component Id="GDPictureLibs" Guid="9ea5ab43-58ff-4813-9a8b-f854784f0275"> <Component Id="GDPictureLibs" Guid="9ea5ab43-58ff-4813-9a8b-f854784f0275">