This commit is contained in:
Userok 2024-12-27 16:07:13 +03:00
parent 42f723d759
commit 9ad2073e09
3 changed files with 41 additions and 26 deletions

View File

@ -1,7 +1,7 @@
<Window xmlns="https://github.com/avaloniaui" <Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="Demka_2.Views.MainWindow" x:Class="Demka_2.Views.MainWindow"
Width="800" Height="600" Width="1200" Height="800"
Title="Список услуг"> Title="Список услуг">
<DockPanel> <DockPanel>
<StackPanel Orientation="Horizontal" DockPanel.Dock="Top" Margin="5"> <StackPanel Orientation="Horizontal" DockPanel.Dock="Top" Margin="5">
@ -28,10 +28,10 @@
<Button Content="Добавить услугу" Name="AddServiceButton" Margin="5" /> <Button Content="Добавить услугу" Name="AddServiceButton" Margin="5" />
<Button Content="Редактировать услугу" Name="EditServiceButton" Margin="5" /> <Button Content="Редактировать услугу" Name="EditServiceButton" Margin="5" />
<Button Content="Удалить услугу" Name="DeleteServiceButton" Margin="5" /> <Button Content="Удалить услугу" Name="DeleteServiceButton" Margin="5" />
<!-- <Button Content="Открыть форму для добавления товаров" Name="OpenServiceFormWindow" Click="OpenServiceFormWindow_Click" Margin="5" />--> <!-- <Button Content="Открыть форму для добавления товаров" Name="OpenServiceFormWindow" Click="OpenServiceFormWindow_Click" Margin="5" /> -->
</StackPanel> </StackPanel>
<ListBox Name="ServiceList" Margin="5"> <ListBox Name="ServiceList" Margin="5" Width="600">
<ListBox.ItemTemplate> <ListBox.ItemTemplate>
<DataTemplate> <DataTemplate>
<StackPanel Orientation="Vertical" Background="{Binding BackgroundColor}" Margin="5"> <StackPanel Orientation="Vertical" Background="{Binding BackgroundColor}" Margin="5">
@ -46,7 +46,6 @@
</DataTemplate> </DataTemplate>
</ListBox.ItemTemplate> </ListBox.ItemTemplate>
</ListBox> </ListBox>
<TextBlock Name="ServiceCountText" DockPanel.Dock="Bottom" Margin="50" HorizontalAlignment="Center" />
<TextBlock Name="ServiceCountText" DockPanel.Dock="Left" Margin="5" HorizontalAlignment="Center" />
</DockPanel> </DockPanel>
</Window> </Window>

View File

@ -145,7 +145,26 @@ public partial class MainWindow : Window
UpdateFilteredServices(); UpdateFilteredServices();
} }
public async void ShowMessage(string message)
{
var messageBox = new Window
{
Title = "Сообщение",
Content = message,
Width = 300,
Height = 150,
WindowStartupLocation = WindowStartupLocation.CenterScreen
};
var okButton = new Button { Content = "ОК" };
okButton.Click += (s, e) => messageBox.Close();
messageBox.Content = new StackPanel
{
Children = { new TextBlock { Text = message }, okButton }
};
await messageBox.ShowDialog(this);
}
private (decimal min, decimal max)? ParseDiscountRange(string rangeText) private (decimal min, decimal max)? ParseDiscountRange(string rangeText)
{ {

View File

@ -24,27 +24,24 @@ namespace Demka_2.Views
SaveButton.Click += SaveButton_Click; SaveButton.Click += SaveButton_Click;
SelectImageButton.Click += SelectImageButton_Click; SelectImageButton.Click += SelectImageButton_Click;
//AddServiceButton.Click += (s, e) =>
//{
// var serviceForm = new ServiceFormWindow(new Service(), Services);
// serviceForm.ShowDialog(this).ContinueWith(_ => UpdateFilteredServices());
//};
/* //EditServiceButton.Click += (s, e) =>
* AddServiceButton.Click += (s, e) => //{
{ // if (_serviceList.SelectedItem is Service selectedService)
var serviceForm = new ServiceFormWindow(new Service(), Services); // {
serviceForm.ShowDialog(this).ContinueWith(_ => UpdateFilteredServices()); // var serviceForm = new ServiceFormWindow(selectedService, Services);
}; // serviceForm.ShowDialog(this).ContinueWith(_ => UpdateFilteredServices());
// }
EditServiceButton.Click += (s, e) => // else
{ // {
if (_serviceList.SelectedItem is Service selectedService) // ShowMessage("Выберите услугу для редактирования.");
{ // }
var serviceForm = new ServiceFormWindow(selectedService, Services); //};
serviceForm.ShowDialog(this).ContinueWith(_ => UpdateFilteredServices());
}
else
{
MessageBox.Show("Выберите услугу для редактирования.");
}
};
*/
} }
private void LoadServiceData() private void LoadServiceData()
@ -59,7 +56,7 @@ namespace Demka_2.Views
ThumbnailImage.Source = new Bitmap(_service.ImagePath); ThumbnailImage.Source = new Bitmap(_service.ImagePath);
} }
} }
private async void ShowMessage(string message) public async void ShowMessage(string message)
{ {
var messageBox = new Window var messageBox = new Window
{ {