Beispiel #1
0
        protected void OnButtonChangeNewClicked(object sender, EventArgs e)
        {
            var filter = new NomenclatureFilterViewModel();

            var nomenclatureRepository = new EntityRepositories.Goods.NomenclatureRepository(new NomenclatureParametersProvider());

            var userRepository = UserSingletonRepository.GetInstance();

            var employeeService = VodovozGtkServicesConfig.EmployeeService;

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

            var nomenclatureAutoCompleteSelectorFactory =
                new NomenclatureAutoCompleteSelectorFactory <Nomenclature, NomenclaturesJournalViewModel>(
                    ServicesConfig.CommonServices,
                    filter,
                    counterpartySelectorFactory,
                    nomenclatureRepository,
                    userRepository
                    );

            var nomenclaturesJournalViewModel =
                new NomenclaturesJournalViewModel(
                    filter,
                    UnitOfWorkFactory.GetDefaultFactory,
                    ServicesConfig.CommonServices,
                    employeeService,
                    nomenclatureAutoCompleteSelectorFactory,
                    counterpartySelectorFactory,
                    nomenclatureRepository,
                    userRepository
                    );

            nomenclaturesJournalViewModel.SelectionMode           = JournalSelectionMode.Single;
            nomenclaturesJournalViewModel.OnEntitySelectedResult += ChangeNewNomenclature_OnEntitySelectedResult;

            MyTab.TabParent.AddSlaveTab(MyTab, nomenclaturesJournalViewModel);
        }
Beispiel #2
0
        void ConfigureDlg()
        {
            if (StoreDocumentHelper.CheckAllPermissions(UoW.IsNew, WarehousePermissions.IncomingWaterEdit, Entity.IncomingWarehouse, Entity.WriteOffWarehouse))
            {
                FailInitialize = true;
                return;
            }

            var editing = StoreDocumentHelper.CanEditDocument(WarehousePermissions.IncomingWaterEdit, Entity.IncomingWarehouse, Entity.WriteOffWarehouse);

            buttonFill.Sensitive = yentryProduct.IsEditable = spinAmount.Sensitive
                                                                  = referenceSrcWarehouse.IsEditable = referenceDstWarehouse.IsEditable = editing;
            incomingwatermaterialview1.Sensitive = editing;

            labelTimeStamp.Binding.AddBinding(Entity, e => e.DateString, w => w.LabelProp).InitializeFromSource();
            spinAmount.Binding.AddBinding(Entity, e => e.Amount, w => w.ValueAsInt).InitializeFromSource();

            referenceSrcWarehouse.ItemsQuery = StoreDocumentHelper.GetRestrictedWarehouseQuery(WarehousePermissions.IncomingWaterEdit);
            referenceSrcWarehouse.Binding.AddBinding(Entity, e => e.WriteOffWarehouse, w => w.Subject).InitializeFromSource();
            referenceDstWarehouse.ItemsQuery = StoreDocumentHelper.GetRestrictedWarehouseQuery(WarehousePermissions.IncomingWaterEdit);
            referenceDstWarehouse.Binding.AddBinding(Entity, e => e.IncomingWarehouse, w => w.Subject).InitializeFromSource();

            incomingwatermaterialview1.DocumentUoW = UoWGeneric;

            var permmissionValidator = new EntityExtendedPermissionValidator(PermissionExtensionSingletonStore.GetInstance(), EmployeeSingletonRepository.GetInstance());

            Entity.CanEdit = permmissionValidator.Validate(typeof(IncomingWater), UserSingletonRepository.GetInstance().GetCurrentUser(UoW).Id, nameof(RetroactivelyClosePermission));
            if (!Entity.CanEdit && Entity.TimeStamp.Date != DateTime.Now.Date)
            {
                spinAmount.Binding.AddFuncBinding(Entity, e => e.CanEdit, w => w.Sensitive).InitializeFromSource();
                yentryProduct.Sensitive              = false;
                referenceDstWarehouse.Sensitive      = false;
                referenceSrcWarehouse.Sensitive      = false;
                buttonFill.Sensitive                 = false;
                incomingwatermaterialview1.Sensitive = false;
                buttonSave.Sensitive                 = false;
            }
            else
            {
                Entity.CanEdit = true;
            }

            var nomenclatureFilter = new NomenclatureFilterViewModel()
            {
                HidenByDefault = true
            };
            var nomenclatureRepository = new EntityRepositories.Goods.NomenclatureRepository(new NomenclatureParametersProvider());

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

            var nomenclatureAutoCompleteSelectorFactory =
                new NomenclatureAutoCompleteSelectorFactory <Nomenclature, NomenclaturesJournalViewModel>(
                    ServicesConfig.CommonServices,
                    nomenclatureFilter,
                    counterpartySelectorFactory,
                    nomenclatureRepository,
                    UserSingletonRepository.GetInstance()
                    );

            yentryProduct.SetEntityAutocompleteSelectorFactory(nomenclatureAutoCompleteSelectorFactory);
            yentryProduct.Binding.AddBinding(Entity, e => e.Product, w => w.Subject).InitializeFromSource();
        }
        void ConfigureDlg()
        {
            if (StoreDocumentHelper.CheckAllPermissions(UoW.IsNew, WarehousePermissions.IncomingWaterEdit, Entity.IncomingWarehouse, Entity.WriteOffWarehouse))
            {
                FailInitialize = true;
                return;
            }

            var editing = StoreDocumentHelper.CanEditDocument(WarehousePermissions.IncomingWaterEdit, Entity.IncomingWarehouse, Entity.WriteOffWarehouse);

            buttonFill.Sensitive = yentryProduct.IsEditable = spinAmount.Sensitive = editing;
            incomingwatermaterialview1.Sensitive = editing;

            labelTimeStamp.Binding.AddBinding(Entity, e => e.DateString, w => w.LabelProp).InitializeFromSource();
            spinAmount.Binding.AddBinding(Entity, e => e.Amount, w => w.ValueAsInt).InitializeFromSource();

            var userHasOnlyAccessToWarehouseAndComplaints =
                ServicesConfig.CommonServices.CurrentPermissionService.ValidatePresetPermission("user_have_access_only_to_warehouse_and_complaints") &&
                !ServicesConfig.CommonServices.UserService.GetCurrentUser(UoW).IsAdmin;

            if (userHasOnlyAccessToWarehouseAndComplaints)
            {
                sourceWarehouseEntry.CanEditReference = destinationWarehouseEntry.CanEditReference = false;
            }
            else
            {
                sourceWarehouseEntry.CanEditReference = destinationWarehouseEntry.CanEditReference = true;
            }

            var availableWarehousesIds = StoreDocumentHelper.GetRestrictedWarehousesIds(UoW, WarehousePermissions.IncomingWaterEdit);
            var warehouseFilter        = new WarehouseJournalFilterViewModel
            {
                IncludeWarehouseIds = availableWarehousesIds
            };
            var warehouseAutocompleteSelectorFactory = new WarehouseSelectorFactory(warehouseFilter);

            sourceWarehouseEntry.SetEntityAutocompleteSelectorFactory(warehouseAutocompleteSelectorFactory);
            sourceWarehouseEntry.Binding.AddBinding(Entity, e => e.WriteOffWarehouse, w => w.Subject).InitializeFromSource();
            destinationWarehouseEntry.SetEntityAutocompleteSelectorFactory(warehouseAutocompleteSelectorFactory);
            destinationWarehouseEntry.Binding.AddBinding(Entity, e => e.IncomingWarehouse, w => w.Subject).InitializeFromSource();

            incomingwatermaterialview1.DocumentUoW = UoWGeneric;

            var permmissionValidator =
                new EntityExtendedPermissionValidator(PermissionExtensionSingletonStore.GetInstance(), _employeeRepository);

            Entity.CanEdit =
                permmissionValidator.Validate(
                    typeof(IncomingWater), _userRepository.GetCurrentUser(UoW).Id, nameof(RetroactivelyClosePermission));

            if (!Entity.CanEdit && Entity.TimeStamp.Date != DateTime.Now.Date)
            {
                spinAmount.Binding.AddFuncBinding(Entity, e => e.CanEdit, w => w.Sensitive).InitializeFromSource();
                yentryProduct.Sensitive             = false;
                destinationWarehouseEntry.Sensitive = false;
                sourceWarehouseEntry.Sensitive      = false;
                buttonFill.Sensitive = false;
                incomingwatermaterialview1.Sensitive = false;
                buttonSave.Sensitive = false;
            }
            else
            {
                Entity.CanEdit = true;
            }

            var nomenclatureFilter = new NomenclatureFilterViewModel()
            {
                HidenByDefault = true
            };
            var nomenclatureRepository =
                new EntityRepositories.Goods.NomenclatureRepository(new NomenclatureParametersProvider(new ParametersProvider()));
            var counterpartyJournalFactory = new CounterpartyJournalFactory();

            var nomenclatureAutoCompleteSelectorFactory =
                new NomenclatureAutoCompleteSelectorFactory <Nomenclature, NomenclaturesJournalViewModel>(
                    ServicesConfig.CommonServices,
                    nomenclatureFilter,
                    counterpartyJournalFactory,
                    nomenclatureRepository,
                    _userRepository
                    );

            yentryProduct.SetEntityAutocompleteSelectorFactory(nomenclatureAutoCompleteSelectorFactory);
            yentryProduct.Binding.AddBinding(Entity, e => e.Product, w => w.Subject).InitializeFromSource();
        }
Beispiel #4
0
        protected void OnButtonAddClicked(object sender, EventArgs e)
        {
            NomenclatureStockFilterViewModel filter = new NomenclatureStockFilterViewModel(
                new WarehouseRepository()
                );

            filter.RestrictWarehouse = DocumentUoW.Root.Warehouse;

            NomenclatureStockBalanceJournalViewModel vm = new NomenclatureStockBalanceJournalViewModel(
                filter,
                UnitOfWorkFactory.GetDefaultFactory,
                ServicesConfig.CommonServices
                );

            vm.SelectionMode           = JournalSelectionMode.Single;
            vm.TabName                 = "Выберите номенклатуру на замену";
            vm.OnEntitySelectedResult += (s, ea) => {
                var selectedNode = ea.SelectedNodes.Cast <NomenclatureStockJournalNode>().FirstOrDefault();
                if (selectedNode == null)
                {
                    return;
                }
                var nomenclature = DocumentUoW.GetById <Nomenclature>(selectedNode.Id);

                newRow = new RegradingOfGoodsDocumentItem()
                {
                    NomenclatureOld = nomenclature,
                    AmountInStock   = selectedNode.StockAmount
                };

                var nomenclatureFilter = new NomenclatureFilterViewModel();

                var nomenclatureRepository = new EntityRepositories.Goods.NomenclatureRepository(new NomenclatureParametersProvider());

                var userRepository = UserSingletonRepository.GetInstance();

                var employeeService = VodovozGtkServicesConfig.EmployeeService;

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

                var nomenclatureAutoCompleteSelectorFactory =
                    new NomenclatureAutoCompleteSelectorFactory <Nomenclature, NomenclaturesJournalViewModel>(
                        ServicesConfig.CommonServices,
                        nomenclatureFilter,
                        counterpartySelectorFactory,
                        nomenclatureRepository,
                        userRepository
                        );

                var nomenclaturesJournalViewModel =
                    new NomenclaturesJournalViewModel(
                        nomenclatureFilter,
                        UnitOfWorkFactory.GetDefaultFactory,
                        ServicesConfig.CommonServices,
                        employeeService,
                        nomenclatureAutoCompleteSelectorFactory,
                        counterpartySelectorFactory,
                        nomenclatureRepository,
                        userRepository
                        );

                nomenclaturesJournalViewModel.SelectionMode           = JournalSelectionMode.Single;
                nomenclaturesJournalViewModel.OnEntitySelectedResult += SelectNewNomenclature_ObjectSelected;

                MyTab.TabParent.AddSlaveTab(MyTab, nomenclaturesJournalViewModel);
            };
            MyTab.TabParent.AddSlaveTab(MyTab, vm);
        }