70 lines
2.1 KiB
C#
70 lines
2.1 KiB
C#
using Avalonia;
|
|
using Avalonia.Controls;
|
|
using Avalonia.Media.Imaging;
|
|
using Avalonia.Platform;
|
|
using System.Reflection;
|
|
using System;
|
|
using Agents.Models;
|
|
using System.Collections.ObjectModel;
|
|
using Avalonia.Interactivity;
|
|
using System.Linq;
|
|
using System.Runtime.ExceptionServices;
|
|
using Avalonia.Media;
|
|
|
|
namespace Agents;
|
|
|
|
public partial class AgentEidtor : Window
|
|
{
|
|
static User11Context db = new User11Context();
|
|
ObservableCollection<Agent> AgentsitemSource = new ObservableCollection<Agent>(db.Agents.OrderBy(it => it.Title));
|
|
public AgentEidtor()
|
|
{
|
|
InitializeComponent();
|
|
ListAgents.ItemsSource = AgentsitemSource;
|
|
}
|
|
|
|
private void ListAgents_SelectionChanged(object? sender, Avalonia.Controls.SelectionChangedEventArgs e)
|
|
{
|
|
Agent agent = db.Agents.Where(it => it == ListAgents.SelectedItem).First();
|
|
TextNewPriority.Text = agent.Priority.ToString();
|
|
TextNewInn.Text = agent.Inn;
|
|
TextNewKPP.Text = agent.Kpp;
|
|
TextNewAddress.Text = agent.Address;
|
|
TextNewDirectorname.Text = agent.Directorname;
|
|
TextNewEmail.Text = agent.Email;
|
|
}
|
|
|
|
private void ButtonChange(object sender, RoutedEventArgs e) // èçìåíåíèå äàííûõ
|
|
{
|
|
try
|
|
{
|
|
Agent agent = db.Agents.Where(it => it == ListAgents.SelectedItem).First();
|
|
|
|
float a = float.Parse(TextNewPriority.Text);
|
|
agent.Priority = Convert.ToInt32(a);
|
|
|
|
agent.Inn = TextNewInn.Text;
|
|
agent.Kpp = TextNewKPP.Text;
|
|
agent.Directorname = TextNewDirectorname.Text;
|
|
agent.Address = TextNewAddress.Text;
|
|
agent.Email = TextNewEmail.Text;
|
|
|
|
db.SaveChanges();
|
|
|
|
Status.Foreground = Brushes.White;
|
|
Status.Text = "Äàííûå ïîëüçîâàòåëÿ èçìåíåíû";
|
|
}
|
|
catch
|
|
{
|
|
Status.Foreground = Brushes.Red;
|
|
Status.Text = "Ïðîèçîøëà îøèáêà";
|
|
}
|
|
|
|
}
|
|
|
|
void Exit(object sender, RoutedEventArgs e) // âûõîä
|
|
{
|
|
new MainWindow().Show();
|
|
Close();
|
|
}
|
|
} |