private void SetWageCalculationService(WageParameterItem wageParameterItem) { switch (wageParameterItem.WageParameterItemType) { case WageParameterItemTypes.Manual: calculationService = new RouteListManualWageCalculationService((ManualWageParameterItem)wageParameterItem, source); break; case WageParameterItemTypes.OldRates: calculationService = new RouteListOldRatesWageCalculationService((OldRatesWageParameterItem)wageParameterItem, source); break; case WageParameterItemTypes.Fixed: calculationService = new RouteListFixedWageCalculationService((FixedWageParameterItem)wageParameterItem, source); break; case WageParameterItemTypes.Percent: calculationService = new RouteListPercentWageCalculationService((PercentWageParameterItem)wageParameterItem, source); break; case WageParameterItemTypes.RatesLevel: calculationService = new RouteListRatesLevelWageCalculationService((RatesLevelWageParameterItem)wageParameterItem, source); break; default: throw new ArgumentOutOfRangeException($"Пропущен один из типов {nameof(WageParameterItemTypes)}"); } }
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; EmployeeWageParameter wageParameterAlias = null; WageParameterItem wageParameterItemAlias = null; var query = UoW.Session.QueryOver <Employee>() .JoinAlias(e => e.WageParameters, () => wageParameterAlias) .JoinAlias(() => wageParameterAlias.WageParameterItem, () => wageParameterItemAlias); if (filters != null && filters.Any()) { foreach (var f in filters) { var criterion = f(); if (criterion != null) { query.Where(criterion); } } } query.Where(e => e.Status == EmployeeStatus.IsWorking) .And(e => e.Category == EmployeeCategory.office) .And(() => wageParameterAlias.EndDate == null || wageParameterAlias.EndDate >= DateTime.Now) .And(() => wageParameterItemAlias.WageParameterItemType == WageParameterItemTypes.SalesPlan); 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> >()); return(query.List <SelectableParameter>()); }) ); 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); vboxParameters.Add(filterWidget); filterWidget.Show(); }