public static IList<Nomenclature> MatchNomenclaturesBySize(IUnitOfWork uow, ItemsType itemType, EmployeeCard employee)
        {
            if(itemType.WearCategory == null)
            {
                logger.Warn ("Вызван подбор номерклатур по размеру, для типа <{0}>, но в нем не указан вид спецодежды.", itemType.Name);
                return null;
            }

            var query = uow.Session.QueryOver<Nomenclature> ()
                .Where (n => n.Type == itemType);

            if (SizeHelper.HasСlothesSizeStd(itemType.WearCategory.Value))
            {
                var disjunction = new Disjunction();
                var employeeSize = employee.GetSize(itemType.WearCategory.Value);

                if (employeeSize == null || String.IsNullOrEmpty(employeeSize.Size) || String.IsNullOrEmpty(employeeSize.StandardCode))
                {
                    logger.Warn("В карточке сотрудника не указан размер для спецодежды типа <{0}>.", itemType.Name);
                    return null;
                }

                foreach (var pair in SizeHelper.MatchSize (employeeSize, SizeUsePlace.Сlothes))
                {
                    disjunction.Add(
                        Restrictions.And(
                            Restrictions.Eq(Projections.Property<Nomenclature>(n => n.SizeStd), pair.StandardCode),
                            Restrictions.Eq(Projections.Property<Nomenclature>(n => n.Size), pair.Size)
                        ));
                }
                query.Where(disjunction);
                if (SizeHelper.HasGrowthStandart(itemType.WearCategory.Value))
                {
                    var growDisjunction = new Disjunction();
                    var growStds = SizeHelper.GetGrowthStandart(itemType.WearCategory.Value, employee.Sex, SizeUsePlace.Сlothes);
                    foreach (var pair in SizeHelper.MatchGrow (growStds, employee.WearGrowth, SizeUsePlace.Сlothes))
                    {
                        growDisjunction.Add(
                            Restrictions.And(
                                Restrictions.Eq(Projections.Property<Nomenclature>(n => n.WearGrowthStd), pair.StandardCode),
                                Restrictions.Eq(Projections.Property<Nomenclature>(n => n.WearGrowth), pair.Size)
                            ));
                    }

                    query.Where(growDisjunction);
                }
            }

            return query.List ();
        }
Exemple #2
0
        public virtual void AddItem(ItemsType itemtype)
        {
            if(Items.Any (i => DomainHelper.EqualDomainObjects (i.Item, itemtype)))
            {
                logger.Warn ("Такое наименование уже добавлено. Пропускаем...");
                return;
            }

            var item = new NormItem () {
                Norm = this,
                Item = itemtype,
                Amount = 1,
                NormPeriod = NormPeriodType.Year,
                PeriodCount = 1
            };

            ObservableItems.Add (item);
        }