diff --git a/.idea/.idea.demofinish/.idea/avalonia.xml b/.idea/.idea.demofinish/.idea/avalonia.xml
index 554c529..157ea80 100644
--- a/.idea/.idea.demofinish/.idea/avalonia.xml
+++ b/.idea/.idea.demofinish/.idea/avalonia.xml
@@ -7,6 +7,7 @@
+
diff --git a/demofinish/EditWindow.axaml b/demofinish/EditWindow.axaml
index 7663c28..3ee1120 100644
--- a/demofinish/EditWindow.axaml
+++ b/demofinish/EditWindow.axaml
@@ -4,6 +4,43 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="demofinish.EditWindow"
+ x:CompileBindings="False"
Title="EditWindow">
- Welcome to Avalonia!
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/demofinish/EditWindow.axaml.cs b/demofinish/EditWindow.axaml.cs
index e33679e..665ec91 100644
--- a/demofinish/EditWindow.axaml.cs
+++ b/demofinish/EditWindow.axaml.cs
@@ -1,13 +1,102 @@
+using System.Linq;
using Avalonia;
using Avalonia.Controls;
+using Avalonia.Interactivity;
using Avalonia.Markup.Xaml;
+using demofinish.Models;
+using Avalonia.Controls.ApplicationLifetimes;
+using System;
namespace demofinish;
public partial class EditWindow : Window
{
+ private readonly MainWindow.AgentPresenter _selectedAgent;
+ private readonly User1Context _context;
+
public EditWindow()
{
InitializeComponent();
}
+
+ public EditWindow(MainWindow.AgentPresenter selectedAgent) : this()
+ {
+ _selectedAgent = selectedAgent;
+ _context = new User1Context();
+
+ InitializeComponent();
+ LoadAgentData();
+ }
+
+ private void LoadAgentData()
+ {
+
+ NameBox.Text = _selectedAgent.Title;
+ AdressBox.Text = _selectedAgent.Address;
+ PhoneBox.Text = _selectedAgent.Phone;
+ EmailBox.Text = _selectedAgent.Email;
+ InnBox.Text = _selectedAgent.Inn;
+ KppBox.Text = _selectedAgent.Kpp;
+ BossNameBox.Text = _selectedAgent.Directorname;
+ PriorityBox.Text = _selectedAgent.Priority.ToString();
+
+
+ var agentTypes = _context.Agenttypes.ToList();
+ AgentTypeBox.ItemsSource = agentTypes;
+
+
+ var currentType = agentTypes.FirstOrDefault(at => at.Id == _selectedAgent.Agenttypeid);
+ AgentTypeBox.SelectedItem = currentType;
+ }
+
+ private void BackButton(object? sender, RoutedEventArgs e)
+ {
+ Close();
+ }
+
+ private async void EditAgent_Button(object? sender, RoutedEventArgs e)
+ {
+
+
+ _selectedAgent.Title = NameBox.Text;
+ _selectedAgent.Address = AdressBox.Text;
+ _selectedAgent.Phone = PhoneBox.Text;
+ _selectedAgent.Email = EmailBox.Text;
+ _selectedAgent.Inn = InnBox.Text;
+ _selectedAgent.Kpp = KppBox.Text;
+ _selectedAgent.Directorname = BossNameBox.Text;
+
+ if (int.TryParse(PriorityBox.Text, out int priority))
+ {
+ _selectedAgent.Priority = priority;
+ }
+
+
+
+ if (AgentTypeBox.SelectedItem is Agenttype selectedType)
+ {
+ _selectedAgent.Agenttypeid = selectedType.Id;
+ }
+
+
+ var dbAgent = _context.Agents.FirstOrDefault(a => a.Id == _selectedAgent.Id);
+ if (dbAgent != null)
+ {
+ dbAgent.Title = _selectedAgent.Title;
+ dbAgent.Address = _selectedAgent.Address;
+ dbAgent.Phone = _selectedAgent.Phone;
+ dbAgent.Email = _selectedAgent.Email;
+ dbAgent.Inn = _selectedAgent.Inn;
+ dbAgent.Kpp = _selectedAgent.Kpp;
+ dbAgent.Directorname = _selectedAgent.Directorname;
+ dbAgent.Priority = _selectedAgent.Priority;
+ dbAgent.Agenttypeid = _selectedAgent.Agenttypeid;
+
+ await _context.SaveChangesAsync();
+
+
+ Close();
+ }
+ }
+
}
\ No newline at end of file
diff --git a/demofinish/MainWindow.axaml b/demofinish/MainWindow.axaml
index 49a2c2f..4c20c6f 100644
--- a/demofinish/MainWindow.axaml
+++ b/demofinish/MainWindow.axaml
@@ -9,7 +9,10 @@
-
+
+
+
+
@@ -45,7 +48,7 @@
-
+
diff --git a/demofinish/MainWindow.axaml.cs b/demofinish/MainWindow.axaml.cs
index 172d69d..a40a94d 100644
--- a/demofinish/MainWindow.axaml.cs
+++ b/demofinish/MainWindow.axaml.cs
@@ -241,5 +241,15 @@ namespace demofinish
{
new AddAgent_Window().ShowDialog(this);
}
+
+ private void AgentListBox_OnSelectionChanged(object? sender, SelectionChangedEventArgs e)
+ {
+ if (AgentListBox.SelectedItem is AgentPresenter selectedAgent)
+ {
+ var editWindow = new EditWindow(selectedAgent);
+ editWindow.ShowDialog(this);
+
+ }
+ }
}
}
\ No newline at end of file
diff --git a/demofinish/Models/Agent.cs b/demofinish/Models/Agent.cs
index e659a7a..fb50ec0 100644
--- a/demofinish/Models/Agent.cs
+++ b/demofinish/Models/Agent.cs
@@ -10,7 +10,7 @@ public partial class Agent
{
public int Id { get; set; }
- public string Title { get; set; } = null!;
+ public string? Title { get; set; } = null!;
public int Agenttypeid { get; set; }
diff --git a/demofinish/Product.axaml b/demofinish/Product.axaml
deleted file mode 100644
index c0342eb..0000000
--- a/demofinish/Product.axaml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
\ No newline at end of file
diff --git a/demofinish/Product.axaml.cs b/demofinish/Product.axaml.cs
deleted file mode 100644
index b512e27..0000000
--- a/demofinish/Product.axaml.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-using Avalonia.Controls;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace demofinish
-{
- public partial class Product : Window
- {
- public Product()
- {
- InitializeComponent();
- }
- }
-}
diff --git a/demofinish/bin/Debug/net8.0/demofinish.dll b/demofinish/bin/Debug/net8.0/demofinish.dll
index 354e001..68764a4 100644
Binary files a/demofinish/bin/Debug/net8.0/demofinish.dll and b/demofinish/bin/Debug/net8.0/demofinish.dll differ
diff --git a/demofinish/bin/Debug/net8.0/demofinish.exe b/demofinish/bin/Debug/net8.0/demofinish.exe
index ac1886e..51363bd 100644
Binary files a/demofinish/bin/Debug/net8.0/demofinish.exe and b/demofinish/bin/Debug/net8.0/demofinish.exe differ
diff --git a/demofinish/bin/Debug/net8.0/demofinish.pdb b/demofinish/bin/Debug/net8.0/demofinish.pdb
index e877715..d514a6e 100644
Binary files a/demofinish/bin/Debug/net8.0/demofinish.pdb and b/demofinish/bin/Debug/net8.0/demofinish.pdb differ
diff --git a/demofinish/obj/Debug/net8.0/Avalonia/Resources.Inputs.cache b/demofinish/obj/Debug/net8.0/Avalonia/Resources.Inputs.cache
index 88600d3..11a50a2 100644
--- a/demofinish/obj/Debug/net8.0/Avalonia/Resources.Inputs.cache
+++ b/demofinish/obj/Debug/net8.0/Avalonia/Resources.Inputs.cache
@@ -1 +1 @@
-4beb2b980d074404d0ba635d434440b61c4fc94b2b026606a450646029801330
+fdd6aec688d5c63eb81de35eaccb215d250e623e506a16f54b2f7bc8e848834f
diff --git a/demofinish/obj/Debug/net8.0/Avalonia/demofinish.dll b/demofinish/obj/Debug/net8.0/Avalonia/demofinish.dll
index 354e001..68764a4 100644
Binary files a/demofinish/obj/Debug/net8.0/Avalonia/demofinish.dll and b/demofinish/obj/Debug/net8.0/Avalonia/demofinish.dll differ
diff --git a/demofinish/obj/Debug/net8.0/Avalonia/demofinish.pdb b/demofinish/obj/Debug/net8.0/Avalonia/demofinish.pdb
index e877715..d514a6e 100644
Binary files a/demofinish/obj/Debug/net8.0/Avalonia/demofinish.pdb and b/demofinish/obj/Debug/net8.0/Avalonia/demofinish.pdb differ
diff --git a/demofinish/obj/Debug/net8.0/Avalonia/resources b/demofinish/obj/Debug/net8.0/Avalonia/resources
index f47c63e..9cfa68e 100644
Binary files a/demofinish/obj/Debug/net8.0/Avalonia/resources and b/demofinish/obj/Debug/net8.0/Avalonia/resources differ
diff --git a/demofinish/obj/Debug/net8.0/apphost.exe b/demofinish/obj/Debug/net8.0/apphost.exe
index ac1886e..51363bd 100644
Binary files a/demofinish/obj/Debug/net8.0/apphost.exe and b/demofinish/obj/Debug/net8.0/apphost.exe differ
diff --git a/demofinish/obj/Debug/net8.0/demofinish.AssemblyInfo.cs b/demofinish/obj/Debug/net8.0/demofinish.AssemblyInfo.cs
index 585b10a..b783d64 100644
--- a/demofinish/obj/Debug/net8.0/demofinish.AssemblyInfo.cs
+++ b/demofinish/obj/Debug/net8.0/demofinish.AssemblyInfo.cs
@@ -13,7 +13,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("demofinish")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
-[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+90bb8777172395f69e346d10fc0a2c18a084d30f")]
+[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+8c009e6908c827bf6a1d1272b6019949a641ac9c")]
[assembly: System.Reflection.AssemblyProductAttribute("demofinish")]
[assembly: System.Reflection.AssemblyTitleAttribute("demofinish")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
diff --git a/demofinish/obj/Debug/net8.0/demofinish.AssemblyInfoInputs.cache b/demofinish/obj/Debug/net8.0/demofinish.AssemblyInfoInputs.cache
index cf8bdc8..8c80b07 100644
--- a/demofinish/obj/Debug/net8.0/demofinish.AssemblyInfoInputs.cache
+++ b/demofinish/obj/Debug/net8.0/demofinish.AssemblyInfoInputs.cache
@@ -1 +1 @@
-91f9c82542ea7ce88c75b51ac0884916ce99761483acd5d6f9fe30f69a84a69a
+af193fa632a0477765702f8f317fecad5f881bbfcdd590732dcd8277d098e7e3
diff --git a/demofinish/obj/Debug/net8.0/demofinish.GeneratedMSBuildEditorConfig.editorconfig b/demofinish/obj/Debug/net8.0/demofinish.GeneratedMSBuildEditorConfig.editorconfig
index 35e51f6..6223a48 100644
--- a/demofinish/obj/Debug/net8.0/demofinish.GeneratedMSBuildEditorConfig.editorconfig
+++ b/demofinish/obj/Debug/net8.0/demofinish.GeneratedMSBuildEditorConfig.editorconfig
@@ -32,6 +32,3 @@ build_metadata.AdditionalFiles.SourceItemGroup = AvaloniaXaml
[C:/Users/prdb/RiderProjects/demka/demofinish/MainWindow.axaml]
build_metadata.AdditionalFiles.SourceItemGroup = AvaloniaXaml
-
-[C:/Users/prdb/RiderProjects/demka/demofinish/Product.axaml]
-build_metadata.AdditionalFiles.SourceItemGroup = AvaloniaXaml
diff --git a/demofinish/obj/Debug/net8.0/demofinish.csproj.CoreCompileInputs.cache b/demofinish/obj/Debug/net8.0/demofinish.csproj.CoreCompileInputs.cache
index b36fcf0..ebf00e3 100644
--- a/demofinish/obj/Debug/net8.0/demofinish.csproj.CoreCompileInputs.cache
+++ b/demofinish/obj/Debug/net8.0/demofinish.csproj.CoreCompileInputs.cache
@@ -1 +1 @@
-794db34d271b78dc26eb8952122868bffa04252fc220655d145e0e2c17e7029c
+acc396a0a6e37aaf884563d01dbdce926298067eebc03e206ee5e786c68604ef
diff --git a/demofinish/obj/Debug/net8.0/demofinish.dll b/demofinish/obj/Debug/net8.0/demofinish.dll
index e292b9b..4c649b0 100644
Binary files a/demofinish/obj/Debug/net8.0/demofinish.dll and b/demofinish/obj/Debug/net8.0/demofinish.dll differ
diff --git a/demofinish/obj/Debug/net8.0/demofinish.pdb b/demofinish/obj/Debug/net8.0/demofinish.pdb
index bd89180..3dabc57 100644
Binary files a/demofinish/obj/Debug/net8.0/demofinish.pdb and b/demofinish/obj/Debug/net8.0/demofinish.pdb differ
diff --git a/demofinish/obj/Debug/net8.0/ref/demofinish.dll b/demofinish/obj/Debug/net8.0/ref/demofinish.dll
index 251087d..8e210af 100644
Binary files a/demofinish/obj/Debug/net8.0/ref/demofinish.dll and b/demofinish/obj/Debug/net8.0/ref/demofinish.dll differ
diff --git a/demofinish/obj/Debug/net8.0/refint/Avalonia/demofinish.dll b/demofinish/obj/Debug/net8.0/refint/Avalonia/demofinish.dll
index 251087d..8e210af 100644
Binary files a/demofinish/obj/Debug/net8.0/refint/Avalonia/demofinish.dll and b/demofinish/obj/Debug/net8.0/refint/Avalonia/demofinish.dll differ
diff --git a/demofinish/obj/Debug/net8.0/refint/demofinish.dll b/demofinish/obj/Debug/net8.0/refint/demofinish.dll
index a7580ec..f611877 100644
Binary files a/demofinish/obj/Debug/net8.0/refint/demofinish.dll and b/demofinish/obj/Debug/net8.0/refint/demofinish.dll differ
diff --git a/demofinish/obj/rider.project.model.nuget.info b/demofinish/obj/rider.project.model.nuget.info
index 4ece931..8f199b2 100644
--- a/demofinish/obj/rider.project.model.nuget.info
+++ b/demofinish/obj/rider.project.model.nuget.info
@@ -1 +1 @@
-17434938584649473
\ No newline at end of file
+17434938679777777
\ No newline at end of file