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(); }
private void Configure() { ViewModel.PropertyChanged += ViewModelOnPropertyChanged; buttonLoad.Binding.AddSource(ViewModel) .AddFuncBinding(vm => !vm.IsGenerating, w => w.Visible) .AddFuncBinding(vm => !vm.IsGenerating, w => w.Sensitive) .InitializeFromSource(); buttonLoad.Clicked += ButtonLoadOnClicked; buttonAbort.Binding.AddSource(ViewModel) .AddBinding(vm => vm.IsGenerating, w => w.Visible) .AddBinding(vm => vm.IsGenerating, w => w.Sensitive) .InitializeFromSource(); buttonAbort.Clicked += (sender, args) => { ViewModel.ReportGenerationCancelationTokenSource.Cancel(); }; buttonExport.Visible = false; datePicker.Binding.AddBinding(ViewModel, vm => vm.EndDate, w => w.DateOrNull).InitializeFromSource(); radioAllNoms.Binding.AddBinding(ViewModel, vm => vm.AllNomenclatures, w => w.Active).InitializeFromSource(); radioGtZNoms.Binding.AddBinding(ViewModel, vm => vm.IsGreaterThanZeroByNomenclature, w => w.Active).InitializeFromSource(); radioLeZNoms.Binding.AddBinding(ViewModel, vm => vm.IsLessOrEqualZeroByNomenclature, w => w.Active).InitializeFromSource(); radioLtMinNoms.Binding.AddBinding(ViewModel, vm => vm.IsLessThanMinByNomenclature, w => w.Active).InitializeFromSource(); radioGeMinNoms.Binding.AddBinding(ViewModel, vm => vm.IsGreaterOrEqualThanMinByNomenclature, w => w.Active).InitializeFromSource(); radioAllWars.Binding.AddBinding(ViewModel, vm => vm.AllWarehouses, w => w.Active).InitializeFromSource(); radioGtZWars.Binding.AddBinding(ViewModel, vm => vm.IsGreaterThanZeroByWarehouse, w => w.Active).InitializeFromSource(); radioLeZWars.Binding.AddBinding(ViewModel, vm => vm.IsLessOrEqualZeroByWarehouse, w => w.Active).InitializeFromSource(); radioLtMinWars.Binding.AddBinding(ViewModel, vm => vm.IsLessThanMinByWarehouse, w => w.Active).InitializeFromSource(); radioGeMinWars.Binding.AddBinding(ViewModel, vm => vm.IsGreaterOrEqualThanMinByWarehouse, w => w.Active).InitializeFromSource(); var nomsWidget = new SelectableParameterReportFilterView(ViewModel.NomsViewModel); vboxNomsFilter.Add(nomsWidget); nomsWidget.Show(); var warsWidget = new SelectableParameterReportFilterView(ViewModel.WarsViewModel); vboxWarsFilter.Add(warsWidget); warsWidget.Show(); eventboxArrow.ButtonPressEvent += (o, args) => { vboxSections.Visible = !vboxSections.Visible; arrowSlider.ArrowType = vboxSections.Visible ? ArrowType.Left : ArrowType.Right; }; treeData.EnableGridLines = TreeViewGridLines.Both; }
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(); }
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(); }
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(); }
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 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(); }
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(); }
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; }
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(); }