42 lines
1.3 KiB
C#
42 lines
1.3 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
using Avalonia.Controls;
|
||
using Avalonia.Interactivity;
|
||
using demo_hard.Models;
|
||
|
||
namespace demo_hard;
|
||
|
||
public partial class NewOrderWindow : Window
|
||
{
|
||
|
||
public NewOrderWindow()
|
||
{
|
||
InitializeComponent();
|
||
}
|
||
public NewOrderWindow(Client client, List<Service> selectedServices, int duration )
|
||
{
|
||
InitializeComponent();
|
||
using var context = new User2Context();
|
||
List<int> orderNumbers = new List<int>();
|
||
orderNumbers = new List<int>(context.Orders.Select(o=>o.Id));
|
||
|
||
OrderNumberText.Text = orderNumbers.Count+1.ToString();
|
||
ClientCode.Text = client.ClientCode.ToString();
|
||
TimeOrder.Text = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss");
|
||
FIO.Text = client.Fio;
|
||
Address.Text = client.Address;
|
||
ServicesList.ItemsSource = selectedServices.Select(it => it.ServiceName).ToList();
|
||
var totalcost = selectedServices.Sum(it =>
|
||
{
|
||
var serviceCost = decimal.TryParse(it.ServiceCost, out var cost) ? cost : 0;
|
||
return cost;
|
||
});
|
||
Cost.Text = $"{totalcost}.00 руб.";
|
||
}
|
||
|
||
private void ButtonBack_OnClick(object? sender, RoutedEventArgs e)
|
||
{
|
||
new OrderWindow().ShowDialog(this);
|
||
}
|
||
} |