new_demo/NewOrderWindow.axaml.cs
2025-03-09 17:00:49 +03:00

42 lines
1.3 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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);
}
}