예제 #1
0
        private void FilterShow(object parameter)
        {
            var grid = parameter as Grid;

            grid.Visibility = grid.Visibility == Visibility.Collapsed ? Visibility.Visible : Visibility.Collapsed;

            if (grid.Visibility == Visibility.Collapsed)
            {
                SelectedCostItem         = CostItems.First();
                SelectedRC               = RCs.First();
                SelectedInOut            = InOuts.First();
                SelectedTransportCompany = TransportCompanies.First();
                SelectedNote             = Notes.First();
            }
        }
예제 #2
0
        private void RefreshFilters()
        {
            if (RCs == null || InOuts == null || TransportCompanies == null || Notes == null)
            {
                return;
            }

            SelectedRC               = RCs.First();
            SelectedInOut            = InOuts.First();
            SelectedTransportCompany = TransportCompanies.First();
            SelectedNote             = Notes.First();

            Filter();

            BC.DataContext.Configuration.AutoDetectChangesEnabled = false;

            RCs.Clear();
            var rcEmpty = new DirectoryRC {
                Name = null
            };

            RCs.Add(rcEmpty);

            foreach (var rc in Costs.Select(c => c.DirectoryRC).Distinct())
            {
                RCs.Add(rc);
            }

            InOuts.Clear();
            InOuts.Add("");

            if (Costs.Any(c => c.IsIncoming))
            {
                InOuts.Add("Приход");
            }

            if (Costs.Any(c => !c.IsIncoming))
            {
                InOuts.Add("Расход");
            }


            TransportCompanies.Clear();
            var transportCompanyEmpty = new DirectoryTransportCompany {
                Name = null
            };

            TransportCompanies.Add(transportCompanyEmpty);

            foreach (var transportCompany in Costs.Select(c => c.DirectoryTransportCompany).Where(t => t != null).Distinct())
            {
                TransportCompanies.Add(transportCompany);
            }


            Notes.Clear();
            var noteEmpty = new DirectoryNote {
                Description = null
            };

            Notes.Add(noteEmpty);

            foreach (var masNotes in Costs.Select(c => c.CurrentNotes.Select(n => n.DirectoryNote)))
            {
                foreach (var note in masNotes)
                {
                    if (!Notes.Contains(note))
                    {
                        Notes.Add(note);
                    }
                }
            }

            OrderNotes();

            BC.DataContext.Configuration.AutoDetectChangesEnabled = true;
        }