feat: pics; delete

This commit is contained in:
Иван Овсянников 2024-09-10 16:12:58 +03:00
parent 72e468684b
commit 381e459f83
27 changed files with 134 additions and 47 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: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\\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\\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}"
},
{
"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\\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\\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\\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}"
},
{
"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\\servicewindow.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}"
},
{
"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: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\\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\\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\\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.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\\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\\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}"
}
],
"DocumentGroupContainers": [
@ -54,15 +54,14 @@
"Children": [
{
"$type": "Document",
"DocumentIndex": 8,
"DocumentIndex": 9,
"Title": "App.axaml",
"DocumentMoniker": "C:\\Users\\Class_Student\\Desktop\\Xofei\\DemoService\\App.axaml",
"RelativeDocumentMoniker": "App.axaml",
"ToolTip": "C:\\Users\\Class_Student\\Desktop\\Xofei\\DemoService\\App.axaml",
"RelativeToolTip": "App.axaml",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.003549|",
"WhenOpened": "2024-09-05T09:32:46.205Z",
"EditorCaption": ""
"WhenOpened": "2024-09-05T09:32:46.205Z"
},
{
"$type": "Document",
@ -78,7 +77,7 @@
},
{
"$type": "Document",
"DocumentIndex": 6,
"DocumentIndex": 8,
"Title": "MainWindow.axaml.cs",
"DocumentMoniker": "C:\\Users\\Class_Student\\Desktop\\Xofei\\DemoService\\MainWindow.axaml.cs",
"RelativeDocumentMoniker": "MainWindow.axaml.cs",
@ -103,45 +102,33 @@
},
{
"$type": "Document",
"DocumentIndex": 4,
"DocumentIndex": 2,
"Title": "ServiceWindow.axaml.cs",
"DocumentMoniker": "C:\\Users\\Class_Student\\Desktop\\Xofei\\DemoService\\ServiceWindow.axaml.cs",
"RelativeDocumentMoniker": "ServiceWindow.axaml.cs",
"ToolTip": "C:\\Users\\Class_Student\\Desktop\\Xofei\\DemoService\\ServiceWindow.axaml.cs",
"RelativeToolTip": "ServiceWindow.axaml.cs",
"ViewState": "AQIAABYAAAAAAAAAAAAgwB0AAAAnAAAA",
"ViewState": "AQIAAEYAAAAAAAAAAAAswJUAAABQAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2024-09-05T10:22:27.057Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 3,
"Title": "AddEditWindow.axaml",
"DocumentMoniker": "C:\\Users\\Class_Student\\Desktop\\Xofei\\DemoService\\AddEditWindow.axaml",
"RelativeDocumentMoniker": "AddEditWindow.axaml",
"ToolTip": "C:\\Users\\Class_Student\\Desktop\\Xofei\\DemoService\\AddEditWindow.axaml",
"RelativeToolTip": "AddEditWindow.axaml",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.003549|",
"WhenOpened": "2024-09-05T10:07:17.245Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 1,
"DocumentIndex": 4,
"Title": "AddEditWindow.axaml.cs",
"DocumentMoniker": "C:\\Users\\Class_Student\\Desktop\\Xofei\\DemoService\\AddEditWindow.axaml.cs",
"RelativeDocumentMoniker": "AddEditWindow.axaml.cs",
"ToolTip": "C:\\Users\\Class_Student\\Desktop\\Xofei\\DemoService\\AddEditWindow.axaml.cs",
"RelativeToolTip": "AddEditWindow.axaml.cs",
"ViewState": "AQIAACAAAAAAAAAAAAArwDIAAAAdAAAA",
"ViewState": "AQIAAB4AAAAAAAAAAAAowDYAAAAKAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2024-09-05T10:07:17.713Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 2,
"DocumentIndex": 3,
"Title": "Context.cs",
"DocumentMoniker": "C:\\Users\\Class_Student\\Desktop\\Xofei\\DemoService\\Utils\\Context.cs",
"RelativeDocumentMoniker": "Utils\\Context.cs",
@ -160,14 +147,14 @@
"RelativeDocumentMoniker": "Models\\Service.cs",
"ToolTip": "C:\\Users\\Class_Student\\Desktop\\Xofei\\DemoService\\Models\\Service.cs",
"RelativeToolTip": "Models\\Service.cs",
"ViewState": "AQIAAAMAAAAAAAAAAAAAABUAAAAAAAAA",
"ViewState": "AQIAAAoAAAAAAAAAAAAgwBsAAAANAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2024-09-05T11:00:44.489Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 9,
"DocumentIndex": 1,
"Title": "Colors.cs",
"DocumentMoniker": "C:\\Users\\Class_Student\\Desktop\\Xofei\\DemoService\\Colors.cs",
"RelativeDocumentMoniker": "Colors.cs",
@ -175,7 +162,41 @@
"RelativeToolTip": "Colors.cs",
"ViewState": "AQIAAAAAAAAAAAAAAAAAABEAAAAAAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2024-09-05T10:07:30.214Z"
"WhenOpened": "2024-09-05T10:07:30.214Z",
"EditorCaption": ""
}
]
}
]
},
{
"Orientation": 0,
"VerticalTabListWidth": 256,
"FloatingWindowState": {
"Id": "b510706a-e105-41a7-aa7c-8fe6fa580242",
"Display": 1,
"X": -5,
"Y": 4,
"Width": 1932,
"Height": 1035,
"WindowState": 2
},
"DocumentGroups": [
{
"DockedWidth": 200,
"SelectedChildIndex": 0,
"Children": [
{
"$type": "Document",
"DocumentIndex": 6,
"Title": "AddEditWindow.axaml",
"DocumentMoniker": "C:\\Users\\Class_Student\\Desktop\\Xofei\\DemoService\\AddEditWindow.axaml",
"RelativeDocumentMoniker": "AddEditWindow.axaml",
"ToolTip": "C:\\Users\\Class_Student\\Desktop\\Xofei\\DemoService\\AddEditWindow.axaml",
"RelativeToolTip": "AddEditWindow.axaml",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.003549|",
"WhenOpened": "2024-09-05T10:07:17.245Z",
"EditorCaption": ""
}
]
}

View File

@ -6,7 +6,7 @@
x:Class="DemoService.AddEditWindow"
Title="AddEditWindow">
<StackPanel>
<TextBlock>
<TextBlock Name="ServiceIDTextBlock">
<Run Text="ID:"/>
<Run Name="ServiceID"/>
</TextBlock>
@ -24,7 +24,7 @@
Click="AddPictureButton_Click">
Добавить картинку
</Button>
<Image/>
<Image Name="ServiceImage"/>
<Button Name="AddServiceButton"
Click="AddServiceButton_Click">
Добавить услугу

View File

@ -14,6 +14,7 @@ namespace DemoService;
public partial class AddEditWindow : Window
{
private bool AdminMode;
private int serviceID;
public AddEditWindow()
{
InitializeComponent();
@ -23,11 +24,35 @@ public partial class AddEditWindow : Window
{
InitializeComponent();
this.AdminMode = AdminMode;
ServiceIDTextBlock.IsVisible = false;
EditServiceButton.IsVisible = false;
Icon = new WindowIcon(new Bitmap(AppDomain.CurrentDomain.BaseDirectory + "/Assets/service_logo.ico"));
}
public AddEditWindow(bool AdminMode, int ID)
{
InitializeComponent();
this.AdminMode = AdminMode;
serviceID = ID;
ServiceID.Text = serviceID.ToString();
using (var context = new OvsyannikovContext())
{
var service = context.Services.Find(serviceID);
ServiceName.Text = service.Title;
Cost.Text = Convert.ToString(service.Cost);
DurationInSeconds.Text = Convert.ToString(service.DurationInSeconds);
Description.Text = service.Description;
Discount.Text = Convert.ToString(service.Discount);
ServiceImage.Source = service.MainImagePathBitmap;
}
AddServiceButton.IsVisible = false;
Icon = new WindowIcon(new Bitmap(AppDomain.CurrentDomain.BaseDirectory + "/Assets/service_logo.ico"));
}
private void AddPictureButton_Click(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
private async void AddPictureButton_Click(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
{
/*OpenFileDialog openFileDialog = new OpenFileDialog();
var topLevel = await openFileDialog.ShowAsync(this);
*/
}
private void AddServiceButton_Click(object? sender, Avalonia.Interactivity.RoutedEventArgs e)

View File

@ -24,7 +24,15 @@ public partial class Service
{
get
{
return new Bitmap(AppDomain.CurrentDomain.BaseDirectory + "/" + MainImagePath);
try
{
return new Bitmap(AppDomain.CurrentDomain.BaseDirectory + "/" + MainImagePath);
}
catch
{
return null;
}
}
}

View File

@ -64,6 +64,8 @@
<StackPanel Orientation="Horizontal"
DockPanel.Dock="Bottom">
<Button Name="EditButton"
Tag="{Binding Id}"
Click="EditButton_Click"
Background="#ff9c1a"
BorderBrush="Chocolate"
BorderThickness="1"
@ -71,6 +73,8 @@
редактировать
</Button>
<Button Name="DeleteButton"
Tag="{Binding Id}"
Click="DeleteButton_Click"
Background="#ff9c1a"
BorderBrush="Chocolate"
BorderThickness="1">

View File

@ -9,6 +9,7 @@ using System.Linq;
using Avalonia.Media.TextFormatting;
using Avalonia.Media.Imaging;
using System;
using DemoService.Context;
namespace DemoService;
@ -66,7 +67,7 @@ public partial class ServiceWindow : Window
}*/
private void AddButton_Click(object? sender, RoutedEventArgs e)
{
AddEditWindow addEditWindow = new();
AddEditWindow addEditWindow = new(AdminMode);
addEditWindow.Show();
Close();
}
@ -122,4 +123,32 @@ public partial class ServiceWindow : Window
}
ServicesListBox.ItemsSource = displayList;
}
private void DeleteButton_Click(object? sender, RoutedEventArgs e)
{
using (var context = new OvsyannikovContext())
{
var service = context.Services.Find((int)(sender as Button).Tag);
context.Remove(service);
context.SaveChanges();
}
Utils.Context.Services = new List<Service>(Utils.Context.DbContext.Services);
displayList = Utils.Context.Services;
switch (AdminMode)
{
case true:
ServicesListBox.ItemsSource = displayList;
break;
case false:
UserServicesListBox.ItemsSource = displayList;
break;
}
}
private void EditButton_Click(object? sender, RoutedEventArgs e)
{
AddEditWindow addEditWindow = new(AdminMode, (int)(sender as Button).Tag);
addEditWindow.Show();
Close();
}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -14,7 +14,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("DemoService")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+be4fb3891efa5fabc94b16e44a97228a3706cd86")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+72e468684b87aad8ee4bcbe0d4770da1c47630c0")]
[assembly: System.Reflection.AssemblyProductAttribute("DemoService")]
[assembly: System.Reflection.AssemblyTitleAttribute("DemoService")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

View File

@ -1 +1 @@
86f0864685c6615ecac0e33e56051598e8d3a6f5be2809fa1842f5039b837041
1742c1a61d4d529bd1a2d881b9fceac23a30fcaef261a4de6d5de09e486a5671

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.