From 1e45582d78413ae5696e0b0bc971fad7e9d64c49 Mon Sep 17 00:00:00 2001
From: 13693261870 <252740454@qq.com>
Date: 星期二, 22 八月 2023 15:48:39 +0800
Subject: [PATCH] 1

---
 DataLoader/ResWin.xaml        |   67 +++++++++++
 DataLoader/MainWindow.xaml.cs |   37 ++++--
 DataLoader/ResWin.xaml.cs     |   86 ++++++++++++++
 DataLoader/MainWindow.xaml    |   14 +-
 DataLoader/DataLoader.csproj  |    8 +
 DataLoader/Model/SysDir.cs    |    5 
 DataLoader/CS/DBHelper.cs     |    2 
 DataLoader/LoginWin.xaml      |    2 
 DataLoader/Model/TreeItem.cs  |  115 +++++++++++++++++++
 9 files changed, 314 insertions(+), 22 deletions(-)

diff --git a/DataLoader/CS/DBHelper.cs b/DataLoader/CS/DBHelper.cs
index bacebbf..13019a2 100644
--- a/DataLoader/CS/DBHelper.cs
+++ b/DataLoader/CS/DBHelper.cs
@@ -66,7 +66,7 @@
         /// </summary>
         public static List<SysDir> GetDirList()
         {
-            string sql = "select * from lf.sys_dir";
+            string sql = "select a.*, fn_get_fullname(a.code, 2) fullName from lf.sys_dir a";
             DataTable dt = Tools.DBHelper.GetDataTable(sql);
             if (null == dt || dt.Rows.Count == 0) return null;
 
diff --git a/DataLoader/DataLoader.csproj b/DataLoader/DataLoader.csproj
index e2e09cf..483ca9a 100644
--- a/DataLoader/DataLoader.csproj
+++ b/DataLoader/DataLoader.csproj
@@ -119,6 +119,10 @@
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
     </ApplicationDefinition>
+    <Compile Include="Model\TreeItem.cs" />
+    <Compile Include="ResWin.xaml.cs">
+      <DependentUpon>ResWin.xaml</DependentUpon>
+    </Compile>
     <Page Include="LoginWin.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
@@ -152,6 +156,10 @@
       <DependentUpon>MainWindow.xaml</DependentUpon>
       <SubType>Code</SubType>
     </Compile>
+    <Page Include="ResWin.xaml">
+      <Generator>MSBuild:Compile</Generator>
+      <SubType>Designer</SubType>
+    </Page>
   </ItemGroup>
   <ItemGroup>
     <Compile Include="Model\SysMeta.cs" />
diff --git a/DataLoader/LoginWin.xaml b/DataLoader/LoginWin.xaml
index 0ddd4d4..2474aac 100644
--- a/DataLoader/LoginWin.xaml
+++ b/DataLoader/LoginWin.xaml
@@ -2,7 +2,7 @@
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:Chrome="clr-namespace:CefSharp.Wpf;assembly=CefSharp.Wpf"
-        Loaded="Window_Loaded" Title="鐧诲綍绐楀彛"
+        Loaded="Window_Loaded" Title="鐧诲綍绐楀彛" ShowInTaskbar="False" WindowStyle="None"
         Height="500" Width="750" WindowStartupLocation="CenterScreen">
     <Grid>
         <Chrome:ChromiumWebBrowser x:Name="web" Margin="1" Grid.Row="1" />
diff --git a/DataLoader/MainWindow.xaml b/DataLoader/MainWindow.xaml
index 49dfa33..0646370 100644
--- a/DataLoader/MainWindow.xaml
+++ b/DataLoader/MainWindow.xaml
@@ -1,8 +1,7 @@
 锘�<Window x:Class="DataLoader.MainWindow"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
-        Height="700" Width="900"
-        Loaded="Window_Loaded"
+        Height="700" Width="900" Loaded="Window_Loaded"
         Title="鏁版嵁鍏ュ簱 v1.5" WindowStartupLocation="CenterScreen">
     <Window.Resources>
         <Style x:Key="btn" TargetType="Button">
@@ -23,8 +22,9 @@
         <Style x:Key="tb" TargetType="TextBox">
             <Setter Property="VerticalAlignment" Value="Center"/>
             <Setter Property="HorizontalAlignment" Value="Stretch"/>
+            <Setter Property="VerticalContentAlignment" Value="Center"/>
             <Setter Property="Height" Value="30"/>
-            <Setter Property="FontSize" Value="20"/>
+            <Setter Property="FontSize" Value="16"/>
         </Style>
 
         <!--Combox-->
@@ -127,7 +127,7 @@
             <Setter Property="BorderThickness" Value="0"/>
         </Style>
 
-        <!--<Style TargetType="DatePickerTextBox">
+        <Style TargetType="DatePickerTextBox">
             <Setter Property="ItemsControl.Template">
                 <Setter.Value>
                     <ControlTemplate>
@@ -135,7 +135,7 @@
                     </ControlTemplate>
                 </Setter.Value>
             </Setter>
-        </Style>-->
+        </Style>
     </Window.Resources>
     <Grid x:Name="gMain">
         <Grid.RowDefinitions>
@@ -164,7 +164,7 @@
         <Button Grid.Row="0" Grid.Column="4" Content="鐧� 褰�" Style="{StaticResource btn}" Click="Login_MouseLeftButtonDown"/>
 
         <Label Grid.Row="1" Grid.Column="0" Content="浠ょ墝锛�" VerticalAlignment="Center" HorizontalAlignment="Right" />
-        <TextBox Grid.Row="1" Grid.Column="1"  Style="{StaticResource tb}" IsReadOnly="True" x:Name="tbToken"/>
+        <TextBox Grid.Row="1" Grid.Column="1" Style="{StaticResource tb}" IsReadOnly="True" x:Name="tbToken"/>
         <Label Grid.Row="1" Grid.Column="2" Content="鍏冩暟鎹被鍨嬶細" VerticalAlignment="Center" HorizontalAlignment="Right" />
         <!--<TextBox Grid.Row="1" Grid.Column="3" Style="{StaticResource tb}" x:Name="tbAcqTim2e"/>-->
         <!--<ComboBox Grid.Row="1" Grid.Column="3" IsReadOnly="True" DisplayMemberPath="Name" Style="{StaticResource ComboBoxStyle}" Width="320" Height="30" HorizontalAlignment="Left" x:Name="cbMetaType"></ComboBox>-->
@@ -187,7 +187,7 @@
 
 
         <Label Grid.Row="3" Grid.Column="0" Content="璧勬簮鐩綍锛�" VerticalAlignment="Center" HorizontalAlignment="Right" />
-        <TextBox Grid.Row="3" Grid.Column="1" Grid.ColumnSpan="3" Style="{StaticResource tb}" x:Name="tbDir"/>
+        <TextBox Grid.Row="3" Grid.Column="1" Grid.ColumnSpan="3" Style="{StaticResource tb}" IsReadOnly="True" x:Name="tbDir"/>
         <Button Grid.Row="3" Grid.Column="4" Content="閫� 鎷�" Style="{StaticResource btn}" Click="Dir_MouseLeftButtonDown" x:Name="btnDir"/>
 
         <Label Grid.Row="4" Grid.Column="0" Content="鏁版嵁鐩綍锛�" VerticalAlignment="Center" HorizontalAlignment="Right" />
diff --git a/DataLoader/MainWindow.xaml.cs b/DataLoader/MainWindow.xaml.cs
index 012e33f..18ce32d 100644
--- a/DataLoader/MainWindow.xaml.cs
+++ b/DataLoader/MainWindow.xaml.cs
@@ -15,9 +15,11 @@
 {
     public partial class MainWindow : Window
     {
-        private ObservableCollection<ViewData> viewDatas = new ObservableCollection<ViewData>();
+        public ResWin resWin;
 
-        private LoginWin win;
+        private LoginWin loginWin;
+
+        private ObservableCollection<ViewData> viewDatas = new ObservableCollection<ViewData>();
 
         public MainWindow()
         {
@@ -60,24 +62,19 @@
         // 璁剧疆
         private void Login_MouseLeftButtonDown(object sender, RoutedEventArgs e)
         {
-            win = new LoginWin();
+            loginWin = new LoginWin();
             this.Hide();
-            win.Show();
+            loginWin.Show();
         }
 
         public void SetLoginInfo()
         {
-            if (win != null) win.Close();
+            if (loginWin != null) loginWin.Close();
             this.Show();
 
-            //this.tbUid.Text = Tool.UserId.ToString();
-            //this.tbToken.Text = Tool.Token;
-
-            //string uidStr = this.tbUid.Text.Trim();
-            //string didStr = this.tbDir.Text.Trim();
-
-            //int.TryParse(uidStr, out Common.UserId);
-            //int.TryParse(didStr, out Common.DirId);
+            this.tbUid.Text = CommonProp.UserId.ToString();
+            this.tbUname.Text = CommonProp.Uname;
+            this.tbToken.Text = CommonProp.Token;
 
             this.btnLoad.IsEnabled = true;
             this.btnImport.IsEnabled = true;
@@ -86,7 +83,21 @@
         // 璧勬簮鐩綍
         private void Dir_MouseLeftButtonDown(object sender, RoutedEventArgs e)
         {
+            resWin = new ResWin();
+            this.Hide();
+            resWin.Show();
+        }
 
+        public void SetRes(string dircode, string fullName)
+        {
+            if (resWin != null) resWin.Close();
+            this.Show();
+
+            if (!string.IsNullOrEmpty(dircode))
+            {
+                CommonProp.Dircode = dircode;
+                this.tbDir.Text = fullName;
+            }
         }
 
         // 鏁版嵁鐩綍
diff --git a/DataLoader/Model/SysDir.cs b/DataLoader/Model/SysDir.cs
index 3787004..97b5abe 100644
--- a/DataLoader/Model/SysDir.cs
+++ b/DataLoader/Model/SysDir.cs
@@ -86,5 +86,10 @@
         /// 缂栫爜
         /// </summary>
         public string code { set; get; }
+
+        /// <summary>
+        /// 瀹屽叏鍚嶇О
+        /// </summary>
+        public string fullName { set; get; }
     }
 }
diff --git a/DataLoader/Model/TreeItem.cs b/DataLoader/Model/TreeItem.cs
new file mode 100644
index 0000000..be96ddb
--- /dev/null
+++ b/DataLoader/Model/TreeItem.cs
@@ -0,0 +1,115 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DataLoader.Model
+{
+    public class TreeItem : INotifyPropertyChanged
+    {
+        private int id;
+
+        private string name;
+
+        private bool isChecked;
+
+        private bool isExpanded;
+
+        private ObservableCollection<TreeItem> child;
+
+        public event PropertyChangedEventHandler PropertyChanged;
+
+        public TreeItem()
+        {
+        }
+
+        public TreeItem(int id, string name, string fullName)
+        {
+            this.id = id;
+            this.name = name;
+            this.FullName = fullName;
+        }
+
+        public int ID
+        {
+            set
+            {
+                this.id = value;
+                ChangProperty("ID");
+            }
+            get
+            {
+                return this.id;
+            }
+        }
+
+        public string Name
+        {
+            set
+            {
+                this.name = value;
+                ChangProperty("Name");
+            }
+            get
+            {
+                return this.name;
+            }
+        }
+
+        public bool IsChecked
+        {
+            set
+            {
+                isChecked = value;
+                ChangProperty("IsChecked");
+            }
+            get
+            {
+                return this.isChecked;
+            }
+        }
+
+        public bool IsExpanded
+        {
+            set
+            {
+                isExpanded = value;
+                ChangProperty("IsExpanded");
+            }
+            get
+            {
+                return isExpanded;
+            }
+        }
+
+        public string FullName
+        {
+            set;
+            get;
+        }
+
+        public ObservableCollection<TreeItem> Child
+        {
+            set
+            {
+                child = value;
+                ChangProperty("Child");
+            }
+            get
+            {
+                return child;
+            }
+        }
+
+        private void ChangProperty(string propName)
+        {
+            if (PropertyChanged != null)
+            {
+                PropertyChanged(this, new PropertyChangedEventArgs(propName));
+            }
+        }
+    }
+}
diff --git a/DataLoader/ResWin.xaml b/DataLoader/ResWin.xaml
new file mode 100644
index 0000000..fd8a6e8
--- /dev/null
+++ b/DataLoader/ResWin.xaml
@@ -0,0 +1,67 @@
+锘�<Window x:Class="DataLoader.ResWin"
+        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+        ShowInTaskbar="False" Loaded="Window_Loaded" Closing="Window_Closing"
+        xmlns:model="clr-namespace:DataLoader.Model" Background="Transparent"
+        Title="璇烽�夋嫨璧勬簮" Height="750" Width="600" WindowStartupLocation="CenterScreen">
+    <Window.Resources>
+        <Style x:Key="CheckBoxStyle" TargetType="{x:Type CheckBox}">
+            <Setter Property="SnapsToDevicePixels" Value="true" />
+            <Setter Property="OverridesDefaultStyle" Value="False" />
+            <Setter Property="Height" Value="52"/>
+            <Setter Property="IsChecked" Value="False"/>
+            <Setter Property="Template">
+                <Setter.Value>
+                    <ControlTemplate TargetType="CheckBox">
+                        <Grid>
+                            <Grid.ColumnDefinitions>
+                                <ColumnDefinition Width="Auto"/>
+                                <ColumnDefinition Width="*"/>
+                            </Grid.ColumnDefinitions>
+                            <Grid Height="{TemplateBinding Height}" Width="{TemplateBinding Height}">
+                                <Rectangle x:Name="CheckBoxRectangle" Fill="#00446F" Opacity="1" RadiusY="0" RadiusX="0"/>
+                                <Rectangle x:Name="CheckBoxRectangleOut" Stroke="#00A0E9" StrokeThickness="1" RadiusY="0" RadiusX="0"/>
+                                <Grid x:Name="CheckedMark" Height="{TemplateBinding Height}" Width="{TemplateBinding Height}" Visibility="Collapsed" >
+                                    <Viewbox>
+                                        <Grid>
+                                            <Path SnapsToDevicePixels="True" StrokeThickness="4" Data="M1,9 L10,17" Stroke="#F6A411"/>
+                                            <Path SnapsToDevicePixels="True" StrokeThickness="4" Data="M8,17 L20,4" Stroke="#F6A411"/>
+                                        </Grid>
+                                    </Viewbox>
+                                </Grid>
+                            </Grid>
+                            <ContentPresenter Grid.Column="1" VerticalAlignment="Center" Margin="8,0,0,0"/>
+                        </Grid>
+                        <ControlTemplate.Triggers>
+                            <Trigger Property="IsChecked" Value="True">
+                                <Setter TargetName="CheckedMark" Property="Visibility" Value="Visible"></Setter>
+                            </Trigger>
+                        </ControlTemplate.Triggers>
+                    </ControlTemplate>
+                </Setter.Value>
+            </Setter>
+        </Style>
+    </Window.Resources>
+    <Grid>
+        <Grid.Background>
+            <SolidColorBrush Color="#0B498F" Opacity="0.3"/>
+        </Grid.Background>
+        <ScrollViewer Grid.Row="0" Grid.Column="0" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" Margin="5" Background="Transparent">
+            <TreeView x:Name="tvResTree" FontSize="13" Background="Transparent" Foreground="White" BorderThickness="0">
+                <TreeView.ItemTemplate>
+                    <HierarchicalDataTemplate DataType="{x:Type model:TreeItem}" ItemsSource="{Binding Path=Child}">
+                        <StackPanel Orientation="Horizontal" Margin="0 10" Background="Transparent">
+                            <CheckBox IsChecked="{Binding IsChecked}" Tag="{Binding ID}" Style="{StaticResource CheckBoxStyle}" Click="CheckBox_Click" Cursor="Hand" Margin="0 0 10 0" VerticalAlignment="Center" BorderBrush="#00A0E9" BorderThickness="1" Background="#00446F" Width="20" Height="20" VerticalContentAlignment='Center'/>
+                            <Border Tag="{Binding ID}" Height="32" VerticalAlignment="Center" BorderBrush="#1A63B5" BorderThickness="1" Padding="15 2 15 0" Cursor="Hand" MouseLeftButtonDown="Border_MouseLeftButtonDown">
+                                <Border.Background>
+                                    <SolidColorBrush Color="#0B498F" Opacity="0.3"/>
+                                </Border.Background>
+                                <TextBlock VerticalAlignment="Center" Text="{Binding Name}" FontSize="16" FontFamily="MicrosoftYaHei" Foreground="White" HorizontalAlignment="Center"/>
+                            </Border>
+                        </StackPanel>
+                    </HierarchicalDataTemplate>
+                </TreeView.ItemTemplate>
+            </TreeView>
+        </ScrollViewer>
+    </Grid>
+</Window>
diff --git a/DataLoader/ResWin.xaml.cs b/DataLoader/ResWin.xaml.cs
new file mode 100644
index 0000000..4810d55
--- /dev/null
+++ b/DataLoader/ResWin.xaml.cs
@@ -0,0 +1,86 @@
+锘縰sing DataLoader.CS;
+using DataLoader.Model;
+using System;
+using System.Linq;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Input;
+
+namespace DataLoader
+{
+    public partial class ResWin : Window
+    {
+        private TreeItem items = new TreeItem();
+
+        private List<SysDir> dirs;
+
+        private CheckBox cbLast;
+
+        public ResWin()
+        {
+            InitializeComponent();
+        }
+
+        private void Border_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
+        {
+            //
+        }
+
+        private void Window_Loaded(object sender, RoutedEventArgs e)
+        {
+            dirs = DBHelper.GetDirList();
+            if (null == dirs || 0 == dirs.Count) return;
+
+            FindTreeItems(dirs, items, 0);
+            this.tvResTree.ItemsSource = items.Child;
+        }
+
+        private void FindTreeItems(List<SysDir> list, TreeItem ti, int pid)
+        {
+            if (ti.Child == null) ti.Child = new ObservableCollection<TreeItem>();
+            foreach (SysDir dir in list)
+            {
+                if (pid == dir.pid)
+                {
+                    TreeItem item = new TreeItem();
+                    item.ID = dir.id;
+                    item.Name = dir.name;
+                    item.FullName = dir.fullName;
+                    item.IsExpanded = true;
+                    ti.Child.Add(item);
+
+                    FindTreeItems(list, item, dir.id);
+                }
+            }
+        }
+
+        private void CheckBox_Click(object sender, RoutedEventArgs e)
+        {
+            CheckBox cb = sender as CheckBox;
+            if (cb.IsChecked == true)
+            {
+                if (null != this.cbLast) this.cbLast.IsChecked = false;
+                this.cbLast = cb;
+            }
+            else
+            {
+                this.cbLast = null;
+            }
+        }
+
+        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
+        {
+            SysDir dir = null;
+            if (this.cbLast != null)
+            {
+                int id = int.Parse(this.cbLast.Tag.ToString());
+                dir = (from d in dirs where d.id == id select d).First<SysDir>();
+            }
+
+            CommonProp.Owner.resWin = null;
+            CommonProp.Owner.SetRes(null == dir ? null : dir.code, null == dir ? null : dir.fullName);
+        }
+    }
+}

--
Gitblit v1.9.3