public DeliveryPointViewModel GetForOpenDeliveryPointViewModel(int id)
        {
            var controller = new NomenclatureFixedPriceController(
                new NomenclatureFixedPriceFactory(),
                new WaterFixedPricesGenerator(
                    new NomenclatureRepository(
                        new NomenclatureParametersProvider(
                            new ParametersProvider()))));

            var dpViewModel = new DeliveryPointViewModel(
                new UserRepository(),
                new GtkTabsOpener(),
                new PhoneRepository(),
                ContactParametersProvider.Instance,
                new CitiesDataLoader(OsmWorker.GetOsmService()),
                new StreetsDataLoader(OsmWorker.GetOsmService()),
                new HousesDataLoader(OsmWorker.GetOsmService()),
                new NomenclatureSelectorFactory(),
                controller,
                new DeliveryPointRepository(),
                new DeliveryScheduleSelectorFactory(),
                EntityUoWBuilder.ForOpen(id),
                UnitOfWorkFactory.GetDefaultFactory,
                ServicesConfig.CommonServices);

            return(dpViewModel);
        }
Пример #2
0
        public void CreateComplaint(Order order)
        {
            if (order != null)
            {
                var nomenclatureRepository = new NomenclatureRepository(new NomenclatureParametersProvider());

                IEntityAutocompleteSelectorFactory employeeSelectorFactory =
                    new DefaultEntityAutocompleteSelectorFactory <Employee, EmployeesJournalViewModel, EmployeeFilterViewModel>(
                        ServicesConfig.CommonServices);

                IEntityAutocompleteSelectorFactory counterpartySelectorFactory =
                    new DefaultEntityAutocompleteSelectorFactory <Counterparty, CounterpartyJournalViewModel,
                                                                  CounterpartyJournalFilterViewModel>(ServicesConfig.CommonServices);

                IEntityAutocompleteSelectorFactory nomenclatureSelectorFactory =
                    new NomenclatureAutoCompleteSelectorFactory <Nomenclature, NomenclaturesJournalViewModel>(ServicesConfig
                                                                                                              .CommonServices, new NomenclatureFilterViewModel(), counterpartySelectorFactory,
                                                                                                              nomenclatureRepository, UserSingletonRepository.GetInstance());

                ISubdivisionRepository subdivisionRepository = new SubdivisionRepository();

                var parameters = new Dictionary <string, object> {
                    { "order", order },
                    { "uowBuilder", EntityUoWBuilder.ForCreate() },
                    { "unitOfWorkFactory", UnitOfWorkFactory.GetDefaultFactory },
                    { "employeeSelectorFactory", employeeSelectorFactory },
                    { "counterpartySelectorFactory", counterpartySelectorFactory },
                    { "subdivisionService", subdivisionRepository },
                    { "nomenclatureSelectorFactory", nomenclatureSelectorFactory },
                    { "nomenclatureRepository", nomenclatureRepository },
                    { "phone", "+7" + this.MangoManager.CurrentCall.Phone.Number }
                };
                tdiNavigation.OpenTdiTabOnTdiNamedArgs <CreateComplaintViewModel>(null, parameters);
            }
        }
 private IJournalAction CreateOpenAnalysisDialogAction()
 {
     return(new JournalAction(
                "Открыть диалог разбора",
                selectedItems => selectedItems.FirstOrDefault() is RouteListJournalNode node &&
                _analysisViewModelStatuses.Contains(node.StatusEnum),
                selectedItems => true,
                selectedItems =>
     {
         if (selectedItems.FirstOrDefault() is RouteListJournalNode selectedNode)
         {
             TabParent.AddTab(
                 new RouteListAnalysisViewModel(
                     EntityUoWBuilder.ForOpen(selectedNode.Id),
                     UnitOfWorkFactory,
                     commonServices,
                     _orderSelectorFactory,
                     _employeeJournalFactory,
                     _counterpartyJournalFactory,
                     _deliveryPointJournalFactory,
                     _subdivisionJournalFactory,
                     _gtkTabsOpener,
                     _undeliveredOrdersJournalOpener,
                     _deliveryShiftRepository,
                     _employeeSettings,
                     _undeliveredOrdersRepository
                     ),
                 this,
                 false
                 );
         }
     }
                ));
 }
Пример #4
0
 private void CreateActivateNodeAction()
 {
     PopupActionsList.Add(
         new JournalAction(
             "Активировать",
             selectedItems => canActivateDistrictsSet && canUpdate &&
             selectedItems.OfType <DistrictsSetJournalNode>().FirstOrDefault()?.Status == DistrictsSetStatus.Draft,
             selectedItems => true,
             selectedItems => {
         var selectedNodes = selectedItems.OfType <DistrictsSetJournalNode>();
         var selectedNode  = selectedNodes.FirstOrDefault();
         if (selectedNode == null)
         {
             return;
         }
         var activeDistrictsSet = UoW.Session.QueryOver <DistrictsSet>().Where(x => x.Status == DistrictsSetStatus.Active).Take(1).SingleOrDefault();
         if (activeDistrictsSet?.DateCreated > selectedNode.DateCreated)
         {
             commonServices.InteractiveService.ShowMessage(ImportanceLevel.Warning, "Нельзя активировать, так как дата создания выбранной версии меньше чем дата создания активной версии");
             return;
         }
         var selectedDistrictsSet = UoW.GetById <DistrictsSet>(selectedNode.Id);
         if (selectedDistrictsSet.Districts.All(x => x.CopyOf == null) &&
             !commonServices.InteractiveService.Question("Для выбранной версии невозможно перенести все приоритеты работы водителей\nПродолжить?"))
         {
             return;
         }
         TabParent.AddSlaveTab(this,
                               new DistrictsSetActivationViewModel(EntityUoWBuilder.ForOpen(selectedNode.Id), QS.DomainModel.UoW.UnitOfWorkFactory.GetDefaultFactory, commonServices)
                               );
     }
             )
         );
 }
Пример #5
0
    void ActionNewRequestToSupplier_Activated(object sender, System.EventArgs e)
    {
        var nomenclatureRepository = new NomenclatureRepository(new NomenclatureParametersProvider());

        IEntityAutocompleteSelectorFactory counterpartySelectorFactory =
            new DefaultEntityAutocompleteSelectorFactory <Counterparty, CounterpartyJournalViewModel,
                                                          CounterpartyJournalFilterViewModel>(ServicesConfig.CommonServices);

        IEntityAutocompleteSelectorFactory nomenclatureSelectorFactory =
            new NomenclatureAutoCompleteSelectorFactory <Nomenclature, NomenclaturesJournalViewModel>(ServicesConfig.CommonServices,
                                                                                                      new NomenclatureFilterViewModel(), counterpartySelectorFactory, nomenclatureRepository,
                                                                                                      UserSingletonRepository.GetInstance());

        tdiMain.OpenTab(
            DialogHelper.GenerateDialogHashName <RequestToSupplier>(0),
            () => new RequestToSupplierViewModel(
                EntityUoWBuilder.ForCreate(),
                UnitOfWorkFactory.GetDefaultFactory,
                ServicesConfig.CommonServices,
                VodovozGtkServicesConfig.EmployeeService,
                new SupplierPriceItemsRepository(),
                counterpartySelectorFactory,
                nomenclatureSelectorFactory,
                nomenclatureRepository,
                UserSingletonRepository.GetInstance()
                )
            );
    }
        private void RegisterOrdersWithoutShipmentForPayment()
        {
            var ordersConfig = RegisterEntity <OrderWithoutShipmentForPayment>(GetOrdersWithoutShipmentForPaymentQuery)
                               .AddDocumentConfiguration(
                //функция диалога создания документа
                () => new OrderWithoutShipmentForPaymentViewModel(
                    EntityUoWBuilder.ForCreate(),
                    UnitOfWorkFactory,
                    _commonServices,
                    _employeeService,
                    new ParametersProvider()
                    ),
                //функция диалога открытия документа
                (RetailOrderJournalNode node) => new OrderWithoutShipmentForPaymentViewModel(
                    EntityUoWBuilder.ForOpen(node.Id),
                    UnitOfWorkFactory,
                    _commonServices,
                    _employeeService,
                    new ParametersProvider()
                    ),
                //функция идентификации документа
                (RetailOrderJournalNode node) => node.EntityType == typeof(OrderWithoutShipmentForPayment),
                "Счет без отгрузки на постоплату",
                new JournalParametersForDocument {
                HideJournalForCreateDialog = false, HideJournalForOpenDialog = true
            }
                );

            //завершение конфигурации
            ordersConfig.FinishConfiguration();
        }
        private void RegisterPayments()
        {
            var complaintConfig = RegisterEntity <Payment>(GetPaymentQuery)
                                  .AddDocumentConfiguration(
                //функция диалога создания документа
                () => new PaymentLoaderViewModel(
                    unitOfWorkFactory,
                    commonServices,
                    navigationManager,
                    organizationParametersProvider,
                    profitCategoryProvider
                    ),
                //функция диалога открытия документа
                (PaymentJournalNode node) => new ManualPaymentMatchingViewModel(
                    EntityUoWBuilder.ForOpen(node.Id),
                    unitOfWorkFactory,
                    commonServices,
                    orderRepository
                    ),
                //функция идентификации документа
                (PaymentJournalNode node) => {
                return(node.EntityType == typeof(Payment));
            },
                "Платежи",
                new JournalParametersForDocument {
                HideJournalForCreateDialog = true, HideJournalForOpenDialog = true
            }
                );

            //завершение конфигурации
            complaintConfig.FinishConfiguration();
        }
Пример #8
0
        private void RegisterPremiums()
        {
            var premiumsConfig = RegisterEntity <Premium>(GetPremiumsQuery)
                                 .AddDocumentConfiguration(
                //функция диалога создания документа
                () => new PremiumViewModel(
                    EntityUoWBuilder.ForCreate(),
                    UnitOfWorkFactory,
                    _commonServices,
                    _employeeService,
                    _employeeJournalFactory,
                    _premiumTemplateJournalFactory
                    ),
                //функция диалога открытия документа
                (PremiumJournalNode node) => new PremiumViewModel(
                    EntityUoWBuilder.ForOpen(node.Id),
                    UnitOfWorkFactory,
                    _commonServices,
                    _employeeService,
                    _employeeJournalFactory,
                    _premiumTemplateJournalFactory
                    ),
                //функция идентификации документа
                (PremiumJournalNode node) => node.EntityType == typeof(Premium),
                "Премия",
                new JournalParametersForDocument {
                HideJournalForCreateDialog = false, HideJournalForOpenDialog = false
            }
                );

            //завершение конфигурации
            premiumsConfig.FinishConfiguration();
        }
Пример #9
0
        public DeliveryPointViewModel GetForCreationDeliveryPointViewModel(Counterparty client)
        {
            var controller = new NomenclatureFixedPriceController(
                new NomenclatureFixedPriceFactory(),
                new WaterFixedPricesGenerator(
                    new NomenclatureRepository(
                        new NomenclatureParametersProvider(
                            new ParametersProvider()))));

            var dpViewModel = new DeliveryPointViewModel(
                new UserRepository(),
                new GtkTabsOpener(),
                new PhoneRepository(),
                new ContactParametersProvider(new ParametersProvider()),
                new CitiesDataLoader(_fiasApiClient),
                new StreetsDataLoader(_fiasApiClient),
                new HousesDataLoader(_fiasApiClient),
                new NomenclatureJournalFactory(),
                controller,
                new DeliveryPointRepository(),
                new DeliveryScheduleSelectorFactory(),
                EntityUoWBuilder.ForCreate(),
                UnitOfWorkFactory.GetDefaultFactory,
                ServicesConfig.CommonServices,
                new RoboAtsCounterpartyJournalFactory(),
                client);

            return(dpViewModel);
        }
Пример #10
0
        private void Item_Activated(object sender, EventArgs e)
        {
            var item = ((MenuItemId <WriteoffItem>)sender).ID;

            ViewModel.NavigationManager.OpenViewModel <NomenclatureViewModel, IEntityUoWBuilder>(
                ViewModel, EntityUoWBuilder.ForOpen(item.Nomenclature.Id));
        }
Пример #11
0
        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;
            }));
        }
Пример #12
0
        /// <summary>
        /// Создает произвольный диалог для класса из доменной модели приложения.
        /// </summary>
        /// <returns>Виджет с интерфейсом ITdiDialog</returns>
        /// <param name="objectClass">Класс объекта для которого нужно создать диалог.</param>
        /// <param name="parameters">Параметры конструктора диалога.</param>
        public static ITdiDialog CreateObjectDialog(Type objectClass, params object[] parameters)
        {
            Type dlgType = GetDialogType(objectClass);

            if (dlgType == null)
            {
                InvalidOperationException ex = new InvalidOperationException(
                    String.Format("Для класса {0} нет привязанного диалога.", objectClass));
                logger.Error(ex);
                throw ex;
            }

            Type[] paramTypes = new Type[parameters.Length];
            for (int i = 0; i < parameters.Length; i++)
            {
                if (parameters[i] is INHibernateProxy)
                {
                    paramTypes[i] = NHibernateProxyHelper.GuessClass(parameters[i]);
                }
                else
                {
                    paramTypes[i] = parameters[i].GetType();
                }
            }

            // Guess ViewModel
            Type viewModelType = typeof(EntityTabViewModelBase <>);

            Type[] typeArgs = { objectClass };
            viewModelType = viewModelType.MakeGenericType(typeArgs);

            if (dlgType.IsSubclassOf(viewModelType))
            {
                Type[] constructorArgs = { typeof(IEntityUoWBuilder), typeof(IUnitOfWorkFactory), typeof(ICommonServices) };
                var    ctor            = dlgType.GetConstructor(constructorArgs);

                return((ITdiDialog)ctor.Invoke(new object[] {
                    EntityUoWBuilder.ForOpen(parameters.FirstOrDefault().GetId()),
                    UnitOfWorkFactory.GetDefaultFactory,
                    ServicesConfig.CommonServices
                }));
            }

            // Guess Dialog
            ConstructorInfo ci = dlgType.GetConstructor(paramTypes);

            if (ci == null)
            {
                InvalidOperationException ex = new InvalidOperationException(
                    String.Format("Конструктор для диалога {0} с параметрами({1}) не найден.", dlgType.ToString(), NHibernate.Util.CollectionPrinter.ToString(paramTypes)));
                logger.Error(ex);
                throw ex;
            }
            logger.Debug("Вызываем конструктор диалога {0} c параметрами {1}.", dlgType.ToString(), NHibernate.Util.CollectionPrinter.ToString(paramTypes));
            return((ITdiDialog)ci.Invoke(parameters));
        }
Пример #13
0
 protected void OnBtnAddPhoneClicked(object sender, EventArgs e)
 {
     TDIMain.MainNotebook.OpenTab(
         DialogHelper.GenerateDialogHashName <Counterparty>(Counterparty.Id),
         () => {
         var dlg = new CounterpartyDlg(EntityUoWBuilder.ForOpenInChildUoW(Counterparty.Id, InfoProvider.UoW), UnitOfWorkFactory.GetDefaultFactory);
         dlg.ActivateContactsTab();
         dlg.TabClosed += (senderObject, eventArgs) => { this.Refresh(); };
         return(dlg);
     }
         );
 }
 protected void OnBtnAddPhoneClicked(object sender, EventArgs e)
 {
     TDIMain.MainNotebook.OpenTab(
         DialogHelper.GenerateDialogHashName <Counterparty>(_counterparty.Id),
         () =>
     {
         var dlg = new CounterpartyDlg(EntityUoWBuilder.ForOpen(_counterparty.Id), UnitOfWorkFactory.GetDefaultFactory);
         dlg.ActivateContactsTab();
         dlg.EntitySaved += (o, args) => Refresh(args.Entity);
         return(dlg);
     }
         );
 }
Пример #15
0
 private void CreateAddNewPaymentAction()
 {
     NodeActionsList.Add(new JournalAction(
                             "Создать новый платеж",
                             x => _paymentPermissionResult.CanCreate,
                             x => _canCreateNewManualPayment,
                             selectedItems =>
     {
         _navigationManager.OpenViewModel <CreateManualPaymentFromBankClientViewModel, IEntityUoWBuilder>(
             this, EntityUoWBuilder.ForCreate());
     }
                             )
                         );
 }
 public void OpenExpense()
 {
     if (Entity.Expense != null)
     {
         NavigationManager.OpenViewModel <ExpenseEmployeeViewModel, IEntityUoWBuilder>(
             this, EntityUoWBuilder.ForOpen(Entity.Expense.Id));
     }
     else if (Entity.CollectiveExpense != null)
     {
         NavigationManager.OpenViewModel <CollectiveExpenseViewModel, IEntityUoWBuilder>(
             this, EntityUoWBuilder.ForOpen(Entity.CollectiveExpense.Id));
     }
     else
     {
         throw new NotSupportedException();
     }
 }
Пример #17
0
        public void CreateComplaint(Order order)
        {
            if (order != null)
            {
                var employeeSelectorFactory = _employeeJournalFactory.CreateEmployeeAutocompleteSelectorFactory();

                var counterpartySelectorFactory = _counterpartyJournalFactory.CreateCounterpartyAutocompleteSelectorFactory();

                var parameters = new Dictionary <string, object> {
                    { "order", order },
                    { "uowBuilder", EntityUoWBuilder.ForCreate() },
                    { "unitOfWorkFactory", UnitOfWorkFactory.GetDefaultFactory },
                    { "employeeSelectorFactory", employeeSelectorFactory },
                    { "counterpartySelectorFactory", counterpartySelectorFactory },
                    { "phone", "+7" + this.MangoManager.CurrentCall.Phone.Number }
                };
                tdiNavigation.OpenTdiTabOnTdiNamedArgs <CreateComplaintViewModel>(null, parameters);
            }
        }
Пример #18
0
        public void CreateComplaintCommand()
        {
            var employeeSelectorFactory = _employeeJournalFactory.CreateEmployeeAutocompleteSelectorFactory();

            var counterpartySelectorFactory = _counterpartyJournalFactory.CreateCounterpartyAutocompleteSelectorFactory();

            var parameters = new Dictionary <string, object> {
                { "uowBuilder", EntityUoWBuilder.ForCreate() },
                { "unitOfWorkFactory", UnitOfWorkFactory.GetDefaultFactory },
                //Autofac: IEmployeeService
                { "employeeSelectorFactory", employeeSelectorFactory },
                { "counterpartySelectorFactory", counterpartySelectorFactory },
                //Autofac: ICommonServices
                //Autofac: IUserRepository
                { "phone", "+7" + ActiveCall.Phone.Number }
            };

            _tdiNavigation.OpenTdiTabOnTdiNamedArgs <CreateComplaintViewModel>(null, parameters);
        }
Пример #19
0
        private void RegisterWriteoffDocument()
        {
            var complaintConfig = RegisterEntity <FuelWriteoffDocument>(GetWriteoffDocumentQuery)
                                  .AddDocumentConfiguration(
                //функция диалога создания документа
                () => new FuelWriteoffDocumentViewModel(
                    EntityUoWBuilder.ForCreate(),
                    UnitOfWorkFactory,
                    employeeService,
                    fuelRepository,
                    subdivisionRepository,
                    commonServices,
                    employeeJournalFactory,
                    reportViewOpener,
                    fileChooserProvider,
                    expenseCategoryJournalFilterViewModel,
                    _subdivisionJournalFactory
                    ),
                //функция диалога открытия документа
                (FuelDocumentJournalNode node) => new FuelWriteoffDocumentViewModel(
                    EntityUoWBuilder.ForOpen(node.Id),
                    UnitOfWorkFactory,
                    employeeService,
                    fuelRepository,
                    subdivisionRepository,
                    commonServices,
                    employeeJournalFactory,
                    reportViewOpener,
                    fileChooserProvider,
                    expenseCategoryJournalFilterViewModel,
                    _subdivisionJournalFactory
                    ),
                //функция идентификации документа
                (FuelDocumentJournalNode node) => {
                return(node.EntityType == typeof(FuelWriteoffDocument));
            },
                "Акт выдачи топлива"
                );

            //завершение конфигурации
            complaintConfig.FinishConfiguration();
        }
        public IEntityAutocompleteSelectorFactory CreateSimpleIncomeCategoryAutocompleteSelectorFactory()
        {
            var commonServices            = ServicesConfig.CommonServices;
            var employeeJournalFactory    = new EmployeeJournalFactory();
            var subdivisionJournalFactory = new SubdivisionJournalFactory();
            var incomeFactory             = new IncomeCategorySelectorFactory();

            var incomeCategoryAutocompleteSelectorFactory =
                new SimpleEntitySelectorFactory <IncomeCategory, IncomeCategoryViewModel>(
                    () =>
            {
                var incomeCategoryJournalViewModel =
                    new SimpleEntityJournalViewModel <IncomeCategory, IncomeCategoryViewModel>(
                        x => x.Name,
                        () => new IncomeCategoryViewModel(
                            EntityUoWBuilder.ForCreate(),
                            UnitOfWorkFactory.GetDefaultFactory,
                            commonServices,
                            employeeJournalFactory,
                            subdivisionJournalFactory,
                            incomeFactory
                            ),
                        node => new IncomeCategoryViewModel(
                            EntityUoWBuilder.ForOpen(node.Id),
                            UnitOfWorkFactory.GetDefaultFactory,
                            commonServices,
                            employeeJournalFactory,
                            subdivisionJournalFactory,
                            incomeFactory
                            ),
                        UnitOfWorkFactory.GetDefaultFactory,
                        commonServices
                        )
                {
                    SelectionMode = JournalSelectionMode.Single
                };
                return(incomeCategoryJournalViewModel);
            });

            return(incomeCategoryAutocompleteSelectorFactory);
        }
Пример #21
0
        private void RegisterPremiumsRaskatGAZelle()
        {
            var premiumRaskatGAZelleConfig =
                RegisterEntity <PremiumRaskatGAZelle>(GetPremiumsRaskatGAZelleQuery)
                .AddDocumentConfigurationWithoutCreation(
                    //функция диалога открытия документа
                    (PremiumJournalNode node) => new PremiumRaskatGAZelleViewModel(
                        EntityUoWBuilder.ForOpen(node.Id),
                        UnitOfWorkFactory,
                        _commonServices
                        ),
                    //функция идентификации документа
                    (PremiumJournalNode node) => node.EntityType == typeof(PremiumRaskatGAZelle),
                    new JournalParametersForDocument {
                HideJournalForCreateDialog = false, HideJournalForOpenDialog = false
            }
                    );

            //завершение конфигурации
            premiumRaskatGAZelleConfig.FinishConfiguration();
        }
        private void RegisterTransferDocument()
        {
            var complaintConfig = RegisterEntity <FuelTransferDocument>(GetTransferDocumentQuery)
                                  .AddDocumentConfiguration(
                //функция диалога создания документа
                () => new FuelTransferDocumentViewModel(
                    EntityUoWBuilder.ForCreate(),
                    UnitOfWorkFactory,
                    _employeeService,
                    _subdivisionRepository,
                    _fuelRepository,
                    _commonServices,
                    _employeeJournalFactory,
                    _carJournalFactory,
                    _reportViewOpener
                    ),
                //функция диалога открытия документа
                (FuelDocumentJournalNode node) => new FuelTransferDocumentViewModel(
                    EntityUoWBuilder.ForOpen(node.Id),
                    UnitOfWorkFactory,
                    _employeeService,
                    _subdivisionRepository,
                    _fuelRepository,
                    _commonServices,
                    _employeeJournalFactory,
                    _carJournalFactory,
                    _reportViewOpener
                    ),
                //функция идентификации документа
                (FuelDocumentJournalNode node) => {
                return(node.EntityType == typeof(FuelTransferDocument));
            },
                "Перемещение"
                );

            //завершение конфигурации
            complaintConfig.FinishConfiguration();
        }
        private void RegisterIncomeInvoice()
        {
            var complaintConfig = RegisterEntity <FuelIncomeInvoice>(GetFuelIncomeQuery)
                                  .AddDocumentConfiguration(
                //функция диалога создания документа
                () => new FuelIncomeInvoiceViewModel(
                    EntityUoWBuilder.ForCreate(),
                    UnitOfWorkFactory,
                    _employeeService,
                    _nomenclatureSelectorFactory,
                    _subdivisionRepository,
                    _fuelRepository,
                    _counterpartyJournalFactory,
                    _commonServices
                    ),
                //функция диалога открытия документа
                (FuelDocumentJournalNode node) => new FuelIncomeInvoiceViewModel(
                    EntityUoWBuilder.ForOpen(node.Id),
                    UnitOfWorkFactory,
                    _employeeService,
                    _nomenclatureSelectorFactory,
                    _subdivisionRepository,
                    _fuelRepository,
                    _counterpartyJournalFactory,
                    _commonServices
                    ),
                //функция идентификации документа
                (FuelDocumentJournalNode node) => {
                return(node.EntityType == typeof(FuelIncomeInvoice));
            },
                "Входящая накладная"
                );

            //завершение конфигурации
            complaintConfig.FinishConfiguration();
        }
Пример #24
0
        protected void OnButtonEditClicked(object sender, EventArgs e)
        {
            if (tableDocuments.GetSelectedObjects().GetLength(0) > 0)
            {
                int          id      = (tableDocuments.GetSelectedObjects() [0] as ViewModel.DocumentVMNode).Id;
                DocumentType DocType = (tableDocuments.GetSelectedObjects() [0] as ViewModel.DocumentVMNode).DocTypeEnum;

                switch (DocType)
                {
                case DocumentType.IncomingInvoice:
                    TabParent.OpenTab(
                        DialogHelper.GenerateDialogHashName <IncomingInvoice>(id),
                        () => {
                        return(new IncomingInvoiceViewModel(
                                   EntityUoWBuilder.ForOpen(id),
                                   UnitOfWorkFactory.GetDefaultFactory,
                                   new WarehousePermissionService(),
                                   VodovozGtkServicesConfig.EmployeeService,
                                   new EntityExtendedPermissionValidator(PermissionExtensionSingletonStore.GetInstance(), EmployeeSingletonRepository.GetInstance()),
                                   new NomenclatureSelectorFactory(),
                                   new OrderSelectorFactory(),
                                   new WarehouseRepository(),
                                   new RdlPreviewOpener(),
                                   ServicesConfig.CommonServices
                                   ));
                    },
                        this
                        );

                    break;

                case DocumentType.IncomingWater:
                    TabParent.OpenTab(
                        DialogHelper.GenerateDialogHashName <IncomingWater>(id),
                        () => new IncomingWaterDlg(id),
                        this);
                    break;

                case DocumentType.MovementDocument:
                    TabParent.OpenTab(
                        DialogHelper.GenerateDialogHashName <MovementDocument>(id),
                        () => {
                        return(new MovementDocumentViewModel(
                                   EntityUoWBuilder.ForOpen(id),
                                   UnitOfWorkFactory.GetDefaultFactory,
                                   new WarehousePermissionService(),
                                   VodovozGtkServicesConfig.EmployeeService,
                                   new EntityExtendedPermissionValidator(PermissionExtensionSingletonStore.GetInstance(), EmployeeSingletonRepository.GetInstance()),
                                   new NomenclatureSelectorFactory(),
                                   new OrderSelectorFactory(),
                                   new WarehouseRepository(),
                                   UserSingletonRepository.GetInstance(),
                                   new RdlPreviewOpener(),
                                   ServicesConfig.CommonServices
                                   ));
                    },
                        this
                        );
                    break;

                case DocumentType.WriteoffDocument:
                    TabParent.OpenTab(
                        DialogHelper.GenerateDialogHashName <WriteoffDocument>(id),
                        () => new WriteoffDocumentDlg(id),
                        this);
                    break;

                case DocumentType.InventoryDocument:
                    TabParent.OpenTab(
                        DialogHelper.GenerateDialogHashName <InventoryDocument>(id),
                        () => new InventoryDocumentDlg(id),
                        this);
                    break;

                case DocumentType.ShiftChangeDocument:
                    TabParent.OpenTab(
                        DialogHelper.GenerateDialogHashName <ShiftChangeWarehouseDocument>(id),
                        () => new ShiftChangeWarehouseDocumentDlg(id),
                        this);
                    break;

                case DocumentType.RegradingOfGoodsDocument:
                    TabParent.OpenTab(
                        DialogHelper.GenerateDialogHashName <RegradingOfGoodsDocument>(id),
                        () => new RegradingOfGoodsDocumentDlg(id),
                        this);
                    break;

                case DocumentType.SelfDeliveryDocument:
                    TabParent.OpenTab(
                        DialogHelper.GenerateDialogHashName <SelfDeliveryDocument>(id),
                        () => new SelfDeliveryDocumentDlg(id),
                        this);
                    break;

                case DocumentType.CarLoadDocument:
                    TabParent.OpenTab(
                        DialogHelper.GenerateDialogHashName <CarLoadDocument>(id),
                        () => new CarLoadDocumentDlg(id),
                        this);
                    break;

                case DocumentType.CarUnloadDocument:
                    TabParent.OpenTab(
                        DialogHelper.GenerateDialogHashName <CarUnloadDocument>(id),
                        () => new CarUnloadDocumentDlg(id),
                        this);
                    break;

                default:
                    throw new NotSupportedException("Тип документа не поддерживается.");
                }
            }
        }
Пример #25
0
        private void CopyNorm(object[] nodes)
        {
            if (nodes.Length != 1)
            {
                return;
            }
            int normId = (nodes[0] as NormJournalNode).Id;
            var page   = NavigationManager.OpenViewModel <NormViewModel, IEntityUoWBuilder>(this, EntityUoWBuilder.ForCreate());

            page.ViewModel.CopyNormFrom(normId);
        }
Пример #26
0
        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();
        }
Пример #27
0
        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 void OpenNomenclature(Nomenclature nomenclature)
 {
     NavigationManager.OpenViewModel <NomenclatureViewModel, IEntityUoWBuilder>(
         this, EntityUoWBuilder.ForOpen(nomenclature.Id));
 }
Пример #29
0
        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;
            }
        }
Пример #30
0
        protected void OnButtonAddEnumItemClicked(object sender, QS.Widgets.EnumItemClickedEventArgs e)
        {
            DocumentType type = (DocumentType)e.ItemEnum;

            switch (type)
            {
            case DocumentType.MovementDocument:
                TabParent.OpenTab(
                    DialogHelper.GenerateDialogHashName(Document.GetDocClass(type), 0),
                    () => {
                    return(new MovementDocumentViewModel(
                               EntityUoWBuilder.ForCreate(),
                               UnitOfWorkFactory.GetDefaultFactory,
                               new WarehousePermissionService(),
                               VodovozGtkServicesConfig.EmployeeService,
                               new EntityExtendedPermissionValidator(PermissionExtensionSingletonStore.GetInstance(), EmployeeSingletonRepository.GetInstance()),
                               new NomenclatureSelectorFactory(),
                               new OrderSelectorFactory(),
                               new WarehouseRepository(),
                               UserSingletonRepository.GetInstance(),
                               new RdlPreviewOpener(),
                               ServicesConfig.CommonServices
                               ));
                },
                    this
                    );
                break;

            case DocumentType.IncomingInvoice:
                TabParent.OpenTab(
                    DialogHelper.GenerateDialogHashName(Document.GetDocClass(type), 0),
                    () => {
                    return(new IncomingInvoiceViewModel(
                               EntityUoWBuilder.ForCreate(),
                               UnitOfWorkFactory.GetDefaultFactory,
                               new WarehousePermissionService(),
                               VodovozGtkServicesConfig.EmployeeService,
                               new EntityExtendedPermissionValidator(PermissionExtensionSingletonStore.GetInstance(), EmployeeSingletonRepository.GetInstance()),
                               new NomenclatureSelectorFactory(),
                               new OrderSelectorFactory(),
                               new WarehouseRepository(),
                               new RdlPreviewOpener(),
                               ServicesConfig.CommonServices
                               ));
                },
                    this
                    );
                break;

            case DocumentType.IncomingWater:
            case DocumentType.WriteoffDocument:
            case DocumentType.SelfDeliveryDocument:
            case DocumentType.CarLoadDocument:
            case DocumentType.CarUnloadDocument:
            case DocumentType.InventoryDocument:
            case DocumentType.ShiftChangeDocument:
            case DocumentType.RegradingOfGoodsDocument:
            default:
                TabParent.OpenTab(
                    DialogHelper.GenerateDialogHashName(Document.GetDocClass(type), 0),
                    () => OrmMain.CreateObjectDialog(Document.GetDocClass(type)),
                    this
                    );
                break;
            }
        }