Я устал, босс… Устал быть в дороге, одинокий, как воробей под дождём…

master
Святой Владислав Солоп 2026-06-15 22:15:01 +10:00
parent 81727a9173
commit 0efb72816d
21 changed files with 229 additions and 9 deletions

View File

@ -5,8 +5,10 @@
<map>
<entry key="App.axaml" value="BathHouseManagmet.csproj" />
<entry key="ViewModels/EmployeeViewModel.axaml" value="BathHouseManagmet.csproj" />
<entry key="Views/AddWindows/AddClientWindow.axaml" value="BathHouseManagmet.csproj" />
<entry key="Views/AddWindows/AddEmployeeWindow.axaml" value="BathHouseManagmet.csproj" />
<entry key="Views/AddWindows/AddPositionWindow.axaml" value="BathHouseManagmet.csproj" />
<entry key="Views/AddWindows/AddServiceWindow.axaml" value="BathHouseManagmet.csproj" />
<entry key="Views/AddWindows/AddZoneWindow.axaml" value="BathHouseManagmet.csproj" />
<entry key="Views/EmployeeView.axaml" value="BathHouseManagmet.csproj" />
<entry key="Views/MainWindow.axaml" value="BathHouseManagmet.csproj" />

View File

@ -5,4 +5,5 @@ public class Client
public int Id { get; set; }
public string Name { get; set; }
public string Surname { get; set; }
public string Email { get; set; }
}

View File

@ -37,6 +37,7 @@ public class ClientRepository : BaseRepository<Client>, IDisposable
Id = reader.GetInt32("id"),
Name = reader.GetString("name"),
Surname = reader.GetString("surname"),
Email = reader.GetString("email")
});
}
}
@ -56,6 +57,7 @@ public class ClientRepository : BaseRepository<Client>, IDisposable
{
command.Parameters.AddWithValue("@name", client.Name);
command.Parameters.AddWithValue("@surname", client.Surname);
command.Parameters.AddWithValue("@email", client.Email);
command.ExecuteNonQuery();
}
}
@ -76,6 +78,7 @@ public class ClientRepository : BaseRepository<Client>, IDisposable
{
command.Parameters.AddWithValue("@name", client.Name);
command.Parameters.AddWithValue("@surname", client.Surname);
command.Parameters.AddWithValue("@email", client.Email);
command.ExecuteNonQuery();
}
}

View File

@ -44,6 +44,10 @@ sealed class Program
s.AddTransient<AddPositionWindow>();
s.AddTransient<AddZoneWindowViewModel>();
s.AddTransient<AddZoneWindow>();
s.AddTransient<AddClientWindowViewModel>();
s.AddTransient<AddClientWindow>();
s.AddTransient<AddServiceWindowViewModel>();
s.AddTransient<AddServiceWindow>();
s.AddTransient<Employee>();

View File

@ -0,0 +1,51 @@
using System;
using System.Collections.Generic;
using BathHouseManagmet.Database;
using BathHouseManagmet.Models;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using Microsoft.Extensions.DependencyInjection;
namespace BathHouseManagmet.ViewModels;
public partial class AddClientWindowViewModel : ViewModelBase
{
private readonly IServiceProvider _serviceProvider;
[ObservableProperty] List<Client> _clients;
[ObservableProperty] string _clientName;
[ObservableProperty] string _clientSurname;
[ObservableProperty] string _clientEmail;
public AddClientWindowViewModel(IServiceProvider serviceProvider)
{
_serviceProvider = serviceProvider;
}
[RelayCommand]
public void AddClient()
{
var client = new Client
{
Name = _clientName,
Surname = _clientSurname,
Email = _clientEmail
};
using (var rep = _serviceProvider.GetRequiredService<ClientRepository>())
rep.Add(client);
CloseWindow();
}
[RelayCommand]
public void CloseWindow()
{
close();
}
private Action close;
public void SetClose(Action close)
{
this.close = close;
}
}

View File

@ -26,13 +26,13 @@ public partial class AddPositionWindowViewModel : ViewModelBase
[RelayCommand]
public void AddPosition()
{
var pos = new Position()
var position = new Position()
{
Name = PositionName
};
using (var rep = _serviceProvider.GetRequiredService<PositionRepository>())
rep.Add(pos);
rep.Add(position);
CloseWindow();
}

View File

@ -0,0 +1,50 @@
using System;
using System.Collections.Generic;
using BathHouseManagmet.Database;
using BathHouseManagmet.Models;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using Microsoft.Extensions.DependencyInjection;
namespace BathHouseManagmet.ViewModels;
public partial class AddServiceWindowViewModel : ViewModelBase
{
private readonly IServiceProvider _serviceProvider;
[ObservableProperty] List<Service> _services;
[ObservableProperty] string _serviceName;
[ObservableProperty] string _serviceDescription;
[ObservableProperty] int _servicePrice;
public AddServiceWindowViewModel(IServiceProvider serviceProvider)
{
_serviceProvider = serviceProvider;
}
[RelayCommand]
public void AddService()
{
var service = new Service
{
Name = _serviceName,
Description = _serviceDescription,
Price = _servicePrice
};
using (var rep = _serviceProvider.GetRequiredService<ServiceRepository>())
rep.Add(service);
CloseWindow();
}
[RelayCommand]
public void CloseWindow()
{
close();
}
private Action close;
public void SetClose(Action close)
{
this.close = close;
}
}

View File

@ -20,6 +20,7 @@ public partial class MainWindowViewModel : ViewModelBase
[ObservableProperty] ZoneViewModel _zoneViewModel;
[ObservableProperty] DiscountViewModel _discountViewModel;
[ObservableProperty] PositionViewModel _positionViewModel;
[ObservableProperty] ClientViewModel _clientViewModel;
public MainWindowViewModel(IServiceProvider serviceProvider)
{
@ -31,6 +32,7 @@ public partial class MainWindowViewModel : ViewModelBase
ZoneViewModel = _serviceProvider.GetRequiredService<ZoneViewModel>();
DiscountViewModel = _serviceProvider.GetRequiredService<DiscountViewModel>();
PositionViewModel = _serviceProvider.GetRequiredService<PositionViewModel>();
ClientViewModel = _serviceProvider.GetRequiredService<ClientViewModel>();
}
[RelayCommand]
@ -62,4 +64,24 @@ public partial class MainWindowViewModel : ViewModelBase
win.Show();
vm.SetClose(win.Close);
}
[RelayCommand]
public void AddClient()
{
var vm = ActivatorUtilities.CreateInstance<AddClientWindowViewModel>(_serviceProvider);
var win = _serviceProvider.GetService<AddClientWindow>();
win.DataContext = vm;
win.Show();
vm.SetClose(win.Close);
}
[RelayCommand]
public void AddService()
{
var vm = ActivatorUtilities.CreateInstance<AddServiceWindowViewModel>(_serviceProvider);
var win = _serviceProvider.GetService<AddServiceWindow>();
win.DataContext = vm;
win.Show();
vm.SetClose(win.Close);
}
}

View File

@ -0,0 +1,23 @@
<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"
xmlns:viewModels="clr-namespace:BathHouseManagmet.ViewModels"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="BathHouseManagmet.Views.AddWindows.AddClientWindow"
Title="AddClientWindow"
x:DataType="viewModels:AddClientWindowViewModel">
<StackPanel>
<TextBlock Text="Введите имя:"/>
<TextBox Text="{Binding ClientName}"/>
<TextBlock Text="Введите фамилию:"/>
<TextBox Text="{Binding ClientSurname}"/>
<TextBlock Text="Введите электронную почту"/>
<TextBox Text="{Binding ClientEmail}"/>
<Button Content="Сохранить" Command="{Binding AddClientCommand}"/>
<Button Content="Отменить" Command="{Binding CloseWindowCommand}"/>
</StackPanel>
</Window>

View File

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

View File

@ -7,6 +7,7 @@
x:Class="BathHouseManagmet.Views.AddWindows.AddPositionWindow"
Title="AddPositionWindow"
x:DataType="viewModels:AddPositionWindowViewModel">
<StackPanel>
<TextBlock Text="Введите название должности: "/>
<TextBox Text="{Binding PositionName}" />
@ -14,4 +15,5 @@
<Button Content="Сохранить" Command="{Binding AddPositionCommand}"/>
<Button Content="Отменить" Command="{Binding CloseWindowCommand}"/>
</StackPanel>
</Window>

View File

@ -0,0 +1,23 @@
<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"
xmlns:viewModels="clr-namespace:BathHouseManagmet.ViewModels"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="BathHouseManagmet.Views.AddWindows.AddServiceWindow"
Title="AddServiceWindow"
x:DataType="viewModels:AddServiceWindowViewModel">
<StackPanel>
<TextBlock Text="Введите название услуги:"/>
<TextBox Text="{Binding ServiceName}"/>
<TextBlock Text="Введите описание услуги:"/>
<TextBox Text="{Binding ServiceDescription}"/>
<TextBlock Text="Введите цену:"/>
<TextBox Text="{Binding ServicePrice}"/>
<Button Content="Сохранить" Command="{Binding AddServiceCommand}"/>
<Button Content="Отменить" Command="{Binding CloseWindowCommand}"/>
</StackPanel>
</Window>

View File

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

View File

@ -7,6 +7,7 @@
x:Class="BathHouseManagmet.Views.AddWindows.AddZoneWindow"
Title="AddZoneWindow"
x:DataType="viewModels:AddZoneWindowViewModel">
<StackPanel>
<TextBlock Text="Введите название зоны: "/>
<TextBox Text="{Binding ZoneName}" />
@ -14,4 +15,5 @@
<Button Content="Сохранить" Command="{Binding AddZoneCommand}"/>
<Button Content="Отменить" Command="{Binding CloseWindowCommand}"/>
</StackPanel>
</Window>

View File

@ -10,7 +10,7 @@
<DataGrid.Columns>
<DataGridTextColumn Header="Имя" Binding="{Binding Name}"/>
<DataGridTextColumn Header="Фамилия" Binding="{Binding Surname}"/>
<DataGridTextColumn Header="Имя" Binding="{Binding Name}"/>
<DataGridTextColumn Header="Почта" Binding="{Binding Email}"/>
</DataGrid.Columns>
</DataGrid>
</UserControl>

View File

@ -30,13 +30,18 @@
<TabItem Header="Должности">
<ContentControl Content="{Binding PositionViewModel}"/>
</TabItem>
<TabItem Header="Клиенты">
<ContentControl Content="{Binding ClientViewModel}"/>
</TabItem>
</TabControl>
</TabItem>
<TabItem Header="Управление">
<TabControl>
<StackPanel>
<Button Content="Добавить должность" Command="{Binding AddPositionCommand}"/>
<Button Content="Добавить зону" Command="{Binding AddZoneCommand}"/>
</TabControl>
<Button Content="Добавить клиента" Command="{Binding AddClientCommand}"/>
<Button Content="Добавить услугу" Command="{Binding AddServiceCommand}"/>
</StackPanel>
</TabItem>
</TabControl>
</StackPanel>

View File

@ -1 +1 @@
5701949aed34672487a5b52a8c51ddb1de93b4a55d04b32b2b14aecc57c0ed85
120d4d31802a89a43a63761c89855710318e5744be4d2245fa83c25618972223

Binary file not shown.

View File

@ -13,10 +13,10 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("BathHouseManagmet")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+66a011e33c6d54c0616e63d203956099fda9c81f")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+81727a9173bad0eb629f1dacad49c41afc58fa61")]
[assembly: System.Reflection.AssemblyProductAttribute("BathHouseManagmet")]
[assembly: System.Reflection.AssemblyTitleAttribute("BathHouseManagmet")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
// Создано классом WriteCodeFragment MSBuild.
// Generated by the MSBuild WriteCodeFragment class.

View File

@ -1 +1 @@
61d476c04075d17df2e69c8326844fd9f8d84c937081e16ee061dd14bf9444bc
b6dda2c085853849dab802a59b20655a846dac333cfb3e8bb9ebd6b9e633feed

View File

@ -27,12 +27,18 @@ build_property.EnableCodeStyleSeverity =
[C:/Users/august/RiderProjects/BathHouseManagmet/App.axaml]
build_metadata.AdditionalFiles.SourceItemGroup = AvaloniaXaml
[C:/Users/august/RiderProjects/BathHouseManagmet/Views/AddWindows/AddClientWindow.axaml]
build_metadata.AdditionalFiles.SourceItemGroup = AvaloniaXaml
[C:/Users/august/RiderProjects/BathHouseManagmet/Views/AddWindows/AddEmployeeWindow.axaml]
build_metadata.AdditionalFiles.SourceItemGroup = AvaloniaXaml
[C:/Users/august/RiderProjects/BathHouseManagmet/Views/AddWindows/AddPositionWindow.axaml]
build_metadata.AdditionalFiles.SourceItemGroup = AvaloniaXaml
[C:/Users/august/RiderProjects/BathHouseManagmet/Views/AddWindows/AddServiceWindow.axaml]
build_metadata.AdditionalFiles.SourceItemGroup = AvaloniaXaml
[C:/Users/august/RiderProjects/BathHouseManagmet/Views/AddWindows/AddZoneWindow.axaml]
build_metadata.AdditionalFiles.SourceItemGroup = AvaloniaXaml