demo2025_products_tiron_baby/ProductsWindow.axaml.cs

54 lines
1.4 KiB
C#
Raw Normal View History

2025-03-25 12:37:37 +00:00
using Avalonia.Controls;
using Avalonia.Interactivity;
using Microsoft.EntityFrameworkCore;
using tiron_demo.Context;
using tiron_demo.Models;
namespace tiron_demo;
public partial class ProductsWindow : Window
{
public ProductsWindow()
{
InitializeComponent();
Products.ItemsSource = Helper.context.Products.Include(x => x.TypeNavigation).Include(x => x.PartnerProducts);
}
private void Button_Click_Add(object? sender, RoutedEventArgs args)
{
AddProduct productWindow = new AddProduct();
productWindow.Show();
Close();
}
private void Button_Click_Back(object? sender, RoutedEventArgs args)
{
MainWindow mainWindow = new MainWindow();
mainWindow.Show();
Close();
}
private void ListBox_DoubleTapped(object? sender, RoutedEventArgs args)
{
var product = Products.SelectedItem as Product;
if (product != null)
{
AddProduct productWindow = new AddProduct(product);
productWindow.Show();
Close();
}
}
private void Button_Click_History(object? sender, RoutedEventArgs args)
{
if (Products.SelectedItem != null)
{
Product product = Products.SelectedItem as Product;
History history = new History(this, 0, product.Id);
history.Show();
Close();
}
}
}