From 53bc240c5f23191352bf47e7171ac00e9ad4c432 Mon Sep 17 00:00:00 2001 From: zhubanghao <58813184@qq.com> Date: Mon, 10 Aug 2026 09:27:17 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E5=AF=B9=E6=AF=94=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .cr/personal/FavoritesList/List.xml | 6 + .../SmartSQL/Models/ColumnDiffInfoModel.cs | 33 ++ SmartSQL/SmartSQL/SmartSQL.csproj | 10 +- .../UserControl/Main/UcMainDbCompare.xaml | 10 +- .../UserControl/Main/UcMainDbCompare.xaml.cs | 64 ++++ .../SmartSQL/Views/TableFieldDiffWindow.xaml | 289 ++++++++++++++++++ .../Views/TableFieldDiffWindow.xaml.cs | 177 +++++++++++ 7 files changed, 587 insertions(+), 2 deletions(-) create mode 100644 .cr/personal/FavoritesList/List.xml create mode 100644 SmartSQL/SmartSQL/Models/ColumnDiffInfoModel.cs create mode 100644 SmartSQL/SmartSQL/Views/TableFieldDiffWindow.xaml create mode 100644 SmartSQL/SmartSQL/Views/TableFieldDiffWindow.xaml.cs diff --git a/.cr/personal/FavoritesList/List.xml b/.cr/personal/FavoritesList/List.xml new file mode 100644 index 0000000..a60e5ed --- /dev/null +++ b/.cr/personal/FavoritesList/List.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/SmartSQL/SmartSQL/Models/ColumnDiffInfoModel.cs b/SmartSQL/SmartSQL/Models/ColumnDiffInfoModel.cs new file mode 100644 index 0000000..5609670 --- /dev/null +++ b/SmartSQL/SmartSQL/Models/ColumnDiffInfoModel.cs @@ -0,0 +1,33 @@ +using System.Windows.Media; + +namespace SmartSQL.Models +{ + public class ColumnDiffInfoModel : NotifyPropertyBase + { + public string SourceColumnName { get; set; } + public string SourceDataType { get; set; } + public string SourceLength { get; set; } + public string SourceNullable { get; set; } + public string SourceIsPrimaryKey { get; set; } + public string SourceIsIdentity { get; set; } + public string SourceDefaultValue { get; set; } + public string SourceComment { get; set; } + + public string TargetColumnName { get; set; } + public string TargetDataType { get; set; } + public string TargetLength { get; set; } + public string TargetNullable { get; set; } + public string TargetIsPrimaryKey { get; set; } + public string TargetIsIdentity { get; set; } + public string TargetDefaultValue { get; set; } + public string TargetComment { get; set; } + + public bool IsColumnExistsInSource { get; set; } + public bool IsColumnExistsInTarget { get; set; } + + public SolidColorBrush DiffForeground { get; set; } + public SolidColorBrush DiffBackground { get; set; } + + public bool IsDifferent { get; set; } + } +} diff --git a/SmartSQL/SmartSQL/SmartSQL.csproj b/SmartSQL/SmartSQL/SmartSQL.csproj index fae0126..d04d3aa 100644 --- a/SmartSQL/SmartSQL/SmartSQL.csproj +++ b/SmartSQL/SmartSQL/SmartSQL.csproj @@ -1,4 +1,4 @@ - + @@ -184,6 +184,7 @@ + @@ -437,6 +438,9 @@ SettingWindow.xaml + + TableFieldDiffWindow.xaml + MSBuild:Compile Designer @@ -814,6 +818,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + diff --git a/SmartSQL/SmartSQL/UserControl/Main/UcMainDbCompare.xaml b/SmartSQL/SmartSQL/UserControl/Main/UcMainDbCompare.xaml index 84ca36f..d9c60e4 100644 --- a/SmartSQL/SmartSQL/UserControl/Main/UcMainDbCompare.xaml +++ b/SmartSQL/SmartSQL/UserControl/Main/UcMainDbCompare.xaml @@ -215,7 +215,15 @@ HeadersVisibility="All" ItemsSource="{Binding DiffInfoData, Mode=TwoWay}" RowHeaderWidth="60" - SelectionUnit="FullRow"> + SelectionUnit="FullRow" + MouseDoubleClick="TableGrid_OnMouseDoubleClick"> + + + + + @@ -252,5 +263,58 @@ namespace SmartSQL.UserControl }); #endregion } + + /// + /// 右键菜单-字段对比详情 + /// + private void MenuItemFieldDiff_OnClick(object sender, RoutedEventArgs e) + { + OpenFieldDiffWindow(); + } + + /// + /// 双击打开字段对比详情 + /// + private void TableGrid_OnMouseDoubleClick(object sender, MouseButtonEventArgs e) + { + OpenFieldDiffWindow(); + } + + /// + /// 打开字段对比详情窗口 + /// + private void OpenFieldDiffWindow() + { + if (TableGrid.SelectedItem == null) + { + Oops.Oh("请先选择要对比的表"); + return; + } + if (_currentSourceConnect == null || _currentTargetConnect == null) + { + Oops.Oh("请先执行比较操作"); + return; + } + + var selectedItem = (DiffInfoModel)TableGrid.SelectedItem; + string sourceTableName = selectedItem.SourceName; + string targetTableName = selectedItem.TargetName; + + if (!selectedItem.SourceIsExists && !selectedItem.TargetIsExists) + { + Oops.Oh("该表在源和目标数据库中都不存在"); + return; + } + + var window = new TableFieldDiffWindow( + _currentSourceConnect, + _currentSourceDatabase, + sourceTableName, + _currentTargetConnect, + _currentTargetDatabase, + targetTableName); + window.Owner = Window.GetWindow(this); + window.Show(); + } } } diff --git a/SmartSQL/SmartSQL/Views/TableFieldDiffWindow.xaml b/SmartSQL/SmartSQL/Views/TableFieldDiffWindow.xaml new file mode 100644 index 0000000..d342db7 --- /dev/null +++ b/SmartSQL/SmartSQL/Views/TableFieldDiffWindow.xaml @@ -0,0 +1,289 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +