Esempio n. 1
0
        public virtual Cost AddCost()
        {
            var cost = new Cost {
                Price = this,
                Name  = "Базовая",
            };

            if (CostType == 0)
            {
                cost.PriceItem = Costs.Select(c => c.PriceItem).FirstOrDefault();
            }

            if (cost.PriceItem == null)
            {
                cost.PriceItem = new PriceItem {
                    FormRule = new FormRule(),
                    Source   = new PriceSource()
                };
            }
            cost.CostFormRule = new CostFormRule {
                Cost = cost, FieldName = ""
            };
            Costs.Add(cost);
            return(cost);
        }
Esempio n. 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;
        }