Mark ne voryi moi kod
This commit is contained in:
parent
a24d02ba9b
commit
0421119ccc
@ -5,18 +5,16 @@
|
||||
mc:Ignorable="d" d:DesignWidth="1000" d:DesignHeight="1000"
|
||||
x:Class="demo_hard.HistoryWindow"
|
||||
x:CompileBindings="False"
|
||||
Title="HistoryWindow">
|
||||
Title="История входов">
|
||||
|
||||
<DockPanel>
|
||||
<StackPanel DockPanel.Dock="Top" HorizontalAlignment="Center" Orientation="Horizontal" Margin="5">
|
||||
<TextBlock HorizontalAlignment="Center" Text="Окно истории входа" Margin="5"/>
|
||||
<ComboBox Width="200">
|
||||
|
||||
</ComboBox>
|
||||
<ComboBox Width="200">
|
||||
|
||||
</ComboBox>
|
||||
<ComboBox x:Name="LoginComboBox" Width="200" SelectionChanged="LoginCombobox_OnSelectedChanged"/>
|
||||
<ComboBox x:Name="SortComboBox" Width="200" SelectionChanged="SortComboBox_OnSelectedChanged"/>
|
||||
<Button Content="Сортировать" Click="SortButton_OnClick" Width="150" Margin="5"/>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel>
|
||||
<ListBox x:Name="LastEnterBox">
|
||||
<ListBox.ItemsPanel>
|
||||
@ -26,7 +24,7 @@
|
||||
</ListBox.ItemsPanel>
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Border>
|
||||
<Border BorderThickness="1" Padding="5" Margin="5">
|
||||
<StackPanel HorizontalAlignment="Center" Spacing="5">
|
||||
<TextBlock Text="{Binding Login}"/>
|
||||
<TextBlock Text="{Binding EnterDatetime}"/>
|
||||
@ -39,5 +37,4 @@
|
||||
</StackPanel>
|
||||
</DockPanel>
|
||||
|
||||
|
||||
</Window>
|
@ -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> lastEnter = new();
|
||||
public List<LastEnter> 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);
|
||||
}
|
||||
|
||||
private void LoadInfo()
|
||||
LastEnterBox.ItemsSource = lastEnter;
|
||||
LoginComboBox.ItemsSource = Enter.Select(it=>it.Login);
|
||||
SortComboBox.ItemsSource = new List<string> { "По возростанию", "по убыванию"};
|
||||
SortLogin();
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void SortLogin()
|
||||
{
|
||||
using var context = new User2Context();
|
||||
LastEnterBox.ItemsSource = context.LastEnters.ToList();
|
||||
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 LoginCombobox_OnSelectedChanged(object? sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
sort = false;
|
||||
SortLogin();
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -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")]
|
||||
|
@ -1 +1 @@
|
||||
5b2767f893e7da3e6840a62cc19d1789e0f7f6add39e0be46f0182d0771bb4f5
|
||||
0aafcd50ff5ad3c25fb9904f65315a156568cf4318344922268bdb3057ae2dd9
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user