Ejemplo n.º 1
0
        private void WatchOrdersButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Orders WindOrder = new Orders();
                WindOrder.CurrentHostingUnit = HostingUnit;
                guestRequestsList            = bL.GetAllGuestRequests(Item => Item.Area == HostingUnit.Area &&
                                                                      Item.Type == HostingUnit.HostingUnitType && Item.Status == Enums.GuestRequestStatus.Active.ToString() &&
                                                                      bL.ifAvailable(HostingUnit, Item.EntryDate, Item.ReleaseDate) != null);
                foreach (var item in guestRequestsList)
                {
                    creatOrder(item, HostingUnit);
                }

                ordersList = bL.getAllOrders(Item => Item.HostingUnitKey == HostingUnit.HostingUnitKey);
                if (ordersList.Count != 0)
                {
                    WindOrder.OrdersGrid.ItemsSource = ordersList;
                }
                WindOrder.ShowDialog();
                HostingUnitFilter(this, new RoutedEventArgs());
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 2
0
        /// <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);
            }
        }