瀏覽代碼

Поиск

y.buzueva2002 2 年之前
父節點
當前提交
4d93353888
共有 4 個文件被更改,包括 38 次插入8 次删除
  1. 1 1
      BuzuevaDemo/App.xaml
  2. 3 1
      BuzuevaDemo/Classes/ViewModel.cs
  3. 21 6
      BuzuevaDemo/Pages/Agents.xaml
  4. 13 0
      BuzuevaDemo/Pages/Agents.xaml.cs

+ 1 - 1
BuzuevaDemo/App.xaml

@@ -12,7 +12,7 @@
             <Setter Property="FontFamily" Value="Monotype Corsiva"/>
         </Style>
 
-        <Style TargetType="TextBlock">
+        <Style TargetType="ComboBox">
             <Setter Property="FontFamily" Value="Monotype Corsiva"/>
         </Style>
     </Application.Resources>

+ 3 - 1
BuzuevaDemo/Classes/ViewModel.cs

@@ -23,14 +23,16 @@ namespace BuzuevaDemo.Classes
             List<Product> bdproduct = DataBase.BaseModel.Product.ToList();
             foreach (Agent bda in bdagent)
             {
+                //извлечение данных тип агента
                 AgentType AT = DataBase.BaseModel.AgentType.FirstOrDefault(x => x.ID == bda.AgentTypeID);
-                bda.TitleType = AT.Title;
+                bda.TitleType = AT.Title; 
                 int skid = 0;
                 buffag = new Agent();
                 buffag.Title = bda.Title;
                 buffag.Phone = bda.Phone;
                 buffag.Priority = bda.Priority;
                 buffag.Logo = bda.Logo;
+                // картинка-загушка
                 if (bda.Logo == "")
                 {
                     bda.Logo = "/agents/picture.png";

+ 21 - 6
BuzuevaDemo/Pages/Agents.xaml

@@ -5,7 +5,7 @@
       xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
       xmlns:local="clr-namespace:BuzuevaDemo.Pages"
       mc:Ignorable="d" 
-      d:DesignHeight="450" d:DesignWidth="800"
+      d:DesignHeight="450" d:DesignWidth="800" 
       Title="Агенты">
     <Page.Resources>
         <DataTemplate x:Key="AllAgent">
@@ -35,16 +35,31 @@
     </Page.Resources>
     <Grid>
         <Grid.RowDefinitions>
-            <RowDefinition Height="64*"/>
+            <RowDefinition Height="64"/>
             <RowDefinition Height="363*"/>
             <RowDefinition Height="23*"/>
         </Grid.RowDefinitions>
-        <StackPanel Orientation="Horizontal" Grid.Row="0" HorizontalAlignment="Stretch" VerticalAlignment="Center" Background="#C6D7FF">
+        <StackPanel Orientation="Horizontal" Grid.Row="0" HorizontalAlignment="Stretch" VerticalAlignment="Center" Background="#C6D7FF" >
             <GroupBox Header="Введите для поиска" Width="300">
-                <TextBox Height="40"/>
+                <TextBox x:Name="poisk" Height="40" TextChanged="Changeg" />
             </GroupBox>
-            <ComboBox  Width="200" Margin="10, 5" Height="40"/>
-            <ComboBox  Width="200" Margin="10, 5" Height="40"/>
+            <ComboBox x:Name="sort" Width="200" Margin="10, 5" Height="40">
+                <TextBlock>Наименование (возр.)</TextBlock>
+                <TextBlock>Наименование (убыв.)</TextBlock>
+                <TextBlock>Размер скидки (возр.)</TextBlock>
+                <TextBlock>Размер скидки (убыв.)</TextBlock>
+                <TextBlock>Приоритет агента (возр.)</TextBlock>
+                <TextBlock>Приоритет агента (убыв.)</TextBlock>
+            </ComboBox>
+            <ComboBox x:Name="filt" Width="200" Margin="10, 5" Height="40" >
+                <TextBlock>Все типы</TextBlock>
+                <TextBlock>МФО</TextBlock>
+                <TextBlock>ПАО</TextBlock>
+                <TextBlock>ООО</TextBlock>
+                <TextBlock>ЗАО</TextBlock>
+                <TextBlock>ОАО</TextBlock>
+                <TextBlock>MKK</TextBlock>
+            </ComboBox>
         </StackPanel>
         <ListBox  Grid.Row="1" x:Name="AllAgent" ItemTemplate="{StaticResource AllAgent}" />
     </Grid>

+ 13 - 0
BuzuevaDemo/Pages/Agents.xaml.cs

@@ -22,12 +22,25 @@ namespace BuzuevaDemo.Pages
     public partial class Agents : Page
     {
         ViewModel view = new ViewModel();
+        List<Agent> filter;
 
         public Agents()
         {
             InitializeComponent();
             AllAgent.ItemsSource = view.agent.ToList();
             AllAgent.Items.Refresh();
+            filter = view.agent.ToList();
+        }
+
+        private void Changeg(object sender, TextChangedEventArgs e)
+        {
+            filter = view.agent;
+            if (poisk.Text != "")
+            {
+                filter = filter.Where(x => x.Title.Contains(poisk.Text) || x.Email.Contains(poisk.Text) || x.Phone.Contains(poisk.Text)).ToList();
+
+            }
+            AllAgent.ItemsSource = filter.ToList();
         }
     }
 }