PageOrderView.xaml.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows;
  7. using System.Windows.Controls;
  8. using System.Windows.Data;
  9. using System.Windows.Documents;
  10. using System.Windows.Input;
  11. using System.Windows.Media;
  12. using System.Windows.Media.Imaging;
  13. using System.Windows.Navigation;
  14. using System.Windows.Shapes;
  15. using WriteErase.ClassBase;
  16. using WriteErase.ClassData;
  17. namespace WriteErase.ClassPages
  18. {
  19. /// <summary>
  20. /// Логика взаимодействия для PageOrderView.xaml
  21. /// </summary>
  22. public partial class PageOrderView : Page
  23. {
  24. public PageOrderView()
  25. {
  26. InitializeComponent();
  27. lvOrder.ItemsSource = BaseConnection.kotBase.Order.ToList();
  28. }
  29. private void btnBackClick(object sender, RoutedEventArgs e)
  30. {
  31. MainFrame.mainFrame.Navigate(new PageMain());
  32. }
  33. private void cbCostSelectionChanged(object sender, SelectionChangedEventArgs e)
  34. {
  35. if (lvOrder != null && cbCost != null)
  36. filter();
  37. }
  38. private void cbDiscountSelectionChanged(object sender, SelectionChangedEventArgs e)
  39. {
  40. if (lvOrder != null && cbDiscount != null)
  41. filter();
  42. }
  43. private void filter()
  44. {
  45. List<Order> list = BaseConnection.kotBase.Order.ToList();
  46. //сортировка по стоимости
  47. switch (cbCost.SelectedIndex)
  48. {
  49. case 1:
  50. {
  51. list = list.OrderBy(tb => tb.CostWithDiscount).ToList();
  52. break;
  53. }
  54. case 2:
  55. {
  56. list = list.OrderByDescending(tb => tb.CostWithoutDiscount).ToList();
  57. break;
  58. }
  59. default:
  60. break;
  61. }
  62. //фильтрация по скидке
  63. switch (cbDiscount.SelectedIndex)
  64. {
  65. case 1:
  66. {
  67. list = list.Where(tb => tb.ProcentCost >= 0.0 && tb.ProcentCost <= 9.99).ToList();
  68. break;
  69. }
  70. case 2:
  71. {
  72. list = list.Where(tb => tb.ProcentCost >= 10.0 && tb.ProcentCost <= 14.99).ToList();
  73. break;
  74. }
  75. case 3:
  76. {
  77. list = list.Where(tb => tb.ProcentCost >= 15.0).ToList();
  78. break;
  79. }
  80. default:
  81. break;
  82. }
  83. lvOrder.ItemsSource = list;
  84. }
  85. }
  86. }