add AddOrder
This commit is contained in:
parent
e1a0c1864a
commit
b8d93e0a74
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -3,8 +3,8 @@
|
|||||||
"WorkspaceRootPath": "C:\\Users\\VivoBook 15X\\Desktop\\\u043F\u0440\u043E\u0433\u0440\u0430\u043C\u043C\u043D\u044B\u0435 \u043C\u043E\u0434\u0443\u043B\u0438\\Demo_Blagodat\\demo_blagodat\\demo_blagodat\\",
|
"WorkspaceRootPath": "C:\\Users\\VivoBook 15X\\Desktop\\\u043F\u0440\u043E\u0433\u0440\u0430\u043C\u043C\u043D\u044B\u0435 \u043C\u043E\u0434\u0443\u043B\u0438\\Demo_Blagodat\\demo_blagodat\\demo_blagodat\\",
|
||||||
"Documents": [
|
"Documents": [
|
||||||
{
|
{
|
||||||
"AbsoluteMoniker": "D:0:0:{B40AB1D5-A904-4458-95A8-8CAE49BE0884}|demo_blagodat.csproj|c:\\users\\vivobook 15x\\desktop\\\u043F\u0440\u043E\u0433\u0440\u0430\u043C\u043C\u043D\u044B\u0435 \u043C\u043E\u0434\u0443\u043B\u0438\\demo_blagodat\\demo_blagodat\\demo_blagodat\\users\\admin.axaml||{6D5344A2-2FCD-49DE-A09D-6A14FD1B1224}",
|
"AbsoluteMoniker": "D:0:0:{B40AB1D5-A904-4458-95A8-8CAE49BE0884}|demo_blagodat.csproj|c:\\users\\vivobook 15x\\desktop\\\u043F\u0440\u043E\u0433\u0440\u0430\u043C\u043C\u043D\u044B\u0435 \u043C\u043E\u0434\u0443\u043B\u0438\\demo_blagodat\\demo_blagodat\\demo_blagodat\\functions\\deleteorder.axaml.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||||
"RelativeMoniker": "D:0:0:{B40AB1D5-A904-4458-95A8-8CAE49BE0884}|demo_blagodat.csproj|solutionrelative:users\\admin.axaml||{6D5344A2-2FCD-49DE-A09D-6A14FD1B1224}"
|
"RelativeMoniker": "D:0:0:{B40AB1D5-A904-4458-95A8-8CAE49BE0884}|demo_blagodat.csproj|solutionrelative:functions\\deleteorder.axaml.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"DocumentGroupContainers": [
|
"DocumentGroupContainers": [
|
||||||
@ -27,13 +27,14 @@
|
|||||||
{
|
{
|
||||||
"$type": "Document",
|
"$type": "Document",
|
||||||
"DocumentIndex": 0,
|
"DocumentIndex": 0,
|
||||||
"Title": "Admin.axaml",
|
"Title": "DeleteOrder.axaml.cs",
|
||||||
"DocumentMoniker": "C:\\Users\\VivoBook 15X\\Desktop\\\u043F\u0440\u043E\u0433\u0440\u0430\u043C\u043C\u043D\u044B\u0435 \u043C\u043E\u0434\u0443\u043B\u0438\\Demo_Blagodat\\demo_blagodat\\demo_blagodat\\Users\\Admin.axaml",
|
"DocumentMoniker": "C:\\Users\\VivoBook 15X\\Desktop\\\u043F\u0440\u043E\u0433\u0440\u0430\u043C\u043C\u043D\u044B\u0435 \u043C\u043E\u0434\u0443\u043B\u0438\\Demo_Blagodat\\demo_blagodat\\demo_blagodat\\Functions\\DeleteOrder.axaml.cs",
|
||||||
"RelativeDocumentMoniker": "Users\\Admin.axaml",
|
"RelativeDocumentMoniker": "Functions\\DeleteOrder.axaml.cs",
|
||||||
"ToolTip": "C:\\Users\\VivoBook 15X\\Desktop\\\u043F\u0440\u043E\u0433\u0440\u0430\u043C\u043C\u043D\u044B\u0435 \u043C\u043E\u0434\u0443\u043B\u0438\\Demo_Blagodat\\demo_blagodat\\demo_blagodat\\Users\\Admin.axaml",
|
"ToolTip": "C:\\Users\\VivoBook 15X\\Desktop\\\u043F\u0440\u043E\u0433\u0440\u0430\u043C\u043C\u043D\u044B\u0435 \u043C\u043E\u0434\u0443\u043B\u0438\\Demo_Blagodat\\demo_blagodat\\demo_blagodat\\Functions\\DeleteOrder.axaml.cs",
|
||||||
"RelativeToolTip": "Users\\Admin.axaml",
|
"RelativeToolTip": "Functions\\DeleteOrder.axaml.cs",
|
||||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.003549|",
|
"ViewState": "AgIAABwAAAAAAAAAAAAAACkAAAAtAAAAAAAAAA==",
|
||||||
"WhenOpened": "2025-03-01T13:52:46.864Z",
|
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||||
|
"WhenOpened": "2025-03-01T21:26:02.846Z",
|
||||||
"EditorCaption": ""
|
"EditorCaption": ""
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -5,7 +5,45 @@
|
|||||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||||
x:Class="demo_blagodat.CreateOrder"
|
x:Class="demo_blagodat.CreateOrder"
|
||||||
Title="Создание заказа">
|
Title="Создание заказа">
|
||||||
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
|
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Orientation="Vertical">
|
||||||
|
|
||||||
|
<StackPanel Spacing="15" HorizontalAlignment="Center" Orientation="Horizontal">
|
||||||
|
|
||||||
|
<StackPanel Orientation="Vertical">
|
||||||
|
<TextBlock Text="Введите ФИО клиента"/>
|
||||||
|
<TextBox Width="300" x:Name="TextNameClient" Text=""/>
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
<StackPanel Orientation="Vertical">
|
||||||
|
<TextBlock Text="Введите продолжительность заказа в минутах"/>
|
||||||
|
<TextBox Width="300" x:Name="TextOrderRentalTime" Text=""/>
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
<StackPanel Orientation="Vertical">
|
||||||
|
<TextBlock Text="Введите дату закрытия заказа в цифрах (если можно)"/>
|
||||||
|
<TextBox Width="300" x:Name="TextOrderClosingDate" Text=""/>
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
<StackPanel Spacing="15" HorizontalAlignment="Center" Orientation="Horizontal">
|
||||||
|
|
||||||
|
<StackPanel Orientation="Vertical">
|
||||||
|
<TextBlock Text="Добавте название услугу"/>
|
||||||
|
<TextBox Width="300" x:Name="TextService" Text=""/>
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Orientation="Horizontal">
|
||||||
<Button Content="Назад" Click="ExitClik"/>
|
<Button Content="Назад" Click="ExitClik"/>
|
||||||
|
<Button Content="Создать заказ" Click="createOrder"/>
|
||||||
|
<Button Content="Добавить услугу в заказ" Click="addServiceToOrder"/>
|
||||||
|
</StackPanel>
|
||||||
|
<StackPanel HorizontalAlignment="Center" Orientation="Vertical">
|
||||||
|
<TextBlock x:Name="MesAddError" Text="" Foreground="Red"/>
|
||||||
|
<TextBlock x:Name="MesAdd" Text="" Foreground="Green"/>
|
||||||
|
</StackPanel>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Window>
|
</Window>
|
||||||
|
@ -3,17 +3,132 @@ using Avalonia.Controls;
|
|||||||
using Avalonia.Interactivity;
|
using Avalonia.Interactivity;
|
||||||
using Avalonia.Markup.Xaml;
|
using Avalonia.Markup.Xaml;
|
||||||
using demo_blagodat.Models;
|
using demo_blagodat.Models;
|
||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace demo_blagodat;
|
namespace demo_blagodat;
|
||||||
|
|
||||||
public partial class CreateOrder : Window
|
public partial class CreateOrder : Window
|
||||||
{
|
{
|
||||||
|
public Order NewOrder = null;
|
||||||
public Employee User;
|
public Employee User;
|
||||||
public CreateOrder(Employee user)
|
public CreateOrder(Employee user)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
User = user;
|
User = user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void createOrder(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string NameClient = TextNameClient.Text;
|
||||||
|
int order_rental_time = int.Parse(TextOrderRentalTime.Text);
|
||||||
|
DateOnly? order_closing_date = DateOnly.TryParse(TextOrderClosingDate.Text, out var Date) ? Date : null;
|
||||||
|
|
||||||
|
if (TextNameClient.Text != "")
|
||||||
|
{
|
||||||
|
if(TextOrderRentalTime.Text != "")
|
||||||
|
{
|
||||||
|
using (User11Context db = new User11Context())
|
||||||
|
{
|
||||||
|
Client? client = db.Clients.Where(it => it.ClientName == NameClient).FirstOrDefault();
|
||||||
|
if (client != null)
|
||||||
|
{
|
||||||
|
Order newOrder = new Order()
|
||||||
|
{
|
||||||
|
OrderId = db.Orders.Max(o => o.OrderId) + 1,
|
||||||
|
OrderDate = DateOnly.FromDateTime(DateTime.Now),
|
||||||
|
OrderTime = TimeOnly.FromDateTime(DateTime.Now),
|
||||||
|
OrderClient = client.ClientCode,
|
||||||
|
OrderRentalTime = order_rental_time,
|
||||||
|
OrderClosingDate = order_closing_date,
|
||||||
|
OrderStatus = "Íîâàÿ",
|
||||||
|
};
|
||||||
|
db.Orders.Add(newOrder);
|
||||||
|
db.SaveChanges();
|
||||||
|
|
||||||
|
NewOrder = newOrder;
|
||||||
|
MesAdd.Text = "Çàêàç ñîçäàí";
|
||||||
|
MesAddError.Text = "";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MesAddError.Text = "Òàêîãî êëèåíòà íåò";
|
||||||
|
MesAdd.Text = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MesAddError.Text = "Ââåäèòå ïðîäîëæèòåëüíîñòü çàêàçà";
|
||||||
|
MesAdd.Text = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MesAddError.Text = "Ââåäèòå èìÿ êëèåíòà";
|
||||||
|
MesAdd.Text = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
catch(Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine(ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addServiceToOrder(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string? newservice = TextService.Text;
|
||||||
|
if (TextService.Text != "")
|
||||||
|
{
|
||||||
|
using (User11Context db = new User11Context())
|
||||||
|
{
|
||||||
|
Service? service = db.Services.Where(it => it.ServiceName == newservice).FirstOrDefault();
|
||||||
|
if (service != null)
|
||||||
|
{
|
||||||
|
Order? order = db.Orders.Where(it => it.OrderId == NewOrder.OrderId).FirstOrDefault();
|
||||||
|
if (order != null)
|
||||||
|
{
|
||||||
|
OrdersWithService newOWS = new OrdersWithService()
|
||||||
|
{
|
||||||
|
Order = order.OrderId,
|
||||||
|
Service = service.ServiceId
|
||||||
|
};
|
||||||
|
db.OrdersWithServices.Add(newOWS);
|
||||||
|
db.SaveChanges();
|
||||||
|
|
||||||
|
MesAddError.Text = "";
|
||||||
|
MesAdd.Text = "Óñëóãà äîáàâëåíà";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MesAddError.Text = "Ñíà÷àëà ñîçäàéòå çàêàç";
|
||||||
|
MesAdd.Text = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MesAddError.Text = "Òàêîé óñëóãè íåò";
|
||||||
|
MesAdd.Text = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MesAddError.Text = "Ââåäèòå íàçâàíèå óñëóãè";
|
||||||
|
MesAdd.Text = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine(ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void ExitClik(object sender, RoutedEventArgs e)
|
private void ExitClik(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
switch (User.EmployeesPosition)
|
switch (User.EmployeesPosition)
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||||
x:Class="demo_blagodat.DeleteOrder"
|
x:Class="demo_blagodat.DeleteOrder"
|
||||||
Title="DeleteOrder">
|
Title="Удалить заказ">
|
||||||
<StackPanel Orientation="Vertical">
|
<StackPanel Orientation="Vertical">
|
||||||
<StackPanel Spacing="15" HorizontalAlignment="Center" Orientation="Vertical">
|
<StackPanel Spacing="15" HorizontalAlignment="Center" Orientation="Vertical">
|
||||||
|
|
||||||
@ -16,7 +16,7 @@
|
|||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
<StackPanel HorizontalAlignment="Center" Orientation="Vertical" VerticalAlignment="Center">
|
<StackPanel HorizontalAlignment="Center" Orientation="Vertical" VerticalAlignment="Center">
|
||||||
<Button Content="Удвлить Клиента" Click="deleteclient"/>
|
<Button Content="Удвлить заказ" Click="deleteclient"/>
|
||||||
<Button Content="Вернуться назад" Click="ExitClik"/>
|
<Button Content="Вернуться назад" Click="ExitClik"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<StackPanel HorizontalAlignment="Center" Orientation="Vertical">
|
<StackPanel HorizontalAlignment="Center" Orientation="Vertical">
|
||||||
|
@ -10,6 +10,7 @@ namespace demo_blagodat;
|
|||||||
|
|
||||||
public partial class DeleteOrder : Window
|
public partial class DeleteOrder : Window
|
||||||
{
|
{
|
||||||
|
public int? idOrder;
|
||||||
public Employee User;
|
public Employee User;
|
||||||
public DeleteOrder(Employee user)
|
public DeleteOrder(Employee user)
|
||||||
{
|
{
|
||||||
@ -23,24 +24,27 @@ public partial class DeleteOrder : Window
|
|||||||
using (User11Context db = new User11Context()) // Ïîäêëþ÷åíèå ê ÁÄ
|
using (User11Context db = new User11Context()) // Ïîäêëþ÷åíèå ê ÁÄ
|
||||||
{
|
{
|
||||||
// Ñîáèðàåì âñå äàííûå ñ ýêðàíà
|
// Ñîáèðàåì âñå äàííûå ñ ýêðàíà
|
||||||
int? id = int.Parse(TextID.Text);
|
idOrder = int.Parse(TextID.Text);
|
||||||
|
|
||||||
|
|
||||||
if (id != null) // Ïðîâåðÿåì íàëè÷èå âàæíûõ äàííûõ
|
if (idOrder != null) // Ïðîâåðÿåì íàëè÷èå âàæíûõ äàííûõ
|
||||||
{
|
{
|
||||||
Order? order = db.Orders.Where(it => it.OrderId == id).FirstOrDefault(); // ñîçäà¸ì ýêçåìïëÿð êëàññà Order
|
Order? order = db.Orders.Where(it => it.OrderId == idOrder).FirstOrDefault(); // ñîçäà¸ì ýêçåìïëÿð êëàññà Order
|
||||||
|
|
||||||
|
int count = db.OrdersWithServices.Where(it => it.Order == order.OrderId).Count();
|
||||||
|
|
||||||
if (order != null)
|
if (order != null)
|
||||||
{
|
{
|
||||||
// Óäàëÿåì Çàêàç èç ÁÄ
|
for (int i = 0; i < count; i++)
|
||||||
db.Orders.Remove(order);
|
{
|
||||||
|
OrdersWithService ordersWithService = db.OrdersWithServices.Where(it => it.Order == order.OrderId).FirstOrDefault();
|
||||||
// Ñîõðàíÿåì èçìåíåíèÿ ÁÄ
|
db.OrdersWithServices.Remove(ordersWithService);
|
||||||
db.SaveChanges();
|
db.SaveChanges();
|
||||||
|
}
|
||||||
|
deleteclient2();
|
||||||
|
|
||||||
// Ìåíÿåì ñîîáùåíèå
|
|
||||||
MesDelError.Text = "";
|
|
||||||
MesDel.Text = "Çàêàç óäàë¸í";
|
MesDel.Text = "Çàêàç óäàë¸í";
|
||||||
|
MesDelError.Text = "";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -49,7 +53,6 @@ public partial class DeleteOrder : Window
|
|||||||
|
|
||||||
// Ñòåðàåì âñå äàííûå
|
// Ñòåðàåì âñå äàííûå
|
||||||
TextID.Text = "";
|
TextID.Text = "";
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -66,7 +69,30 @@ public partial class DeleteOrder : Window
|
|||||||
|
|
||||||
// Ìåíÿåì ñîîáùåíèå
|
// Ìåíÿåì ñîîáùåíèå
|
||||||
MesDel.Text = "";
|
MesDel.Text = "";
|
||||||
MesDelError.Text = "Ïðîâåðüòå äàííûå";
|
MesDelError.Text = "ïðîèçîøëà îøèáêà";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void deleteclient2()
|
||||||
|
{
|
||||||
|
try // Êîíñòðóêöèÿ äëÿ îáðàáîòêè èñêëþ÷åíèé
|
||||||
|
{
|
||||||
|
using (User11Context db = new User11Context()) // Ïîäêëþ÷åíèå ê ÁÄ
|
||||||
|
{
|
||||||
|
Order order = db.Orders.Where(it => it.OrderId == idOrder).FirstOrDefault();
|
||||||
|
db.Orders.Remove(order);
|
||||||
|
db.SaveChanges();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
// Âûâîäèì ñîîáùåíèå îá îøèáêå â êîíñîëü
|
||||||
|
Console.WriteLine(ex.Message);
|
||||||
|
|
||||||
|
// Ìåíÿåì ñîîáùåíèå
|
||||||
|
MesDel.Text = "";
|
||||||
|
MesDelError.Text = "ïðîèçîøëà îøèáêà";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -94,7 +94,7 @@ public partial class Admin : Window
|
|||||||
|
|
||||||
private void deleteOrder(object sender, RoutedEventArgs e)
|
private void deleteOrder(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
new DeleteServices(User).Show();
|
new DeleteOrder(User).Show();
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -14,7 +14,7 @@ using System.Reflection;
|
|||||||
[assembly: System.Reflection.AssemblyCompanyAttribute("demo_blagodat")]
|
[assembly: System.Reflection.AssemblyCompanyAttribute("demo_blagodat")]
|
||||||
[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+62a5c37073e8de050b3ef6eac3fb262f6ca7c0f9")]
|
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+e1a0c1864ae93b140382bb5253f30e14f658b6bb")]
|
||||||
[assembly: System.Reflection.AssemblyProductAttribute("demo_blagodat")]
|
[assembly: System.Reflection.AssemblyProductAttribute("demo_blagodat")]
|
||||||
[assembly: System.Reflection.AssemblyTitleAttribute("demo_blagodat")]
|
[assembly: System.Reflection.AssemblyTitleAttribute("demo_blagodat")]
|
||||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||||
|
@ -1 +1 @@
|
|||||||
15c2bfa45e197aa1289a0c26d723f2a088b9752d4152eedee31e9c27fdbc6bfd
|
60e5bbf7d18ab8cc5ef27cc140454e6bbb540cd3aab7e9ed7c9eb5da0fe665a0
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user