소스 검색

Изменение приоритета и форма редактирования

Barsik Kato 2 년 전
부모
커밋
920ff426db

+ 2 - 2
Session1/Pages/AgentList.xaml

@@ -8,7 +8,7 @@
       d:DesignHeight="450" d:DesignWidth="600"
       d:DesignHeight="450" d:DesignWidth="600"
       Title="AgentList">
       Title="AgentList">
     <Page.Resources>
     <Page.Resources>
-        <DataTemplate x:Key="lbItem">
+        <DataTemplate x:Key="lbItem" >
             <Border Grid.Row="1" BorderBrush="Black" BorderThickness="1">
             <Border Grid.Row="1" BorderBrush="Black" BorderThickness="1">
                 <StackPanel Background="{Binding AgentBackground}" Height="110" Width="580" Orientation="Horizontal">
                 <StackPanel Background="{Binding AgentBackground}" Height="110" Width="580" Orientation="Horizontal">
                     <Image Source="{Binding AgentImage}" Height="100" Width="100" HorizontalAlignment="Left"/>
                     <Image Source="{Binding AgentImage}" Height="100" Width="100" HorizontalAlignment="Left"/>
@@ -47,7 +47,7 @@
                 <ComboBoxItem>Все типы</ComboBoxItem>
                 <ComboBoxItem>Все типы</ComboBoxItem>
             </ComboBox>
             </ComboBox>
         </StackPanel>
         </StackPanel>
-        <ListBox x:Name="agentList" Grid.Row="1" ItemTemplate="{DynamicResource lbItem}" SelectionChanged="agentList_SelectionChanged"/>
+        <ListBox x:Name="agentList" Grid.Row="1" ItemTemplate="{DynamicResource lbItem}" SelectionChanged="agentList_SelectionChanged" SelectionMode="Extended" MouseDoubleClick="agentList_MouseDoubleClick"></ListBox>
         <StackPanel Grid.Row="2" Orientation="Horizontal">
         <StackPanel Grid.Row="2" Orientation="Horizontal">
             <Button x:Name="addAgent">Добавить</Button>
             <Button x:Name="addAgent">Добавить</Button>
             <Button x:Name="changePriority" Visibility="Hidden" Click="ChangePriority_Click">Изменить приоритет на ...</Button>
             <Button x:Name="changePriority" Visibility="Hidden" Click="ChangePriority_Click">Изменить приоритет на ...</Button>

+ 13 - 1
Session1/Pages/AgentList.xaml.cs

@@ -86,9 +86,21 @@ namespace Session1
 
 
         private void ChangePriority_Click(object sender, RoutedEventArgs e)
         private void ChangePriority_Click(object sender, RoutedEventArgs e)
         {
         {
-            ChangePriority changePriority = new ChangePriority((List<Agent>)agentList.SelectedItems);
+            List<Agent> selectedAgents = new List<Agent>();
+            foreach(Agent agent in agentList.SelectedItems)
+            {
+                selectedAgents.Add(agent);
+            }
+            ChangePriority changePriority = new ChangePriority(selectedAgents);
             changePriority.ShowDialog();
             changePriority.ShowDialog();
             UnitedChange();
             UnitedChange();
         }
         }
+
+        private void agentList_MouseDoubleClick(object sender, MouseButtonEventArgs e)
+        {
+            EditAgent editAgent = new EditAgent((Agent)agentList.SelectedItem);
+            editAgent.ShowDialog();
+            UnitedChange();
+        }
     }
     }
 }
 }

+ 7 - 0
Session1/Session1.csproj

@@ -115,6 +115,9 @@
     <Compile Include="Windows\ChangePriority.xaml.cs">
     <Compile Include="Windows\ChangePriority.xaml.cs">
       <DependentUpon>ChangePriority.xaml</DependentUpon>
       <DependentUpon>ChangePriority.xaml</DependentUpon>
     </Compile>
     </Compile>
+    <Compile Include="Windows\EditAgent.xaml.cs">
+      <DependentUpon>EditAgent.xaml</DependentUpon>
+    </Compile>
     <Page Include="MainWindow.xaml">
     <Page Include="MainWindow.xaml">
       <Generator>MSBuild:Compile</Generator>
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
       <SubType>Designer</SubType>
@@ -136,6 +139,10 @@
       <SubType>Designer</SubType>
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
       <Generator>MSBuild:Compile</Generator>
     </Page>
     </Page>
+    <Page Include="Windows\EditAgent.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
   </ItemGroup>
   </ItemGroup>
   <ItemGroup>
   <ItemGroup>
     <Compile Include="Model1.Context.cs">
     <Compile Include="Model1.Context.cs">

+ 2 - 2
Session1/Windows/ChangePriority.xaml

@@ -8,8 +8,8 @@
         Title="Изменение приоритета" Height="181.968" Width="229.509">
         Title="Изменение приоритета" Height="181.968" Width="229.509">
     <Grid>
     <Grid>
         <StackPanel>
         <StackPanel>
-            <TextBlock x:Name="priorityBox" Width="180" Margin="20"></TextBlock>
-            <Button x:Name="Save" Margin="10" Width="80" Click="Save_Click">Сохранить</Button>
+            <TextBox x:Name="priorityBox" Height="20" Width="180" Margin="0, 20"></TextBox>
+            <Button x:Name="Save" Margin="10" Width="80" Click="Save_Click">Изменить</Button>
             <Button x:Name="Cancel" Width="80" Click="Cancel_Click">Отмена</Button>
             <Button x:Name="Cancel" Width="80" Click="Cancel_Click">Отмена</Button>
         </StackPanel>
         </StackPanel>
     </Grid>
     </Grid>

+ 2 - 1
Session1/Windows/ChangePriority.xaml.cs

@@ -22,8 +22,9 @@ namespace Session1
         List<Agent> selectedAgents = new List<Agent>();
         List<Agent> selectedAgents = new List<Agent>();
         public ChangePriority(List<Agent> selectedAgents)
         public ChangePriority(List<Agent> selectedAgents)
         {
         {
-            this.selectedAgents = selectedAgents;
             InitializeComponent();
             InitializeComponent();
+            this.selectedAgents = selectedAgents;
+            priorityBox.Text = selectedAgents.OrderByDescending(x => x.Priority).First().Priority.ToString();
         }
         }
 
 
         private void Cancel_Click(object sender, RoutedEventArgs e)
         private void Cancel_Click(object sender, RoutedEventArgs e)

+ 59 - 0
Session1/Windows/EditAgent.xaml

@@ -0,0 +1,59 @@
+<Window x:Class="Session1.EditAgent"
+        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:Session1"
+        mc:Ignorable="d"
+        Title="EditAgent" Height="480" Width="800">
+    <Grid>
+        <Grid.ColumnDefinitions>
+            <ColumnDefinition Width="191*"/>
+            <ColumnDefinition Width="227*"/>
+            <ColumnDefinition Width="252*"/>
+        </Grid.ColumnDefinitions>
+        <GroupBox Header="Изображение">
+            <StackPanel Grid.Column="0" VerticalAlignment="Center">
+                <Image x:Name="agentImg" Height="150" Width="150"></Image>
+                <TextBox x:Name="imgPath" Width="150"></TextBox>
+                <Button x:Name="addImage" Width="150">Добавить изображение</Button>
+            </StackPanel>
+        </GroupBox>
+        <GroupBox Header="Основные данные" Grid.Column="1">
+            <StackPanel VerticalAlignment="Center">
+                <GroupBox Header="Наименование">
+                    <TextBox x:Name="agentName" Width="150"></TextBox>
+                </GroupBox>
+                <GroupBox Header="Тип агента">
+                    <ComboBox x:Name="agentType" Width="150"></ComboBox>
+                </GroupBox>
+                <GroupBox Header="Приоритет">
+                    <TextBox x:Name="agentPriority" Width="150"></TextBox>
+                </GroupBox>
+                <GroupBox Header="Адрес">
+                    <TextBox x:Name="agentAddress" Width="150"></TextBox>
+                </GroupBox>
+                <GroupBox Header="ИНН">
+                    <TextBox x:Name="agentINN" Width="150"></TextBox>
+                </GroupBox>
+                <GroupBox Header="КПП">
+                    <TextBox x:Name="agentKPP" Width="150"></TextBox>
+                </GroupBox>
+                <GroupBox Header="Директор">
+                    <TextBox x:Name="agentDirector" Width="150"></TextBox>
+                </GroupBox>
+                <GroupBox Header="Телефон">
+                    <TextBox x:Name="agentPhone" Width="150"></TextBox>
+                </GroupBox>
+                <GroupBox Header="Почта">
+                    <TextBox x:Name="agentEmail" Width="150"></TextBox>
+                </GroupBox>
+                <Button x:Name="save" Click="save_Click">Сохранить</Button>
+                <Button x:Name="cancel" Click="cancel_Click">Отмена</Button>
+            </StackPanel>
+        </GroupBox>
+        <GroupBox Header="История реализации" Grid.Column="2">
+            <ListView x:Name="historyBox"></ListView>
+        </GroupBox>
+    </Grid>
+</Window>

+ 60 - 0
Session1/Windows/EditAgent.xaml.cs

@@ -0,0 +1,60 @@
+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 Session1
+{
+    /// <summary>
+    /// Логика взаимодействия для EditAgent.xaml
+    /// </summary>
+    public partial class EditAgent : Window
+    {
+        Agent selectedAgent;
+        public EditAgent(Agent selectedAgent)
+        {
+            InitializeComponent();
+            this.selectedAgent = selectedAgent;
+            foreach (AgentType type in BaseConnect.baseModel.AgentType)
+            {
+                agentType.Items.Add(type);
+            }
+            agentType.DisplayMemberPath = "Title";
+            LoadAgentData();
+        }
+
+        private void LoadAgentData()
+        {
+            agentImg.Source = new BitmapImage(new Uri(selectedAgent.AgentImage, UriKind.Relative));
+            imgPath.Text = selectedAgent.Logo;
+            agentName.Text = selectedAgent.Title;
+            agentType.SelectedItem = selectedAgent.AgentType;
+            agentPriority.Text = selectedAgent.Priority.ToString();
+            agentAddress.Text = selectedAgent.Address;
+            agentINN.Text = selectedAgent.INN;
+            agentKPP.Text = selectedAgent.KPP;
+            agentPhone.Text = selectedAgent.Phone;
+            agentDirector.Text = selectedAgent.DirectorName;
+            agentEmail.Text = selectedAgent.Email;
+        }
+
+        private void save_Click(object sender, RoutedEventArgs e)
+        {
+
+        }
+
+        private void cancel_Click(object sender, RoutedEventArgs e)
+        {
+            Close();
+        }
+    }
+}