Procházet zdrojové kódy

Добавлен список исполнителей

Данилов Денис před 1 rokem
rodič
revize
28cf83b805

+ 5 - 0
esoft/Class/ActualContext.cs

@@ -17,6 +17,7 @@ namespace esoft.Class
         readonly List<User> users;
         readonly List<Executor> executor;
         readonly List<Manager> manager;
+        readonly List<esoft.Entities.Task> tasks;
 
         public List<User> Users
         {
@@ -30,6 +31,10 @@ namespace esoft.Class
         {
             get { return manager; }
         }
+        public List<esoft.Entities.Task> Tasks
+        {
+            get { return esoftEntities.GetContext().Task.ToList(); }
+        }
 
         /// <summary>
         /// Заполнение контекстом полей

+ 79 - 6
esoft/Class/ExecuterFill.cs

@@ -1,5 +1,6 @@
 using esoft.Entities;
 using System;
+using System.CodeDom.Compiler;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
@@ -13,9 +14,15 @@ namespace esoft.Class
     /// </summary>
     public class ExecuterFill : User
     {
-        string grade; //Уровень Менеджера
-        int managerID; //Менеджер которому подчиняется Исполнитель
-        string fioUser; //ФИО Исполнителя
+        string grade;          //Уровень Менеджера
+        int managerID;        //Менеджер которому подчиняется Исполнитель
+        string fioUser;      //ФИО Исполнителя
+        string fioManager;  //ФИО Менеджера
+
+        int numberTasks_Plan;         //Количество задач запланирована
+        int numberTasks_Executed;    //Количество задач исполняется
+        int numberTasks_Done;       //Количество задач выполнена
+        int numberTasks_Сancelled; //Количество задач отменена
 
         public string Grade
         {
@@ -32,6 +39,32 @@ namespace esoft.Class
             get { return fioUser; }
             set { fioUser = value; }
         }
+
+        public string FioManager
+        {
+            get { return fioManager; }
+            set { fioManager = value; }
+        }
+        public int NumberTask_Plan
+        {
+            get { return numberTasks_Plan; }
+            set { numberTasks_Plan = value; }
+        }
+        public int NumberTask_Executed
+        {
+            get { return numberTasks_Executed; }
+            set { numberTasks_Executed = value; }
+        }
+        public int NumberTask_Done
+        {
+            get { return numberTasks_Done; }
+            set { numberTasks_Done = value; }
+        }
+        public int NumberTask_Сancelled
+        {
+            get { return numberTasks_Сancelled; }
+            set { numberTasks_Сancelled = value; }
+        }
         /// <summary>
         /// Метод формирующий удоный для работы список Исполнителей
         /// </summary>
@@ -41,8 +74,8 @@ namespace esoft.Class
             List<ExecuterFill> executerFills = new List<ExecuterFill>();
             try
             {
-                
-                List<Executor> executors = esoftEntities.GetContext().Executor.ToList();
+                ActualContext actualContext = new ActualContext();
+                List<esoft.Entities.Executor> executors = esoftEntities.GetContext().Executor.ToList();
                 List<User> users = esoftEntities.GetContext().User.ToList();
                 foreach (var user in users)
                 {
@@ -61,7 +94,15 @@ namespace esoft.Class
                                 IsDeleted = user.IsDeleted,
                                 FioUser = UserInFIO.SoloUser(user),
                                 Grade = executer.Grade,
-                                managerID = executer.ManagerID
+                                managerID = executer.ManagerID,
+                                FioManager = UserInFIO.SoloUser(
+                                actualContext.Users.FirstOrDefault(
+                                    x => x.ID == actualContext.Executor.FirstOrDefault(
+                                        z => z.ID == executer.ID).ManagerID)),
+                                NumberTask_Plan = GetPlanTaskCountForExecutor(executer.ID),
+                                NumberTask_Executed = GetExecutedTaskCountForExecutor(executer.ID),
+                                NumberTask_Done = GetDoneTaskCountForExecutor(executer.ID),
+                                NumberTask_Сancelled = GetCancelledTaskCountForExecutor(executer.ID),
                             });
                         }
                     }
@@ -76,5 +117,37 @@ namespace esoft.Class
             }
             return executerFills;
         }
+
+        private static int GetPlanTaskCountForExecutor(int executorID)
+        {
+            ActualContext actualContext = new ActualContext();
+            {
+                return actualContext.Tasks.Count(task => task.ExecutorID == executorID && task.Status == "запланирована");
+            }
+        }
+
+        private static int GetExecutedTaskCountForExecutor(int executorID)
+        {
+            ActualContext actualContext = new ActualContext();
+            {
+                return actualContext.Tasks.Count(task => task.ExecutorID == executorID && task.Status == "исполняется");
+            }
+        }
+
+        private static int GetDoneTaskCountForExecutor(int executorID)
+        {
+            ActualContext actualContext = new ActualContext();
+            {
+                return actualContext.Tasks.Count(task => task.ExecutorID == executorID && task.Status == "выполнена");
+            }
+        }
+
+        private static int GetCancelledTaskCountForExecutor(int executorID)
+        {
+            ActualContext actualContext = new ActualContext();
+            {
+                return actualContext.Tasks.Count(task => task.ExecutorID == executorID && task.Status == "отменена");
+            }
+        }
     }
 }

+ 14 - 0
esoft/Pages/AddExecutorPage.xaml

@@ -0,0 +1,14 @@
+<Page x:Class="esoft.Pages.AddExecutorPage"
+      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
+      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
+      xmlns:local="clr-namespace:esoft.Pages"
+      mc:Ignorable="d" 
+      d:DesignHeight="450" d:DesignWidth="800"
+      Title="AddExecutorPage">
+
+    <Grid>
+        
+    </Grid>
+</Page>

+ 28 - 0
esoft/Pages/AddExecutorPage.xaml.cs

@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace esoft.Pages
+{
+    /// <summary>
+    /// Логика взаимодействия для AddExecutorPage.xaml
+    /// </summary>
+    public partial class AddExecutorPage : Page
+    {
+        public AddExecutorPage()
+        {
+            InitializeComponent();
+        }
+    }
+}

+ 118 - 0
esoft/Pages/ExecutorsListPage.xaml

@@ -0,0 +1,118 @@
+<Page x:Class="esoft.Pages.ExecutorsListPage"
+      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
+      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
+      xmlns:local="clr-namespace:esoft.Pages"
+      mc:Ignorable="d" 
+      d:DesignHeight="1000"
+      Title="Список исполнителей" Width="1920" >
+
+
+    <Grid Width="1920">
+        <Grid.RowDefinitions>
+            <RowDefinition Height="auto"></RowDefinition>
+            <RowDefinition Height="*"></RowDefinition>
+        </Grid.RowDefinitions>
+
+        <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Height="50" Margin="0,0,0,-13">
+            <ComboBox Margin="5" Width="200" Height="25" Name="cbManager" DisplayMemberPath="" FontSize="16" SelectionChanged="cbManager_SelectionChanged">
+                <ComboBox.ToolTip>
+                    <ToolTip>
+                        Отбор по менеджеру
+                    </ToolTip>
+                </ComboBox.ToolTip>
+            </ComboBox>
+            <ComboBox Margin="5" Width="200" Height="25" Name="cbExecutor" DisplayMemberPath="" FontSize="16" SelectionChanged="cbExecutor_SelectionChanged">
+                <ComboBox.ToolTip>
+                    <ToolTip>
+                        Отбор по исполнителю
+                    </ToolTip>
+                </ComboBox.ToolTip>
+            </ComboBox>
+
+            <TextBox Margin="5" Width="200" Height="25" Name="Search" FontSize="16" TextChanged="Search_TextChanged">
+                <TextBox.Resources>
+                    <Style TargetType="{x:Type Border}">
+                        <Setter Property="CornerRadius" Value="12"/>
+                    </Style>
+                </TextBox.Resources>
+                <TextBox.ToolTip>
+                    <ToolTip>
+                        Поиск по наименованию
+                    </ToolTip>
+                </TextBox.ToolTip>
+            </TextBox>
+            <Button Height="25" Name="btnClearFilter" Content="Очистка фильтра" Width="200" Margin ="5" FontSize="16" Click="btnClearFilter_Click" Style="{StaticResource  StandartButtons}">
+                <Button.Resources>
+                    <Style TargetType="Border">
+                        <Setter Property="CornerRadius" Value="10"/>
+                    </Style>
+                </Button.Resources>
+            </Button>
+        </StackPanel>
+
+        <StackPanel Background="#e6e6e6" Margin="0,15,0,0" Grid.Row="1">
+            <TextBlock Text="ФИО исполнителя" FontSize="26" Margin="50, 15, 0, 0" VerticalAlignment ="Center" FontWeight="Bold"></TextBlock>
+            <TextBlock Text="Кол-во (заплан.)" Margin="330, -35, 0, 0" FontSize="26" VerticalAlignment ="Center" FontWeight="Bold" TextWrapping="Wrap"></TextBlock>
+            <TextBlock Text="Кол-во (испол.)" Margin="570, -35, 0, 0" FontSize="26" VerticalAlignment ="Center" FontWeight="Bold" TextWrapping="Wrap"></TextBlock>
+            <TextBlock Text="Кол-во (выпол.)" Margin="800, -35, 0, 0" FontSize="26" VerticalAlignment ="Center" FontWeight="Bold" TextWrapping="Wrap"></TextBlock>
+            <TextBlock Text="Кол-во (отмен.)" Margin="1040, -35, 0, 0" FontSize="26" VerticalAlignment ="Center" FontWeight="Bold" TextWrapping="Wrap"></TextBlock>
+            <TextBlock Text="Грэйд" HorizontalAlignment="Center" Margin="800, -35, 0, 0" VerticalAlignment ="Center" FontSize="26" FontWeight="Bold" TextWrapping="Wrap"></TextBlock>
+            <TextBlock Text="Менеджер" HorizontalAlignment="Center" Margin="1300, -35, 0, 0" VerticalAlignment ="Center" FontSize="26" FontWeight="Bold" TextWrapping="Wrap"></TextBlock>
+        </StackPanel>
+
+        <ListView Grid.Row="1" x:Name="LViewExecutors" Height="720" Width="1900" HorizontalAlignment="Center" VerticalAlignment="Top" Background="{x:Null}" BorderBrush="{x:Null}" Margin="0,83,0,0" MouseDoubleClick="LViewExecutors_MouseDoubleClick">
+            <ListView.ItemContainerStyle>
+                <Style TargetType="ListViewItem">
+                    <Setter Property="Margin" Value="0,0,0,10"/>
+                    <Setter Property="Width" Value="1870"/>
+                    <Setter Property="Background" Value="#73bbff"/>
+                    <Style.Resources>
+                        <Style TargetType="Border">
+                            <Setter Property="CornerRadius" Value="30"/>
+                        </Style>
+                    </Style.Resources>
+                </Style>
+            </ListView.ItemContainerStyle>
+
+            <ListView.ItemTemplate>
+                <DataTemplate>
+                    <Grid HorizontalAlignment="Center" Width="1900" Height="109">
+                        <TextBlock Text="{Binding FioUser}" Margin="50, 0, 0, 0" VerticalAlignment="Center" FontSize="26"></TextBlock>
+                        <TextBlock Text="{Binding NumberTask_Plan}" Margin="430, 0, 0, 0" VerticalAlignment="Center" FontSize="26"></TextBlock>
+                        <TextBlock Text="{Binding NumberTask_Executed}" Margin="650, 0, 0, 0" VerticalAlignment="Center" FontSize="26"></TextBlock>
+                        <TextBlock Text="{Binding NumberTask_Done}" Margin="890, 0, 0, 0" VerticalAlignment="Center" FontSize="26"></TextBlock>
+                        <TextBlock Text="{Binding NumberTask_Сancelled}" Margin="1120, 0, 0, 0" VerticalAlignment="Center" FontSize="26"></TextBlock>
+                        <TextBlock Text="{Binding Grade}" Margin="1325, 0, 0, 0" VerticalAlignment="Center" FontSize="26"></TextBlock>
+                        <TextBlock Text="{Binding FioManager}" Margin="1540, 0, 0, 0" VerticalAlignment="Center" FontSize="26"></TextBlock>
+                    </Grid>
+                </DataTemplate>
+            </ListView.ItemTemplate>
+        </ListView>
+
+        <Button Grid.Row="1" HorizontalAlignment="Left" Name="BtnDeleteExecutor" Content="Удалить исполнителя" Width="240" Height="40" BorderThickness="0" Style="{StaticResource  StandartButtons}" Margin="1600,805,0,0" Click="BtnDeleteExecutor_Click">
+            <Button.Resources>
+                <Style TargetType="Border">
+                    <Setter Property="CornerRadius" Value="10"/>
+                </Style>
+            </Button.Resources>
+        </Button>
+
+        <Button Grid.Row="1" HorizontalAlignment="Left" Name="BtnAddExecutor" Content="Добавить исполнителя" Width="240" Height="40" BorderThickness="0" Style="{StaticResource  StandartButtons}" Margin="1350,805,0,0" Click="BtnAddExecutor_Click">
+            <Button.Resources>
+                <Style TargetType="Border">
+                    <Setter Property="CornerRadius" Value="10"/>
+                </Style>
+            </Button.Resources>
+        </Button>
+
+        <Button Grid.Row="1" HorizontalAlignment="Left" Name="BtnUpdate" Content="Обновить список" Width="196" Height="40" BorderThickness="0" Style="{StaticResource  StandartButtons}" Margin="1142,805,0,0" Click="BtnUpdate_Click">
+            <Button.Resources>
+                <Style TargetType="Border">
+                    <Setter Property="CornerRadius" Value="10"/>
+                </Style>
+            </Button.Resources>
+        </Button>
+    </Grid>
+</Page>

+ 118 - 0
esoft/Pages/ExecutorsListPage.xaml.cs

@@ -0,0 +1,118 @@
+using esoft.Class;
+using esoft.Entities;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net.NetworkInformation;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace esoft.Pages
+{
+    /// <summary>
+    /// Логика взаимодействия для ExecutorsListPage.xaml
+    /// </summary>
+    public partial class ExecutorsListPage : Page
+    {
+        ActualContext actualContext = new ActualContext();                 // Контекст таблиц
+        ExecuterFill executer = new ExecuterFill();                       // Полученный контекст формы
+        List<ExecuterFill> executerContext = new List<ExecuterFill>();   // Список исполнителей
+
+        public ExecutorsListPage()
+        {
+            InitializeComponent();
+            LViewExecutors.ItemsSource = Class.ExecuterFill.Fill();
+            FillForm();
+        }
+
+        private void FillForm()
+        {
+            List<User> usersExecutor = actualContext.Users.Where(user => actualContext.Executor.Any(ex => ex.ID == user.ID)).ToList(); // Получение списка исполнителей
+            cbExecutor.ItemsSource = UserInFIO.GroupUser(usersExecutor);
+
+            List<User> usersManager = actualContext.Users.Where(user => actualContext.Manager.Any(manager => manager.ID == user.ID)).ToList(); // Получение списка менеджеров
+            cbManager.ItemsSource = UserInFIO.GroupUser(usersManager);
+        }
+
+        private void BtnDeleteExecutor_Click(object sender, RoutedEventArgs e)
+        {
+
+        }
+
+        private void BtnAddExecutor_Click(object sender, RoutedEventArgs e)
+        {
+
+        }
+
+        private void BtnUpdate_Click(object sender, RoutedEventArgs e)
+        {
+            LViewExecutors.ItemsSource = Class.ExecuterFill.Fill();
+        }
+
+        private void LViewExecutors_MouseDoubleClick(object sender, MouseButtonEventArgs e)
+        {
+
+        }
+
+        private void FilterTasks()
+        {
+            // Получение актуальных данных задач из базы или контекста приложения
+            executerContext = Class.ExecuterFill.Fill();
+
+            if (cbExecutor.SelectedItem != null)
+            {
+                string selectedExecutor = cbExecutor.SelectedItem.ToString();
+                executerContext = executerContext.Where(task => task.FioUser == selectedExecutor).ToList();
+            }
+
+            if (cbManager.SelectedItem != null)
+            {
+                string selectedManager = cbManager.SelectedItem.ToString();
+                executerContext = executerContext.Where(task => task.FioManager == selectedManager).ToList();
+            }
+
+            if (!string.IsNullOrEmpty(Search.Text))
+            {
+                string searchText = Search.Text.ToLower(); // Преобразование текста поиска к нижнему регистру (для удобства сравнения)
+
+                // Фильтрация задач по содержанию текста в полях Title
+                executerContext = executerContext.Where(task => task.FioUser.ToLower().Contains(searchText)).ToList();
+            }
+
+            LViewExecutors.ItemsSource = executerContext;
+        }
+
+        private void cbManager_SelectionChanged(object sender, SelectionChangedEventArgs e)
+        {
+            FilterTasks();
+        }
+
+        private void cbExecutor_SelectionChanged(object sender, SelectionChangedEventArgs e)
+        {
+            FilterTasks();
+        }
+        private void Search_TextChanged(object sender, TextChangedEventArgs e)
+        {
+            FilterTasks();
+        }
+        private void btnClearFilter_Click(object sender, RoutedEventArgs e)
+        {
+            // Очистка выбранных значений комбо боксов
+            cbExecutor.SelectedItem = null;
+            cbManager.SelectedItem = null;
+            Search.Text = string.Empty;
+
+            // Очистка фильтров и отображение всех задач без фильтрации
+            LViewExecutors.ItemsSource = Class.ExecuterFill.Fill();
+        }
+    }
+}

+ 14 - 0
esoft/esoft.csproj

@@ -138,6 +138,14 @@
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
+    <Page Include="Pages\AddExecutorPage.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
+    <Page Include="Pages\ExecutorsListPage.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
     <Page Include="Pages\LoginPage.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
@@ -151,6 +159,12 @@
     <Compile Include="Pages\AddEditServicePage.xaml.cs">
       <DependentUpon>AddEditServicePage.xaml</DependentUpon>
     </Compile>
+    <Compile Include="Pages\AddExecutorPage.xaml.cs">
+      <DependentUpon>AddExecutorPage.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="Pages\ExecutorsListPage.xaml.cs">
+      <DependentUpon>ExecutorsListPage.xaml</DependentUpon>
+    </Compile>
     <Compile Include="Pages\LoginPage.xaml.cs">
       <DependentUpon>LoginPage.xaml</DependentUpon>
     </Compile>