feat: disable buttons for user

This commit is contained in:
Иван Овсянников 2024-09-09 14:45:33 +03:00
parent 637276e6f1
commit be4fb3891e
42 changed files with 217 additions and 84 deletions

Binary file not shown.

Binary file not shown.

View File

@ -7,40 +7,40 @@
"RelativeMoniker": "D:0:0:{4C331754-91EE-4598-950D-54DF0C075B84}|DemoService.csproj|solutionrelative:servicewindow.axaml.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}" "RelativeMoniker": "D:0:0:{4C331754-91EE-4598-950D-54DF0C075B84}|DemoService.csproj|solutionrelative:servicewindow.axaml.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
}, },
{ {
"AbsoluteMoniker": "D:0:0:{4C331754-91EE-4598-950D-54DF0C075B84}|DemoService.csproj|c:\\users\\class_student\\desktop\\xofei\\demoservice\\servicewindow.axaml||{6D5344A2-2FCD-49DE-A09D-6A14FD1B1224}", "AbsoluteMoniker": "D:0:0:{4C331754-91EE-4598-950D-54DF0C075B84}|DemoService.csproj|c:\\users\\class_student\\desktop\\xofei\\demoservice\\addeditwindow.axaml||{6D5344A2-2FCD-49DE-A09D-6A14FD1B1224}",
"RelativeMoniker": "D:0:0:{4C331754-91EE-4598-950D-54DF0C075B84}|DemoService.csproj|solutionrelative:servicewindow.axaml||{6D5344A2-2FCD-49DE-A09D-6A14FD1B1224}" "RelativeMoniker": "D:0:0:{4C331754-91EE-4598-950D-54DF0C075B84}|DemoService.csproj|solutionrelative:addeditwindow.axaml||{6D5344A2-2FCD-49DE-A09D-6A14FD1B1224}"
}, },
{ {
"AbsoluteMoniker": "D:0:0:{4C331754-91EE-4598-950D-54DF0C075B84}|DemoService.csproj|c:\\users\\class_student\\desktop\\xofei\\demoservice\\mainwindow.axaml.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}", "AbsoluteMoniker": "D:0:0:{4C331754-91EE-4598-950D-54DF0C075B84}|DemoService.csproj|c:\\users\\class_student\\desktop\\xofei\\demoservice\\servicewindow.axaml||{6D5344A2-2FCD-49DE-A09D-6A14FD1B1224}",
"RelativeMoniker": "D:0:0:{4C331754-91EE-4598-950D-54DF0C075B84}|DemoService.csproj|solutionrelative:mainwindow.axaml.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}" "RelativeMoniker": "D:0:0:{4C331754-91EE-4598-950D-54DF0C075B84}|DemoService.csproj|solutionrelative:servicewindow.axaml||{6D5344A2-2FCD-49DE-A09D-6A14FD1B1224}"
}, },
{ {
"AbsoluteMoniker": "D:0:0:{4C331754-91EE-4598-950D-54DF0C075B84}|DemoService.csproj|c:\\users\\class_student\\desktop\\xofei\\demoservice\\models\\service.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}", "AbsoluteMoniker": "D:0:0:{4C331754-91EE-4598-950D-54DF0C075B84}|DemoService.csproj|c:\\users\\class_student\\desktop\\xofei\\demoservice\\models\\service.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{4C331754-91EE-4598-950D-54DF0C075B84}|DemoService.csproj|solutionrelative:models\\service.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}" "RelativeMoniker": "D:0:0:{4C331754-91EE-4598-950D-54DF0C075B84}|DemoService.csproj|solutionrelative:models\\service.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
}, },
{ {
"AbsoluteMoniker": "D:0:0:{4C331754-91EE-4598-950D-54DF0C075B84}|DemoService.csproj|c:\\users\\class_student\\desktop\\xofei\\demoservice\\utils\\context.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}", "AbsoluteMoniker": "D:0:0:{4C331754-91EE-4598-950D-54DF0C075B84}|DemoService.csproj|c:\\users\\class_student\\desktop\\xofei\\demoservice\\mainwindow.axaml.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{4C331754-91EE-4598-950D-54DF0C075B84}|DemoService.csproj|solutionrelative:utils\\context.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}" "RelativeMoniker": "D:0:0:{4C331754-91EE-4598-950D-54DF0C075B84}|DemoService.csproj|solutionrelative:mainwindow.axaml.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
"AbsoluteMoniker": "D:0:0:{4C331754-91EE-4598-950D-54DF0C075B84}|DemoService.csproj|c:\\users\\class_student\\desktop\\xofei\\demoservice\\mainwindow.axaml||{6D5344A2-2FCD-49DE-A09D-6A14FD1B1224}",
"RelativeMoniker": "D:0:0:{4C331754-91EE-4598-950D-54DF0C075B84}|DemoService.csproj|solutionrelative:mainwindow.axaml||{6D5344A2-2FCD-49DE-A09D-6A14FD1B1224}"
}, },
{ {
"AbsoluteMoniker": "D:0:0:{4C331754-91EE-4598-950D-54DF0C075B84}|DemoService.csproj|c:\\users\\class_student\\desktop\\xofei\\demoservice\\colors.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}", "AbsoluteMoniker": "D:0:0:{4C331754-91EE-4598-950D-54DF0C075B84}|DemoService.csproj|c:\\users\\class_student\\desktop\\xofei\\demoservice\\colors.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{4C331754-91EE-4598-950D-54DF0C075B84}|DemoService.csproj|solutionrelative:colors.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}" "RelativeMoniker": "D:0:0:{4C331754-91EE-4598-950D-54DF0C075B84}|DemoService.csproj|solutionrelative:colors.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
}, },
{
"AbsoluteMoniker": "D:0:0:{4C331754-91EE-4598-950D-54DF0C075B84}|DemoService.csproj|c:\\users\\class_student\\desktop\\xofei\\demoservice\\addeditwindow.axaml.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{4C331754-91EE-4598-950D-54DF0C075B84}|DemoService.csproj|solutionrelative:addeditwindow.axaml.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
"AbsoluteMoniker": "D:0:0:{4C331754-91EE-4598-950D-54DF0C075B84}|DemoService.csproj|c:\\users\\class_student\\desktop\\xofei\\demoservice\\addeditwindow.axaml||{6D5344A2-2FCD-49DE-A09D-6A14FD1B1224}",
"RelativeMoniker": "D:0:0:{4C331754-91EE-4598-950D-54DF0C075B84}|DemoService.csproj|solutionrelative:addeditwindow.axaml||{6D5344A2-2FCD-49DE-A09D-6A14FD1B1224}"
},
{ {
"AbsoluteMoniker": "D:0:0:{4C331754-91EE-4598-950D-54DF0C075B84}|DemoService.csproj|c:\\users\\class_student\\desktop\\xofei\\demoservice\\app.axaml||{6D5344A2-2FCD-49DE-A09D-6A14FD1B1224}", "AbsoluteMoniker": "D:0:0:{4C331754-91EE-4598-950D-54DF0C075B84}|DemoService.csproj|c:\\users\\class_student\\desktop\\xofei\\demoservice\\app.axaml||{6D5344A2-2FCD-49DE-A09D-6A14FD1B1224}",
"RelativeMoniker": "D:0:0:{4C331754-91EE-4598-950D-54DF0C075B84}|DemoService.csproj|solutionrelative:app.axaml||{6D5344A2-2FCD-49DE-A09D-6A14FD1B1224}" "RelativeMoniker": "D:0:0:{4C331754-91EE-4598-950D-54DF0C075B84}|DemoService.csproj|solutionrelative:app.axaml||{6D5344A2-2FCD-49DE-A09D-6A14FD1B1224}"
}, },
{ {
"AbsoluteMoniker": "D:0:0:{4C331754-91EE-4598-950D-54DF0C075B84}|DemoService.csproj|c:\\users\\class_student\\desktop\\xofei\\demoservice\\mainwindow.axaml||{6D5344A2-2FCD-49DE-A09D-6A14FD1B1224}", "AbsoluteMoniker": "D:0:0:{4C331754-91EE-4598-950D-54DF0C075B84}|DemoService.csproj|c:\\users\\class_student\\desktop\\xofei\\demoservice\\addeditwindow.axaml.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{4C331754-91EE-4598-950D-54DF0C075B84}|DemoService.csproj|solutionrelative:mainwindow.axaml||{6D5344A2-2FCD-49DE-A09D-6A14FD1B1224}" "RelativeMoniker": "D:0:0:{4C331754-91EE-4598-950D-54DF0C075B84}|DemoService.csproj|solutionrelative:addeditwindow.axaml.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
"AbsoluteMoniker": "D:0:0:{4C331754-91EE-4598-950D-54DF0C075B84}|DemoService.csproj|c:\\users\\class_student\\desktop\\xofei\\demoservice\\utils\\context.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{4C331754-91EE-4598-950D-54DF0C075B84}|DemoService.csproj|solutionrelative:utils\\context.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
} }
], ],
"DocumentGroupContainers": [ "DocumentGroupContainers": [
@ -54,7 +54,7 @@
"Children": [ "Children": [
{ {
"$type": "Document", "$type": "Document",
"DocumentIndex": 8, "DocumentIndex": 7,
"Title": "App.axaml", "Title": "App.axaml",
"DocumentMoniker": "C:\\Users\\Class_Student\\Desktop\\Xofei\\DemoService\\App.axaml", "DocumentMoniker": "C:\\Users\\Class_Student\\Desktop\\Xofei\\DemoService\\App.axaml",
"RelativeDocumentMoniker": "App.axaml", "RelativeDocumentMoniker": "App.axaml",
@ -66,7 +66,7 @@
}, },
{ {
"$type": "Document", "$type": "Document",
"DocumentIndex": 9, "DocumentIndex": 5,
"Title": "MainWindow.axaml", "Title": "MainWindow.axaml",
"DocumentMoniker": "C:\\Users\\Class_Student\\Desktop\\Xofei\\DemoService\\MainWindow.axaml", "DocumentMoniker": "C:\\Users\\Class_Student\\Desktop\\Xofei\\DemoService\\MainWindow.axaml",
"RelativeDocumentMoniker": "MainWindow.axaml", "RelativeDocumentMoniker": "MainWindow.axaml",
@ -78,7 +78,7 @@
}, },
{ {
"$type": "Document", "$type": "Document",
"DocumentIndex": 2, "DocumentIndex": 4,
"Title": "MainWindow.axaml.cs", "Title": "MainWindow.axaml.cs",
"DocumentMoniker": "C:\\Users\\Class_Student\\Desktop\\Xofei\\DemoService\\MainWindow.axaml.cs", "DocumentMoniker": "C:\\Users\\Class_Student\\Desktop\\Xofei\\DemoService\\MainWindow.axaml.cs",
"RelativeDocumentMoniker": "MainWindow.axaml.cs", "RelativeDocumentMoniker": "MainWindow.axaml.cs",
@ -91,7 +91,7 @@
}, },
{ {
"$type": "Document", "$type": "Document",
"DocumentIndex": 1, "DocumentIndex": 2,
"Title": "ServiceWindow.axaml", "Title": "ServiceWindow.axaml",
"DocumentMoniker": "C:\\Users\\Class_Student\\Desktop\\Xofei\\DemoService\\ServiceWindow.axaml", "DocumentMoniker": "C:\\Users\\Class_Student\\Desktop\\Xofei\\DemoService\\ServiceWindow.axaml",
"RelativeDocumentMoniker": "ServiceWindow.axaml", "RelativeDocumentMoniker": "ServiceWindow.axaml",
@ -109,14 +109,14 @@
"RelativeDocumentMoniker": "ServiceWindow.axaml.cs", "RelativeDocumentMoniker": "ServiceWindow.axaml.cs",
"ToolTip": "C:\\Users\\Class_Student\\Desktop\\Xofei\\DemoService\\ServiceWindow.axaml.cs", "ToolTip": "C:\\Users\\Class_Student\\Desktop\\Xofei\\DemoService\\ServiceWindow.axaml.cs",
"RelativeToolTip": "ServiceWindow.axaml.cs", "RelativeToolTip": "ServiceWindow.axaml.cs",
"ViewState": "AQIAAAAAAAAAAAAAAAAAABIAAAAnAAAA", "ViewState": "AQIAAEwAAAAAAAAAAAAmwBgAAAApAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|", "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2024-09-05T10:22:27.057Z", "WhenOpened": "2024-09-05T10:22:27.057Z",
"EditorCaption": "" "EditorCaption": ""
}, },
{ {
"$type": "Document", "$type": "Document",
"DocumentIndex": 7, "DocumentIndex": 1,
"Title": "AddEditWindow.axaml", "Title": "AddEditWindow.axaml",
"DocumentMoniker": "C:\\Users\\Class_Student\\Desktop\\Xofei\\DemoService\\AddEditWindow.axaml", "DocumentMoniker": "C:\\Users\\Class_Student\\Desktop\\Xofei\\DemoService\\AddEditWindow.axaml",
"RelativeDocumentMoniker": "AddEditWindow.axaml", "RelativeDocumentMoniker": "AddEditWindow.axaml",
@ -128,7 +128,7 @@
}, },
{ {
"$type": "Document", "$type": "Document",
"DocumentIndex": 6, "DocumentIndex": 8,
"Title": "AddEditWindow.axaml.cs", "Title": "AddEditWindow.axaml.cs",
"DocumentMoniker": "C:\\Users\\Class_Student\\Desktop\\Xofei\\DemoService\\AddEditWindow.axaml.cs", "DocumentMoniker": "C:\\Users\\Class_Student\\Desktop\\Xofei\\DemoService\\AddEditWindow.axaml.cs",
"RelativeDocumentMoniker": "AddEditWindow.axaml.cs", "RelativeDocumentMoniker": "AddEditWindow.axaml.cs",
@ -141,13 +141,13 @@
}, },
{ {
"$type": "Document", "$type": "Document",
"DocumentIndex": 4, "DocumentIndex": 9,
"Title": "Context.cs", "Title": "Context.cs",
"DocumentMoniker": "C:\\Users\\Class_Student\\Desktop\\Xofei\\DemoService\\Utils\\Context.cs", "DocumentMoniker": "C:\\Users\\Class_Student\\Desktop\\Xofei\\DemoService\\Utils\\Context.cs",
"RelativeDocumentMoniker": "Utils\\Context.cs", "RelativeDocumentMoniker": "Utils\\Context.cs",
"ToolTip": "C:\\Users\\Class_Student\\Desktop\\Xofei\\DemoService\\Utils\\Context.cs", "ToolTip": "C:\\Users\\Class_Student\\Desktop\\Xofei\\DemoService\\Utils\\Context.cs",
"RelativeToolTip": "Utils\\Context.cs", "RelativeToolTip": "Utils\\Context.cs",
"ViewState": "AQIAAAAAAAAAAAAAAAAAABEAAAAAAAAA", "ViewState": "AQIAAAAAAAAAAAAAAAAAAA4AAAAvAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|", "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2024-09-05T10:39:51.541Z", "WhenOpened": "2024-09-05T10:39:51.541Z",
"EditorCaption": "" "EditorCaption": ""
@ -160,14 +160,14 @@
"RelativeDocumentMoniker": "Models\\Service.cs", "RelativeDocumentMoniker": "Models\\Service.cs",
"ToolTip": "C:\\Users\\Class_Student\\Desktop\\Xofei\\DemoService\\Models\\Service.cs", "ToolTip": "C:\\Users\\Class_Student\\Desktop\\Xofei\\DemoService\\Models\\Service.cs",
"RelativeToolTip": "Models\\Service.cs", "RelativeToolTip": "Models\\Service.cs",
"ViewState": "AQIAAAAAAAAAAAAAAAAAABkAAAAAAAAA", "ViewState": "AQIAAAAAAAAAAAAAAAAAACIAAAAAAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|", "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2024-09-05T11:00:44.489Z", "WhenOpened": "2024-09-05T11:00:44.489Z",
"EditorCaption": "" "EditorCaption": ""
}, },
{ {
"$type": "Document", "$type": "Document",
"DocumentIndex": 5, "DocumentIndex": 6,
"Title": "Colors.cs", "Title": "Colors.cs",
"DocumentMoniker": "C:\\Users\\Class_Student\\Desktop\\Xofei\\DemoService\\Colors.cs", "DocumentMoniker": "C:\\Users\\Class_Student\\Desktop\\Xofei\\DemoService\\Colors.cs",
"RelativeDocumentMoniker": "Colors.cs", "RelativeDocumentMoniker": "Colors.cs",

View File

@ -19,7 +19,9 @@
<Button Name="UserButton" <Button Name="UserButton"
Click="UserLogIn" Click="UserLogIn"
HorizontalAlignment="Center" HorizontalAlignment="Center"
Margin="0 0 0 30"> Margin="0 0 0 30"
BorderBrush="Chocolate"
BorderThickness="1">
<TextBlock HorizontalAlignment="Center" <TextBlock HorizontalAlignment="Center"
VerticalAlignment="Center"> VerticalAlignment="Center">
Войти как пользователь Войти как пользователь
@ -39,7 +41,9 @@
<Button Name="AdminButton" <Button Name="AdminButton"
Click="AdminLogIn" Click="AdminLogIn"
HorizontalAlignment="Center" HorizontalAlignment="Center"
Width="200"> Width="200"
BorderBrush="Chocolate"
BorderThickness="1">
<TextBlock HorizontalAlignment="Center" <TextBlock HorizontalAlignment="Center"
VerticalAlignment="Center"> VerticalAlignment="Center">
Войти как администратор Войти как администратор

View File

@ -1,4 +1,5 @@
using System; using Avalonia.Media.Imaging;
using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace DemoService.Models; namespace DemoService.Models;
@ -19,6 +20,14 @@ public partial class Service
public string? MainImagePath { get; set; } public string? MainImagePath { get; set; }
public Bitmap? MainImagePathBitmap
{
get
{
return new Bitmap(AppDomain.CurrentDomain.BaseDirectory + "/" + MainImagePath);
}
}
public virtual ICollection<Clientservice> ClientServices { get; set; } = new List<Clientservice>(); public virtual ICollection<Clientservice> ClientServices { get; set; } = new List<Clientservice>();
public virtual ICollection<Servicephoto> ServicePhotos { get; set; } = new List<Servicephoto>(); public virtual ICollection<Servicephoto> ServicePhotos { get; set; } = new List<Servicephoto>();

View File

@ -5,61 +5,140 @@
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="600" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="600"
x:Class="DemoService.ServiceWindow" x:Class="DemoService.ServiceWindow"
x:CompileBindings="False" x:CompileBindings="False"
Title="Сервис «Подай на 16»"> Title="Сервис «Подай на 16»"
<StackPanel Orientation="Vertical"> WindowStartupLocation="CenterScreen"
Width="800" Height="600">
<StackPanel Orientation="Vertical"
Margin="10">
<Grid RowDefinitions="Auto" <Grid RowDefinitions="Auto"
ColumnDefinitions="* Auto Auto"> ColumnDefinitions="* Auto Auto"
<TextBox Grid.Column="0" Margin="0 0 0 10">
Watermark="Поиск"/> <TextBox Name="SearchTextBox"
Grid.Column="0"
KeyUp="SearchTextBox_KeyUp"
Watermark="Поиск"
Margin="0 0 10 0"/>
<ComboBox Name="SortComboBox" <ComboBox Name="SortComboBox"
Grid.Column="1" Grid.Column="1"
SelectionChanged="SortComboBox_SelectionChanged"> SelectionChanged="SortComboBox_SelectionChanged"
Margin="0 0 10 0">
<ComboBoxItem>Не сортировать</ComboBoxItem> <ComboBoxItem>Не сортировать</ComboBoxItem>
<ComboBoxItem>По возрастанию</ComboBoxItem> <ComboBoxItem>По возрастанию</ComboBoxItem>
<ComboBoxItem>По убыванию</ComboBoxItem> <ComboBoxItem>По убыванию</ComboBoxItem>
</ComboBox> </ComboBox>
<ComboBox Grid.Column="2" <ComboBox Name="FilterComboBox"
SelectedIndex="0"> Grid.Column="2"
<ComboBoxItem>Фильтрация</ComboBoxItem> SelectionChanged="FilterComboBox_SelectionChanged">
<ComboBoxItem>Все</ComboBoxItem>
<ComboBoxItem>От 0% до 5%</ComboBoxItem>
<ComboBoxItem>От 5% до 15%</ComboBoxItem>
<ComboBoxItem>От 15% до 30%</ComboBoxItem>
<ComboBoxItem>От 30% до 70%</ComboBoxItem>
<ComboBoxItem>От 70% до 100%</ComboBoxItem>
</ComboBox> </ComboBox>
</Grid> </Grid>
<Button Name="AddButton" Click="AddButton_Click"> <Button Name="AddButton"
Добавить Click="AddButton_Click"
HorizontalAlignment="Center"
Margin="0 0 0 10"
Background="#ff9c1a"
BorderBrush="Chocolate"
BorderThickness="1">
Добавить услугу
</Button> </Button>
<ScrollViewer> <ScrollViewer>
<ListBox Name="ServicesListBox"> <ListBox Name="ServicesListBox"
MaxHeight="500"
BorderBrush="Gray"
BorderThickness="1">
<ListBox.ItemTemplate> <ListBox.ItemTemplate>
<DataTemplate> <DataTemplate>
<StackPanel Orientation="Horizontal"> <Border BorderBrush="Gray"
<Image/> BorderThickness="1"
<StackPanel Orientation="Vertical"> Margin="-6 -3 -6 -11">
<TextBlock Name="ServiceName" <DockPanel Margin="5">
Text="{Binding Title}"/> <Image DockPanel.Dock="Left"
<TextBlock> Source="{Binding MainImagePathBitmap}"
<Run Name="PreviousCost"/> Height="100" Width="100"
<Run Name="ActualCost" Margin="10 0 15 0"/>
Text="{Binding Cost}"/> <StackPanel Orientation="Horizontal"
<Run Text="рублей за"/> DockPanel.Dock="Bottom">
<Run Name="Time" <Button Name="EditButton"
Text="{Binding DurationInSeconds}"/> Background="#ff9c1a"
<Run Text="минут"/> BorderBrush="Chocolate"
</TextBlock> BorderThickness="1"
<TextBlock> Margin="0 0 5 0">
<Run Text="* скидка"/> редактировать
<Run Name="Discount"
Text="{Binding Discount}"/>
</TextBlock>
<StackPanel Name="AdminServicePanel"
Orientation="Horizontal">
<Button Name="EditButton">
Изменить
</Button> </Button>
<Button Name="DeleteButton"> <Button Name="DeleteButton"
Удалить Background="#ff9c1a"
BorderBrush="Chocolate"
BorderThickness="1">
удалить
</Button> </Button>
</StackPanel> </StackPanel>
</StackPanel> <StackPanel Orientation="Vertical">
</StackPanel> <TextBlock Name="ServiceName"
Text="{Binding Title}"
Margin="0 0 0 5"/>
<TextBlock Margin="0 0 0 3">
<Run Name="PreviousCost"/>
<Run Name="ActualCost"
Text="{Binding Cost}"/>
<Run Text="рублей за"/>
<Run Name="Time"
Text="{Binding DurationInSeconds}"/>
<Run Text="минут"/>
</TextBlock>
<TextBlock FontSize="12">
<Run Text="* скидка"/>
<Run Name="Discount"
Text="{Binding Discount}"/>
</TextBlock>
</StackPanel>
</DockPanel>
</Border>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</ScrollViewer>
<ScrollViewer>
<ListBox Name="UserServicesListBox"
MaxHeight="540"
BorderBrush="Gray"
BorderThickness="1">
<ListBox.ItemTemplate>
<DataTemplate>
<Border BorderBrush="Gray"
BorderThickness="1"
Margin="-6 -3 -6 -11">
<DockPanel Margin="5">
<Image DockPanel.Dock="Left"
Source="{Binding MainImagePathBitmap}"
Height="100" Width="100"
Margin="10 0 15 0"/>
<StackPanel Orientation="Vertical"
VerticalAlignment="Center">
<TextBlock Name="ServiceName"
Text="{Binding Title}"
Margin="0 0 0 5"/>
<TextBlock Margin="0 0 0 3">
<Run Name="PreviousCost"/>
<Run Name="ActualCost"
Text="{Binding Cost}"/>
<Run Text="рублей за"/>
<Run Name="Time"
Text="{Binding DurationInSeconds}"/>
<Run Text="минут"/>
</TextBlock>
<TextBlock FontSize="12">
<Run Text="* скидка"/>
<Run Name="Discount"
Text="{Binding Discount}"/>
</TextBlock>
</StackPanel>
</DockPanel>
</Border>
</DataTemplate> </DataTemplate>
</ListBox.ItemTemplate> </ListBox.ItemTemplate>
</ListBox> </ListBox>

View File

@ -1,10 +1,12 @@
using Avalonia; using Avalonia;
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Interactivity; using Avalonia.Interactivity;
using Avalonia.Input;
using Avalonia.Markup.Xaml; using Avalonia.Markup.Xaml;
using DemoService.Models; using DemoService.Models;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Avalonia.Media.TextFormatting;
namespace DemoService; namespace DemoService;
@ -16,22 +18,32 @@ public partial class ServiceWindow : Window
{ {
InitializeComponent(); InitializeComponent();
ServicesListBox.ItemsSource = displayList; ServicesListBox.ItemsSource = displayList;
UserServicesListBox.ItemsSource = displayList;
ServicesListBox.Background = Colors.lightYellow;
UserServicesListBox.Background = Colors.lightYellow;
SortComboBox.SelectedIndex = 0; SortComboBox.SelectedIndex = 0;
FilterComboBox.SelectedIndex = 0;
} }
public ServiceWindow(bool admin) public ServiceWindow(bool admin)
{ {
InitializeComponent(); InitializeComponent();
AdminMode = admin; AdminMode = admin;
if (!admin) switch (AdminMode)
{ {
AddButton.IsVisible = false; case true:
ServicesListBox.ItemsSource = displayList;
UserServicesListBox.IsVisible = false;
ServicesListBox.Background = Colors.lightYellow;
break;
case false:
AddButton.IsVisible = false;
UserServicesListBox.ItemsSource = displayList;
ServicesListBox.IsVisible = false;
UserServicesListBox.Background = Colors.lightYellow;
break;
} }
ServicesListBox.ItemsSource = displayList;
/*foreach (var service in ServicesListBox.ItemsSource)
{
}*/
SortComboBox.SelectedIndex = 0; SortComboBox.SelectedIndex = 0;
FilterComboBox.SelectedIndex = 0;
} }
public void AddButtonClick(object sender, RoutedEventArgs args) public void AddButtonClick(object sender, RoutedEventArgs args)
{ {
@ -48,25 +60,30 @@ public partial class ServiceWindow : Window
} }
return null; return null;
}*/ }*/
private void AddButton_Click(object? sender, RoutedEventArgs e)
private void AddButton_Click(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
{ {
AddEditWindow addEditWindow = new(); AddEditWindow addEditWindow = new();
addEditWindow.Show(); addEditWindow.Show();
Close(); Close();
} }
private void SortComboBox_SelectionChanged(object? sender, SelectionChangedEventArgs e)
private void SortComboBox_SelectionChanged(object? sender, Avalonia.Controls.SelectionChangedEventArgs e) {
DisplayService();
}
private void SearchTextBox_KeyUp(object? sender, KeyEventArgs e)
{
DisplayService();
}
private void FilterComboBox_SelectionChanged(object? sender, SelectionChangedEventArgs e)
{ {
DisplayService(); DisplayService();
} }
private void DisplayService() private void DisplayService()
{ {
displayList = Utils.Context.Services;
switch (SortComboBox.SelectedIndex) switch (SortComboBox.SelectedIndex)
{ {
case 0: case 0:
displayList = Utils.Context.Services;
break; break;
case 1: case 1:
displayList = displayList.OrderBy(service => service.Cost).ToList(); displayList = displayList.OrderBy(service => service.Cost).ToList();
@ -75,6 +92,30 @@ public partial class ServiceWindow : Window
displayList = displayList.OrderByDescending(service => service.Cost).ToList(); displayList = displayList.OrderByDescending(service => service.Cost).ToList();
break; break;
} }
switch (FilterComboBox.SelectedIndex)
{
case 0:
break;
case 1:
displayList = displayList.Where(x => x.Discount >= 0 && x.Discount < (decimal)0.05).ToList();
break;
case 2:
displayList = displayList.Where(x => x.Discount >= (decimal)0.05 && x.Discount < (decimal)0.15).ToList();
break;
case 3:
displayList = displayList.Where(x => x.Discount >= (decimal)0.15 && x.Discount < (decimal)0.30).ToList();
break;
case 4:
displayList = displayList.Where(x => x.Discount >= (decimal)0.30 && x.Discount < (decimal)0.70).ToList();
break;
case 5:
displayList = displayList.Where(x => x.Discount >= (decimal)0.70 && x.Discount < (decimal)1.00).ToList();
break;
}
if (!string.IsNullOrEmpty(SearchTextBox.Text))
{
displayList = displayList.Where(x => x.Title.ToLower().Contains(SearchTextBox.Text.ToLower())).ToList();
}
ServicesListBox.ItemsSource = displayList; ServicesListBox.ItemsSource = displayList;
} }
} }

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 89 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 62 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

View File

@ -14,7 +14,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("DemoService")] [assembly: System.Reflection.AssemblyCompanyAttribute("DemoService")]
[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+609078ea462253630054069be0330dc4b3f38a0e")] [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+637276e6f1ae2f151c8bcb1b5548e94a3aad69e5")]
[assembly: System.Reflection.AssemblyProductAttribute("DemoService")] [assembly: System.Reflection.AssemblyProductAttribute("DemoService")]
[assembly: System.Reflection.AssemblyTitleAttribute("DemoService")] [assembly: System.Reflection.AssemblyTitleAttribute("DemoService")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

View File

@ -1 +1 @@
9eeb21b35df534b1e2f2b94e81e5de38ee31b8487505819886f13062429cfbfb 450845604949cc7c05026513da56f34051141ae7614eaaab1866abf2954968cf

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.