Update 优化
This commit is contained in:
parent
bca7469cfa
commit
b1a10fea30
|
|
@ -16,6 +16,7 @@
|
||||||
<RowDefinition Height="50" />
|
<RowDefinition Height="50" />
|
||||||
<RowDefinition Height="*" />
|
<RowDefinition Height="*" />
|
||||||
<RowDefinition Height="*" />
|
<RowDefinition Height="*" />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="*" />
|
<ColumnDefinition Width="*" />
|
||||||
|
|
@ -45,6 +46,7 @@
|
||||||
<avalonEdit:TextEditor
|
<avalonEdit:TextEditor
|
||||||
Name="TextEditor"
|
Name="TextEditor"
|
||||||
Grid.Row="1"
|
Grid.Row="1"
|
||||||
|
Grid.Column="0"
|
||||||
MinHeight="200"
|
MinHeight="200"
|
||||||
VerticalAlignment="Stretch"
|
VerticalAlignment="Stretch"
|
||||||
FontFamily="Consolas"
|
FontFamily="Consolas"
|
||||||
|
|
@ -52,14 +54,34 @@
|
||||||
LineNumbersForeground="Black"
|
LineNumbersForeground="Black"
|
||||||
ShowLineNumbers="True"
|
ShowLineNumbers="True"
|
||||||
SyntaxHighlighting="SQL" />
|
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
|
<DataGrid
|
||||||
x:Name="ResultDataGrid"
|
x:Name="ResultDataGrid"
|
||||||
Grid.Row="2"
|
Grid.Row="2"
|
||||||
Grid.Column="0"
|
Grid.Column="0"
|
||||||
Grid.ColumnSpan="2"
|
Grid.ColumnSpan="2"
|
||||||
Width="Auto"
|
|
||||||
Margin="5"
|
Margin="5"
|
||||||
HorizontalAlignment="Left"
|
HorizontalAlignment="Stretch"
|
||||||
hc:DataGridAttach.CanUnselectAllWithBlankArea="True" />
|
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>
|
</Grid>
|
||||||
</Page>
|
</Page>
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,7 @@ namespace ExcelHelper.Views.Pages
|
||||||
// 替换 DuckDBDataAdapter 使用 DataTable.Load 方法
|
// 替换 DuckDBDataAdapter 使用 DataTable.Load 方法
|
||||||
private void ExecuteButton_Click(object sender, RoutedEventArgs e)
|
private void ExecuteButton_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
|
StatusTextBlock.Text = "执行中...";
|
||||||
// 获取 SQL 查询文本
|
// 获取 SQL 查询文本
|
||||||
string sqlQuery = TextEditor.Text;
|
string sqlQuery = TextEditor.Text;
|
||||||
|
|
||||||
|
|
@ -65,16 +66,28 @@ namespace ExcelHelper.Views.Pages
|
||||||
|
|
||||||
// 将结果绑定到 DataGrid
|
// 将结果绑定到 DataGrid
|
||||||
ResultDataGrid.ItemsSource = dataTable.DefaultView;
|
ResultDataGrid.ItemsSource = dataTable.DefaultView;
|
||||||
|
StatusTextBlock.Text = $"执行完成,共 {dataTable.Rows.Count} 行";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
StatusTextBlock.Text = $"查询失败:{ex.Message}";
|
||||||
MessageBox.Show($"查询执行失败:{ex.Message}", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
|
MessageBox.Show($"查询执行失败:{ex.Message}", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||||
}
|
}
|
||||||
|
|
||||||
connection.Close();
|
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