DemoService/ServiceWindow.axaml.cs

46 lines
1.1 KiB
C#
Raw Normal View History

2024-09-04 09:08:53 +00:00
using Avalonia;
using Avalonia.Controls;
2024-09-05 13:11:39 +00:00
using Avalonia.Interactivity;
2024-09-04 09:08:53 +00:00
using Avalonia.Markup.Xaml;
2024-09-05 13:11:39 +00:00
using DemoService.Models;
2024-09-04 09:08:53 +00:00
namespace DemoService;
public partial class ServiceWindow : Window
{
2024-09-05 13:11:39 +00:00
private readonly bool AdminMode;
2024-09-04 09:08:53 +00:00
public ServiceWindow()
{
InitializeComponent();
2024-09-05 13:11:39 +00:00
ServicesListBox.ItemsSource = Utils.Context.Services;
2024-09-04 09:08:53 +00:00
}
public ServiceWindow(bool admin)
{
InitializeComponent();
2024-09-05 13:11:39 +00:00
AdminMode = admin;
if (!admin)
{
AddButton.IsVisible = false;
}
ServicesListBox.ItemsSource = Utils.Context.Services;
foreach (var service in ServicesListBox.ItemsSource)
{
}
}
public void AddButtonClick(object sender, RoutedEventArgs args)
{
AddEditWindow addEditWindow = new();
addEditWindow.Show();
Close();
}
private decimal? CostAfterDiscount(decimal previousCost, decimal? discount)
{
if (discount.HasValue || discount != 0)
{
decimal actualCost = previousCost - previousCost * discount.Value;
return actualCost;
}
return null;
2024-09-04 09:08:53 +00:00
}
}