73 lines
2.1 KiB
C#
73 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 ComboBox_SelectionChanged(object? sender, Avalonia.Controls.SelectionChangedEventArgs e)
|
|||
|
{
|
|||
|
if (sender != null)
|
|||
|
{
|
|||
|
Agent agent = db.Agents.Where(it => it == ListAgents.SelectedItem).FirstOrDefault();
|
|||
|
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 ButtonUpdate(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.Green;
|
|||
|
Status.Text = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><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();
|
|||
|
}
|
|||
|
}
|