feat: service adding

This commit is contained in:
Иван Овсянников 2024-09-09 16:26:07 +03:00
parent be4fb3891e
commit 72e468684b
28 changed files with 85 additions and 42 deletions

Binary file not shown.

Binary file not shown.

View File

@ -3,20 +3,28 @@
"WorkspaceRootPath": "C:\\Users\\Class_Student\\Desktop\\Xofei\\DemoService\\",
"Documents": [
{
"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\\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\\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\\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\\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\\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\\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}",
@ -26,21 +34,13 @@
"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}",
"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}"
},
{
"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\\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}"
}
],
"DocumentGroupContainers": [
@ -50,11 +50,11 @@
"DocumentGroups": [
{
"DockedWidth": 200,
"SelectedChildIndex": 4,
"SelectedChildIndex": 8,
"Children": [
{
"$type": "Document",
"DocumentIndex": 7,
"DocumentIndex": 8,
"Title": "App.axaml",
"DocumentMoniker": "C:\\Users\\Class_Student\\Desktop\\Xofei\\DemoService\\App.axaml",
"RelativeDocumentMoniker": "App.axaml",
@ -66,7 +66,7 @@
},
{
"$type": "Document",
"DocumentIndex": 5,
"DocumentIndex": 7,
"Title": "MainWindow.axaml",
"DocumentMoniker": "C:\\Users\\Class_Student\\Desktop\\Xofei\\DemoService\\MainWindow.axaml",
"RelativeDocumentMoniker": "MainWindow.axaml",
@ -78,20 +78,20 @@
},
{
"$type": "Document",
"DocumentIndex": 4,
"DocumentIndex": 6,
"Title": "MainWindow.axaml.cs",
"DocumentMoniker": "C:\\Users\\Class_Student\\Desktop\\Xofei\\DemoService\\MainWindow.axaml.cs",
"RelativeDocumentMoniker": "MainWindow.axaml.cs",
"ToolTip": "C:\\Users\\Class_Student\\Desktop\\Xofei\\DemoService\\MainWindow.axaml.cs",
"RelativeToolTip": "MainWindow.axaml.cs",
"ViewState": "AQIAAAAAAAAAAAAAAAAAAC8AAAABAAAA",
"ViewState": "AQIAABAAAAAAAAAAAADgvx8AAAAYAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2024-09-05T10:07:04.004Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 2,
"DocumentIndex": 5,
"Title": "ServiceWindow.axaml",
"DocumentMoniker": "C:\\Users\\Class_Student\\Desktop\\Xofei\\DemoService\\ServiceWindow.axaml",
"RelativeDocumentMoniker": "ServiceWindow.axaml",
@ -103,20 +103,20 @@
},
{
"$type": "Document",
"DocumentIndex": 0,
"DocumentIndex": 4,
"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": "AQIAAEwAAAAAAAAAAAAmwBgAAAApAAAA",
"ViewState": "AQIAABYAAAAAAAAAAAAgwB0AAAAnAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2024-09-05T10:22:27.057Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 1,
"DocumentIndex": 3,
"Title": "AddEditWindow.axaml",
"DocumentMoniker": "C:\\Users\\Class_Student\\Desktop\\Xofei\\DemoService\\AddEditWindow.axaml",
"RelativeDocumentMoniker": "AddEditWindow.axaml",
@ -128,46 +128,46 @@
},
{
"$type": "Document",
"DocumentIndex": 8,
"DocumentIndex": 1,
"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": "AQIAAAAAAAAAAAAAAAAAABgAAAABAAAA",
"ViewState": "AQIAACAAAAAAAAAAAAArwDIAAAAdAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2024-09-05T10:07:17.713Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 9,
"DocumentIndex": 2,
"Title": "Context.cs",
"DocumentMoniker": "C:\\Users\\Class_Student\\Desktop\\Xofei\\DemoService\\Utils\\Context.cs",
"RelativeDocumentMoniker": "Utils\\Context.cs",
"ToolTip": "C:\\Users\\Class_Student\\Desktop\\Xofei\\DemoService\\Utils\\Context.cs",
"RelativeToolTip": "Utils\\Context.cs",
"ViewState": "AQIAAAAAAAAAAAAAAAAAAA4AAAAvAAAA",
"ViewState": "AQIAAAAAAAAAAAAAAAAAAAkAAAAbAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2024-09-05T10:39:51.541Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 3,
"DocumentIndex": 0,
"Title": "Service.cs",
"DocumentMoniker": "C:\\Users\\Class_Student\\Desktop\\Xofei\\DemoService\\Models\\Service.cs",
"RelativeDocumentMoniker": "Models\\Service.cs",
"ToolTip": "C:\\Users\\Class_Student\\Desktop\\Xofei\\DemoService\\Models\\Service.cs",
"RelativeToolTip": "Models\\Service.cs",
"ViewState": "AQIAAAAAAAAAAAAAAAAAACIAAAAAAAAA",
"ViewState": "AQIAAAMAAAAAAAAAAAAAABUAAAAAAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2024-09-05T11:00:44.489Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 6,
"DocumentIndex": 9,
"Title": "Colors.cs",
"DocumentMoniker": "C:\\Users\\Class_Student\\Desktop\\Xofei\\DemoService\\Colors.cs",
"RelativeDocumentMoniker": "Colors.cs",
@ -175,8 +175,7 @@
"RelativeToolTip": "Colors.cs",
"ViewState": "AQIAAAAAAAAAAAAAAAAAABEAAAAAAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2024-09-05T10:07:30.214Z",
"EditorCaption": ""
"WhenOpened": "2024-09-05T10:07:30.214Z"
}
]
}

View File

@ -6,6 +6,10 @@
x:Class="DemoService.AddEditWindow"
Title="AddEditWindow">
<StackPanel>
<TextBlock>
<Run Text="ID:"/>
<Run Name="ServiceID"/>
</TextBlock>
<TextBox Name="ServiceName"
Watermark="Название"/>
<TextBox Name="Cost"

View File

@ -1,14 +1,29 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using Avalonia.Media.Imaging;
using DemoService.Context;
using DemoService.Models;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Net;
namespace DemoService;
public partial class AddEditWindow : Window
{
private bool AdminMode;
public AddEditWindow()
{
InitializeComponent();
Icon = new WindowIcon(new Bitmap(AppDomain.CurrentDomain.BaseDirectory + "/Assets/service_logo.ico"));
}
public AddEditWindow(bool AdminMode)
{
InitializeComponent();
this.AdminMode = AdminMode;
Icon = new WindowIcon(new Bitmap(AppDomain.CurrentDomain.BaseDirectory + "/Assets/service_logo.ico"));
}
private void AddPictureButton_Click(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
@ -17,6 +32,24 @@ public partial class AddEditWindow : Window
private void AddServiceButton_Click(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
{
Service service = new Service()
{
Id = Utils.Context.Services.Count + 1,
Title = ServiceName.Text,
Cost = Convert.ToDecimal(Cost.Text),
DurationInSeconds = Convert.ToInt32(DurationInSeconds.Text),
Description = Description.Text,
Discount = Convert.ToDecimal(Discount.Text)
};
using (var context = new OvsyannikovContext())
{
context.Add(service);
context.SaveChanges();
}
Utils.Context.Services = new List<Service>(Utils.Context.DbContext.Services);
ServiceWindow serviceWindow = new(AdminMode);
serviceWindow.Show();
Close();
}
private void EditServiceButton_Click(object? sender, Avalonia.Interactivity.RoutedEventArgs e)

View File

@ -1,5 +1,7 @@
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Media.Imaging;
using System;
namespace DemoService
{
@ -13,6 +15,7 @@ namespace DemoService
UserButton.Background = Colors.orange;
PasswordError.Foreground = Colors.white;
AdminButton.Background = Colors.orange;
Icon = new WindowIcon(new Bitmap(AppDomain.CurrentDomain.BaseDirectory + "/Assets/service_logo.ico"));
}
private void UserLogIn(object sender, RoutedEventArgs args)
{

View File

@ -7,12 +7,14 @@ using DemoService.Models;
using System.Collections.Generic;
using System.Linq;
using Avalonia.Media.TextFormatting;
using Avalonia.Media.Imaging;
using System;
namespace DemoService;
public partial class ServiceWindow : Window
{
private readonly bool AdminMode;
private bool AdminMode;
private List<Service> displayList = Utils.Context.Services;
public ServiceWindow()
{
@ -23,12 +25,13 @@ public partial class ServiceWindow : Window
UserServicesListBox.Background = Colors.lightYellow;
SortComboBox.SelectedIndex = 0;
FilterComboBox.SelectedIndex = 0;
Icon = new WindowIcon(new Bitmap(AppDomain.CurrentDomain.BaseDirectory + "/Assets/service_logo.ico"));
}
public ServiceWindow(bool admin)
public ServiceWindow(bool AdminMode)
{
InitializeComponent();
AdminMode = admin;
switch (AdminMode)
this.AdminMode = AdminMode;
switch (this.AdminMode)
{
case true:
ServicesListBox.ItemsSource = displayList;
@ -44,10 +47,11 @@ public partial class ServiceWindow : Window
}
SortComboBox.SelectedIndex = 0;
FilterComboBox.SelectedIndex = 0;
Icon = new WindowIcon(new Bitmap(AppDomain.CurrentDomain.BaseDirectory + "/Assets/service_logo.ico"));
}
public void AddButtonClick(object sender, RoutedEventArgs args)
{
AddEditWindow addEditWindow = new();
AddEditWindow addEditWindow = new(AdminMode);
addEditWindow.Show();
Close();
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1 +1 @@
a4b66c87d30d886b851e6996ec8713f5fa99453f82238650ad43cdf4941c1709
d478605abe656e117538812cf502b5c4db0e055ca55446419d244706776777ee

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+637276e6f1ae2f151c8bcb1b5548e94a3aad69e5")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+be4fb3891efa5fabc94b16e44a97228a3706cd86")]
[assembly: System.Reflection.AssemblyProductAttribute("DemoService")]
[assembly: System.Reflection.AssemblyTitleAttribute("DemoService")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

View File

@ -1 +1 @@
450845604949cc7c05026513da56f34051141ae7614eaaab1866abf2954968cf
86f0864685c6615ecac0e33e56051598e8d3a6f5be2809fa1842f5039b837041

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.