history window

This commit is contained in:
1billy17 2025-02-15 11:50:31 +03:00
parent fafd4f40eb
commit 48d3d61340
27 changed files with 294 additions and 46 deletions

View File

@ -3,7 +3,15 @@
<component name="AvaloniaProject"> <component name="AvaloniaProject">
<option name="projectPerEditor"> <option name="projectPerEditor">
<map> <map>
<entry key="demo5/AdminWindow.axaml" value="demo5/demo5.csproj" />
<entry key="demo5/BlankWindow.axaml" value="demo5/demo5.csproj" />
<entry key="demo5/FormOrderWindow.axaml" value="demo5/demo5.csproj" />
<entry key="demo5/HistoryWindow.axaml" value="demo5/demo5.csproj" />
<entry key="demo5/MainWindow.axaml" value="demo5/demo5.csproj" /> <entry key="demo5/MainWindow.axaml" value="demo5/demo5.csproj" />
<entry key="demo5/MegaSellerWindow.axaml" value="demo5/demo5.csproj" />
<entry key="demo5/SallerWindow.axaml" value="demo5/demo5.csproj" />
<entry key="demo5/SellerWindow.axaml" value="demo5/demo5.csproj" />
<entry key="demo5/TakeOrderWindow.axaml" value="demo5/demo5.csproj" />
</map> </map>
</option> </option>
</component> </component>

View File

@ -1,4 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="VcsDirectoryMappings" defaultProject="true" /> <component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project> </project>

View File

@ -5,5 +5,32 @@
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="demo5.AdminWindow" x:Class="demo5.AdminWindow"
Title="AdminWindow"> Title="AdminWindow">
Welcome to Avalonia! <DockPanel>
</Window> <Border>
<Grid>
<Grid ColumnDefinitions="Auto, 1*" VerticalAlignment="Center" Margin="10,0,0,0">
<StackPanel HorizontalAlignment="Left" VerticalAlignment="Center" Grid.Column="1" MaxWidth="250">
<Image Width="150" Height="250" x:Name="ClientImage"/>
</StackPanel>
</Grid>
<Grid ColumnDefinitions="Auto, 1*" HorizontalAlignment="Center" VerticalAlignment="Center">
<StackPanel HorizontalAlignment="Left" VerticalAlignment="Center" Grid.Column="1" MaxWidth="250" Spacing="15">
<TextBlock x:Name="FioTextBlock" FontSize="16"/>
<TextBlock x:Name="RoleTextBlock" FontSize="14"/>
<Button x:Name="FormReportsButton" Height="80" Width="300" BorderThickness="2" Click="FormReportsButton_OnClick">
<TextBlock Text="Сформировать отчеты" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Button>
<Button x:Name="WorkOnСonsumablesButton" Height="80" Width="300" BorderThickness="2" Click="WorkOnСonsumablesButton_OnClick">
<TextBlock Text="Работать с материалами" HorizontalAlignment="Center" VerticalAlignment="Center"></TextBlock>
</Button>
<Button x:Name="ViewHitoryButton" Height="80" Width="300" BorderThickness="2" Click="ViewHitoryButton_OnClick">
<TextBlock Text="Посмотреть историю" HorizontalAlignment="Center" VerticalAlignment="Center"></TextBlock>
</Button>
</StackPanel>
</Grid>
</Grid>
</Border>
</DockPanel>
</Window>

View File

@ -1,13 +1,52 @@
using Avalonia; using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Markup.Xaml; using Avalonia.Input;
using Avalonia.Interactivity;
using Avalonia.Media.Imaging;
using demo5.Models;
using demo5.MyModels;
namespace demo5; namespace demo5;
public partial class AdminWindow : Window public partial class AdminWindow : Window
{ {
public AdminWindow() public AdminWindow(Client client)
{ {
InitializeComponent(); InitializeComponent();
FioTextBlock.Text = client.Fio;
RoleTextBlock.Text = client.RoleNavigation.Name;
try
{
string absolutePath = Path.Combine(AppContext.BaseDirectory, client.Photopath);
ClientImage.Source = new Bitmap(absolutePath);
}
catch
{
ClientImage.Source = null;
}
} }
private void FormReportsButton_OnClick(object? sender, RoutedEventArgs e)
{
BlankWindow blankWindow = new BlankWindow();
blankWindow.ShowDialog(this);
}
private void WorkOnСonsumablesButton_OnClick(object? sender, RoutedEventArgs e)
{
BlankWindow blankWindow1 = new BlankWindow();
blankWindow1.ShowDialog(this);
}
private void ViewHitoryButton_OnClick(object? sender, RoutedEventArgs e)
{
HistoryWindow historyWindow = new HistoryWindow();
historyWindow.ShowDialog(this);
}
} }

View File

@ -3,7 +3,26 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:CompileBindings="False"
x:Class="demo5.HistoryWindow" x:Class="demo5.HistoryWindow"
Title="HistoryWindow"> Title="HistoryWindow">
Welcome to Avalonia! <DockPanel>
<StackPanel HorizontalAlignment="Center" Orientation="Horizontal" DockPanel.Dock="Top" Spacing="10" Height="50">
<ComboBox VerticalAlignment="Center" Width="100" x:Name="LoginComboBox" SelectionChanged="LoginComboBox_OnSelectionChanged"/>
<ComboBox VerticalAlignment="Center" Width="100" x:Name="DateComboBox" SelectionChanged="DateComboBox_OnSelectionChanged"/>
</StackPanel>
<Border>
<ListBox x:Name="HistoryListBox" Margin="10">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Spacing="10">
<TextBlock Text="{Binding Email}"></TextBlock>
<TextBlock Text="{Binding LastLogin, StringFormat=yyyy-MM-dd}"></TextBlock>
<TextBlock Text="{Binding SuccessLogin}"></TextBlock>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Border>
</DockPanel>
</Window> </Window>

View File

@ -1,13 +1,74 @@
using Avalonia; using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Markup.Xaml; using Avalonia.Interactivity;
using demo5.Models;
namespace demo5; namespace demo5;
public partial class HistoryWindow : Window public partial class HistoryWindow : Window
{ {
private ObservableCollection<HistoryPresenter> history = new();
private List<HistoryPresenter> dataSourceHistory;
public HistoryWindow() public HistoryWindow()
{ {
InitializeComponent(); InitializeComponent();
DataContext = this;
using var context = new Demo5Context();
dataSourceHistory = context.Clients.Select(client => new HistoryPresenter
{
Email = client.Email,
LastLogin = client.LastLogin,
SuccessLoginBool = client.SuccessLogin
}).ToList();
LoginComboBox.ItemsSource = dataSourceHistory.Select(it => it.Email).Distinct().ToList();
DateComboBox.ItemsSource = dataSourceHistory.Select(it => it.LastLogin).Where(it => it.HasValue).Distinct().ToList();
HistoryListBox.ItemsSource = history;
DisplayServices();
} }
}
public class HistoryPresenter
{
public string Email { get; set; } = string.Empty;
public DateTime? LastLogin { get; set; }
public bool? SuccessLoginBool { get; set; }
public string SuccessLogin => SuccessLoginBool.HasValue ? (SuccessLoginBool.Value ? "Успешно" : "Не успешно") : "";
}
private void DisplayServices()
{
var filteredData = dataSourceHistory;
if (LoginComboBox.SelectedItem is string selectedEmail)
{
filteredData = filteredData.Where(it => it.Email == selectedEmail).ToList();
}
if (DateComboBox.SelectedItem is DateTime selectedDate)
{
filteredData = filteredData.Where(it => it.LastLogin.HasValue && it.LastLogin.Value.Date == selectedDate.Date).ToList();
}
history.Clear();
foreach (var item in filteredData.OrderBy(it => it.LastLogin))
{
history.Add(item);
}
}
public void LoginComboBox_OnSelectionChanged(object? sender, RoutedEventArgs e)
{
DisplayServices();
}
public void DateComboBox_OnSelectionChanged(object? sender, RoutedEventArgs e)
{
DisplayServices();
}
}

View File

@ -26,42 +26,52 @@ public partial class MainWindow : Window
{ {
using var context = new Demo5Context(); using var context = new Demo5Context();
var LoginText = LoginTextBox?.Text; var loginText = LoginTextBox?.Text;
var Password = PasswordTextBox?.Text; var password = PasswordTextBox?.Text;
if (string.IsNullOrEmpty(LoginText) || string.IsNullOrEmpty(Password)) if (string.IsNullOrEmpty(loginText) || string.IsNullOrEmpty(password))
{ {
return; return;
} }
var client = context.Clients var client = context.Clients
.Include(c => c.RoleNavigation) .Include(c => c.RoleNavigation)
.FirstOrDefault(it => it.Email == LoginText); .FirstOrDefault(it => it.Email == loginText);
if (client != null && client.Password == Password) if (client != null)
{ {
switch (client.Role) client.LastLogin = DateTime.Now;
if (client.Password == password)
{ {
case 1: client.SuccessLogin = true;
BlankWindow blankWindow = new BlankWindow(); context.Clients.Update(client);
blankWindow.ShowDialog(this); context.SaveChanges();
break;
case 2: switch (client.Role)
SellerWindow sallerWindow = new SellerWindow(client); {
sallerWindow.ShowDialog(this); case 1:
break; new BlankWindow().ShowDialog(this);
case 3: break;
MegaSellerWindow megaSellerWindow = new MegaSellerWindow(); case 2:
megaSellerWindow.ShowDialog(this); new SellerWindow(client).ShowDialog(this);
break; break;
case 4: case 3:
AdminWindow adminWindow = new AdminWindow(); new MegaSellerWindow(client).ShowDialog(this);
adminWindow.ShowDialog(this); break;
break; case 4:
default: new AdminWindow(client).ShowDialog(this);
BlankWindow blankWindow2 = new BlankWindow(); break;
blankWindow2.ShowDialog(this); default:
return; new BlankWindow().ShowDialog(this);
return;
}
}
else
{
client.SuccessLogin = false;
context.Clients.Update(client);
context.SaveChanges();
} }
} }
} }

View File

@ -5,5 +5,29 @@
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="demo5.MegaSellerWindow" x:Class="demo5.MegaSellerWindow"
Title="MegaSellerWindow"> Title="MegaSellerWindow">
Welcome to Avalonia! <DockPanel>
</Window> <Border>
<Grid>
<Grid ColumnDefinitions="Auto, 1*" VerticalAlignment="Center" Margin="10,0,0,0">
<StackPanel HorizontalAlignment="Left" VerticalAlignment="Center" Grid.Column="1" MaxWidth="250">
<Image Width="150" Height="250" x:Name="ClientImage"/>
</StackPanel>
</Grid>
<Grid ColumnDefinitions="Auto, 1*" HorizontalAlignment="Center" VerticalAlignment="Center">
<StackPanel HorizontalAlignment="Left" VerticalAlignment="Center" Grid.Column="1" MaxWidth="250" Spacing="15">
<TextBlock x:Name="FioTextBlock" FontSize="16"/>
<TextBlock x:Name="RoleTextBlock" FontSize="14"/>
<Button x:Name="FormOrderButton" Height="80" Width="300" BorderThickness="2" Click="FormOrderButton_OnClick">
<TextBlock Text="Сформировать заказ" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Button>
<Button x:Name="TakeOrderButton" Height="80" Width="300" BorderThickness="2" Click="TakeOrderButton_OnClick">
<TextBlock Text="Принять заказ" HorizontalAlignment="Center" VerticalAlignment="Center"></TextBlock>
</Button>
</StackPanel>
</Grid>
</Grid>
</Border>
</DockPanel>
</Window>

View File

@ -1,13 +1,46 @@
using Avalonia; using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Markup.Xaml; using Avalonia.Input;
using Avalonia.Interactivity;
using Avalonia.Media.Imaging;
using demo5.Models;
using demo5.MyModels;
namespace demo5; namespace demo5;
public partial class MegaSellerWindow : Window public partial class MegaSellerWindow : Window
{ {
public MegaSellerWindow() public MegaSellerWindow(Client client)
{ {
InitializeComponent(); InitializeComponent();
FioTextBlock.Text = client.Fio;
RoleTextBlock.Text = client.RoleNavigation.Name;
try
{
string absolutePath = Path.Combine(AppContext.BaseDirectory, client.Photopath);
ClientImage.Source = new Bitmap(absolutePath);
}
catch
{
ClientImage.Source = null;
}
}
private void FormOrderButton_OnClick(object? sender, RoutedEventArgs e)
{
FormOrderWindow formOrderWindow = new FormOrderWindow();
formOrderWindow.ShowDialog(this);
}
private void TakeOrderButton_OnClick(object? sender, RoutedEventArgs e)
{
TakeOrderWindow takeOrderWindow = new TakeOrderWindow();
takeOrderWindow.ShowDialog(this);
} }
} }

View File

@ -0,0 +1,9 @@
<Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="demo5.TakeOrderWindow"
Title="TakeOrderWindow">
Welcome to Avalonia!
</Window>

View File

@ -0,0 +1,13 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
namespace demo5;
public partial class TakeOrderWindow : Window
{
public TakeOrderWindow()
{
InitializeComponent();
}
}

Binary file not shown.

Binary file not shown.

View File

@ -1 +1 @@
8948c0c28b75c3e276f21eb6eb86f7feeb43240c1e1ea3af04a080bdc30d141f d13374ee09495133f83e3063e39392fb7a826b075cf6c61a3b477d7c86689d9a

View File

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

View File

@ -1 +1 @@
5d85425ecb3c1ae34c6e36ade359dd0f925831013e3aae1c7054d3b2991eff96 927d8002c66c1b9968645ad5047d41eea4470c5049e02071cf2ffc8f07e94c20

View File

@ -42,3 +42,6 @@ build_metadata.AdditionalFiles.SourceItemGroup = AvaloniaXaml
[/Users/feitanportor/dev/C\#/demo5/demo5/SellerWindow.axaml] [/Users/feitanportor/dev/C\#/demo5/demo5/SellerWindow.axaml]
build_metadata.AdditionalFiles.SourceItemGroup = AvaloniaXaml build_metadata.AdditionalFiles.SourceItemGroup = AvaloniaXaml
[/Users/feitanportor/dev/C\#/demo5/demo5/TakeOrderWindow.axaml]
build_metadata.AdditionalFiles.SourceItemGroup = AvaloniaXaml

View File

@ -1 +1 @@
a252263bc118cc3d616f2f20814f72e4df244c5ee117fd7662fb87b455a54ae8 50f63526e6b823c15b5234c1d359abd7c4c2cd06793a3ed14005c4093c354f81

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1 +1 @@
17386709210962391 17386709532954604