/// <summary> /// filtering the OrderList according to status, registrationDate and text on the 'search' textBox /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void OrderFilter(object sender, RoutedEventArgs e) { string orderStatus = null; string ordersSince = null; TimeSpan span; string text = tbxSearch.Text; if (cbxOrderStatus.SelectedItem != null) { orderStatus = ((ComboBoxItem)cbxOrderStatus.SelectedItem).Content.ToString(); } if (cbxAllOrderSince.SelectedItem != null) { ordersSince = ((ComboBoxItem)cbxOrderStatus.SelectedItem).Content.ToString(); } try { if (ordersSince != null || ordersSince != "All") { span = ordersSince == "This week" ? new TimeSpan(7, 0, 0, 0) : ordersSince == "This month" ? new TimeSpan(30, 0, 0, 0) : new TimeSpan(372, 0, 0, 0); ordersList = bL.AllOrdersSince(span); } else { ordersList = bL.getAllOrders(); } ordersList = ordersList.Where(item => item.HostingUnitKey == CurrentHostingUnit.HostingUnitKey && (item.OrderStatus.ToString().Contains(text) || item.OrderKey.Contains(text) || text == "Search" || text == "") && (item.OrderStatus.ToString() == orderStatus || orderStatus == null || orderStatus == "All")).ToList(); OrdersGrid.ItemsSource = ordersList; } catch (Exception ex) { MessageBox.Show(ex.Message, "לא נמצאו הזמנות", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.Cancel, MessageBoxOptions.RightAlign); } }