history_sort_filter

This commit is contained in:
Your Name 2025-02-21 16:09:01 +03:00
parent 24fcb4b4bd
commit 9425badd58
15 changed files with 47 additions and 6 deletions

View File

@ -16,7 +16,7 @@
<Image x:Name="Image" Width="150" Height="150"/>
<TextBlock x:Name="FioName" Foreground="Black"/>
<TextBlock x:Name="RoleName" Foreground="Black"/>
<Button Content="Сформировать заказ" Click="History_OnClick" Background="LightGray" Width="170"/>
<Button Content="История" Click="History_OnClick" Background="LightGray" Width="170"/>
</StackPanel>
</DockPanel>
</Border>

View File

@ -11,6 +11,12 @@
<StackPanel DockPanel.Dock="Top" Orientation="Horizontal" Background="Gray" Height="30">
<Button Content="Назад" Click="Back_OnClick" Width="120" Background="LightGray" Foreground="Black" HorizontalAlignment="Left" DockPanel.Dock="Left"/>
<TextBlock x:Name="TimerText" Foreground="White" Margin="10,5,0,0" HorizontalAlignment="Center"/>
<ComboBox VerticalAlignment="Center" Width="100" x:Name="SortComboBox" SelectionChanged="SortComboBox_OnSelectionChanged">
<ComboBoxItem Content="сброс"/>
<ComboBoxItem Content="later"/>
<ComboBoxItem Content="nah"/>
</ComboBox>
<ComboBox VerticalAlignment="Center" Width="100" x:Name="FilterCombobox" SelectionChanged="FilterCombobox_OnSelectionChanged"/>
</StackPanel>
<ScrollViewer DockPanel.Dock="Top" VerticalScrollBarVisibility="Auto">

View File

@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using Avalonia;
@ -12,12 +13,13 @@ namespace dmeo040225;
public partial class HistoryWindow : Window
{
public ObservableCollection<User> Users { get; set; } = new();
ObservableCollection<User> Users = new ObservableCollection<User>();
List<UserPresenter> dataSourceUsers;
public HistoryWindow()
{
InitializeComponent();
using var context = new DatabaseContext();
var users = context.Users.Select(user => new UserPresenter
dataSourceUsers = context.Users.Select(user => new UserPresenter
{
Id = user.Id,
RoleId = user.RoleId,
@ -27,8 +29,9 @@ public partial class HistoryWindow : Window
Logorno = user.Logorno,
}).ToList();
Users = new ObservableCollection<User>(users);
ListBoxHistory.ItemsSource = Users;
FilterCombobox.ItemsSource = dataSourceUsers.Select(user => user.Login).ToList();
DisplayServices();
TimerService.Instance.TimeUpdated += UpdateTimerText;
TimerService.Instance.TimerExpired += LogoutUser;
@ -52,6 +55,38 @@ public partial class HistoryWindow : Window
}
}
public void DisplayServices()
{
var temp = dataSourceUsers;
Users.Clear();
switch (SortComboBox.SelectedIndex)
{
case 1: temp = temp.OrderBy(it => it.Lastlogin).ToList(); break;
case 0: temp = temp.OrderByDescending(it => it.Lastlogin).ToList(); break;
default: break;
}
if (FilterCombobox.SelectionBoxItem != null)
{
temp = temp.Where(u => u.Login == FilterCombobox.SelectionBoxItem.ToString()).ToList();
}
foreach (var item in temp)
{
Users.Add(item);
}
}
private void SortComboBox_OnSelectionChanged(object? sender, SelectionChangedEventArgs e)
{
DisplayServices();
}
private void FilterCombobox_OnSelectionChanged(object? sender, SelectionChangedEventArgs e)
{
DisplayServices();
}
private void Back_OnClick(object? sender, RoutedEventArgs e)
{
Close();

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -13,7 +13,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("dmeo040225")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+7df29eaed73ff8157467edb785b5cec0c2f2baac")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+24fcb4b4bdec7f65156773fbaab0680cea833382")]
[assembly: System.Reflection.AssemblyProductAttribute("dmeo040225")]
[assembly: System.Reflection.AssemblyTitleAttribute("dmeo040225")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

View File

@ -1 +1 @@
8148ae1978269f085dafca0635f8af2746f8bdf7cc4fe5ae6804146ebc19fd26
619dff8a150155e86bea2906fa1ba070e670274bf639e016b092abdd96b0f3a8

Binary file not shown.

Binary file not shown.

Binary file not shown.