Quellcode durchsuchen

Много чего сделал)

Pavel Nagornev vor 2 Jahren
Ursprung
Commit
d89dd868df

+ 16 - 0
DemoExam/DemoExam.csproj

@@ -64,8 +64,15 @@
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
     </ApplicationDefinition>
+    <Compile Include="Model\DataBase.cs" />
     <Compile Include="Model\PAgent.cs" />
     <Compile Include="ViewModel\ViewModel.cs" />
+    <Compile Include="windows\WindowChangePriority.xaml.cs">
+      <DependentUpon>WindowChangePriority.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="windows\WindowEditAgent.xaml.cs">
+      <DependentUpon>WindowEditAgent.xaml</DependentUpon>
+    </Compile>
     <Page Include="MainWindow.xaml">
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
@@ -82,6 +89,14 @@
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
+    <Page Include="windows\WindowChangePriority.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
+    <Page Include="windows\WindowEditAgent.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
   </ItemGroup>
   <ItemGroup>
     <Compile Include="Model\Agent.cs">
@@ -176,6 +191,7 @@
   </ItemGroup>
   <ItemGroup />
   <ItemGroup>
+    <Resource Include="images\logo.ico" />
     <Resource Include="images\logo.png" />
     <Content Include="Model\Model.Context.tt">
       <Generator>TextTemplatingFileGenerator</Generator>

+ 4 - 2
DemoExam/MainWindow.xaml

@@ -5,7 +5,9 @@
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
         xmlns:local="clr-namespace:DemoExam"
         mc:Ignorable="d"
-        Title="MainWindow" Height="450" Width="800">
+        Title="Приятный шелест" Height="450" Width="800"
+        Icon="images/logo.ico"
+        >
     
     
     
@@ -22,7 +24,7 @@
 
 
         <Image Source="images/logo.png"></Image>
-        <TextBlock Grid.Column="1" FontSize="25" Text="Название" HorizontalAlignment="Center" VerticalAlignment="Center"></TextBlock>
+        <TextBlock Grid.Column="1" FontSize="25" Text="Приятный шелест" HorizontalAlignment="Center" VerticalAlignment="Center"></TextBlock>
         
         <Frame x:Name="pageContener" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2"></Frame>
 

+ 4 - 1
DemoExam/MainWindow.xaml.cs

@@ -1,4 +1,5 @@
-using DemoExam.pages.agents;
+using DemoExam.Model;
+using DemoExam.pages.agents;
 using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -25,6 +26,8 @@ namespace DemoExam
         {
             public static Frame PageContener { get; set; }
         }
+
+       
         public MainWindow()
         {
             InitializeComponent();

+ 4 - 1
DemoExam/Model/Agent.cs

@@ -11,7 +11,8 @@ namespace DemoExam.Model
 {
     using System;
     using System.Collections.Generic;
-    
+    using System.Windows.Input;
+
     public partial class Agent
     {
         [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
@@ -20,6 +21,8 @@ namespace DemoExam.Model
             this.AgentPriorityHistory = new HashSet<AgentPriorityHistory>();
             this.ProductSale = new HashSet<ProductSale>();
             this.Shop = new HashSet<Shop>();
+            ChangeImageBinding = new CommandBinding(ChangeImageCommand);
+            ChangeImageBinding.Executed += ChangeImageFunc;
         }
     
         public int ID { get; set; }

+ 13 - 0
DemoExam/Model/DataBase.cs

@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DemoExam.Model
+{
+    public static class DataBase
+    {
+        public static Entities Base { get; set; } = new Entities();
+    }
+}

+ 110 - 3
DemoExam/Model/PAgent.cs

@@ -1,19 +1,126 @@
-using System;
+using Microsoft.Win32;
+using System;
 using System.Collections.Generic;
+using System.ComponentModel;
+using System.IO;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using System.Windows.Input;
 
 namespace DemoExam.Model
 {
-    partial class Agent
+    partial class Agent:INotifyPropertyChanged
     {
         public int GetCountSaleOnYear
         {
             get
             {
-                En
+                int countSale = 0;
+                var listSale = DataBase.Base.ProductSale.Where(x => x.AgentID == ID);
+                if (listSale != null && listSale.Count() != 0)
+                {
+                    foreach (var item in listSale)
+                    {
+                        if ((DateTime.Now - (DateTime)item.SaleDate).Days < 365)
+                        {
+                            countSale += item.ProductCount;
+                        }
+                    }
+                }
+                return countSale;
             }
         }
+
+        public string GetActualImage
+        {
+            get
+            {
+                string pathImage = Environment.CurrentDirectory + Logo;
+                return pathImage;
+            }
+        }
+
+        public double GetDiscont
+        {
+            get
+            {
+                double discount = 0;
+                double sum = 0;
+                var listSale = DataBase.Base.ProductSale.Where(x => x.AgentID == ID);
+                foreach (var item in listSale)
+                {
+                    sum += Convert.ToDouble(item.ProductCount * item.Product.MinCostForAgent);
+                }
+
+                if (sum >= 0 && sum < 10000)
+                {
+                    discount = 0;
+                }
+                if (sum >= 10000 && sum < 50000)
+                {
+                    discount = 0.05;
+                }
+                if (sum > 50000 && sum < 150000)
+                {
+                    discount = 0.1;
+                }
+                if (sum > 150000 && sum < 500000)
+                {
+                    discount = 0.2;
+                }
+                if (sum > 500000)
+                {
+                    discount = 0.25;
+                }
+                return discount;
+
+            }
+        }
+
+        public string GetDiscountToString
+        {
+            get
+            {
+                return (GetDiscont * 100).ToString() + "%";
+            }
+        }
+
+
+        public bool ChangeBackground
+        {
+            get
+            {
+                if (GetDiscont != 0.25) return false;
+                return true;
+            }
+
+        }
+
+
+
+
+
+        public RoutedCommand ChangeImageCommand { get; } = new RoutedCommand();
+        public CommandBinding ChangeImageBinding;
+
+        public event PropertyChangedEventHandler PropertyChanged;
+
+        public void ChangeImageFunc(object sender, EventArgs e)
+        {
+            string fileName = string.Empty;
+            OpenFileDialog fileDialog = new OpenFileDialog();
+            if (fileDialog.ShowDialog() == true)
+            {
+                fileName = fileDialog.SafeFileName;
+                File.Copy(fileDialog.FileName, Environment.CurrentDirectory + @"\agents\" + fileName, true);
+
+            }
+            Logo = @"\agents\" + fileName;
+            PropertyChanged(this, new PropertyChangedEventArgs("GetActualImage"));
+        }
+
+
+
     }
 }

+ 238 - 3
DemoExam/ViewModel/ViewModel.cs

@@ -1,29 +1,264 @@
 using DemoExam.Model;
+using Microsoft.Win32;
 using System;
 using System.Collections.Generic;
 using System.Collections.ObjectModel;
 using System.ComponentModel;
+using System.IO;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using System.Windows.Input;
 
 namespace DemoExam.ViewModel
 {
-    public class ViewModel:INotifyPropertyChanged
+    public class ViewModel : INotifyPropertyChanged
     {
 
         public event PropertyChangedEventHandler PropertyChanged;
-        public static Entities DataBase = new Entities();
-        private ObservableCollection<Agent> outPutList = new ObservableCollection<Agent>(DataBase.Agent.ToList());
+        public Entities DataBase = new Entities();
+        private ObservableCollection<Agent> outPutList;
 
 
         public ObservableCollection<Agent> GetListAgent
         {
             get
             {
+                if (outPutList == null)
+                {
+                    outPutList = new ObservableCollection<Agent>(DataBase.Agent.ToList());
+                }
                 return outPutList;
             }
         }
 
+
+
+        int setSortIndex;
+        public int SetSortIndex
+        {
+            get
+            {
+                return setSortIndex;
+            }
+            set
+            {
+                setSortIndex = value;
+
+                FiltFunc(setFiltValue);
+                SearchFunc(searchText);
+                SortFunc(setSortIndex);
+                PropertyChanged(this, new PropertyChangedEventArgs("GetListAgent"));
+            }
+        }
+
+        public void SortFunc(int index)
+        {
+            switch (index)
+            {
+                case 0:
+                    outPutList = new ObservableCollection<Agent>(outPutList.OrderBy(x => x.Title));
+                    break;
+                case 1:
+                    outPutList = new ObservableCollection<Agent>(outPutList.OrderBy(x => x.GetDiscont));
+                    break;
+                case 2:
+                    outPutList = new ObservableCollection<Agent>(outPutList.OrderBy(x => x.Priority));
+                    break;
+                case 3:
+                    outPutList = new ObservableCollection<Agent>(outPutList.OrderBy(x => x.Title).Reverse());
+                    break;
+                case 4:
+                    outPutList = new ObservableCollection<Agent>(outPutList.OrderBy(x => x.GetDiscont).Reverse());
+                    break;
+                case 5:
+                    outPutList = new ObservableCollection<Agent>(outPutList.OrderBy(x => x.Priority).Reverse());
+                    break;
+
+            }
+
+        }
+
+
+
+
+        public List<string> GetListTypeAgent
+        {
+            get
+            {
+                List<string> nameAgentType = new List<string>();
+                nameAgentType.Add("Все типы");
+                var temp = DataBase.AgentType;
+                foreach (var item in temp)
+                {
+                    nameAgentType.Add(item.Title);
+                }
+                return nameAgentType;
+            }
+        }
+
+        string setFiltValue = string.Empty;
+        public string SetFiltValue
+        {
+            get
+            {
+                return setFiltValue;
+            }
+            set
+            {
+                setFiltValue = value;
+                FiltFunc(setFiltValue);
+                SearchFunc(searchText);
+                SortFunc(setSortIndex);
+                PropertyChanged(this, new PropertyChangedEventArgs("GetListAgent"));
+            }
+        }
+
+
+        public void FiltFunc(string filtString)
+        {
+            if (filtString == "Все типы" || filtString == "")
+            {
+                outPutList = new ObservableCollection<Agent>(DataBase.Agent.ToList());
+            }
+            else
+            {
+                outPutList = new ObservableCollection<Agent>(outPutList.Where(x => x.AgentType.Title == filtString));
+            }
+
+        }
+
+        string searchText = String.Empty;
+        public string SearchText
+        {
+            get
+            {
+                return searchText;
+            }
+            set
+            {
+                searchText = value;
+                FiltFunc(setFiltValue);
+                SearchFunc(searchText);
+                SortFunc(setSortIndex);
+                PropertyChanged(this, new PropertyChangedEventArgs("GetListAgent"));
+            }
+        }
+
+        public void SearchFunc(string text)
+        {
+            outPutList = new ObservableCollection<Agent>(outPutList.Where(x => x.Title.Contains(text) || x.Email.Contains(text) || x.Phone.Contains(text)));
+        }
+
+
+        List<Agent> selectedAgentsList = new List<Agent>();
+        public void SetSelectedAgents(IList<object> selectedAgents)
+        {
+            selectedAgentsList = new List<Agent>();
+            foreach (var item in selectedAgents)
+            {
+                selectedAgentsList.Add((Agent)item);
+            }
+            PropertyChanged(this, new PropertyChangedEventArgs("IsVisibleButton"));
+        }
+
+        public bool IsVisibleButton
+        {
+            get
+            {
+                if (selectedAgentsList.Count() > 1)
+                {
+                    return true;
+                }
+                return false;
+            }
+        }
+
+
+        int priority = -1;
+        public int GetMaxPriority
+        {
+            get
+            {
+                if (priority == -1)
+                {
+                    if (selectedAgentsList.Count() != 0)
+                    {
+
+                        foreach (var i in selectedAgentsList)
+                        {
+                            if (priority < i.Priority)
+                            {
+                                priority = i.Priority;
+                            }
+                        }
+                        return priority;
+                    }
+                    return priority;
+                }
+                else
+                {
+                    return priority;
+                }
+            }
+
+            set
+            {
+                priority = value;
+            }
+
+        }
+
+
+        public void SetPriority(int value)
+        {
+
+            for (int i = 0; i < selectedAgentsList.Count(); i++)
+            {
+                selectedAgentsList[i].Priority = value;
+            }
+
+        }
+
+        Agent selectedAgent;
+        public Agent SelectedAgent
+        {
+            get
+            {
+                return selectedAgent;
+            }
+            set
+            {
+                selectedAgent = value;
+            }
+        }
+
+
+        string selectedAgentType = string.Empty;
+        public string AgentTypeSelectedAgent
+        {
+            get 
+            {
+                if (selectedAgentType == "")
+                {
+                    return SelectedAgent.AgentType.Title.ToString();
+                }
+                return selectedAgentType;
+            }
+            set
+            {
+                SelectedAgent.AgentTypeID = DataBase.AgentType.FirstOrDefault(x => x.Title == value).ID;
+                selectedAgentType = value;
+            }
+        }
+
+
+
+        public ViewModel()
+        {
+          
+
+        }
+
     }
 }

BIN
DemoExam/images/logo.ico


+ 52 - 4
DemoExam/pages/agents/PageAgents.xaml

@@ -10,9 +10,31 @@
 
     <Page.Resources>
 
+        <Style x:Key="stlStackPanelDiscoind" TargetType="StackPanel">
+            <Style.Triggers>
+                <DataTrigger Binding="{Binding ChangeBackground}" Value="True">
+                    <Setter Property="Background" Value="Green"></Setter>
+                </DataTrigger>
+                <DataTrigger Binding="{Binding ChangeBackground}" Value="False">
+                    <Setter Property="Background" Value="White"></Setter>
+                </DataTrigger>
+            </Style.Triggers>
+        </Style>
+
+        <Style x:Key="stlButtonChange" TargetType="Button">
+            <Style.Triggers>
+                <DataTrigger Binding="{Binding IsVisibleButton}" Value="True">
+                    <Setter Property="Visibility" Value="Visible"/>
+                </DataTrigger>
+                <DataTrigger Binding="{Binding IsVisibleButton}" Value="False">
+                    <Setter Property="Visibility" Value="Collapsed"/>
+                </DataTrigger>
+            </Style.Triggers>
+        </Style>
+        
         <DataTemplate x:Key="listAgentTmpl">
-            <StackPanel Orientation="Horizontal">
-                <Image Width="200" Height="150"></Image>
+            <StackPanel Orientation="Horizontal" Style="{StaticResource stlStackPanelDiscoind}" Width="1000">
+                <Image Source="{Binding GetActualImage}" Width="200" Height="150"></Image>
                 <StackPanel Orientation="Vertical">
                     <StackPanel Orientation="Horizontal">
                         <TextBlock Text="{Binding Path=AgentType.Title}"></TextBlock>
@@ -20,7 +42,7 @@
                         <TextBlock Text="{Binding Path=Title}"></TextBlock>
                     </StackPanel>
                     <StackPanel Orientation="Horizontal">
-                        <TextBlock Text="#количество продаж"></TextBlock>
+                        <TextBlock Text="{Binding GetCountSaleOnYear}"></TextBlock>
                         <TextBlock Text=" продаж за год"></TextBlock>
                     </StackPanel>
                     <StackPanel Orientation="Horizontal">
@@ -31,8 +53,14 @@
                         <TextBlock Text="{Binding Path=Priority}"></TextBlock>
                     </StackPanel>
                 </StackPanel>
+                <StackPanel Orientation="Horizontal" Margin="100,0,0,0">
+                    <TextBlock Text="{Binding GetDiscountToString}"></TextBlock>
+                </StackPanel>
             </StackPanel>
         </DataTemplate>
+
+
+        
     </Page.Resources>
     
     
@@ -43,6 +71,26 @@
         </Grid.RowDefinitions>
 
 
-        <ListBox Grid.Row="1" ItemTemplate="{StaticResource listAgentTmpl}" ItemsSource="{Binding GetListAgent}"></ListBox>
+        <StackPanel Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="Center">
+            <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
+                <ComboBox SelectedIndex="{Binding SetSortIndex}" Width="250" Height="30">
+                    <ComboBoxItem>Название (возростание)</ComboBoxItem>
+                    <ComboBoxItem>Размер скидки (возростание)</ComboBoxItem>
+                    <ComboBoxItem>Приоритет агента (возростание)</ComboBoxItem>
+                    <ComboBoxItem>Название (убывание)</ComboBoxItem>
+                    <ComboBoxItem>Размер скидки (убывание)</ComboBoxItem>
+                    <ComboBoxItem>Приоритет агента (убывание)</ComboBoxItem>
+                </ComboBox>
+                <ComboBox  Width="250" Height="30" ItemsSource="{Binding GetListTypeAgent}" SelectedValue="{Binding SetFiltValue}">
+                </ComboBox>
+                <TextBox Width="250" Height="30" Text="{Binding SearchText}"></TextBox>
+            </StackPanel>
+
+
+            <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
+                <Button Content="Изменить на..." Style="{StaticResource stlButtonChange}" Width="250" Height="30" Click="Button_ChangePriority_Click"></Button>
+            </StackPanel>
+        </StackPanel>
+        <ListBox x:Name="lstAgents" Grid.Row="1" ItemTemplate="{StaticResource listAgentTmpl}" ItemsSource="{Binding GetListAgent}" HorizontalContentAlignment="Center" SelectionMode="Extended" SelectionChanged="lstAgents_SelectionChanged" SelectedItem="{Binding SelectedAgent}" MouseDoubleClick="lstAgents_MouseDoubleClick"></ListBox>
     </Grid>
 </Page>

+ 26 - 1
DemoExam/pages/agents/PageAgents.xaml.cs

@@ -1,4 +1,5 @@
-using System;
+using DemoExam.windows;
+using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
@@ -27,5 +28,29 @@ namespace DemoExam.pages.agents
             DataContext = agentsViewModel;
 
         }
+
+
+
+        private void lstAgents_SelectionChanged(object sender, SelectionChangedEventArgs e)
+        {
+            List<object> listAgents = new List<object>();
+            foreach (var item in lstAgents.SelectedItems)
+            {
+                listAgents.Add(item);
+            }
+            agentsViewModel.SetSelectedAgents(listAgents);
+        }
+
+        private void Button_ChangePriority_Click(object sender, RoutedEventArgs e)
+        {
+            var WindowChangePri = new WindowChangePriority(agentsViewModel);
+            WindowChangePri.ShowDialog();
+        }
+
+        private void lstAgents_MouseDoubleClick(object sender, MouseButtonEventArgs e)
+        {
+            var windowEditAgent = new WindowEditAgent(agentsViewModel);
+            windowEditAgent.ShowDialog();
+        }
     }
 }

+ 20 - 0
DemoExam/windows/WindowChangePriority.xaml

@@ -0,0 +1,20 @@
+<Window x:Class="DemoExam.windows.WindowChangePriority"
+        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+        xmlns:local="clr-namespace:DemoExam.windows"
+        mc:Ignorable="d"
+        Title="Изменение приоритета" Height="170" Width="350"
+        Closed="Window_Closed"
+        >
+    <Grid>
+        <StackPanel Orientation="Vertical" VerticalAlignment="Center" HorizontalAlignment="Center">
+            <StackPanel Orientation="Horizontal">
+                <TextBlock Margin="0,0,50,0">Приоритет</TextBlock>
+                <TextBox Width="150" Text="{Binding GetMaxPriority}"></TextBox>
+            </StackPanel>
+            <Button Margin="0,50,0,0" Click="Button_Click">Сохранить</Button>
+        </StackPanel>
+    </Grid>
+</Window>

+ 45 - 0
DemoExam/windows/WindowChangePriority.xaml.cs

@@ -0,0 +1,45 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Shapes;
+
+namespace DemoExam.windows
+{
+    /// <summary>
+    /// Логика взаимодействия для WindowChangePriority.xaml
+    /// </summary>
+    public partial class WindowChangePriority : Window
+    {
+        ViewModel.ViewModel VM;
+        public WindowChangePriority(ViewModel.ViewModel VM)
+        {
+            InitializeComponent();
+            this.VM = VM;
+            DataContext = VM;
+        }
+
+        private void Button_Click(object sender, RoutedEventArgs e)
+        {
+            VM.SetPriority(VM.GetMaxPriority);
+            VM.DataBase.SaveChanges();
+            MessageBox.Show("Изменения успешно сохранены!");
+            VM.GetMaxPriority = -1;
+            this.Close();
+        }
+
+
+        private void Window_Closed(object sender, EventArgs e)
+        {
+            VM.GetMaxPriority = -1;
+        }
+    }
+}

+ 55 - 0
DemoExam/windows/WindowEditAgent.xaml

@@ -0,0 +1,55 @@
+<Window x:Class="DemoExam.windows.WindowEditAgent"
+        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+        xmlns:local="clr-namespace:DemoExam.windows"
+        mc:Ignorable="d"
+        Title="Настройки агента" Height="650" Width="400"
+        Icon="..\images\logo.ico"
+        
+        MinHeight="650"
+        MaxHeight="650"
+        MinWidth="400"
+        MaxWidth="400"
+        >
+    <Grid>
+        <StackPanel Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="Center">
+            <GroupBox Header="Наименование">
+                <TextBox Width="250" Text="{Binding Path=SelectedAgent.Title}"></TextBox>
+            </GroupBox>
+            <GroupBox Header="Тип агента">
+                <ComboBox ItemsSource="{Binding GetListTypeAgent}" SelectedValue="{Binding AgentTypeSelectedAgent}"></ComboBox>
+            </GroupBox>
+            <GroupBox Header="Приоритет">
+                <TextBox Width="250" Text="{Binding Path=SelectedAgent.Priority}"></TextBox>
+            </GroupBox>
+
+            <StackPanel Orientation="Vertical">
+                <GroupBox Header="Приоритет">
+                    <Image Width="200" Height="150" Source="{Binding Path=SelectedAgent.GetActualImage}"></Image>
+                </GroupBox>
+                <Button Command="{Binding Path = SelectedAgent.ChangeImageCommand}">Загрузить фотографию</Button>
+            </StackPanel>
+            <GroupBox Header="Адрес">
+                <TextBox Width="250" Text="{Binding Path=SelectedAgent.Address}"></TextBox>
+            </GroupBox>
+            <GroupBox Header="ИНН">
+                <TextBox Width="250" Text="{Binding Path=SelectedAgent.INN}"></TextBox>
+            </GroupBox>
+            <GroupBox Header="КПП">
+                <TextBox Width="250" Text="{Binding Path=SelectedAgent.KPP}"></TextBox>
+            </GroupBox>
+            <GroupBox Header="Имя директора">
+                <TextBox Width="250" Text="{Binding Path=SelectedAgent.DirectorName}"></TextBox>
+            </GroupBox>
+            <GroupBox Header="Телефон">
+                <TextBox Width="250" Text="{Binding Path=SelectedAgent.Phone}"></TextBox>
+            </GroupBox>
+            <GroupBox Header="Email">
+                <TextBox Width="250" Text="{Binding Path=SelectedAgent.Email}"></TextBox>
+            </GroupBox>
+            <Button Click="Button_Save_Click">Сохранить</Button>
+        </StackPanel>
+    </Grid>
+</Window>

+ 38 - 0
DemoExam/windows/WindowEditAgent.xaml.cs

@@ -0,0 +1,38 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Shapes;
+
+namespace DemoExam.windows
+{
+    /// <summary>
+    /// Логика взаимодействия для WindowEditAgent.xaml
+    /// </summary>
+    public partial class WindowEditAgent : Window
+    {
+        ViewModel.ViewModel VM;
+        public WindowEditAgent(ViewModel.ViewModel VM)
+        {
+            InitializeComponent();
+            DataContext = VM;
+            this.VM = VM;
+            CommandBindings.Add(VM.SelectedAgent.ChangeImageBinding);
+        }
+
+        private void Button_Save_Click(object sender, RoutedEventArgs e)
+        {
+            VM.DataBase.SaveChanges();
+            MessageBox.Show("Изменения успешно сохранены");
+            this.Close();
+        }
+    }
+}