|
@@ -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();
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|