public IEntityAutocompleteSelectorFactory CreateSimpleExpenseCategoryAutocompleteSelectorFactory() { var expenceCategoryfilterViewModel = new ExpenseCategoryJournalFilterViewModel(); expenceCategoryfilterViewModel.ExcludedIds = _excludedIds; expenceCategoryfilterViewModel.HidenByDefault = true; var employeeFilter = new EmployeeFilterViewModel { Status = EmployeeStatus.IsWorking }; var employeeJournalFactory = new EmployeeJournalFactory(employeeFilter); var subdivisionJournalFactory = new SubdivisionJournalFactory(); var expenseFactory = new ExpenseCategorySelectorFactory(); return(new SimpleEntitySelectorFactory <ExpenseCategory, ExpenseCategoryViewModel>(() => { var journal = new SimpleEntityJournalViewModel <ExpenseCategory, ExpenseCategoryViewModel>( x => x.Name, () => new ExpenseCategoryViewModel( EntityUoWBuilder.ForCreate(), UnitOfWorkFactory.GetDefaultFactory, ServicesConfig.CommonServices, employeeJournalFactory, subdivisionJournalFactory, expenseFactory ), node => new ExpenseCategoryViewModel( EntityUoWBuilder.ForOpen(node.Id), UnitOfWorkFactory.GetDefaultFactory, ServicesConfig.CommonServices, employeeJournalFactory, subdivisionJournalFactory, expenseFactory ), UnitOfWorkFactory.GetDefaultFactory, ServicesConfig.CommonServices ); journal.SelectionMode = JournalSelectionMode.Single; journal.SetFilter(expenceCategoryfilterViewModel, filter => { if (filter.ShowArchive) { return Restrictions.Not(Restrictions.In("Id", filter.ExcludedIds.ToArray())); } return Restrictions.Conjunction() .Add(Restrictions.Not(Restrictions.In("Id", filter.ExcludedIds.ToArray()))) .Add(Restrictions.Eq( Projections.Property <ExpenseCategory>(c => c.IsArchive), filter.ShowArchive)); }); return journal; })); }
public CashRequestViewModel( IEntityUoWBuilder uowBuilder, IUnitOfWorkFactory unitOfWorkFactory, ICommonServices commonServices, IFileChooserProvider fileChooserProvider, IEmployeeRepository employeeRepository, CashRepository cashRepository, ConsoleInteractiveService consoleInteractiveService ) : base(uowBuilder, unitOfWorkFactory, commonServices) { this.uowBuilder = uowBuilder ?? throw new ArgumentNullException(nameof(uowBuilder)); this.cashRepository = cashRepository ?? throw new ArgumentNullException(nameof(cashRepository)); this.unitOfWorkFactory = unitOfWorkFactory ?? throw new ArgumentNullException(nameof(unitOfWorkFactory)); this.consoleInteractiveService = consoleInteractiveService ?? throw new ArgumentNullException(nameof(consoleInteractiveService)); var filterViewModel = new ExpenseCategoryJournalFilterViewModel { ExcludedIds = CategoryRepository.ExpenseSelfDeliveryCategories(UoW).Select(x => x.Id), HidenByDefault = true }; ExpenseCategoryAutocompleteSelectorFactory = new SimpleEntitySelectorFactory <ExpenseCategory, ExpenseCategoryViewModel>( () => { var expenseCategoryJournalViewModel = new SimpleEntityJournalViewModel <ExpenseCategory, ExpenseCategoryViewModel>( x => x.Name, () => new ExpenseCategoryViewModel( EntityUoWBuilder.ForCreate(), unitOfWorkFactory, ServicesConfig.CommonServices, fileChooserProvider, filterViewModel ), node => new ExpenseCategoryViewModel( EntityUoWBuilder.ForOpen(node.Id), unitOfWorkFactory, ServicesConfig.CommonServices, fileChooserProvider, filterViewModel ), unitOfWorkFactory, ServicesConfig.CommonServices ) { SelectionMode = JournalSelectionMode.Single }; expenseCategoryJournalViewModel.SetFilter(filterViewModel, filter => Restrictions.Not(Restrictions.In("Id", filter.ExcludedIds.ToArray()))); return(expenseCategoryJournalViewModel); }); var expenseCategorySelectorFactory = CurrentEmployee = employeeRepository.GetEmployeeForCurrentUser(UoW); if (uowBuilder.IsNewEntity) { TabName = "Создание новой заявки на выдачу ДС"; } else { TabName = $"{Entity.Title}"; } int userId = ServicesConfig.CommonServices.UserService.CurrentUserId; var isAdmin = ServicesConfig.CommonServices.UserService.GetCurrentUser(UoW).IsAdmin; IsAdminPanelVisible = isAdmin; var currentRole = getUserRole(userId); UserRole = currentRole; if (!dialogLoadedOnce) { savedUserRole = UserRole; dialogLoadedOnce = true; } if (isAdmin) { UserRole = savedUserRole; } IsNewEntity = uowBuilder.IsNewEntity; ConfigureEntityChangingRelations(); }
void ConfigureDlg() { if (!UoW.IsNew) { enumcomboOperation.Sensitive = false; specialListCmbOrganisation.Sensitive = false; } accessfilteredsubdivisionselectorwidget.OnSelected += Accessfilteredsubdivisionselectorwidget_OnSelected; if (Entity.RelatedToSubdivision != null) { accessfilteredsubdivisionselectorwidget.SelectIfPossible(Entity.RelatedToSubdivision); } enumcomboOperation.ItemsEnum = typeof(ExpenseType); enumcomboOperation.Binding.AddBinding(Entity, s => s.TypeOperation, w => w.SelectedItem).InitializeFromSource(); var filterCasher = new EmployeeFilterViewModel { Status = EmployeeStatus.IsWorking }; yentryCasher.RepresentationModel = new ViewModel.EmployeesVM(filterCasher); yentryCasher.Binding.AddBinding(Entity, s => s.Casher, w => w.Subject).InitializeFromSource(); var filterEmployee = new EmployeeFilterViewModel { Status = EmployeeStatus.IsWorking }; yentryEmployee.RepresentationModel = new ViewModel.EmployeesVM(filterEmployee); yentryEmployee.Binding.AddBinding(Entity, s => s.Employee, w => w.Subject).InitializeFromSource(); yentryEmployee.ChangedByUser += (sender, e) => UpdateEmployeeBalaceInfo(); ydateDocument.Binding.AddBinding(Entity, s => s.Date, w => w.Date).InitializeFromSource(); ydateDocument.Sensitive = canEditDate; IFileChooserProvider fileChooserProvider = new FileChooser("Расход " + DateTime.Now + ".csv"); var filterViewModel = new ExpenseCategoryJournalFilterViewModel { ExcludedIds = CategoryRepository.ExpenseSelfDeliveryCategories(UoW).Select(x => x.Id), HidenByDefault = true }; var expenseCategorySelectorFactory = new SimpleEntitySelectorFactory <ExpenseCategory, ExpenseCategoryViewModel>( () => { var expenseCategoryJournalViewModel = new SimpleEntityJournalViewModel <ExpenseCategory, ExpenseCategoryViewModel>( x => x.Name, () => new ExpenseCategoryViewModel( EntityUoWBuilder.ForCreate(), UnitOfWorkFactory.GetDefaultFactory, ServicesConfig.CommonServices, fileChooserProvider, filterViewModel ), node => new ExpenseCategoryViewModel( EntityUoWBuilder.ForOpen(node.Id), UnitOfWorkFactory.GetDefaultFactory, ServicesConfig.CommonServices, fileChooserProvider, filterViewModel ), UnitOfWorkFactory.GetDefaultFactory, ServicesConfig.CommonServices ) { SelectionMode = JournalSelectionMode.Single }; expenseCategoryJournalViewModel.SetFilter(filterViewModel, filter => Restrictions.Not(Restrictions.In("Id", filter.ExcludedIds.ToArray()))); return(expenseCategoryJournalViewModel); } ); entityVMEntryExpenseCategory.SetEntityAutocompleteSelectorFactory(expenseCategorySelectorFactory); entityVMEntryExpenseCategory.Binding.AddBinding(Entity, e => e.ExpenseCategory, w => w.Subject).InitializeFromSource(); specialListCmbOrganisation.ShowSpecialStateNot = true; specialListCmbOrganisation.ItemsList = UoW.GetAll <Organization>(); specialListCmbOrganisation.Binding.AddBinding(Entity, e => e.Organisation, w => w.SelectedItem).InitializeFromSource(); yspinMoney.Binding.AddBinding(Entity, s => s.Money, w => w.ValueAsDecimal).InitializeFromSource(); ytextviewDescription.Binding.AddBinding(Entity, s => s.Description, w => w.Buffer.Text).InitializeFromSource(); ExpenseType type = (ExpenseType)enumcomboOperation.SelectedItem; ylabelEmployeeWageBalance.Visible = type == ExpenseType.EmployeeAdvance || type == ExpenseType.Salary || (type == ExpenseType.Advance && (new EmployeeCategory[] { EmployeeCategory.office }).All(x => x != Entity?.Employee?.Category)); UpdateEmployeeBalaceInfo(); UpdateSubdivision(); if (!CanEdit) { table1.Sensitive = false; accessfilteredsubdivisionselectorwidget.Sensitive = false; buttonSave.Sensitive = false; ytextviewDescription.Editable = false; } }
private void ConfigureEntityViewModelEntry() { var incomeCategoryFilter = new IncomeCategoryJournalFilterViewModel(); var expenseCategoryFilter = new ExpenseCategoryJournalFilterViewModel { ExcludedIds = new CategoryRepository(new ParametersProvider()).ExpenseSelfDeliveryCategories(UoW).Select(x => x.Id), HidenByDefault = true }; var commonServices = ServicesConfig.CommonServices; IFileChooserProvider chooserIncomeProvider = new FileChooser("Приход " + DateTime.Now + ".csv"); IFileChooserProvider chooserExpenseProvider = new FileChooser("Расход " + DateTime.Now + ".csv"); var employeeJournalFactory = new EmployeeJournalFactory(); var subdivisionJournalFactory = new SubdivisionJournalFactory(); var incomeCategoryAutocompleteSelectorFactory = new SimpleEntitySelectorFactory <IncomeCategory, IncomeCategoryViewModel>( () => { var incomeCategoryJournalViewModel = new SimpleEntityJournalViewModel <IncomeCategory, IncomeCategoryViewModel>( x => x.Name, () => new IncomeCategoryViewModel( EntityUoWBuilder.ForCreate(), UnitOfWorkFactory.GetDefaultFactory, commonServices, chooserIncomeProvider, incomeCategoryFilter, employeeJournalFactory, subdivisionJournalFactory ), node => new IncomeCategoryViewModel( EntityUoWBuilder.ForOpen(node.Id), UnitOfWorkFactory.GetDefaultFactory, commonServices, chooserIncomeProvider, incomeCategoryFilter, employeeJournalFactory, subdivisionJournalFactory ), UnitOfWorkFactory.GetDefaultFactory, commonServices ) { SelectionMode = JournalSelectionMode.Single }; return(incomeCategoryJournalViewModel); }); var expenseCategoryAutocompleteSelectorFactory = new SimpleEntitySelectorFactory <ExpenseCategory, ExpenseCategoryViewModel>( () => { var expenseCategoryJournalViewModel = new SimpleEntityJournalViewModel <ExpenseCategory, ExpenseCategoryViewModel>( x => x.Name, () => new ExpenseCategoryViewModel( EntityUoWBuilder.ForCreate(), UnitOfWorkFactory.GetDefaultFactory, ServicesConfig.CommonServices, chooserExpenseProvider, expenseCategoryFilter, employeeJournalFactory, subdivisionJournalFactory ), node => new ExpenseCategoryViewModel( EntityUoWBuilder.ForOpen(node.Id), UnitOfWorkFactory.GetDefaultFactory, ServicesConfig.CommonServices, chooserExpenseProvider, expenseCategoryFilter, employeeJournalFactory, subdivisionJournalFactory ), UnitOfWorkFactory.GetDefaultFactory, ServicesConfig.CommonServices ) { SelectionMode = JournalSelectionMode.Single }; expenseCategoryJournalViewModel.SetFilter(expenseCategoryFilter, filter => Restrictions.Not(Restrictions.In("Id", filter.ExcludedIds.ToArray()))); return(expenseCategoryJournalViewModel); }); entityVMEntryCashIncomeCategory.SetEntityAutocompleteSelectorFactory(incomeCategoryAutocompleteSelectorFactory); entityVMEntryCashExpenseCategory.SetEntityAutocompleteSelectorFactory(expenseCategoryAutocompleteSelectorFactory); }
public CashRequestViewModel( IEntityUoWBuilder uowBuilder, IUnitOfWorkFactory unitOfWorkFactory, ICommonServices commonServices, IFileChooserProvider fileChooserProvider, IEmployeeRepository employeeRepository, ICashRepository cashRepository, IEmployeeJournalFactory employeeJournalFactory, ISubdivisionJournalFactory subdivisionJournalFactory ) : base(uowBuilder, unitOfWorkFactory, commonServices) { this.uowBuilder = uowBuilder ?? throw new ArgumentNullException(nameof(uowBuilder)); _cashRepository = cashRepository ?? throw new ArgumentNullException(nameof(cashRepository)); EmployeeJournalFactory = employeeJournalFactory ?? throw new ArgumentNullException(nameof(employeeJournalFactory)); SubdivisionJournalFactory = subdivisionJournalFactory ?? throw new ArgumentNullException(nameof(subdivisionJournalFactory)); var filterViewModel = new ExpenseCategoryJournalFilterViewModel { ExcludedIds = new CategoryRepository(new ParametersProvider()).ExpenseSelfDeliveryCategories(UoW).Select(x => x.Id), HidenByDefault = true }; ExpenseCategoryAutocompleteSelectorFactory = new SimpleEntitySelectorFactory <ExpenseCategory, ExpenseCategoryViewModel>( () => { var expenseCategoryJournalViewModel = new SimpleEntityJournalViewModel <ExpenseCategory, ExpenseCategoryViewModel>( x => x.Name, () => new ExpenseCategoryViewModel( EntityUoWBuilder.ForCreate(), unitOfWorkFactory, ServicesConfig.CommonServices, fileChooserProvider, filterViewModel, EmployeeJournalFactory, SubdivisionJournalFactory ), node => new ExpenseCategoryViewModel( EntityUoWBuilder.ForOpen(node.Id), unitOfWorkFactory, ServicesConfig.CommonServices, fileChooserProvider, filterViewModel, EmployeeJournalFactory, SubdivisionJournalFactory ), unitOfWorkFactory, ServicesConfig.CommonServices ) { SelectionMode = JournalSelectionMode.Single }; expenseCategoryJournalViewModel.SetFilter(filterViewModel, filter => Restrictions.Not(Restrictions.In("Id", filter.ExcludedIds.ToArray()))); return(expenseCategoryJournalViewModel); }); var expenseCategorySelectorFactory = CurrentEmployee = employeeRepository.GetEmployeeForCurrentUser(UoW); if (uowBuilder.IsNewEntity) { TabName = "Создание новой заявки на выдачу ДС"; } else { TabName = $"{Entity.Title}"; } int userId = ServicesConfig.CommonServices.UserService.CurrentUserId; UserRoles = getUserRoles(userId); IsRoleChooserSensitive = UserRoles.Count() > 1; UserRole = UserRoles.First(); IsNewEntity = uowBuilder.IsNewEntity; ConfigureEntityChangingRelations(); }