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.Navigation;
using System.Windows.Shapes;
using WriteErase.ClassBase;
using WriteErase.ClassData;
namespace WriteErase.ClassPages
{
///
/// Логика взаимодействия для PageOrderView.xaml
///
public partial class PageOrderView : Page
{
public PageOrderView()
{
InitializeComponent();
lvOrder.ItemsSource = BaseConnection.kotBase.Order.ToList();
}
private void btnBackClick(object sender, RoutedEventArgs e)
{
MainFrame.mainFrame.Navigate(new PageMain());
}
private void cbCostSelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (lvOrder != null && cbCost != null)
filter();
}
private void cbDiscountSelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (lvOrder != null && cbDiscount != null)
filter();
}
private void filter()
{
List list = BaseConnection.kotBase.Order.ToList();
//сортировка по стоимости
switch (cbCost.SelectedIndex)
{
case 1:
{
list = list.OrderBy(tb => tb.CostWithDiscount).ToList();
break;
}
case 2:
{
list = list.OrderByDescending(tb => tb.CostWithoutDiscount).ToList();
break;
}
default:
break;
}
//фильтрация по скидке
switch (cbDiscount.SelectedIndex)
{
case 1:
{
list = list.Where(tb => tb.ProcentCost >= 0.0 && tb.ProcentCost <= 9.99).ToList();
break;
}
case 2:
{
list = list.Where(tb => tb.ProcentCost >= 10.0 && tb.ProcentCost <= 14.99).ToList();
break;
}
case 3:
{
list = list.Where(tb => tb.ProcentCost >= 15.0).ToList();
break;
}
default:
break;
}
lvOrder.ItemsSource = list;
}
}
}