Alexey преди 7 месеца
родител
ревизия
0a0c2acd7f
променени са 2 файла, в които са добавени 79 реда и са изтрити 80 реда
  1. 33 15
      PP_Ven_MosS/Pages/ApplicationsListAdmin.xaml
  2. 46 65
      PP_Ven_MosS/Pages/ApplicationsListAdmin.xaml.cs

+ 33 - 15
PP_Ven_MosS/Pages/ApplicationsListAdmin.xaml

@@ -14,8 +14,8 @@
             <RowDefinition></RowDefinition>
         </Grid.RowDefinitions>
         <Grid.ColumnDefinitions>
-            <ColumnDefinition></ColumnDefinition>
-            <ColumnDefinition></ColumnDefinition>
+            <ColumnDefinition Width="400"></ColumnDefinition>
+            <ColumnDefinition Width="400"></ColumnDefinition>
         </Grid.ColumnDefinitions>
         <StackPanel Grid.Row="0" Grid.Column="0" HorizontalAlignment="Center" VerticalAlignment="Center" Orientation="Horizontal">
             <TextBlock Text="Служебные записки" FontWeight="Bold" FontSize="20"></TextBlock>
@@ -23,7 +23,7 @@
         <StackPanel Grid.Row="0" Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center" Orientation="Horizontal">
             <TextBlock Text="Мероприятия" FontWeight="Bold" FontSize="20"></TextBlock>
         </StackPanel>
-        <StackPanel Grid.Row="1" Grid.Column="0" HorizontalAlignment="Center" VerticalAlignment="Top" Orientation="Vertical" Visibility="Hidden">
+        <StackPanel Grid.Row="1" Grid.Column="0" HorizontalAlignment="Center" VerticalAlignment="Top" Orientation="Vertical">
             <StackPanel Orientation="Horizontal" >
                 <GroupBox Height="60" Header="Введите текст для поиска" BorderThickness="2" BorderBrush="#FF0000" Margin="10,0,0,0">
                     <TextBox Name="TB_Search_app" Width="200" Height="30"/>
@@ -39,23 +39,21 @@
                 </ListView.ItemsPanel>
                 <ListView.ItemTemplate>
                     <DataTemplate>
-                        <Border  Width="800" Height="200"  BorderThickness="1" BorderBrush="Red">
-                            <StackPanel Orientation="Horizontal">
-                                <StackPanel Margin="10,0,0,0" Width="300" HorizontalAlignment="Center" Orientation="Vertical">
-                                    <TextBlock Text="{Binding DateApp}"/>
-                                    <TextBlock Text="{Binding PlaceApp}" TextWrapping="Wrap"/>
-                                    <TextBlock Text="{Binding TypeApp}" Uid="{Binding AppType}"/>
-                                    <TextBlock Text="{Binding DescApp}"/>
-                                    <TextBlock Text="{Binding UserApp}"  Uid="{Binding AppUser}"/>
-                                    <TextBlock Text="{Binding StatusApp}"  Uid="{Binding AppStatus}"/>
-                                </StackPanel>
+                        <Border Width="150" Height="100" BorderThickness="1" BorderBrush="Red">
+                            <StackPanel Margin="10,0,0,0" Width="300" HorizontalAlignment="Center" Orientation="Vertical">
+                                <TextBlock Text="{Binding DateApp}"/>
+                                <TextBlock Text="{Binding PlaceApp}" TextWrapping="Wrap"/>
+                                <TextBlock Text="{Binding Path=Application_type.Title_app_type}" Uid="{Binding AppType}"/>
+                                <TextBlock Text="{Binding DescApp}"/>
+                                <TextBlock Text="{Binding Path=User.Surname}" Uid="{Binding AppUser}"/>
+                                <TextBlock Text="{Binding Path=Status_application.Title_status_app}" Uid="{Binding AppStatus}"/>
                             </StackPanel>
                         </Border>
                     </DataTemplate>
                 </ListView.ItemTemplate>
             </ListView>
         </StackPanel>
-        <StackPanel Grid.Row="1" Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Top" Orientation="Vertical" Visibility="Hidden">
+        <StackPanel Grid.Row="1" Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Top" Orientation="Vertical">
             <StackPanel Orientation="Horizontal" >
                 <GroupBox Height="60" Header="Введите текст для поиска" BorderThickness="2" BorderBrush="#FF0000" Margin="10,0,0,0">
                     <TextBox Name="TB_Search_event" Width="200" Height="30"/>
@@ -63,7 +61,27 @@
                 <ComboBox Name="CB_Sort_event" Width="100" Height="30" Margin="10,10,0,0"></ComboBox>
                 <ComboBox Name="CB_Filter_event" Width="100" Height="30" Margin="10,10,0,0"></ComboBox>
             </StackPanel>
-            
+            <ListView Grid.Row="1" Grid.Column="1" Name="EventsList">
+                <ListView.ItemsPanel>
+                    <ItemsPanelTemplate>
+                        <WrapPanel Orientation="Vertical" HorizontalAlignment="Center"/>
+                    </ItemsPanelTemplate>
+                </ListView.ItemsPanel>
+                <ListView.ItemTemplate>
+                    <DataTemplate>
+                        <Border Width="150" Height="100" BorderThickness="1" BorderBrush="Red">
+                            <StackPanel Margin="10,0,0,0" Width="300" HorizontalAlignment="Center" Orientation="Vertical">
+                                <TextBlock Text="{Binding DateEv}"/>
+                                <TextBlock Text="{Binding PlaceEv}" TextWrapping="Wrap"/>
+                                <TextBlock Text="{Binding Path=Events_type.Title_events_type}" Uid="{Binding AppType}"/>
+                                <TextBlock Text="{Binding DescEv}"/>
+                                <TextBlock Text="{Binding Path=User.Surname}" Uid="{Binding AppUser}"/>
+                                <TextBlock Text="{Binding Path=Status_event.Title_status_event}" Uid="{Binding AppStatus}"/>
+                            </StackPanel>
+                        </Border>
+                    </DataTemplate>
+                </ListView.ItemTemplate>
+            </ListView>
         </StackPanel>
     </Grid>
 </Page>

+ 46 - 65
PP_Ven_MosS/Pages/ApplicationsListAdmin.xaml.cs

@@ -33,80 +33,61 @@ namespace PP_Ven_MosS.Pages
     }
     public partial class ApplicationsListAdmin : Page
     {
-        
         PP_MininEntities DB = new PP_MininEntities();
-        public List<Applications> appl;
+        int id;
+
         public ApplicationsListAdmin()
         {
-            appl = application();
-        }
-        public List<Applications> application()
-        {
-            List<Applications> app = new List<Applications>();
-            Applications buff;
-            List<Applications> dbapp = DB.Applications.ToList();
-            foreach (Applications appl in dbapp)
-            {
-                buff = new Applications();
-                buff.Id_application = appl.Id_application;
-                buff.Date_app = appl.Date_app;
-                buff.Place_app = appl.Place_app;
-                buff.Id_app_type = appl.Id_app_type;
-                buff.Description = appl.Description;
-                buff.Id_user = appl.Id_user;
-                buff.Id_status_app = appl.Id_status_app;
-
-                Application_type appType = DB.Application_type.FirstOrDefault(x => x.Id_app_type == appl.Id_app_type);
-                buff.ApplicType = appType.Title_app_type.ToString();
-
-                app.Add(buff);
-            }
-            return app;
+            InitializeComponent();
+            ApplicationList.ItemsSource = DB.Applications.ToList();
+            Applications appl = DB.Applications.Where(x => x.Id_application == id).FirstOrDefault();
+            CB_Filter_app.ItemsSource = new List<string>();
+            CB_Sort_app.ItemsSource = new List<string>();
+            CB_Sort_app.SelectedIndex = 0;
+            CB_Filter_app.SelectedIndex = 0;
         }
-
         public ApplicationsListAdmin(int id)
         {
             InitializeComponent();
-            ApplicationList.ItemsSource = DB.Application.ToList();
-            User user = DB.User.Where(x => x.Id_user == id).FirstOrDefault();
-            CB_Filter_app.ItemsSource = new List<string>() { "Все", "Скидка 0-9,99%", "Скидка 10-14,99%", "Скидка 15% и более" };
-            CB_Sort_app.ItemsSource = new List<string>() { "Без сортировки", "По имени А-Я", "По имени Я-А" };
+            ApplicationList.ItemsSource = DB.Applications.ToList();
+            Applications appl = DB.Applications.Where(x => x.Id_application == id).FirstOrDefault();
+
+            CB_Filter_app.ItemsSource = new List<string>();
+            CB_Sort_app.ItemsSource = new List<string>();
             CB_Sort_app.SelectedIndex = 0;
             CB_Filter_app.SelectedIndex = 0;
+            this.id = id;
+        }
+        private void Filter()
+        {
+            List<Applications> applications = DB.Applications.ToList();
+            if (CB_Sort_app.SelectedIndex != 0)
+            {
+                switch (CB_Sort_app.SelectedIndex)
+                {
+                    case 1:
+                        applications = applications.OrderBy(x => x.Date_app).ToList();
+                        break;
+                    case 2:
+                        applications = applications.OrderByDescending(x => x.Date_app).ToList();
+                        break;
+                }
+            }
+            if (!string.IsNullOrEmpty(TB_Search_app.Text))
+            {
+                applications = applications.Where(x => x.Description.ToUpper().Contains(TB_Search_app.Text.ToUpper())).ToList();
+            }
+            ApplicationList.ItemsSource = applications;
         }
-    }
-}
-
-//public class Product
-//{
-//    public List<Goods> gds;
-//    public Product()
-//    {
-//        gds = product();
-//    }
-
-//    public List<Goods> product()
-//    {
-//        List<Goods> goods = new List<Goods>();
-//        Goods buff;
-//        List<Goods> bdgoods = DataBase.BaseModel.Goods.ToList();
-
-//        foreach (Goods good in bdgoods)
-//        {
-//            buff = new Goods();
-//            buff.ID_Goods = good.ID_Goods;
-//            buff.Title_Goods = good.Title_Goods;
-//            buff.Price_Goods = good.Price_Goods;
-//            buff.Buying_Goods = good.Buying_Goods;
-//            buff.Picture = good.Picture;
-//            buff.Description = good.Description;
-//            buff.ID_Type_Goods = good.ID_Type_Goods;
 
-//            Type_Goods type_Goods = DataBase.BaseModel.Type_Goods.FirstOrDefault(x => x.ID_Type_Goods == good.ID_Type_Goods);
-//            buff.TypeOfGoods = type_Goods.Title_Type_Goods;
+        private void SortFilterChanged(object sender, SelectionChangedEventArgs e)
+        {
+            Filter();
+        }
 
-//            goods.Add(buff);
-//        }
-//        return goods;
-//    }
-//}
+        private void SearchChanged(object sender, TextChangedEventArgs e)
+        {
+            Filter();
+        }
+    }
+}