Ver Fonte

Вывод списка агентов

Валерия Семенова há 2 anos atrás
pai
commit
04358768ba

+ 37 - 2
PleasantRustle/Add.xaml

@@ -5,8 +5,43 @@
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
         xmlns:local="clr-namespace:PleasantRustle"
         xmlns:local="clr-namespace:PleasantRustle"
         mc:Ignorable="d"
         mc:Ignorable="d"
-        Title="Добавление агента" Height="450" Width="800">
+        Title="Добавление агента" MinWidth="300" MinHeight="680">
     <Grid>
     <Grid>
-        
+        <StackPanel>
+            <GroupBox Header="Наименование агента" BorderBrush="#FF46B29D" FontFamily="Monotype Corsiva" FontSize="18">
+                <TextBox/>
+            </GroupBox>
+            <GroupBox Header="Тип агента" BorderBrush="#FF46B29D" FontFamily="Monotype Corsiva" FontSize="18">
+                <ComboBox/>
+            </GroupBox>
+            <GroupBox Header="Юридический адресс" BorderBrush="#FF46B29D" FontFamily="Monotype Corsiva" FontSize="18">
+                <TextBox/>
+            </GroupBox>
+            <GroupBox Header="ИНН" BorderBrush="#FF46B29D" FontFamily="Monotype Corsiva" FontSize="18">
+                <TextBox/>
+            </GroupBox>
+            <GroupBox Header="КПП" BorderBrush="#FF46B29D" FontFamily="Monotype Corsiva" FontSize="18">
+                <TextBox/>
+            </GroupBox>
+            <GroupBox Header="Директор" BorderBrush="#FF46B29D" FontFamily="Monotype Corsiva" FontSize="18">
+                <TextBox/>
+            </GroupBox>
+            <GroupBox Header="Телефон агента" BorderBrush="#FF46B29D" FontFamily="Monotype Corsiva" FontSize="18">
+                <TextBox/>
+            </GroupBox>
+            <GroupBox Header="Электронная почта агента" BorderBrush="#FF46B29D" FontFamily="Monotype Corsiva" FontSize="18">
+                <TextBox/>
+            </GroupBox>
+            <GroupBox Header="Логотип агента" BorderBrush="#FF46B29D" FontFamily="Monotype Corsiva" FontSize="18">
+                <Button Content="Загрузить логотип агента" Background="#FF46B29D" BorderBrush="{x:Null}" Foreground="White" FontFamily="Monotype Corsiva" FontSize="18"/>
+            </GroupBox>
+            <GroupBox Header="Приоритет" BorderBrush="#FF46B29D" FontFamily="Monotype Corsiva" FontSize="18">
+                <TextBox/>
+            </GroupBox>
+            <StackPanel>
+                <Button Content="Готово" Background="#FF46B29D" BorderBrush="{x:Null}" Foreground="White" FontFamily="Monotype Corsiva" FontSize="18" Margin="50,20"/>
+                <Button Content="Назад" Background="#FF46B29D" BorderBrush="{x:Null}" Foreground="White" FontFamily="Monotype Corsiva" FontSize="18" Margin="50,0"/>
+            </StackPanel>
+        </StackPanel>
     </Grid>
     </Grid>
 </Window>
 </Window>

+ 1 - 1
PleasantRustle/MainWindow.xaml

@@ -5,7 +5,7 @@
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
         xmlns:local="clr-namespace:PleasantRustle"
         xmlns:local="clr-namespace:PleasantRustle"
         mc:Ignorable="d"
         mc:Ignorable="d"
-        Title="Приятный шелест" Height="450" Width="800" FontFamily="Monotype Corsiva" MinWidth="890" MinHeight="830">
+        Title="Приятный шелест" Width="800" FontFamily="Monotype Corsiva" MinWidth="890" MinHeight="830">
     <Grid>
     <Grid>
         <Grid.RowDefinitions>
         <Grid.RowDefinitions>
             <RowDefinition Height="100"/>
             <RowDefinition Height="100"/>

+ 5 - 5
PleasantRustle/Pages/Main.xaml

@@ -46,14 +46,14 @@
             <RowDefinition Height="1*"/>
             <RowDefinition Height="1*"/>
         </Grid.RowDefinitions>
         </Grid.RowDefinitions>
         <StackPanel Orientation="Horizontal" Margin="0,10">
         <StackPanel Orientation="Horizontal" Margin="0,10">
-            <TextBox x:Name="Search"  Width="390" Height="20" Margin="5,0" Loaded="TextBox_Loaded"/>
+            <TextBox x:Name="Search"  Width="390" Height="20" Margin="5,0" TextChanged="Search_TextChanged"/>
             <ComboBox Width="190" Height="20" Margin="5,0" SelectionChanged="ComboBox_SelectionChanged">
             <ComboBox Width="190" Height="20" Margin="5,0" SelectionChanged="ComboBox_SelectionChanged">
-                <ComboBoxItem Content="Наименование (по убыванию)" FontFamily="Monotype Corsiva" FontSize="18"/>
                 <ComboBoxItem Content="Наименование (по возрастанию)" FontFamily="Monotype Corsiva" FontSize="18"/>
                 <ComboBoxItem Content="Наименование (по возрастанию)" FontFamily="Monotype Corsiva" FontSize="18"/>
-                <ComboBoxItem Content="Размер скидки (по убыванию)" FontFamily="Monotype Corsiva" FontSize="18"/>
+                <ComboBoxItem Content="Наименование (по убыванию)" FontFamily="Monotype Corsiva" FontSize="18"/>
                 <ComboBoxItem Content="Размер скидки (по возрастанию)" FontFamily="Monotype Corsiva" FontSize="18"/>
                 <ComboBoxItem Content="Размер скидки (по возрастанию)" FontFamily="Monotype Corsiva" FontSize="18"/>
-                <ComboBoxItem Content="Приоритет (по убыванию)" FontFamily="Monotype Corsiva" FontSize="18"/>
+                <ComboBoxItem Content="Размер скидки (по убыванию)" FontFamily="Monotype Corsiva" FontSize="18"/>
                 <ComboBoxItem Content="Приоритет (по возрастанию)" FontFamily="Monotype Corsiva" FontSize="18"/>
                 <ComboBoxItem Content="Приоритет (по возрастанию)" FontFamily="Monotype Corsiva" FontSize="18"/>
+                <ComboBoxItem Content="Приоритет (по убыванию)" FontFamily="Monotype Corsiva" FontSize="18"/>
             </ComboBox>
             </ComboBox>
             <ComboBox Width="190" Height="20" Margin="5,0" SelectionChanged="ComboBox_SelectionChanged_1">
             <ComboBox Width="190" Height="20" Margin="5,0" SelectionChanged="ComboBox_SelectionChanged_1">
                 <ComboBoxItem Content="Все типы" FontFamily="Monotype Corsiva" FontSize="18"/>
                 <ComboBoxItem Content="Все типы" FontFamily="Monotype Corsiva" FontSize="18"/>
@@ -67,7 +67,7 @@
         </StackPanel>
         </StackPanel>
         <ListBox x:Name="listboxPleasant" Grid.Row="1" ItemTemplate="{StaticResource PleasantRustleInfo}"/>
         <ListBox x:Name="listboxPleasant" Grid.Row="1" ItemTemplate="{StaticResource PleasantRustleInfo}"/>
         <StackPanel Grid.Row="2">
         <StackPanel Grid.Row="2">
-            <Button x:Name="buttonAdd" Click="buttonAdd_Click" Content="Добавить агента" Margin="50,10,50,0" Background="White" BorderBrush="#FF46B29D" FontFamily="Monotype Corsiva" FontSize="18"/>
+            <Button x:Name="buttonAdd" Click="buttonAdd_Click" Content="Добавить агента" Margin="50,10,50,0" Background="#FF46B29D" BorderBrush="{x:Null}" Foreground="White" FontFamily="Monotype Corsiva" FontSize="18"/>
         </StackPanel>
         </StackPanel>
     </Grid>
     </Grid>
 </Page>
 </Page>

+ 49 - 6
PleasantRustle/Pages/Main.xaml.cs

@@ -32,25 +32,68 @@ namespace PleasantRustle.Pages
             InitializeComponent();
             InitializeComponent();
             listboxPleasant.ItemsSource = agents;
             listboxPleasant.ItemsSource = agents;
         }
         }
-        private void TextBox_Loaded(object sender, RoutedEventArgs e)
-        {           
-
+        private void Search_TextChanged(object sender, TextChangedEventArgs e)
+        {
+            if (Search.Text != "")
+            {
+                List<Agent> agents1 = agents.Where(x => x.Title.Contains(Search.Text)).ToList();
+                listboxPleasant.ItemsSource = agents1;
+            }
+            else
+            {
+                listboxPleasant.ItemsSource = agents;
+            }
         }
         }
 
 
         private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
         private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
         {
         {
-            
+            ComboBox comboBox = sender as ComboBox;
+            switch (comboBox.SelectedIndex)
+            {
+                case 0:
+                    agents = agents.OrderBy(x => x.Title).ToList();
+                    break;
+                case 1:
+                    agents = agents.OrderBy(x => x.Title).ToList();
+                    agents.Reverse();
+                    break;
+                case 2:
+                    agents = agents.OrderBy(x => x.Title).ToList();
+                    break;
+                case 3:
+                    agents = agents.OrderBy(x => x.Title).ToList();
+                    agents.Reverse();
+                    break;
+                case 4:
+                    agents = agents.OrderBy(x => x.Priority).ToList();
+                    break;
+                case 5:
+                    agents = agents.OrderBy(x => x.Priority).ToList();
+                    agents.Reverse();
+                    break;
+            }
         }
         }
 
 
         private void ComboBox_SelectionChanged_1(object sender, SelectionChangedEventArgs e)
         private void ComboBox_SelectionChanged_1(object sender, SelectionChangedEventArgs e)
         {
         {
-            
+            ComboBox comboBox = sender as ComboBox;
+            int agentType = (int)comboBox.SelectedIndex+1;
+            if (agentType != 1)
+            {
+                List<Agent> agents1 = agents.Where(x => x.AgentTypeID == agentType).ToList();
+                listboxPleasant.ItemsSource = agents1;
+            }
+            else
+            {
+                listboxPleasant.ItemsSource = agents;
+            }
+
         }
         }
 
 
         private void buttonAdd_Click(object sender, RoutedEventArgs e)
         private void buttonAdd_Click(object sender, RoutedEventArgs e)
         {
         {
             Add add = new Add();
             Add add = new Add();
             add.ShowDialog();
             add.ShowDialog();
-        }
+        }       
     }
     }
 }
 }