void ActionFuelTransferDocuments_Activated(object sender, System.EventArgs e) { ISubdivisionRepository subdivisionRepository = new SubdivisionRepository(); IFuelRepository fuelRepository = new FuelRepository(); ICounterpartyJournalFactory counterpartyJournalFactory = new CounterpartyJournalFactory(); INomenclatureSelectorFactory nomenclatureSelectorFactory = new NomenclatureSelectorFactory(); IEmployeeJournalFactory employeeJournalFactory = new EmployeeJournalFactory(); ICarJournalFactory carJournalFactory = new CarJournalFactory(); IFileChooserProvider fileChooserProvider = new Vodovoz.FileChooser("Категория Расхода.csv"); var expenseCategoryJournalFilterViewModel = new ExpenseCategoryJournalFilterViewModel(); var fuelDocumentsJournalViewModel = new FuelDocumentsJournalViewModel( UnitOfWorkFactory.GetDefaultFactory, ServicesConfig.CommonServices, VodovozGtkServicesConfig.EmployeeService, subdivisionRepository, fuelRepository, counterpartyJournalFactory, nomenclatureSelectorFactory, employeeJournalFactory, carJournalFactory, new GtkReportViewOpener(), fileChooserProvider, expenseCategoryJournalFilterViewModel ); tdiMain.AddTab(fuelDocumentsJournalViewModel); }
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); }