Update 优化
This commit is contained in:
parent
bca7469cfa
commit
b1a10fea30
|
|
@ -16,6 +16,7 @@
|
|||
<RowDefinition Height="50" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
|
|
@ -45,6 +46,7 @@
|
|||
<avalonEdit:TextEditor
|
||||
Name="TextEditor"
|
||||
Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
MinHeight="200"
|
||||
VerticalAlignment="Stretch"
|
||||
FontFamily="Consolas"
|
||||
|
|
@ -52,14 +54,34 @@
|
|||
LineNumbersForeground="Black"
|
||||
ShowLineNumbers="True"
|
||||
SyntaxHighlighting="SQL" />
|
||||
<ListBox
|
||||
x:Name="FunctionListBox"
|
||||
Grid.Row="1"
|
||||
Grid.Column="1"
|
||||
Margin="5"
|
||||
SelectionChanged="FunctionListBox_SelectionChanged">
|
||||
<ListBoxItem Content="INSTALL spatial; LOAD spatial;" />
|
||||
<ListBoxItem Content="st_read()" />
|
||||
<!-- ...add more functions if needed... -->
|
||||
</ListBox>
|
||||
<DataGrid
|
||||
x:Name="ResultDataGrid"
|
||||
Grid.Row="2"
|
||||
Grid.Column="0"
|
||||
Grid.ColumnSpan="2"
|
||||
Width="Auto"
|
||||
Margin="5"
|
||||
HorizontalAlignment="Left"
|
||||
hc:DataGridAttach.CanUnselectAllWithBlankArea="True" />
|
||||
HorizontalAlignment="Stretch"
|
||||
ColumnWidth="*"
|
||||
hc:DataGridAttach.CanUnselectAllWithBlankArea="True"
|
||||
ScrollViewer.HorizontalScrollBarVisibility="Auto"
|
||||
MinColumnWidth="100" />
|
||||
<StackPanel
|
||||
Grid.Row="3"
|
||||
Orientation="Horizontal">
|
||||
<TextBlock
|
||||
x:Name="StatusTextBlock"
|
||||
Margin="5"
|
||||
Text="准备就绪" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Page>
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ namespace ExcelHelper.Views.Pages
|
|||
// 替换 DuckDBDataAdapter 使用 DataTable.Load 方法
|
||||
private void ExecuteButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
StatusTextBlock.Text = "执行中...";
|
||||
// 获取 SQL 查询文本
|
||||
string sqlQuery = TextEditor.Text;
|
||||
|
||||
|
|
@ -65,16 +66,28 @@ namespace ExcelHelper.Views.Pages
|
|||
|
||||
// 将结果绑定到 DataGrid
|
||||
ResultDataGrid.ItemsSource = dataTable.DefaultView;
|
||||
StatusTextBlock.Text = $"执行完成,共 {dataTable.Rows.Count} 行";
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
StatusTextBlock.Text = $"查询失败:{ex.Message}";
|
||||
MessageBox.Show($"查询执行失败:{ex.Message}", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
|
||||
connection.Close();
|
||||
}
|
||||
}
|
||||
|
||||
private void FunctionListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
if (FunctionListBox.SelectedItem is ListBoxItem item)
|
||||
{
|
||||
var functionText = item.Content.ToString();
|
||||
var caretOffset = TextEditor.CaretOffset;
|
||||
TextEditor.Document.Insert(caretOffset, functionText);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue