diff --git a/HistoryWindow.axaml b/HistoryWindow.axaml
index 42515a7..743d548 100644
--- a/HistoryWindow.axaml
+++ b/HistoryWindow.axaml
@@ -5,39 +5,36 @@
mc:Ignorable="d" d:DesignWidth="1000" d:DesignHeight="1000"
x:Class="demo_hard.HistoryWindow"
x:CompileBindings="False"
- Title="HistoryWindow">
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ Title="История входов">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/HistoryWindow.axaml.cs b/HistoryWindow.axaml.cs
index 9581baf..63515e2 100644
--- a/HistoryWindow.axaml.cs
+++ b/HistoryWindow.axaml.cs
@@ -1,4 +1,6 @@
using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
using System.Linq;
using Avalonia.Controls;
using Avalonia.Interactivity;
@@ -9,15 +11,86 @@ namespace demo_hard;
public partial class HistoryWindow : Window
{
+ private ObservableCollection lastEnter = new();
+ public List Enter = new();
+ public bool sort = true;
public HistoryWindow()
{
+ using var context = new User2Context();
InitializeComponent();
- LoadInfo();
+
+
+ Enter = context.LastEnters.Select(it => new LastEnter
+ {
+ EmployeId = it.EmployeId,
+ Login = it.Login,
+ EnterDatetime = it.EnterDatetime,
+ EnterType = it.EnterType,
+ }).ToList();
+
+ foreach (var e in Enter)
+ {
+ lastEnter.Add(e);
+ }
+
+ LastEnterBox.ItemsSource = lastEnter;
+ LoginComboBox.ItemsSource = Enter.Select(it=>it.Login);
+ SortComboBox.ItemsSource = new List { "По возростанию", "по убыванию"};
+ SortLogin();
+ }
+
+
+
+ private void SortLogin()
+ {
+ var temp = Enter;
+ if (LoginComboBox.SelectedItem is string login)
+ {
+ temp = temp.Where(it => it.Login == login).ToList();
+ }
+
+ temp = sort? temp.OrderBy(it => it.Login).ToList(): temp.OrderByDescending(it=>it. Login).ToList();
+
+ lastEnter.Clear();
+
+ foreach (var items in temp)
+ {
+ lastEnter.Add(items);
+ }
}
- private void LoadInfo()
+ private void LoginCombobox_OnSelectedChanged(object? sender, SelectionChangedEventArgs e)
{
- using var context = new User2Context();
- LastEnterBox.ItemsSource = context.LastEnters.ToList();
+ sort = false;
+ SortLogin();
}
- }
\ No newline at end of file
+
+ private void SortButton_OnClick(object? sender, RoutedEventArgs e)
+ {
+ sort = !sort;
+ SortLogin();
+ }
+
+ private void SortDateTime()
+ {
+ var temp = Enter;
+ if (SortComboBox.SelectedItem is string sortOption)
+ {
+ temp = sortOption == "По возрастанию" ? temp.OrderBy(it=>it.EnterDatetime).ToList() : temp.OrderByDescending(it=>it.EnterDatetime).ToList();
+ }
+
+ lastEnter.Clear();
+ foreach (var datetime in temp)
+ {
+ lastEnter.Add(datetime);
+ }
+
+
+
+ }
+
+ private void SortComboBox_OnSelectedChanged(object? sender, SelectionChangedEventArgs e)
+ {
+ SortDateTime();
+ }
+}
\ No newline at end of file
diff --git a/bin/Debug/net8.0/demo_hard.dll b/bin/Debug/net8.0/demo_hard.dll
index 5d1bfa3..58b0853 100644
Binary files a/bin/Debug/net8.0/demo_hard.dll and b/bin/Debug/net8.0/demo_hard.dll differ
diff --git a/bin/Debug/net8.0/demo_hard.exe b/bin/Debug/net8.0/demo_hard.exe
index 02bafbb..5feb603 100644
Binary files a/bin/Debug/net8.0/demo_hard.exe and b/bin/Debug/net8.0/demo_hard.exe differ
diff --git a/bin/Debug/net8.0/demo_hard.pdb b/bin/Debug/net8.0/demo_hard.pdb
index a1ed085..6501e72 100644
Binary files a/bin/Debug/net8.0/demo_hard.pdb and b/bin/Debug/net8.0/demo_hard.pdb differ
diff --git a/obj/Debug/net8.0/Avalonia/demo_hard.dll b/obj/Debug/net8.0/Avalonia/demo_hard.dll
index 5d1bfa3..58b0853 100644
Binary files a/obj/Debug/net8.0/Avalonia/demo_hard.dll and b/obj/Debug/net8.0/Avalonia/demo_hard.dll differ
diff --git a/obj/Debug/net8.0/Avalonia/demo_hard.pdb b/obj/Debug/net8.0/Avalonia/demo_hard.pdb
index a1ed085..6501e72 100644
Binary files a/obj/Debug/net8.0/Avalonia/demo_hard.pdb and b/obj/Debug/net8.0/Avalonia/demo_hard.pdb differ
diff --git a/obj/Debug/net8.0/Avalonia/resources b/obj/Debug/net8.0/Avalonia/resources
index e3f6e5e..d990735 100644
Binary files a/obj/Debug/net8.0/Avalonia/resources and b/obj/Debug/net8.0/Avalonia/resources differ
diff --git a/obj/Debug/net8.0/apphost.exe b/obj/Debug/net8.0/apphost.exe
index 02bafbb..5feb603 100644
Binary files a/obj/Debug/net8.0/apphost.exe and b/obj/Debug/net8.0/apphost.exe differ
diff --git a/obj/Debug/net8.0/demo_hard.AssemblyInfo.cs b/obj/Debug/net8.0/demo_hard.AssemblyInfo.cs
index bc3d9af..2fa26f6 100644
--- a/obj/Debug/net8.0/demo_hard.AssemblyInfo.cs
+++ b/obj/Debug/net8.0/demo_hard.AssemblyInfo.cs
@@ -13,7 +13,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("demo_hard")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
-[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+76087f367db98dd96eb5d00b84f1cbdda7da181d")]
+[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+a24d02ba9bcc9b996f261baa314bdc3640928f7c")]
[assembly: System.Reflection.AssemblyProductAttribute("demo_hard")]
[assembly: System.Reflection.AssemblyTitleAttribute("demo_hard")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
diff --git a/obj/Debug/net8.0/demo_hard.AssemblyInfoInputs.cache b/obj/Debug/net8.0/demo_hard.AssemblyInfoInputs.cache
index 84b83e0..7d45ff1 100644
--- a/obj/Debug/net8.0/demo_hard.AssemblyInfoInputs.cache
+++ b/obj/Debug/net8.0/demo_hard.AssemblyInfoInputs.cache
@@ -1 +1 @@
-5b2767f893e7da3e6840a62cc19d1789e0f7f6add39e0be46f0182d0771bb4f5
+0aafcd50ff5ad3c25fb9904f65315a156568cf4318344922268bdb3057ae2dd9
diff --git a/obj/Debug/net8.0/demo_hard.dll b/obj/Debug/net8.0/demo_hard.dll
index e2f7bc2..a7981e7 100644
Binary files a/obj/Debug/net8.0/demo_hard.dll and b/obj/Debug/net8.0/demo_hard.dll differ
diff --git a/obj/Debug/net8.0/demo_hard.pdb b/obj/Debug/net8.0/demo_hard.pdb
index f3c47d7..42caadb 100644
Binary files a/obj/Debug/net8.0/demo_hard.pdb and b/obj/Debug/net8.0/demo_hard.pdb differ
diff --git a/obj/Debug/net8.0/ref/demo_hard.dll b/obj/Debug/net8.0/ref/demo_hard.dll
index 0c05a3b..b184918 100644
Binary files a/obj/Debug/net8.0/ref/demo_hard.dll and b/obj/Debug/net8.0/ref/demo_hard.dll differ
diff --git a/obj/Debug/net8.0/refint/Avalonia/demo_hard.dll b/obj/Debug/net8.0/refint/Avalonia/demo_hard.dll
index 0c05a3b..b184918 100644
Binary files a/obj/Debug/net8.0/refint/Avalonia/demo_hard.dll and b/obj/Debug/net8.0/refint/Avalonia/demo_hard.dll differ
diff --git a/obj/Debug/net8.0/refint/demo_hard.dll b/obj/Debug/net8.0/refint/demo_hard.dll
index 963ca67..826014f 100644
Binary files a/obj/Debug/net8.0/refint/demo_hard.dll and b/obj/Debug/net8.0/refint/demo_hard.dll differ