61 lines
1.8 KiB
C#
61 lines
1.8 KiB
C#
|
using Agents.Models;
|
|||
|
using Avalonia;
|
|||
|
using Avalonia.Controls;
|
|||
|
using Avalonia.Interactivity;
|
|||
|
using Avalonia.Markup.Xaml;
|
|||
|
using Avalonia.Media;
|
|||
|
using System;
|
|||
|
using System.Collections.ObjectModel;
|
|||
|
using System.Linq;
|
|||
|
|
|||
|
namespace Agents;
|
|||
|
|
|||
|
public partial class ProductEditor : Window
|
|||
|
{
|
|||
|
static User11Context db = new User11Context();
|
|||
|
ObservableCollection<Product> products = new ObservableCollection<Product>(db.Products);
|
|||
|
public ProductEditor()
|
|||
|
{
|
|||
|
InitializeComponent();
|
|||
|
ListProducts.ItemsSource = products;
|
|||
|
}
|
|||
|
private void ComboBox_SelectionChanged(object? sender, Avalonia.Controls.SelectionChangedEventArgs e)
|
|||
|
{
|
|||
|
Product product = db.Products.Where(it=>it == ListProducts.SelectedItem).FirstOrDefault();
|
|||
|
TextNewProductionpersoncount.Text = product.Productionpersoncount.ToString();
|
|||
|
TextNewArticlenumber.Text = product.Articlenumber.ToString();
|
|||
|
TextNewMincostforagent.Text = product.Mincostforagent.ToString();
|
|||
|
}
|
|||
|
|
|||
|
private void ButtonUpdate(object sender, RoutedEventArgs e)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
Product product = db.Products.Where(it => it == ListProducts.SelectedItem).First();
|
|||
|
|
|||
|
float a = float.Parse(TextNewProductionpersoncount.Text);
|
|||
|
product.Productionpersoncount = Convert.ToInt32(a);
|
|||
|
|
|||
|
product.Articlenumber = TextNewArticlenumber.Text;
|
|||
|
|
|||
|
float i = float.Parse(TextNewMincostforagent.Text);
|
|||
|
product.Mincostforagent = Convert.ToInt32(i);
|
|||
|
db.SaveChanges();
|
|||
|
|
|||
|
Status.Foreground = Brushes.Green;
|
|||
|
Status.Text = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
|
|||
|
}
|
|||
|
catch
|
|||
|
{
|
|||
|
Status.Foreground = Brushes.Red;
|
|||
|
Status.Text = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
void Exit(object sender, RoutedEventArgs e)
|
|||
|
{
|
|||
|
new MainWindow().Show();
|
|||
|
Close();
|
|||
|
}
|
|||
|
}
|