Exemple #1
0
        private void ConfigureMultipleFilter()
        {
            _filter.CreateParameterSet(
                "Основания скидок",
                "discount_reason",
                new ParametersFactory(UoW, (filters) =>
            {
                SelectableEntityParameter <DiscountReason> resultAlias = null;
                var query = UoW.Session.QueryOver <DiscountReason>();
                if (filters != null && filters.Any())
                {
                    foreach (var f in filters)
                    {
                        query.Where(f());
                    }
                }

                query.SelectList(list => list
                                 .Select(x => x.Id).WithAlias(() => resultAlias.EntityId)
                                 .Select(x => x.Name).WithAlias(() => resultAlias.EntityTitle)
                                 );
                query.TransformUsing(Transformers.AliasToBean <SelectableEntityParameter <DiscountReason> >());
                return(query.List <SelectableParameter>());
            })
                );

            _filter.CreateParameterSet(
                "Промонаборы",
                "promotional_set",
                new ParametersFactory(UoW, (filters) =>
            {
                SelectableEntityParameter <PromotionalSet> resultAlias = null;
                var query = UoW.Session.QueryOver <PromotionalSet>()
                            .Where(x => !x.IsArchive);
                if (filters != null && filters.Any())
                {
                    foreach (var f in filters)
                    {
                        query.Where(f());
                    }
                }

                query.SelectList(list => list
                                 .Select(x => x.Id).WithAlias(() => resultAlias.EntityId)
                                 .Select(x => x.Name).WithAlias(() => resultAlias.EntityTitle)
                                 );
                query.TransformUsing(Transformers.AliasToBean <SelectableEntityParameter <PromotionalSet> >());
                return(query.List <SelectableParameter>());
            })
                );

            var viewModel    = new SelectableParameterReportFilterViewModel(_filter);
            var filterWidget = new SelectableParameterReportFilterView(viewModel);

            vboxMultipleFilter.Add(filterWidget);
            filterWidget.Show();
        }
        void ConfigureDlg()
        {
            UoW = UnitOfWorkFactory.CreateWithoutRoot();
            lstGeoGrp.SetRenderTextFunc <GeographicGroup>(g => string.Format("{0}", g.Name));
            lstGeoGrp.ItemsList = _geographicGroupRepository.GeographicGroupsWithCoordinates(UoW);

            var nomenclatureTypeParam = _filter.CreateParameterSet(
                "Типы номенклатур",
                "nomenclature_type",
                new ParametersEnumFactory <NomenclatureCategory>()
                );

            var nomenclatureParam = _filter.CreateParameterSet(
                "Номенклатуры",
                "nomenclature",
                new ParametersFactory(UoW, (filters) => {
                SelectableEntityParameter <Nomenclature> resultAlias = null;
                var query = UoW.Session.QueryOver <Nomenclature>()
                            .Where(x => !x.IsArchive);
                if (filters != null && filters.Any())
                {
                    foreach (var f in filters)
                    {
                        var filterCriterion = f();
                        if (filterCriterion != null)
                        {
                            query.Where(filterCriterion);
                        }
                    }
                }

                query.SelectList(list => list
                                 .Select(x => x.Id).WithAlias(() => resultAlias.EntityId)
                                 .Select(x => x.OfficialName).WithAlias(() => resultAlias.EntityTitle)
                                 );
                query.TransformUsing(Transformers.AliasToBean <SelectableEntityParameter <Nomenclature> >());
                return(query.List <SelectableParameter>());
            })
                );

            nomenclatureParam.AddFilterOnSourceSelectionChanged(nomenclatureTypeParam,
                                                                () => {
                var selectedValues = nomenclatureTypeParam.GetSelectedValues();
                if (!selectedValues.Any())
                {
                    return(null);
                }
                return(Restrictions.On <Nomenclature>(x => x.Category).IsIn(nomenclatureTypeParam.GetSelectedValues().ToArray()));
            }
                                                                );

            //Предзагрузка. Для избежания ленивой загрузки
            UoW.Session.QueryOver <ProductGroup>().Fetch(SelectMode.Fetch, x => x.Childs).List();

            _filter.CreateParameterSet(
                "Группы товаров",
                "product_group",
                new RecursiveParametersFactory <ProductGroup>(UoW,
                                                              (filters) => {
                var query = UoW.Session.QueryOver <ProductGroup>();
                if (filters != null && filters.Any())
                {
                    foreach (var f in filters)
                    {
                        query.Where(f());
                    }
                }
                return(query.List());
            },
                                                              x => x.Name,
                                                              x => x.Childs)
                );

            var viewModel    = new SelectableParameterReportFilterViewModel(_filter);
            var filterWidget = new SelectableParameterReportFilterView(viewModel);

            vboxParameters.Add(filterWidget);
            filterWidget.Show();
        }
Exemple #3
0
        private void ConfigureDlg()
        {
            dateperiodpicker1.StartDate = dateperiodpicker1.EndDate = DateTime.Today;

            var nomenclatureTypeParam = filter.CreateParameterSet(
                "Типы номенклатур",
                "nomenclature_type",
                new ParametersEnumFactory <NomenclatureCategory>()
                );

            var nomenclatureParam = filter.CreateParameterSet(
                "Номенклатуры",
                "nomenclature",
                new ParametersFactory(UoW, (filters) => {
                SelectableEntityParameter <Nomenclature> resultAlias = null;
                var query = UoW.Session.QueryOver <Nomenclature>()
                            .Where(x => !x.IsArchive);
                if (filters != null && filters.Any())
                {
                    foreach (var f in filters)
                    {
                        var filterCriterion = f();
                        if (filterCriterion != null)
                        {
                            query.Where(filterCriterion);
                        }
                    }
                }

                query.SelectList(list => list
                                 .Select(x => x.Id).WithAlias(() => resultAlias.EntityId)
                                 .Select(x => x.OfficialName).WithAlias(() => resultAlias.EntityTitle)
                                 );
                query.TransformUsing(Transformers.AliasToBean <SelectableEntityParameter <Nomenclature> >());
                return(query.List <SelectableParameter>());
            })
                );

            nomenclatureParam.AddFilterOnSourceSelectionChanged(nomenclatureTypeParam,
                                                                () => {
                var selectedValues = nomenclatureTypeParam.GetSelectedValues();
                if (!selectedValues.Any())
                {
                    return(null);
                }
                return(Restrictions.On <Nomenclature>(x => x.Category).IsIn(nomenclatureTypeParam.GetSelectedValues().ToArray()));
            }
                                                                );

            //Предзагрузка. Для избежания ленивой загрузки
            UoW.Session.QueryOver <ProductGroup>().Fetch(SelectMode.Fetch, x => x.Childs).List();

            filter.CreateParameterSet(
                "Группы товаров",
                "product_group",
                new RecursiveParametersFactory <ProductGroup>(UoW,
                                                              (filters) => {
                var query = UoW.Session.QueryOver <ProductGroup>();
                if (filters != null && filters.Any())
                {
                    foreach (var f in filters)
                    {
                        query.Where(f());
                    }
                }
                return(query.List());
            },
                                                              x => x.Name,
                                                              x => x.Childs)
                );

            var viewModel    = new SelectableParameterReportFilterViewModel(filter);
            var filterWidget = new SelectableParameterReportFilterView(viewModel);

            vboxParameters.Add(filterWidget);
            filterWidget.Show();
        }
Exemple #4
0
        private void ConfigureFilter()
        {
            var subdivisionsFilter = _filter.CreateParameterSet(
                "Подразделения",
                "subdivision",
                new ParametersFactory(UoW, (filters) =>
            {
                SelectableEntityParameter <Subdivision> resultAlias = null;
                var query = UoW.Session.QueryOver <Subdivision>();
                if (filters != null && filters.Any())
                {
                    foreach (var f in filters)
                    {
                        query.Where(f());
                    }
                }

                query.SelectList(list => list
                                 .Select(x => x.Id).WithAlias(() => resultAlias.EntityId)
                                 .Select(x => x.Name).WithAlias(() => resultAlias.EntityTitle)
                                 );
                query.TransformUsing(Transformers.AliasToBean <SelectableEntityParameter <Subdivision> >());
                return(query.List <SelectableParameter>());
            })
                );

            var orderAuthorsFilter = _filter.CreateParameterSet(
                "Авторы заказов",
                "order_author",
                new ParametersFactory(UoW, (filters) =>
            {
                SelectableEntityParameter <Employee> resultAlias = null;
                var query = UoW.Session.QueryOver <Employee>();

                if (filters != null && filters.Any())
                {
                    foreach (var f in filters)
                    {
                        var criterion = f();

                        if (criterion != null)
                        {
                            query.Where(criterion);
                        }
                    }
                }

                var authorProjection = CustomProjections.Concat_WS(
                    " ",
                    Projections.Property <Employee>(x => x.LastName),
                    Projections.Property <Employee>(x => x.Name),
                    Projections.Property <Employee>(x => x.Patronymic)
                    );

                query.SelectList(list => list
                                 .Select(x => x.Id).WithAlias(() => resultAlias.EntityId)
                                 .Select(authorProjection).WithAlias(() => resultAlias.EntityTitle)
                                 );
                query.TransformUsing(Transformers.AliasToBean <SelectableEntityParameter <Employee> >());
                var paremetersSet = query.List <SelectableParameter>();

                return(paremetersSet);
            })
                );

            orderAuthorsFilter.AddFilterOnSourceSelectionChanged(subdivisionsFilter,
                                                                 () =>
            {
                var selectedValues = subdivisionsFilter.GetSelectedValues().ToArray();

                return(!selectedValues.Any()
                                                ? null
                                                : subdivisionsFilter.FilterType == SelectableFilterType.Include
                                                        ? Restrictions.On <Employee>(x => x.Subdivision).IsIn(selectedValues)
                                                        : Restrictions.On <Employee>(x => x.Subdivision).Not.IsIn(selectedValues));
            }
                                                                 );

            var viewModel    = new SelectableParameterReportFilterViewModel(_filter);
            var filterWidget = new SelectableParameterReportFilterView(viewModel);

            vboxMultiParameters.Add(filterWidget);
            filterWidget.Show();
        }
Exemple #5
0
        void ConfigureDlg()
        {
            if (StoreDocumentHelper.CheckAllPermissions(UoW.IsNew, WarehousePermissions.InventoryEdit, Entity.Warehouse))
            {
                FailInitialize = true;
                return;
            }

            var editing = StoreDocumentHelper.CanEditDocument(WarehousePermissions.InventoryEdit, Entity.Warehouse);

            ydatepickerDocDate.Sensitive = yentryrefWarehouse.IsEditable = ytextviewCommnet.Editable = editing;

            ytreeviewItems.Sensitive                   =
                buttonAdd.Sensitive                    =
                    buttonFillItems.Sensitive          =
                        buttonFine.Sensitive           =
                            buttonDeleteFine.Sensitive = editing;

            ydatepickerDocDate.Binding.AddBinding(Entity, e => e.TimeStamp, w => w.Date).InitializeFromSource();
            yentryrefWarehouse.ItemsQuery = StoreDocumentHelper.GetRestrictedWarehouseQuery(WarehousePermissions.InventoryEdit);
            yentryrefWarehouse.Binding.AddBinding(Entity, e => e.Warehouse, w => w.Subject).InitializeFromSource();

            ytextviewCommnet.Binding.AddBinding(Entity, e => e.Comment, w => w.Buffer.Text).InitializeFromSource();

            string errorMessage       = "Не установлены единицы измерения у следующих номенклатур :" + Environment.NewLine;
            int    wrongNomenclatures = 0;

            foreach (var item in UoWGeneric.Root.Items)
            {
                if (item.Nomenclature.Unit == null)
                {
                    errorMessage += string.Format("Номер: {0}. Название: {1}{2}",
                                                  item.Nomenclature.Id, item.Nomenclature.Name, Environment.NewLine);
                    wrongNomenclatures++;
                }
            }
            if (wrongNomenclatures > 0)
            {
                MessageDialogHelper.RunErrorDialog(errorMessage);
                FailInitialize = true;
                return;
            }

            var permmissionValidator =
                new EntityExtendedPermissionValidator(PermissionExtensionSingletonStore.GetInstance(), _employeeRepository);

            Entity.CanEdit =
                permmissionValidator.Validate(
                    typeof(InventoryDocument), ServicesConfig.UserService.CurrentUserId, nameof(RetroactivelyClosePermission));

            if (!Entity.CanEdit && Entity.TimeStamp.Date != DateTime.Now.Date)
            {
                ydatepickerDocDate.Binding.AddFuncBinding(Entity, e => e.CanEdit, w => w.Sensitive).InitializeFromSource();
                yentryrefWarehouse.Binding.AddFuncBinding(Entity, e => e.CanEdit, w => w.Sensitive).InitializeFromSource();
                ytextviewCommnet.Binding.AddFuncBinding(Entity, e => e.CanEdit, w => w.Sensitive).InitializeFromSource();
                buttonSave.Sensitive                       = false;
                ytreeviewItems.Sensitive                   =
                    buttonAdd.Sensitive                    =
                        buttonFillItems.Sensitive          =
                            buttonFine.Sensitive           =
                                buttonDeleteFine.Sensitive = false;
            }
            else
            {
                Entity.CanEdit = true;
            }

            filter = new SelectableParametersReportFilter(UoW);

            var nomenclatureParam = filter.CreateParameterSet(
                "Номенклатуры",
                "nomenclature",
                new ParametersFactory(UoW, (filters) => {
                SelectableEntityParameter <Nomenclature> resultAlias = null;
                var query = UoW.Session.QueryOver <Nomenclature>()
                            .Where(x => !x.IsArchive);
                if (filters != null && filters.Any())
                {
                    foreach (var f in filters)
                    {
                        var filterCriterion = f();
                        if (filterCriterion != null)
                        {
                            query.Where(filterCriterion);
                        }
                    }
                }

                query.SelectList(list => list
                                 .Select(x => x.Id).WithAlias(() => resultAlias.EntityId)
                                 .Select(x => x.OfficialName).WithAlias(() => resultAlias.EntityTitle)
                                 );
                query.TransformUsing(Transformers.AliasToBean <SelectableEntityParameter <Nomenclature> >());
                return(query.List <SelectableParameter>());
            })
                );

            var nomenclatureTypeParam = filter.CreateParameterSet(
                "Типы номенклатур",
                "nomenclature_type",
                new ParametersEnumFactory <NomenclatureCategory>()
                );

            nomenclatureParam.AddFilterOnSourceSelectionChanged(nomenclatureTypeParam,
                                                                () => {
                var selectedValues = nomenclatureTypeParam.GetSelectedValues();
                if (!selectedValues.Any())
                {
                    return(null);
                }
                return(Restrictions.On <Nomenclature>(x => x.Category).IsIn(nomenclatureTypeParam.GetSelectedValues().ToArray()));
            }
                                                                );

            //Предзагрузка. Для избежания ленивой загрузки
            UoW.Session.QueryOver <ProductGroup>().Fetch(SelectMode.Fetch, x => x.Childs).List();

            filter.CreateParameterSet(
                "Группы товаров",
                "product_group",
                new RecursiveParametersFactory <ProductGroup>(UoW,
                                                              (filters) => {
                var query = UoW.Session.QueryOver <ProductGroup>();
                if (filters != null && filters.Any())
                {
                    foreach (var f in filters)
                    {
                        query.Where(f());
                    }
                }
                return(query.List());
            },
                                                              x => x.Name,
                                                              x => x.Childs)
                );

            var filterViewModel = new SelectableParameterReportFilterViewModel(filter);
            var filterWidget    = new SelectableParameterReportFilterView(filterViewModel);

            vboxParameters.Add(filterWidget);
            filterWidget.Show();

            ConfigNomenclatureColumns();
        }
        private void ConfigureReport()
        {
            var geoGroups = _filter.CreateParameterSet(
                "Части города",
                "geographic_groups",
                new ParametersFactory(UoW, (filters) => {
                SelectableEntityParameter <GeographicGroup> resultAlias = null;
                var query = UoW.Session.QueryOver <GeographicGroup>();

                if (filters != null && filters.Any())
                {
                    foreach (var f in filters)
                    {
                        query.Where(f());
                    }
                }

                query.SelectList(list => list
                                 .Select(x => x.Id).WithAlias(() => resultAlias.EntityId)
                                 .Select(x => x.Name).WithAlias(() => resultAlias.EntityTitle)
                                 );
                query.TransformUsing(Transformers.AliasToBean <SelectableEntityParameter <GeographicGroup> >());
                return(query.List <SelectableParameter>());
            })
                );

            District        districtAlias     = null;
            DistrictsSet    districtsSetAlias = null;
            GeographicGroup geoGroupAlias     = null;
            var             districtParameter = _filter.CreateParameterSet(
                "Районы",
                "districts",
                new ParametersFactory(UoW, (filters) => {
                SelectableEntityParameter <District> resultAlias = null;

                var query = UoW.Session.QueryOver(() => districtAlias)
                            .JoinAlias(() => districtAlias.DistrictsSet, () => districtsSetAlias)
                            .Left.JoinAlias(() => districtAlias.GeographicGroup, () => geoGroupAlias)
                            .Where(() => districtsSetAlias.Status == DistrictsSetStatus.Active);

                if (filters != null && filters.Any())
                {
                    foreach (var f in filters)
                    {
                        var filterCriterion = f();
                        if (filterCriterion != null)
                        {
                            query.Where(filterCriterion);
                        }
                    }
                }

                query.SelectList(list => list
                                 .Select(() => districtAlias.Id).WithAlias(() => resultAlias.EntityId)
                                 .Select(() => districtAlias.DistrictName).WithAlias(() => resultAlias.EntityTitle)
                                 );
                var result = query.TransformUsing(Transformers.AliasToBean <SelectableEntityParameter <District> >())
                             .List <SelectableEntityParameter <District> >();
                foreach (var parameter in result)
                {
                    parameter.EntityTitle = $"{parameter.EntityId} {parameter.EntityTitle}";
                }
                return(result.Cast <SelectableParameter>().ToList());
            })
                );

            districtParameter.AddFilterOnSourceSelectionChanged(geoGroups, () => {
                var selectedValues = geoGroups.GetSelectedValues();
                if (!selectedValues.Any())
                {
                    return(null);
                }
                return(Restrictions.On(() => geoGroupAlias.Id).IsIn(selectedValues.ToArray()));
            });

            var viewModel    = new SelectableParameterReportFilterViewModel(_filter);
            var filterWidget = new SelectableParameterReportFilterView(viewModel);

            vboxSelectableFilter.Add(filterWidget);
            filterWidget.Show();
        }
Exemple #7
0
        private void ConfigureDlg()
        {
            dateperiodpicker.StartDate = dateperiodpicker.EndDate = DateTime.Today;

            var nomenclatureTypeParam = filter.CreateParameterSet(
                "Типы номенклатур",
                "nomenclature_type",
                new ParametersEnumFactory <NomenclatureCategory>()
                );

            var nomenclatureParam = filter.CreateParameterSet(
                "Номенклатуры",
                "nomenclature",
                new ParametersFactory(UoW, (filters) => {
                SelectableEntityParameter <Nomenclature> resultAlias = null;
                var query = UoW.Session.QueryOver <Nomenclature>()
                            .Where(x => !x.IsArchive);
                if (filters != null && filters.Any())
                {
                    foreach (var f in filters)
                    {
                        var filterCriterion = f();
                        if (filterCriterion != null)
                        {
                            query.Where(filterCriterion);
                        }
                    }
                }

                query.SelectList(list => list
                                 .Select(x => x.Id).WithAlias(() => resultAlias.EntityId)
                                 .Select(x => x.OfficialName).WithAlias(() => resultAlias.EntityTitle)
                                 );
                query.TransformUsing(Transformers.AliasToBean <SelectableEntityParameter <Nomenclature> >());
                return(query.List <SelectableParameter>());
            })
                );

            nomenclatureParam.AddFilterOnSourceSelectionChanged(nomenclatureTypeParam,
                                                                () => {
                var selectedValues = nomenclatureTypeParam.GetSelectedValues();
                if (!selectedValues.Any())
                {
                    return(null);
                }
                return(Restrictions.On <Nomenclature>(x => x.Category).IsIn(nomenclatureTypeParam.GetSelectedValues().ToArray()));
            }
                                                                );

            //Предзагрузка. Для избежания ленивой загрузки
            UoW.Session.QueryOver <ProductGroup>().Fetch(SelectMode.Fetch, x => x.Childs).List();

            filter.CreateParameterSet(
                "Группы товаров",
                "product_group",
                new RecursiveParametersFactory <ProductGroup>(UoW,
                                                              (filters) => {
                var query = UoW.Session.QueryOver <ProductGroup>();
                if (filters != null && filters.Any())
                {
                    foreach (var f in filters)
                    {
                        query.Where(f());
                    }
                }
                return(query.List());
            },
                                                              x => x.Name,
                                                              x => x.Childs)
                );

            filter.CreateParameterSet(
                "Контрагенты",
                "counterparty",
                new ParametersFactory(UoW, (filters) => {
                SelectableEntityParameter <Counterparty> resultAlias = null;
                var query = UoW.Session.QueryOver <Counterparty>()
                            .Where(x => !x.IsArchive);
                if (filters != null && filters.Any())
                {
                    foreach (var f in filters)
                    {
                        query.Where(f());
                    }
                }

                query.SelectList(list => list
                                 .Select(x => x.Id).WithAlias(() => resultAlias.EntityId)
                                 .Select(x => x.FullName).WithAlias(() => resultAlias.EntityTitle)
                                 );
                query.TransformUsing(Transformers.AliasToBean <SelectableEntityParameter <Counterparty> >());
                return(query.List <SelectableParameter>());
            })
                );

            filter.CreateParameterSet(
                "Организации",
                "organization",
                new ParametersFactory(UoW, (filters) => {
                SelectableEntityParameter <Organization> resultAlias = null;
                var query = UoW.Session.QueryOver <Organization>();
                if (filters != null && filters.Any())
                {
                    foreach (var f in filters)
                    {
                        query.Where(f());
                    }
                }

                query.SelectList(list => list
                                 .Select(x => x.Id).WithAlias(() => resultAlias.EntityId)
                                 .Select(x => x.FullName).WithAlias(() => resultAlias.EntityTitle)
                                 );
                query.TransformUsing(Transformers.AliasToBean <SelectableEntityParameter <Organization> >());
                return(query.List <SelectableParameter>());
            })
                );

            filter.CreateParameterSet(
                "Основания скидок",
                "discount_reason",
                new ParametersFactory(UoW, (filters) => {
                SelectableEntityParameter <DiscountReason> resultAlias = null;
                var query = UoW.Session.QueryOver <DiscountReason>();
                if (filters != null && filters.Any())
                {
                    foreach (var f in filters)
                    {
                        query.Where(f());
                    }
                }

                query.SelectList(list => list
                                 .Select(x => x.Id).WithAlias(() => resultAlias.EntityId)
                                 .Select(x => x.Name).WithAlias(() => resultAlias.EntityTitle)
                                 );
                query.TransformUsing(Transformers.AliasToBean <SelectableEntityParameter <DiscountReason> >());
                return(query.List <SelectableParameter>());
            })
                );

            filter.CreateParameterSet(
                "Подразделения",
                "subdivision",
                new ParametersFactory(UoW, (filters) => {
                SelectableEntityParameter <Subdivision> resultAlias = null;
                var query = UoW.Session.QueryOver <Subdivision>();
                if (filters != null && filters.Any())
                {
                    foreach (var f in filters)
                    {
                        query.Where(f());
                    }
                }

                query.SelectList(list => list
                                 .Select(x => x.Id).WithAlias(() => resultAlias.EntityId)
                                 .Select(x => x.Name).WithAlias(() => resultAlias.EntityTitle)
                                 );
                query.TransformUsing(Transformers.AliasToBean <SelectableEntityParameter <Subdivision> >());
                return(query.List <SelectableParameter>());
            })
                );

            if (!userIsSalesRepresentative)
            {
                filter.CreateParameterSet(
                    "Авторы заказов",
                    "order_author",
                    new ParametersFactory(UoW, (filters) => {
                    SelectableEntityParameter <Employee> resultAlias = null;
                    var query = UoW.Session.QueryOver <Employee>();

                    if (filters != null && filters.Any())
                    {
                        foreach (var f in filters)
                        {
                            query.Where(f());
                        }
                    }

                    IProjection authorProjection = Projections.SqlFunction(
                        new SQLFunctionTemplate(NHibernateUtil.String, "CONCAT_WS(' ', ?2, ?1, ?3)"),
                        NHibernateUtil.String,
                        Projections.Property <Employee>(x => x.Name),
                        Projections.Property <Employee>(x => x.LastName),
                        Projections.Property <Employee>(x => x.Patronymic)
                        );

                    query.SelectList(list => list
                                     .Select(x => x.Id).WithAlias(() => resultAlias.EntityId)
                                     .Select(authorProjection).WithAlias(() => resultAlias.EntityTitle)
                                     );
                    query.TransformUsing(Transformers.AliasToBean <SelectableEntityParameter <Employee> >());
                    var paremetersSet = query.List <SelectableParameter>();

                    return(paremetersSet);
                })
                    );
            }

            filter.CreateParameterSet(
                "Части города",
                "geographic_group",
                new ParametersFactory(UoW, (filters) => {
                SelectableEntityParameter <GeographicGroup> resultAlias = null;
                var query = UoW.Session.QueryOver <GeographicGroup>();

                if (filters != null && filters.Any())
                {
                    foreach (var f in filters)
                    {
                        query.Where(f());
                    }
                }

                query.SelectList(list => list
                                 .Select(x => x.Id).WithAlias(() => resultAlias.EntityId)
                                 .Select(x => x.Name).WithAlias(() => resultAlias.EntityTitle)
                                 );
                query.TransformUsing(Transformers.AliasToBean <SelectableEntityParameter <GeographicGroup> >());
                return(query.List <SelectableParameter>());
            })
                );

            filter.CreateParameterSet(
                "Тип оплаты",
                "payment_type",
                new ParametersEnumFactory <PaymentType>()
                );

            filter.CreateParameterSet(
                "Промонаборы",
                "promotional_set",
                new ParametersFactory(UoW, (filters) => {
                SelectableEntityParameter <PromotionalSet> resultAlias = null;
                var query = UoW.Session.QueryOver <PromotionalSet>()
                            .Where(x => !x.IsArchive);
                if (filters != null && filters.Any())
                {
                    foreach (var f in filters)
                    {
                        query.Where(f());
                    }
                }

                query.SelectList(list => list
                                 .Select(x => x.Id).WithAlias(() => resultAlias.EntityId)
                                 .Select(x => x.Name).WithAlias(() => resultAlias.EntityTitle)
                                 );
                query.TransformUsing(Transformers.AliasToBean <SelectableEntityParameter <PromotionalSet> >());
                return(query.List <SelectableParameter>());
            })
                );

            var viewModel    = new SelectableParameterReportFilterViewModel(filter);
            var filterWidget = new SelectableParameterReportFilterView(viewModel);

            vboxParameters.Add(filterWidget);
            filterWidget.Show();
        }
Exemple #8
0
        void ConfigureDlg()
        {
            buttonHelp.Clicked += ShowInfoWindow;

            dateperiodpicker.StartDate = dateperiodpicker.EndDate = DateTime.Today;

            filter.CreateParameterSet(
                "Части города",
                "geographic_group",
                new ParametersFactory(UoW, (filters) =>
            {
                SelectableEntityParameter <GeographicGroup> resultAlias = null;
                var query = UoW.Session.QueryOver <GeographicGroup>();

                if (filters != null && filters.Any())
                {
                    foreach (var f in filters)
                    {
                        query.Where(f());
                    }
                }

                query.SelectList(list => list
                                 .Select(x => x.Id).WithAlias(() => resultAlias.EntityId)
                                 .Select(x => x.Name).WithAlias(() => resultAlias.EntityTitle)
                                 );

                query.TransformUsing(Transformers.AliasToBean <SelectableEntityParameter <GeographicGroup> >());

                return(query.List <SelectableParameter>());
            })
                );

            filter.CreateParameterSet(
                "Подразделения",
                "subdivision",
                new ParametersFactory(UoW, (filters) =>
            {
                SelectableEntityParameter <Subdivision> resultAlias = null;
                var query = UoW.Session.QueryOver <Subdivision>();
                if (filters != null && filters.Any())
                {
                    foreach (var f in filters)
                    {
                        query.Where(f());
                    }
                }

                query.SelectList(list => list
                                 .Select(x => x.Id).WithAlias(() => resultAlias.EntityId)
                                 .Select(x => x.Name).WithAlias(() => resultAlias.EntityTitle)
                                 );

                query.TransformUsing(Transformers.AliasToBean <SelectableEntityParameter <Subdivision> >());

                return(query.List <SelectableParameter>());
            })
                );

            filter.CreateParameterSet(
                "Авторы заказов",
                "order_author",
                new ParametersFactory(UoW, (filters) =>
            {
                SelectableEntityParameter <Employee> resultAlias = null;
                var query = UoW.Session.QueryOver <Employee>();

                if (filters != null && filters.Any())
                {
                    foreach (var f in filters)
                    {
                        query.Where(f());
                    }
                }

                IProjection authorProjection = Projections.SqlFunction(
                    new SQLFunctionTemplate(NHibernateUtil.String, "CONCAT_WS(' ', ?2, ?1, ?3)"),
                    NHibernateUtil.String,
                    Projections.Property <Employee>(x => x.Name),
                    Projections.Property <Employee>(x => x.LastName),
                    Projections.Property <Employee>(x => x.Patronymic)
                    );

                query.SelectList(list => list
                                 .Select(x => x.Id).WithAlias(() => resultAlias.EntityId)
                                 .Select(authorProjection).WithAlias(() => resultAlias.EntityTitle)
                                 );

                query.TransformUsing(Transformers.AliasToBean <SelectableEntityParameter <Employee> >());

                var paremetersSet = query.List <SelectableParameter>();

                return(paremetersSet);
            })
                );

            filter.CreateParameterSet(
                "Контрагенты",
                "counterparty",
                new ParametersFactory(UoW, (filters) =>
            {
                SelectableEntityParameter <Counterparty> resultAlias = null;
                var query = UoW.Session.QueryOver <Counterparty>()
                            .Where(x => !x.IsArchive);
                if (filters != null && filters.Any())
                {
                    foreach (var f in filters)
                    {
                        query.Where(f());
                    }
                }

                query.SelectList(list => list
                                 .Select(x => x.Id).WithAlias(() => resultAlias.EntityId)
                                 .Select(x => x.FullName).WithAlias(() => resultAlias.EntityTitle)
                                 );

                query.TransformUsing(Transformers.AliasToBean <SelectableEntityParameter <Counterparty> >());

                return(query.List <SelectableParameter>());
            })
                );

            var viewModel    = new SelectableParameterReportFilterViewModel(filter);
            var filterWidget = new SelectableParameterReportFilterView(viewModel);

            vboxParameters.Add(filterWidget);
            filterWidget.Show();
        }
Exemple #9
0
        private void ConfigureDlg()
        {
            dateperiodpicker1.StartDate = dateperiodpicker1.EndDate = DateTime.Today;

            var nomenclatureTypeParam = filter.CreateParameterSet(
                "Типы номенклатур",
                "nomenclature_type",
                new ParametersEnumFactory <NomenclatureCategory>()
                );

            var nomenclatureParam = filter.CreateParameterSet(
                "Номенклатуры",
                "nomenclature",
                new ParametersFactory(UoW, (filters) => {
                SelectableEntityParameter <Nomenclature> resultAlias = null;
                var query = UoW.Session.QueryOver <Nomenclature>()
                            .Where(x => !x.IsArchive);
                if (filters != null && filters.Any())
                {
                    foreach (var f in filters)
                    {
                        var filterCriterion = f();
                        if (filterCriterion != null)
                        {
                            query.Where(filterCriterion);
                        }
                    }
                }

                query.SelectList(list => list
                                 .Select(x => x.Id).WithAlias(() => resultAlias.EntityId)
                                 .Select(x => x.OfficialName).WithAlias(() => resultAlias.EntityTitle)
                                 );
                query.TransformUsing(Transformers.AliasToBean <SelectableEntityParameter <Nomenclature> >());
                return(query.List <SelectableParameter>());
            })
                );

            nomenclatureParam.AddFilterOnSourceSelectionChanged(nomenclatureTypeParam,
                                                                () => {
                var selectedValues = nomenclatureTypeParam.GetSelectedValues();
                if (!selectedValues.Any())
                {
                    return(null);
                }
                return(Restrictions.On <Nomenclature>(x => x.Category).IsIn(nomenclatureTypeParam.GetSelectedValues().ToArray()));
            }
                                                                );

            //Предзагрузка. Для избежания ленивой загрузки
            UoW.Session.QueryOver <ProductGroup>().Fetch(SelectMode.Fetch, x => x.Childs).List();

            filter.CreateParameterSet(
                "Группы товаров",
                "product_group",
                new RecursiveParametersFactory <ProductGroup>(UoW,
                                                              (filters) => {
                var query = UoW.Session.QueryOver <ProductGroup>();
                if (filters != null && filters.Any())
                {
                    foreach (var f in filters)
                    {
                        query.Where(f());
                    }
                }
                return(query.List());
            },
                                                              x => x.Name,
                                                              x => x.Childs)
                );

            var viewModel    = new SelectableParameterReportFilterViewModel(filter);
            var filterWidget = new SelectableParameterReportFilterView(viewModel);

            vboxParameters.Add(filterWidget);
            filterWidget.Show();

            ytreeSortPriority.ColumnsConfig = FluentColumnsConfig <SelectableSortTypeNode> .Create()
                                              .AddColumn("").AddToggleRenderer(x => x.Selected)
                                              .AddColumn("Имя").AddEnumRenderer(x => x.SortType)
                                              .Finish();

            ytreeSortPriority.HeadersVisible = false;
            ytreeSortPriority.Reorderable    = true;

            ytreeSortPriority.ItemsDataSource = selectableSortTypeNodes;

            foreach (SortType enumItem in Enum.GetValues(typeof(SortType)))
            {
                selectableSortTypeNodes.Add(new SelectableSortTypeNode(enumItem));
            }

            RefreshAvailableSortTypes();

            yentryrefWarehouse.Changed += YentryrefWarehouse_Changed;
        }
Exemple #10
0
        void ConfigureDlg()
        {
            canEdit = !UoW.IsNew && StoreDocumentHelper.CanEditDocument(WarehousePermissions.ShiftChangeEdit, Entity.Warehouse);

            if (Entity.Id != 0 && Entity.TimeStamp < DateTime.Today)
            {
                var permissionValidator = new EntityExtendedPermissionValidator(PermissionExtensionSingletonStore.GetInstance(), EmployeeSingletonRepository.GetInstance());
                canEdit &= permissionValidator.Validate(typeof(ShiftChangeWarehouseDocument), UserSingletonRepository.GetInstance().GetCurrentUser(UoW).Id, nameof(RetroactivelyClosePermission));
            }

            canCreate = UoW.IsNew && !StoreDocumentHelper.CheckCreateDocument(WarehousePermissions.ShiftChangeCreate, Entity.Warehouse);

            if (!canCreate && UoW.IsNew)
            {
                FailInitialize = true;
                return;
            }

            if (!canEdit && !UoW.IsNew)
            {
                MessageDialogHelper.RunWarningDialog("У вас нет прав на изменение этого документа.");
            }

            ydatepickerDocDate.Sensitive = yentryrefWarehouse.IsEditable = ytextviewCommnet.Editable = canEdit || canCreate;

            ytreeviewNomenclatures.Sensitive =
                buttonFillItems.Sensitive    =
                    buttonAdd.Sensitive      = canEdit || canCreate;

            ytreeviewNomenclatures.ItemsDataSource = Entity.ObservableItems;
            ytreeviewNomenclatures.YTreeModel?.EmitModelChanged();

            ydatepickerDocDate.Binding.AddBinding(Entity, e => e.TimeStamp, w => w.Date).InitializeFromSource();
            if (UoW.IsNew)
            {
                yentryrefWarehouse.ItemsQuery = StoreDocumentHelper.GetRestrictedWarehouseQuery(WarehousePermissions.ShiftChangeCreate);
            }
            if (!UoW.IsNew)
            {
                yentryrefWarehouse.ItemsQuery = StoreDocumentHelper.GetRestrictedWarehouseQuery(WarehousePermissions.ShiftChangeEdit);
            }
            yentryrefWarehouse.Binding.AddBinding(Entity, e => e.Warehouse, w => w.Subject).InitializeFromSource();
            yentryrefWarehouse.Changed += OnWarehouseChanged;

            ytextviewCommnet.Binding.AddBinding(Entity, e => e.Comment, w => w.Buffer.Text).InitializeFromSource();

            string errorMessage       = "Не установлены единицы измерения у следующих номенклатур :" + Environment.NewLine;
            int    wrongNomenclatures = 0;

            foreach (var item in Entity.Items)
            {
                if (item.Nomenclature.Unit == null)
                {
                    errorMessage += string.Format("Номер: {0}. Название: {1}{2}",
                                                  item.Nomenclature.Id, item.Nomenclature.Name, Environment.NewLine);
                    wrongNomenclatures++;
                }
            }
            if (wrongNomenclatures > 0)
            {
                MessageDialogHelper.RunErrorDialog(errorMessage);
                FailInitialize = true;
                return;
            }

            filter = new SelectableParametersReportFilter(UoW);

            var nomenclatureParam = filter.CreateParameterSet(
                "Номенклатуры",
                "nomenclature",
                new ParametersFactory(UoW, (filters) => {
                SelectableEntityParameter <Nomenclature> resultAlias = null;
                var query = UoW.Session.QueryOver <Nomenclature>()
                            .Where(x => !x.IsArchive);
                if (filters != null && filters.Any())
                {
                    foreach (var f in filters)
                    {
                        var filterCriterion = f();
                        if (filterCriterion != null)
                        {
                            query.Where(filterCriterion);
                        }
                    }
                }

                query.SelectList(list => list
                                 .Select(x => x.Id).WithAlias(() => resultAlias.EntityId)
                                 .Select(x => x.OfficialName).WithAlias(() => resultAlias.EntityTitle)
                                 );
                query.TransformUsing(Transformers.AliasToBean <SelectableEntityParameter <Nomenclature> >());
                return(query.List <SelectableParameter>());
            })
                );

            var nomenclatureTypeParam = filter.CreateParameterSet(
                "Типы номенклатур",
                "nomenclature_type",
                new ParametersEnumFactory <NomenclatureCategory>()
                );

            nomenclatureParam.AddFilterOnSourceSelectionChanged(nomenclatureTypeParam,
                                                                () => {
                var selectedValues = nomenclatureTypeParam.GetSelectedValues();
                if (!selectedValues.Any())
                {
                    return(null);
                }
                return(Restrictions.On <Nomenclature>(x => x.Category).IsIn(nomenclatureTypeParam.GetSelectedValues().ToArray()));
            }
                                                                );

            //Предзагрузка. Для избежания ленивой загрузки
            UoW.Session.QueryOver <ProductGroup>().Fetch(SelectMode.Fetch, x => x.Childs).List();

            filter.CreateParameterSet(
                "Группы товаров",
                "product_group",
                new RecursiveParametersFactory <ProductGroup>(UoW,
                                                              (filters) => {
                var query = UoW.Session.QueryOver <ProductGroup>();
                if (filters != null && filters.Any())
                {
                    foreach (var f in filters)
                    {
                        query.Where(f());
                    }
                }
                return(query.List());
            },
                                                              x => x.Name,
                                                              x => x.Childs)
                );

            var filterViewModel = new SelectableParameterReportFilterViewModel(filter);
            var filterWidget    = new SelectableParameterReportFilterView(filterViewModel);

            vboxParameters.Add(filterWidget);
            filterWidget.Show();

            ConfigureNomenclaturesView();
        }