This commit is contained in:
Alex 2025-02-11 16:24:30 +03:00
commit 32b5507370
209 changed files with 7126 additions and 0 deletions

View File

@ -0,0 +1,13 @@
# Default ignored files
/shelf/
/workspace.xml
# Rider ignored files
/contentModel.xml
/modules.xml
/.idea.demo_hard.iml
/projectSettingsUpdater.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise" />
</project>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="UserContentModel">
<attachedFolders />
<explicitIncludes />
<explicitExcludes />
</component>
</project>

View File

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

10
App.axaml Normal file
View File

@ -0,0 +1,10 @@
<Application xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="demo_hard.App"
RequestedThemeVariant="Default">
<!-- "Default" ThemeVariant follows system theme variant. "Dark" or "Light" are other available options. -->
<Application.Styles>
<FluentTheme />
</Application.Styles>
</Application>

23
App.axaml.cs Normal file
View File

@ -0,0 +1,23 @@
using Avalonia;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Markup.Xaml;
namespace demo_hard;
public partial class App : Application
{
public override void Initialize()
{
AvaloniaXamlLoader.Load(this);
}
public override void OnFrameworkInitializationCompleted()
{
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{
desktop.MainWindow = new MainWindow();
}
base.OnFrameworkInitializationCompleted();
}
}

31
EnterHistoryWindow.axaml Normal file
View File

@ -0,0 +1,31 @@
<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="demo_hard.EnterHistoryWindow"
x:CompileBindings="False"
Title="EnterHistoryWindow">
<DockPanel>
<StackPanel Orientation="Vertical">
<TextBlock Text="История входа сотрудников" TextAlignment="Center" FontWeight="Bold" FontSize="20" Margin="0,0,0,10" />
<StackPanel Orientation="Horizontal">
<ComboBox x:Name="LoginComboBox" DataContext="{Binding Login}" SelectionChanged="LoginComboBox_OnSelectionChanged"/>
<Button Content="Отсортировать по дате по возрастанию" Click="Button_Asc" ></Button>
<Button Content="Отсортировать по дате по убыванию" Click="Button_Desc" ></Button>
</StackPanel>
<ListBox x:Name="lastEnters">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Spacing="80">
<TextBlock Text="{Binding EmployeId}"></TextBlock>
<TextBlock Text="{Binding Login}"></TextBlock>
<TextBlock Text="{Binding EnterDatetime}"></TextBlock>
<TextBlock Text="{Binding EnterType}"></TextBlock>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</StackPanel>
</DockPanel>
</Window>

View File

@ -0,0 +1,81 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using Avalonia.Controls;
using Avalonia.Interactivity;
using demo_hard.Models;
namespace demo_hard;
public partial class EnterHistoryWindow : Window
{
private ObservableCollection<LastEnter> lastEnter = new();
public List<LastEnter> dataLastEnter;
public bool sort = true;
public EnterHistoryWindow()
{
InitializeComponent();
using var context = new User2Context();
dataLastEnter = context.LastEnters.Select(it => new LastEnter
{
EmployeId = it.EmployeId,
EnterDatetime = it.EnterDatetime,
EnterType = it.EnterType,
Login = it.Login
}).ToList();
foreach (var newlastEnter in dataLastEnter)
{
lastEnter.Add(newlastEnter);
}
lastEnters.ItemsSource = lastEnter;
LoginComboBox.ItemsSource = dataLastEnter.Select(it => it.Login);
SortLogin();
}
private void SortLogin()
{
var temp = dataLastEnter;
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 userlogin in temp)
{
lastEnter.Add(userlogin);
}
}
private void LoginComboBox_OnSelectionChanged(object? sender, SelectionChangedEventArgs e)
{
sort=!sort;
SortLogin();
}
private void Button_Asc(object? sender, RoutedEventArgs e)
{
var sortedList = dataLastEnter.OrderBy(it => it.EnterDatetime).ToList();
lastEnter.Clear();
foreach (var item in sortedList)
{
lastEnter.Add(item);
}
}
private void Button_Desc(object? sender, RoutedEventArgs e)
{
var sortedList = dataLastEnter.OrderByDescending(it => it.EnterDatetime).ToList();
lastEnter.Clear();
foreach (var descList in sortedList)
{
lastEnter.Add(descList);
}
}
}

28
FunctionWindow.axaml Normal file
View File

@ -0,0 +1,28 @@
<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="demo_hard.FunctionWindow"
x:CompileBindings="False"
Title="FunctionWindow">
<DockPanel>
<StackPanel DockPanel.Dock="Top" HorizontalAlignment="Center" Orientation="Horizontal" >
<StackPanel>
<Image Source="{Binding Image}" Width="100" Height="100" Margin="5" HorizontalAlignment="Center"/>
</StackPanel>
<StackPanel>
<TextBlock x:Name="Fio">
<Run Text="ФИО:"/>
<Run Text="{Binding Fio}"/>
</TextBlock>
<TextBlock>
<Run Text="Роль:"/>
<Run Text="{Binding RoleId}"/>
</TextBlock>
</StackPanel>
<Button Content="Назад" Click="Back_Button"/>
<Button Content="Далее" Click="Next_Function_Button"/>
</StackPanel>
</DockPanel>
</Window>

66
FunctionWindow.axaml.cs Normal file
View File

@ -0,0 +1,66 @@
using System;
using System.IO;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Markup.Xaml;
using Avalonia.Media.Imaging;
using demo_hard.Models;
namespace demo_hard;
public partial class FunctionWindow : Window
{
public FunctionWindow(Employee user)
{
InitializeComponent();
DataContext = new ImageEmployee()
{
EmployeId = user.EmployeId,
Fio = user.Fio,
EmployeLogin = user.EmployeLogin,
EmployePassword = user.EmployePassword,
RoleId = user.RoleId,
EmployePhoto = user.EmployePhoto
};
}
public FunctionWindow()
{
InitializeComponent();
}
private void Back_Button(object? sender, RoutedEventArgs e)
{
new MainWindow().ShowDialog(this);
}
private void Next_Function_Button(object? sender, RoutedEventArgs e)
{
new SallerWindow().ShowDialog(this);
}
public class ImageEmployee: Employee
{
Bitmap? Image
{
get
{
try
{
string absolutePath = Path.Combine(AppContext.BaseDirectory, EmployePhoto);
return new Bitmap(absolutePath);
}
catch(Exception e)
{
Console.WriteLine(e.Message);
return null;
}
}
}
}
}

24
MainWindow.axaml Normal file
View File

@ -0,0 +1,24 @@
<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="demo_hard.MainWindow"
x:CompileBindings="True"
Title="demo_hard">
<DockPanel>
<StackPanel HorizontalAlignment="Center" Orientation="Horizontal" DockPanel.Dock="Top">
<TextBlock Text="Точки проката горнолыжного комплекса «Благодать»"/>
</StackPanel>
<StackPanel Orientation="Vertical" VerticalAlignment="Center" Margin="5">
<TextBlock Text="Введите логин" HorizontalAlignment="Center" Margin="5"/>
<TextBox x:Name="LoginBox" Margin="5" Width="200"/>
<TextBlock Text="Введите пароль" HorizontalAlignment="Center" Margin="5"/>
<TextBox x:Name="PasswordBox" Margin="5" Width="200" PasswordChar="*"/>
<TextBlock x:Name="WrongData" Text="" HorizontalAlignment="Center"/>
<Button x:Name="ForPassword" Content="Показать пароль" Margin="5" Click="TogglePasswordVisibility" HorizontalAlignment="Center"/>
<Button x:Name="Authorize" Content="Авторизироваться" Margin="5" Click="AuthorizeButton" HorizontalAlignment="Center"/>
</StackPanel>
</DockPanel>
</Window>

43
MainWindow.axaml.cs Normal file
View File

@ -0,0 +1,43 @@
using System;
using System.Linq;
using Avalonia.Controls;
using Avalonia.Interactivity;
using demo_hard.Models;
//using demo_hard.Models;
using Tmds.DBus.Protocol;
namespace demo_hard;
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void TogglePasswordVisibility(object? sender, RoutedEventArgs e)
{
PasswordBox.PasswordChar = PasswordBox.PasswordChar == '*' ? '\0' : '*';
}
private void AuthorizeButton(object? sender, RoutedEventArgs e)
{
using var context = new User2Context();
var user = context.Employees.FirstOrDefault(it => it.EmployeLogin == LoginBox.Text && it.EmployePassword == PasswordBox.Text);
if (user != null)
{
var functionWindow = new FunctionWindow(user);
{
DataContext = user;
};
functionWindow.ShowDialog(this);
}
else
{
WrongData.Text = "Неверный логин или пароль";
}
}
}

25
Models/Client.cs Normal file
View File

@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
namespace demo_hard.Models;
public partial class Client
{
public int Id { get; set; }
public string Fio { get; set; } = null!;
public int ClientCode { get; set; }
public string Passport { get; set; } = null!;
public DateOnly Birthday { get; set; }
public string Address { get; set; } = null!;
public string Email { get; set; } = null!;
public string Password { get; set; } = null!;
public int RoleId { get; set; }
}

19
Models/Employee.cs Normal file
View File

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
namespace demo_hard.Models;
public partial class Employee
{
public int EmployeId { get; set; }
public int RoleId { get; set; }
public string Fio { get; set; } = null!;
public string EmployeLogin { get; set; } = null!;
public string EmployePassword { get; set; } = null!;
public string? EmployePhoto { get; set; }
}

15
Models/LastEnter.cs Normal file
View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
namespace demo_hard.Models;
public partial class LastEnter
{
public int EmployeId { get; set; }
public DateTime EnterDatetime { get; set; }
public string EnterType { get; set; } = null!;
public string? Login { get; set; }
}

25
Models/Order.cs Normal file
View File

@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
namespace demo_hard.Models;
public partial class Order
{
public int Id { get; set; }
public string OrderCode { get; set; } = null!;
public DateOnly OrderDate { get; set; }
public TimeOnly OrderTime { get; set; }
public int ClientCode { get; set; }
public int ServiceId { get; set; }
public string Status { get; set; } = null!;
public DateOnly? DateClose { get; set; }
public int RentalTime { get; set; }
}

11
Models/Role.cs Normal file
View File

@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
namespace demo_hard.Models;
public partial class Role
{
public int RoleId { get; set; }
public string RoleName { get; set; } = null!;
}

15
Models/Service.cs Normal file
View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
namespace demo_hard.Models;
public partial class Service
{
public int Id { get; set; }
public string ServiceName { get; set; } = null!;
public string ServiceCode { get; set; } = null!;
public string ServiceCost { get; set; } = null!;
}

166
Models/User2Context.cs Normal file
View File

@ -0,0 +1,166 @@
using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;
namespace demo_hard.Models;
public partial class User2Context : DbContext
{
public User2Context()
{
}
public User2Context(DbContextOptions<User2Context> options)
: base(options)
{
}
public virtual DbSet<Client> Clients { get; set; }
public virtual DbSet<Employee> Employees { get; set; }
public virtual DbSet<LastEnter> LastEnters { get; set; }
public virtual DbSet<Order> Orders { get; set; }
public virtual DbSet<Role> Roles { get; set; }
public virtual DbSet<Service> Services { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
#warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see https://go.microsoft.com/fwlink/?LinkId=723263.
=> optionsBuilder.UseNpgsql("Host=45.67.56.214;Port=5454;USERNAME=user2;DATABASE=user2;Password=hGcLvi0i");
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Client>(entity =>
{
entity.HasKey(e => e.Id).HasName("clients_pk");
entity.ToTable("clients");
entity.Property(e => e.Id).HasColumnName("id");
entity.Property(e => e.Address)
.HasColumnType("character varying")
.HasColumnName("address");
entity.Property(e => e.Birthday).HasColumnName("birthday");
entity.Property(e => e.ClientCode).HasColumnName("client_code");
entity.Property(e => e.Email)
.HasColumnType("character varying")
.HasColumnName("email");
entity.Property(e => e.Fio)
.HasColumnType("character varying")
.HasColumnName("fio");
entity.Property(e => e.Passport)
.HasColumnType("character varying")
.HasColumnName("passport");
entity.Property(e => e.Password)
.HasColumnType("character varying")
.HasColumnName("password");
entity.Property(e => e.RoleId).HasColumnName("role_id");
});
modelBuilder.Entity<Employee>(entity =>
{
entity.HasKey(e => e.EmployeId).HasName("employees_pk");
entity.ToTable("employees");
entity.Property(e => e.EmployeId)
.ValueGeneratedNever()
.HasColumnName("employe_id");
entity.Property(e => e.EmployeLogin)
.HasColumnType("character varying")
.HasColumnName("employe_login");
entity.Property(e => e.EmployePassword)
.HasColumnType("character varying")
.HasColumnName("employe_password");
entity.Property(e => e.EmployePhoto)
.HasColumnType("character varying")
.HasColumnName("employe_photo");
entity.Property(e => e.Fio)
.HasColumnType("character varying")
.HasColumnName("fio");
entity.Property(e => e.RoleId).HasColumnName("role_id");
});
modelBuilder.Entity<LastEnter>(entity =>
{
entity.HasKey(e => e.EmployeId).HasName("last_enter_pk");
entity.ToTable("last_enter");
entity.Property(e => e.EmployeId)
.ValueGeneratedNever()
.HasColumnName("employe_id");
entity.Property(e => e.EnterDatetime)
.HasColumnType("timestamp without time zone")
.HasColumnName("enter_datetime");
entity.Property(e => e.EnterType)
.HasColumnType("character varying")
.HasColumnName("enter_type");
entity.Property(e => e.Login)
.HasColumnType("character varying")
.HasColumnName("login");
});
modelBuilder.Entity<Order>(entity =>
{
entity.HasKey(e => e.Id).HasName("orders_pk");
entity.ToTable("orders");
entity.Property(e => e.Id).HasColumnName("id");
entity.Property(e => e.ClientCode).HasColumnName("client_code");
entity.Property(e => e.DateClose).HasColumnName("date_close");
entity.Property(e => e.OrderCode)
.HasColumnType("character varying")
.HasColumnName("order_code");
entity.Property(e => e.OrderDate).HasColumnName("order_date");
entity.Property(e => e.OrderTime).HasColumnName("order_time");
entity.Property(e => e.RentalTime).HasColumnName("rental_time");
entity.Property(e => e.ServiceId).HasColumnName("service_id");
entity.Property(e => e.Status)
.HasColumnType("character varying")
.HasColumnName("status");
});
modelBuilder.Entity<Role>(entity =>
{
entity.HasKey(e => e.RoleId).HasName("roles_pk");
entity.ToTable("roles");
entity.Property(e => e.RoleId).HasColumnName("role_id");
entity.Property(e => e.RoleName)
.HasColumnType("character varying")
.HasColumnName("role_name");
});
modelBuilder.Entity<Service>(entity =>
{
entity.HasKey(e => e.Id).HasName("service_pk");
entity.ToTable("service");
entity.HasIndex(e => e.ServiceCode, "service_unique").IsUnique();
entity.Property(e => e.Id)
.ValueGeneratedNever()
.HasColumnName("id");
entity.Property(e => e.ServiceCode)
.HasColumnType("character varying")
.HasColumnName("service_code");
entity.Property(e => e.ServiceCost)
.HasColumnType("character varying")
.HasColumnName("service_cost");
entity.Property(e => e.ServiceName)
.HasColumnType("character varying")
.HasColumnName("service_name");
});
OnModelCreatingPartial(modelBuilder);
}
partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
}

21
Program.cs Normal file
View File

@ -0,0 +1,21 @@
using Avalonia;
using System;
namespace demo_hard;
class Program
{
// Initialization code. Don't use any Avalonia, third-party APIs or any
// SynchronizationContext-reliant code before AppMain is called: things aren't initialized
// yet and stuff might break.
[STAThread]
public static void Main(string[] args) => BuildAvaloniaApp()
.StartWithClassicDesktopLifetime(args);
// Avalonia configuration, don't remove; also used by visual designer.
public static AppBuilder BuildAvaloniaApp()
=> AppBuilder.Configure<App>()
.UsePlatformDetect()
.WithInterFont()
.LogToTrace();
}

19
SallerWindow.axaml Normal file
View File

@ -0,0 +1,19 @@
<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="demo_hard.SallerWindow"
Title="SallerWindow">
<DockPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" DockPanel.Dock="Top">
<TextBlock Text="Добро пожаловать в окно создания заказа"/>
</StackPanel>
<StackPanel>
<Button Content="История входа" x:Name="EnterHistory" Click="EnterHistory_OnClick"></Button>
<TextBlock Text="Номер заказа"/>
<TextBlock Text="Сделать штрих кода нада"/>
<Image x:Name="Barcode" Width="300" Height="100"></Image>
</StackPanel>
</DockPanel>
</Window>

26
SallerWindow.axaml.cs Normal file
View File

@ -0,0 +1,26 @@
using System.IO;
using System.Threading.Tasks;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Markup.Xaml;
using Avalonia.Svg.Skia;
using Npgsql;
using ZXing;
using ZXing.Rendering;
namespace demo_hard;
public partial class SallerWindow : Window
{
public SallerWindow()
{
InitializeComponent();
}
private void EnterHistory_OnClick(object? sender, RoutedEventArgs e)
{
var lastEnter = new EnterHistoryWindow();
lastEnter.ShowDialog(this);
}
}

18
app.manifest Normal file
View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<!-- This manifest is used on Windows only.
Don't remove it as it might cause problems with window transparency and embedded controls.
For more details visit https://learn.microsoft.com/en-us/windows/win32/sbscs/application-manifests -->
<assemblyIdentity version="1.0.0.0" name="demo_hard.Desktop"/>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- A list of the Windows versions that this application has been tested on
and is designed to work with. Uncomment the appropriate elements
and Windows will automatically select the most compatible environment. -->
<!-- Windows 10 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
</application>
</compatibility>
</assembly>

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.

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.

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.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

BIN
bin/Debug/net8.0/ExCSS.dll Normal file

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.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
bin/Debug/net8.0/Npgsql.dll Normal file

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.

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.

Some files were not shown because too many files have changed in this diff Show More