diff --git a/GUIs.Common/SQLEditor/Placeholders.vb b/GUIs.Common/SQLEditor/Placeholders.vb index 70630ec4..b5db4b83 100644 --- a/GUIs.Common/SQLEditor/Placeholders.vb +++ b/GUIs.Common/SQLEditor/Placeholders.vb @@ -52,7 +52,7 @@ Namespace SQLEditor Return oGroup1 End Function - Public Function GetManualPlaceholders(pPlaceholders As Dictionary(Of String, String), pPrefix As String) As GalleryItemGroup + Public Function GetManualPlaceholders(pPlaceholders As Dictionary(Of String, String), pPrefix As String, pTitle As String) As GalleryItemGroup Dim oImage As SvgImage = My.Resources.handtool Dim oItems As New List(Of GalleryItem)() Dim oPrefix As String = pPrefix @@ -63,18 +63,18 @@ Namespace SQLEditor If pPlaceholders.Count > 0 Then For Each oManualPlaceholder In pPlaceholders - Dim oPlaceholder = New Placeholder(oManualPlaceholder.Key, "Manuelles Attribut", oPrefix, oManualPlaceholder.Value) + Dim oPlaceholder = New Placeholder(oManualPlaceholder.Key, pTitle, oPrefix, oManualPlaceholder.Value) oItems.Add(GetGalleryItem(oPlaceholder, oImage)) Next Else Return Nothing End If - Dim oGroup1 = New GalleryItemGroup() With {.Caption = "Manuelle Attribute"} + Dim oGroup1 = New GalleryItemGroup() With {.Caption = pTitle} oGroup1.Items.AddRange(oItems.ToArray) Return oGroup1 End Function - Public Function GetAutomaticPlaceholders(pPlaceholders As Dictionary(Of String, String), pPrefix As String) As GalleryItemGroup + Public Function GetAutomaticPlaceholders(pPlaceholders As Dictionary(Of String, String), pPrefix As String, pTitle As String) As GalleryItemGroup Dim oImage As SvgImage = My.Resources.autoarrange Dim oItems As New List(Of GalleryItem)() Dim oPrefix As String = pPrefix @@ -85,14 +85,14 @@ Namespace SQLEditor If pPlaceholders.Count > 0 Then For Each oManualPlaceholder In pPlaceholders - Dim oPlaceholder = New Placeholder(oManualPlaceholder.Key, "Automatisches Attribut", oPrefix, oManualPlaceholder.Value) + Dim oPlaceholder = New Placeholder(oManualPlaceholder.Key, pTitle, oPrefix, oManualPlaceholder.Value) oItems.Add(GetGalleryItem(oPlaceholder, oImage)) Next Else Return Nothing End If - Dim oGroup1 = New GalleryItemGroup() With {.Caption = "Automatisches Attribut"} + Dim oGroup1 = New GalleryItemGroup() With {.Caption = pTitle} oGroup1.Items.AddRange(oItems.ToArray) Return oGroup1 diff --git a/GUIs.Common/frmSQLEditor.vb b/GUIs.Common/frmSQLEditor.vb index 859c1703..07e104b5 100644 --- a/GUIs.Common/frmSQLEditor.vb +++ b/GUIs.Common/frmSQLEditor.vb @@ -23,10 +23,11 @@ Public Class frmSQLEditor Public Property PlaceholdersManual As Dictionary(Of String, String) Public Property PlaceholdersManualPrefix As String + Public Property PlaceholdersManualTitle As String = "Manuelles Attribut" Public Property PlaceholdersAutomatic As Dictionary(Of String, String) Public Property PlaceholdersAutomaticPrefix As String - + Public Property PlaceholdersAutomaticTitle As String = "Automatisches Attribut" Public Property PlaceholdersWindream As List(Of String) Public Sub New(pLogConfig As LogConfig, pDatabase As MSSQLServer) @@ -72,7 +73,10 @@ Public Class frmSQLEditor End If GalleryConnection.Gallery.Groups.Add(oConnectionGroup) - GalleryConnection.Gallery.SetItemCheck(oSelectedItem, True) + + If oSelectedItem IsNot Nothing Then + GalleryConnection.Gallery.SetItemCheck(oSelectedItem, True) + End If Dim oPlaceholderGroups = LoadPlaceholders() GalleryPlaceholders.Gallery.Groups.AddRange(oPlaceholderGroups.ToArray) @@ -104,12 +108,12 @@ Public Class frmSQLEditor Placeholders.GetUserPlaceholders() } - Dim oAutomaticAttributes = Placeholders.GetAutomaticPlaceholders(PlaceholdersAutomatic, PlaceholdersAutomaticPrefix) + Dim oAutomaticAttributes = Placeholders.GetAutomaticPlaceholders(PlaceholdersAutomatic, PlaceholdersAutomaticPrefix, PlaceholdersAutomaticTitle) If oAutomaticAttributes IsNot Nothing Then oPlaceholders.Add(oAutomaticAttributes) End If - Dim oManualPlaceholders = Placeholders.GetManualPlaceholders(PlaceholdersManual, PlaceholdersManualPrefix) + Dim oManualPlaceholders = Placeholders.GetManualPlaceholders(PlaceholdersManual, PlaceholdersManualPrefix, PlaceholdersManualTitle) If oManualPlaceholders IsNot Nothing Then oPlaceholders.Add(oManualPlaceholders) End If @@ -163,7 +167,11 @@ Public Class frmSQLEditor Private Sub ClearPlaceholders() - GridPlaceholders.DataSource = New List(Of SQLEditor.Placeholder) + Dim oPlaceholders As List(Of SQLEditor.Placeholder) = GridPlaceholders.DataSource + + oPlaceholders.ForEach(Sub(placeholder) placeholder.Value = "") + + GridPlaceholders.DataSource = oPlaceholders End Sub Private Function GetGalleryItem(pConnection As Connection) As GalleryItem @@ -179,6 +187,19 @@ Public Class frmSQLEditor Private Property LastPatterns As New List(Of Pattern) Private Sub RichEditControl1_ContentChanged(sender As Object, e As EventArgs) Handles txtSQLCommand.ContentChanged + UpdatePlaceholders() + End Sub + + Private Sub BarButtonItem3_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnExecuteSQL.ItemClick + ExecuteSQL() + End Sub + + Private Class Connection + Public Property Id As Integer + Public Property Name As String + End Class + + Private Sub UpdatePlaceholders() Dim oSqlText = txtSQLCommand.Document.Text Dim oPatterns = Patterns.GetAllPatterns(oSqlText) @@ -196,15 +217,6 @@ Public Class frmSQLEditor LastPatterns = oPatterns End Sub - Private Sub BarButtonItem3_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnExecuteSQL.ItemClick - ExecuteSQL() - End Sub - - Private Class Connection - Public Property Id As Integer - Public Property Name As String - End Class - Private Sub ExecuteSQL() Try ViewPlaceholders.FocusInvalidRow() @@ -234,6 +246,9 @@ Public Class frmSQLEditor oDatatable = Database.GetDatatable(oSql) End If + If ClearPlaceholdersAfterSuccessfulExecute Then + ClearPlaceholders() + End If Dim oForm As New frmSQLResult(oDatatable) oForm.Show()