jj: Work in Progress: Vector Fields / Lookup Field

This commit is contained in:
Jonathan Jenne
2018-08-07 16:14:14 +02:00
parent c5e59b617e
commit d352487f29
3 changed files with 128 additions and 15 deletions

View File

@@ -525,9 +525,13 @@ Public Class frmIndex
table.Columns.RemoveAt(columnCount)
End While
Const LOOKUP_NO_RECORDS As String = "Keine Datensätze ausgewählt"
Const LOOKUP_N_RECORDS As String = "{0} Datensätze ausgewählt"
Const LOOKUP_CONTROL_HEIGHT As Integer = 24
Dim lookupButton As New Button()
lookupButton.Location = New Point(311, y - 1)
lookupButton.Size = New Size(27, 27)
lookupButton.Size = New Size(LOOKUP_CONTROL_HEIGHT, LOOKUP_CONTROL_HEIGHT)
lookupButton.Image = My.Resources.gear_32xSM
pnlIndex.Controls.Add(lookupButton)
@@ -536,16 +540,18 @@ Public Class frmIndex
Dim listbox As New ListBox()
Dim gridLookup As New DevExpress.XtraEditors.GridLookUpEdit()
gridLookup.Name = "cmbMulti" & indexname
gridLookup.Font = New Font(gridLookup.Font.FontFamily, 10)
gridLookup.Location = New Point(11, y)
gridLookup.Size = New Size(300, 30)
gridLookup.Size = New Size(300, LOOKUP_CONTROL_HEIGHT)
' TODO: Hier noch die Vorbelegung für Vektor Indexe einfügen
gridLookup.Properties.DataSource = Nothing
gridLookup.Properties.PopupFormSize = New Size(gridLookup.Properties.PopupFormSize.Width, 100)
gridLookup.Properties.NullText = $"Keine Datensätze ausgewählt"
gridLookup.Properties.NullText = LOOKUP_NO_RECORDS
' Da das gridLookup ein Readonly Control sein soll,
' aber sich 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)
e.Cancel = True
End Sub
@@ -569,7 +575,7 @@ Public Class frmIndex
If result = DialogResult.OK Then
Dim values As List(Of Object) = frm.SelectedValues
gridLookup.Properties.DataSource = values
gridLookup.Properties.NullText = IIf(values.Count = 0, "Keine Datensätze ausgewählt", $"{values.Count} Datensätze ausgewählt")
gridLookup.Properties.NullText = IIf(values.Count = 0, LOOKUP_NO_RECORDS, String.Format(LOOKUP_N_RECORDS, values.Count))
End If
End Sub
@@ -577,8 +583,10 @@ Public Class frmIndex
Else
Dim textBox As New TextBox()
textBox.Name = "cmbSingle" & indexname
textBox.Font = New Font(textBox.Font.FontFamily, 9)
textBox.Location = New Point(11, y)
textBox.Size = New Size(300, 27)
textBox.Size = New Size(300, LOOKUP_CONTROL_HEIGHT)
AddHandler lookupButton.Click, Sub()
Dim frm As New frmLookupGrid()
@@ -907,7 +915,43 @@ Public Class frmIndex
End If
End If
End If
If ctrl.Name.StartsWith("cmb") Then
If ctrl.Name.StartsWith("cmbMulti") Then
Dim cmbMulti As DevExpress.XtraEditors.LookUpEdit = ctrl
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, "cmb", ""), cmbMulti.Text)
result = True
End If
ElseIf ctrl.Name.StartsWith("cmbSingle") Then
Dim cmbSingle As TextBox = ctrl
If cmbSingle.Text = "" Then
Dim optional_index As Boolean = ClassDatabase.Execute_Scalar("SELECT OPTIONAL FROM TBDD_INDEX_MAN WHERE DOK_ID = " & dokartid & " AND NAME = '" & Replace(cmbSingle.Name, "cmbMulti", "") & "'", MyConnectionString, True)
If optional_index = False Then
MsgBox("Bitte wählen Sie einen Wert aus der Combobox.", MsgBoxStyle.Exclamation)
cmbSingle.Focus()
Return False
Else
Indexwert_Postprocessing(Replace(cmbSingle.Name, "cmbMulti", ""), "")
result = True
End If
Else
Indexwert_Postprocessing(Replace(cmbSingle.Name, "cmb", ""), cmbSingle.Text)
result = True
End If
ElseIf ctrl.Name.StartsWith("cmb") Then
Dim cmb As ComboBox = ctrl
If cmb.Text = "" Then
Dim optional_index As Boolean = ClassDatabase.Execute_Scalar("SELECT OPTIONAL FROM TBDD_INDEX_MAN WHERE DOK_ID = " & dokartid & " AND NAME = '" & Replace(cmb.Name, "cmb", "") & "'", MyConnectionString, True)