MoskalenkoSergey 6 сар өмнө
parent
commit
650f56a9f7

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

@@ -109,10 +109,10 @@ namespace PP_Ven_MosS.Pages
                 switch (CB_Sort_app.SelectedIndex)
                 {
                     case 1:
-                        applications = applications.Where(x=>x.Date_app.Day<DateTime.Today.Day).OrderBy(x => x.Date_app).ToList();
+                        applications = applications.Where(x=>x.Date_app < DateTime.Today).OrderBy(x => x.Date_app).ToList();
                         break;
                     case 2:
-                        applications = applications.Where(x => x.Date_app.Day == DateTime.Today.Day).OrderBy(x => x.Date_app).ToList();
+                        applications = applications.Where(x => x.Date_app == DateTime.Today).OrderBy(x => x.Date_app).ToList();
                         break;
                 }
             }
@@ -140,10 +140,10 @@ namespace PP_Ven_MosS.Pages
                 switch (CB_Sort_event.SelectedIndex)
                 {
                     case 1:
-                        events = events.Where(x => x.Date_event.Day < DateTime.Today.Day).OrderBy(x => x.Date_event).ToList();
+                        events = events.Where(x => x.Date_event < DateTime.Today).OrderBy(x => x.Date_event).ToList();
                         break;
                     case 2:
-                        events = events.Where(x => x.Date_event.Day == DateTime.Today.Day).OrderBy(x => x.Date_event).ToList();
+                        events = events.Where(x => x.Date_event == DateTime.Today).OrderBy(x => x.Date_event).ToList();
                         break;
                 }
             }

+ 4 - 4
PP_Ven_MosS/Pages/ApplicationsListUser.xaml.cs

@@ -62,10 +62,10 @@ namespace PP_Ven_MosS
                 switch (CB_Sort_app.SelectedIndex)
                 {
                     case 1:
-                        applications = applications.Where(x => x.Date_app.Day < DateTime.Today.Day).OrderBy(x => x.Date_app).ToList();
+                        applications = applications.Where(x => x.Date_app < DateTime.Today).OrderBy(x => x.Date_app).ToList();
                         break;
                     case 2:
-                        applications = applications.Where(x => x.Date_app.Day == DateTime.Today.Day).OrderBy(x => x.Date_app).ToList();
+                        applications = applications.Where(x => x.Date_app == DateTime.Today).OrderBy(x => x.Date_app).ToList();
                         break;
                 }
             }
@@ -93,10 +93,10 @@ namespace PP_Ven_MosS
                 switch (CB_Sort_event.SelectedIndex)
                 {
                     case 1:
-                        events = events.Where(x => x.Date_event.Day < DateTime.Today.Day).OrderBy(x => x.Date_event).ToList();
+                        events = events.Where(x => x.Date_event < DateTime.Today).OrderBy(x => x.Date_event).ToList();
                         break;
                     case 2:
-                        events = events.Where(x => x.Date_event.Day == DateTime.Today.Day).OrderBy(x => x.Date_event).ToList();
+                        events = events.Where(x => x.Date_event == DateTime.Today).OrderBy(x => x.Date_event).ToList();
                         break;
                 }
             }

+ 3 - 7
PP_Ven_MosS/Pages/Avtorization.xaml.cs

@@ -35,24 +35,20 @@ namespace PP_Ven_MosS
         {
             string GHCPass = PBPass.Password.GetHashCode().ToString();
             User user = Database.entities.User.FirstOrDefault(x => x.Login == TBLog.Text && x.Password == GHCPass);
+            UserRole.userrole = user.Id_role;
+            UserID.userid = user.Id_user;
             if (user != null)
             {
                 if (user.Id_role == 1)
                 {
-                    UserRole.userrole = user.Id_role;
-                    UserID.userid = user.Id_user;
-                    FrameClass.MainFrame.Navigate(new ApplicationsListUser());
+                    FrameClass.MainFrame.Navigate(new MenuAdmin());
                 }
                 else if (user.Id_role == 2)
                 {
-                    UserRole.userrole = user.Id_role;
-                    UserID.userid = user.Id_user;
                     FrameClass.MainFrame.Navigate(new ApplicationsListAdmin());
                 }
                 else if (user.Id_role == 3)
                 {
-                    UserRole.userrole = user.Id_role;
-                    UserID.userid = user.Id_user;
                     FrameClass.MainFrame.Navigate(new ApplicationsListUser());
                 }
             }

+ 2 - 1
PP_Ven_MosS/Pages/CreateApplication.xaml.cs

@@ -39,7 +39,8 @@ namespace PP_Ven_MosS.Pages
                 Id_app_type = CBTypeApp.SelectedIndex + 1,
                 Place_app = PlaceApp.Text,
                 Date_app = DateTime.Now,
-                Id_status_app = 2
+                Id_status_app = 2,
+                Id_employee = null
             };
             switch (MessageBox.Show("Уверены в своем решении?", "Служебная записка", MessageBoxButton.YesNo))
             {

+ 1 - 0
PP_Ven_MosS/Pages/CreateEvent.xaml.cs

@@ -39,6 +39,7 @@ namespace PP_Ven_MosS.Pages
                 Date_event = DateTime.Now,
                 Id_status_event = 2,
                 Title_event = TitleEv.Text,
+                
             };
             switch (MessageBox.Show("Уверены в своем решении?", "Организация мероприятия", MessageBoxButton.YesNo))
             {

+ 8 - 6
PP_Ven_MosS/Pages/MenuAdmin.xaml

@@ -47,17 +47,19 @@
                 </ListView.ItemsPanel>
                 <ListView.ItemTemplate>
                     <DataTemplate>
-                        <Border Width="500" Height="120" BorderThickness="1" BorderBrush="Red">
-                            <StackPanel Margin="10,0,0,0" Width="300" Orientation="Vertical" HorizontalAlignment="Left">
+                        <Border Width="500" Height="150" BorderThickness="1" BorderBrush="Red">
+                            <StackPanel Orientation="Horizontal">
+                                <StackPanel Margin="10,0,0,0" Width="300" Orientation="Vertical" HorizontalAlignment="Left">
                                 <TextBlock Text="{Binding Date_app}"/>
                                 <TextBlock Text="{Binding Place_app}"/>
                                 <TextBlock Text="{Binding Path=Application_type.Title_app_type}"/>
                                 <TextBlock Text="{Binding Description}"/>
                                 <TextBlock Text="{Binding Path=User.Surname}"/>
-                                <TextBlock Text="{Binding Path=Status_application.Title_status_app}" FontWeight="Bold"/>
-                                <GroupBox Header="Назначить исполнителя" FontSize="20" Style="{StaticResource GBSt}">
-                                    <ComboBox SelectionChanged="EmployChanged" Name="CBEmploy" Width="200" Height="30" Margin="10,10,0,0"/>
-                                </GroupBox>
+                                    <TextBlock Text="{Binding Path=Status_application.Title_status_app}" FontWeight="Bold"/>
+                                    <GroupBox Header="Назначить исполнителя" FontSize="10" Style="{StaticResource GBSt}" HorizontalAlignment="Right">
+                                            <ComboBox x:Name="CBEmpl" Height="20" Loaded="CBEmpl_Loaded"/>
+                                        </GroupBox>
+                                    </StackPanel>
                             </StackPanel>
                         </Border>
                     </DataTemplate>

+ 29 - 8
PP_Ven_MosS/Pages/MenuAdmin.xaml.cs

@@ -3,6 +3,7 @@ using PP_Ven_MosS.ModelBase;
 using System;
 using System.Collections.Generic;
 using System.Linq;
+using System.Net;
 using System.Text;
 using System.Threading.Tasks;
 using System.Windows;
@@ -37,6 +38,20 @@ namespace PP_Ven_MosS.Pages
             get { return apptype; }
             set { apptype = value; }
         }
+        private string employee;
+        public string Employee
+        {
+            get { return employee; }
+            set { employee = value; }
+        }
+
+        private void CBEmpl_Loaded(object sender, RoutedEventArgs e)
+        {
+            ComboBox cb = (ComboBox)sender;
+            cb.ItemsSource = DB.User.ToList().Where(x => x.Id_role == 2);
+            cb.DisplayMemberPath = "Surname";
+        }
+
     }
     public partial class MenuAdmin : Page
     {
@@ -46,23 +61,27 @@ namespace PP_Ven_MosS.Pages
         {
 
             InitializeComponent();
+            
+
             ApplicationList.ItemsSource = DB.Applications.ToList();
             Applications appl = DB.Applications.Where(x => x.Id_status_app == id).FirstOrDefault();
             CB_Filter_app.ItemsSource = new List<string> { "Фильтр по статусу", "Выполнен", "Не выполнен" };
             CB_Sort_app.ItemsSource = new List<string>() { "Фильтр по дате", "Не сегодня", "Сегодня" };
             CB_Sort_app.SelectedIndex = 0;
             CB_Filter_app.SelectedIndex = 0;
+           
             
-
-            
-
             EventList.ItemsSource = DB.Event.ToList();
             Event evnt = DB.Event.Where(x => x.Id_event == id).FirstOrDefault();
             CB_Filter_event.ItemsSource = new List<string>() { "Фильтр по статусу", "Проведено", "Не проведено" };
             CB_Sort_event.ItemsSource = new List<string>() { "Фильтр по дате", "Не сегодня", "Сегодня" };
             CB_Sort_event.SelectedIndex = 0;
             CB_Filter_event.SelectedIndex = 0;
+            
+
+            
         }
+        
         public MenuAdmin(int id)
         {
             InitializeComponent();
@@ -72,6 +91,8 @@ namespace PP_Ven_MosS.Pages
             CB_Sort_app.ItemsSource = DB.Applications.ToList();
             CB_Sort_app.SelectedIndex = 0;
             CB_Filter_app.SelectedIndex = 0;
+            
+
             this.id = id;
 
             EventList.ItemsSource = DB.Event.ToList();
@@ -82,7 +103,7 @@ namespace PP_Ven_MosS.Pages
             CB_Filter_event.SelectedIndex = 0;
             this.id = id;
         }
-
+        
         private void Filter()
         {
             List<Applications> applications = DB.Applications.ToList();
@@ -91,10 +112,10 @@ namespace PP_Ven_MosS.Pages
                 switch (CB_Sort_app.SelectedIndex)
                 {
                     case 1:
-                        applications = applications.Where(x => x.Date_app.Day < DateTime.Today.Day).OrderBy(x => x.Date_app).ToList();
+                        applications = applications.Where(x => x.Date_app < DateTime.Today).OrderBy(x => x.Date_app).ToList();
                         break;
                     case 2:
-                        applications = applications.Where(x => x.Date_app.Day == DateTime.Today.Day).OrderBy(x => x.Date_app).ToList();
+                        applications = applications.Where(x => x.Date_app == DateTime.Today).OrderBy(x => x.Date_app).ToList();
                         break;
                 }
             }
@@ -122,10 +143,10 @@ namespace PP_Ven_MosS.Pages
                 switch (CB_Sort_event.SelectedIndex)
                 {
                     case 1:
-                        events = events.Where(x => x.Date_event.Day < DateTime.Today.Day).OrderBy(x => x.Date_event).ToList();
+                        events = events.Where(x => x.Date_event < DateTime.Today).OrderBy(x => x.Date_event).ToList();
                         break;
                     case 2:
-                        events = events.Where(x => x.Date_event.Day == DateTime.Today.Day).OrderBy(x => x.Date_event).ToList();
+                        events = events.Where(x => x.Date_event == DateTime.Today).OrderBy(x => x.Date_event).ToList();
                         break;
                 }
             }

+ 3 - 3
PP_Ven_MosS/Pages/Registration.xaml

@@ -28,6 +28,9 @@
                 <GroupBox Header="Фамилия" FontSize="20" Style="{StaticResource GBSt}">
                     <TextBox Name="Surn"/>
                 </GroupBox>
+                <GroupBox Header="Выберите роль" FontSize="20" Style="{StaticResource GBSt}">
+                    <ComboBox x:Name="CBRole"/>
+                </GroupBox>
                 <GroupBox Header="Имя" FontSize="20" Style="{StaticResource GBSt}">
                     <TextBox Name="Nam"/>
                 </GroupBox>
@@ -46,9 +49,6 @@
                 <GroupBox Header="Пароль" FontSize="20" Style="{StaticResource GBSt}">
                     <PasswordBox Name="password" />
                 </GroupBox>
-                <GroupBox Header="Выберите роль" FontSize="20" Style="{StaticResource GBSt}">
-                    <ComboBox Name="CBRole"/>
-                </GroupBox>
                 <Button Margin="15" Name="Registr" FontSize="20" Click="reg_Click" Content="Завершить" Style="{StaticResource BtnSt}"></Button>
                 <Button Margin="15" Name="Back" FontSize="20" Click="Back_Click" Content="Выйти" Style="{StaticResource BtnSt}"></Button>
             </StackPanel>

+ 9 - 10
PP_Ven_MosS/Pages/Registration.xaml.cs

@@ -112,24 +112,24 @@ namespace PP_Ven_MosS.Pages
                     Classes.Database.entities.User.Add(newUser);
                     Classes.Database.entities.SaveChanges();
                     MessageBox.Show("Вы зарегистрировались!");
-                    if (user.Id_role == 1)
+                    UserID.userid = newUser.Id_user;
+                    UserRole.userrole = newUser.Id_role;
+                    if (UserRole.userrole == 1)
                     {
-                        UserID.userid = user.Id_user;
-                        UserRole.userrole  = user.Id_role;
                         FrameClass.MainFrame.Navigate(new MenuAdmin());
                     }
-                    else if (user.Id_role == 2)
+                    else if (UserRole.userrole == 2)
                     {
-                        UserID.userid = user.Id_user;
-                        UserRole.userrole = user.Id_role;
                         FrameClass.MainFrame.Navigate(new ApplicationsListAdmin());
                     }
-                    else
+                    else if (UserRole.userrole == 3)
                     {
-                        UserID.userid = user.Id_user;
-                        UserRole.userrole = user.Id_role;
                         FrameClass.MainFrame.Navigate(new ApplicationsListUser());
                     }
+                    else
+                    {
+                        MessageBox.Show("Ошибка");
+                    }
                 }
                 catch
                 {
@@ -137,7 +137,6 @@ namespace PP_Ven_MosS.Pages
                 }
             }
         }
-
         private void Back_Click(object sender, RoutedEventArgs e)
         {
             FrameClass.MainFrame.Navigate(new Avtorization());