Browse Source

Finish cb employee

MoskalenkoSergey 6 months ago
parent
commit
79e5b9734f

+ 13 - 0
PP_Ven_MosS/Classes/EmployeeID.cs

@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PP_Ven_MosS.Classes
+{
+    internal class EmployeeID
+    {
+        public static int employeeid;
+    }
+}

+ 1 - 0
PP_Ven_MosS/PP_Ven_MosS.csproj

@@ -64,6 +64,7 @@
       <Generator>MSBuild:Compile</Generator>
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
       <SubType>Designer</SubType>
     </ApplicationDefinition>
     </ApplicationDefinition>
+    <Compile Include="Classes\EmployeeID.cs" />
     <Compile Include="Classes\UserRole.cs" />
     <Compile Include="Classes\UserRole.cs" />
     <Compile Include="Classes\ViewModel.cs" />
     <Compile Include="Classes\ViewModel.cs" />
     <Compile Include="ModelBase\Applications.cs">
     <Compile Include="ModelBase\Applications.cs">

+ 1 - 1
PP_Ven_MosS/Pages/ApplicationsListAdmin.xaml.cs

@@ -48,7 +48,7 @@ namespace PP_Ven_MosS.Pages
             
             
             InitializeComponent();
             InitializeComponent();
            
            
-            ApplicationList.ItemsSource = DB.Applications.ToList();
+            ApplicationList.ItemsSource = DB.Applications.ToList().Where(x => x.Id_employee == user.Id_user);
             Applications appl = DB.Applications.Where(x => x.Id_status_app == id).FirstOrDefault();
             Applications appl = DB.Applications.Where(x => x.Id_status_app == id).FirstOrDefault();
             CB_Filter_app.ItemsSource = new List<string> { "Фильтр по статусу", "Выполнен", "Не выполнен" };
             CB_Filter_app.ItemsSource = new List<string> { "Фильтр по статусу", "Выполнен", "Не выполнен" };
             CB_Sort_app.ItemsSource = new List<string>() { "Фильтр по дате","Не сегодня", "Сегодня" };
             CB_Sort_app.ItemsSource = new List<string>() { "Фильтр по дате","Не сегодня", "Сегодня" };

+ 1 - 1
PP_Ven_MosS/Pages/MenuAdmin.xaml

@@ -57,7 +57,7 @@
                                 <TextBlock Text="{Binding Path=User.Surname}"/>
                                 <TextBlock Text="{Binding Path=User.Surname}"/>
                                     <TextBlock Text="{Binding Path=Status_application.Title_status_app}" FontWeight="Bold"/>
                                     <TextBlock Text="{Binding Path=Status_application.Title_status_app}" FontWeight="Bold"/>
                                     <GroupBox Header="Назначить исполнителя" FontSize="10" Style="{StaticResource GBSt}" HorizontalAlignment="Right">
                                     <GroupBox Header="Назначить исполнителя" FontSize="10" Style="{StaticResource GBSt}" HorizontalAlignment="Right">
-                                            <ComboBox x:Name="CBEmpl" Height="20" Loaded="CBEmpl_Loaded"/>
+                                            <ComboBox x:Name="CBEmpl" Height="20" Loaded="CBEmpl_Loaded" SelectionChanged="CBEmpl_SelectionChanged" Uid="{Binding Id_application}"/>
                                         </GroupBox>
                                         </GroupBox>
                                     </StackPanel>
                                     </StackPanel>
                             </StackPanel>
                             </StackPanel>

+ 27 - 4
PP_Ven_MosS/Pages/MenuAdmin.xaml.cs

@@ -50,8 +50,35 @@ namespace PP_Ven_MosS.Pages
             ComboBox cb = (ComboBox)sender;
             ComboBox cb = (ComboBox)sender;
             cb.ItemsSource = DB.User.ToList().Where(x => x.Id_role == 2);
             cb.ItemsSource = DB.User.ToList().Where(x => x.Id_role == 2);
             cb.DisplayMemberPath = "Surname";
             cb.DisplayMemberPath = "Surname";
+            cb.SelectedValuePath = "Id_user";
+            int appId = int.Parse(cb.Uid);
+            Applications ap = DB.Applications.FirstOrDefault(x => x.Id_application == appId);
+            if (ap.Id_employee != null)
+            {
+                cb.SelectedValue = Convert.ToInt32(ap.Id_employee);
+            }
         }
         }
 
 
+        private void CBEmpl_SelectionChanged(object sender, SelectionChangedEventArgs e)
+        {
+            PP_MininEntities2 DB = new PP_MininEntities2();
+            ComboBox cb = (ComboBox)sender;
+            cb.DisplayMemberPath = "Surname";
+            cb.SelectedValuePath = "Id_user";
+            if(cb.Uid != null) { 
+                int appId = int.Parse(cb.Uid);
+                Applications ap = DB.Applications.FirstOrDefault(x => x.Id_application == appId);
+                if (cb.SelectedItem != null)
+                {
+                    if (ap != null)
+                    {
+                        ap.Id_employee = Convert.ToInt32(cb.SelectedValue);
+                        DB.SaveChanges();
+                    }
+                }
+                
+            }
+        }
     }
     }
     public partial class MenuAdmin : Page
     public partial class MenuAdmin : Page
     {
     {
@@ -62,7 +89,6 @@ namespace PP_Ven_MosS.Pages
 
 
             InitializeComponent();
             InitializeComponent();
             
             
-
             ApplicationList.ItemsSource = DB.Applications.ToList();
             ApplicationList.ItemsSource = DB.Applications.ToList();
             Applications appl = DB.Applications.Where(x => x.Id_status_app == id).FirstOrDefault();
             Applications appl = DB.Applications.Where(x => x.Id_status_app == id).FirstOrDefault();
             CB_Filter_app.ItemsSource = new List<string> { "Фильтр по статусу", "Выполнен", "Не выполнен" };
             CB_Filter_app.ItemsSource = new List<string> { "Фильтр по статусу", "Выполнен", "Не выполнен" };
@@ -77,9 +103,6 @@ namespace PP_Ven_MosS.Pages
             CB_Sort_event.ItemsSource = new List<string>() { "Фильтр по дате", "Не сегодня", "Сегодня" };
             CB_Sort_event.ItemsSource = new List<string>() { "Фильтр по дате", "Не сегодня", "Сегодня" };
             CB_Sort_event.SelectedIndex = 0;
             CB_Sort_event.SelectedIndex = 0;
             CB_Filter_event.SelectedIndex = 0;
             CB_Filter_event.SelectedIndex = 0;
-            
-
-            
         }
         }
         
         
         public MenuAdmin(int id)
         public MenuAdmin(int id)