void ConfigureDlg()
        {
            if (StoreDocumentHelper.CheckAllPermissions(UoW.IsNew, WarehousePermissions.RegradingOfGoodsEdit, Entity.Warehouse))
            {
                FailInitialize = true;
                return;
            }

            var editing = StoreDocumentHelper.CanEditDocument(WarehousePermissions.RegradingOfGoodsEdit, Entity.Warehouse);

            ytextviewCommnet.Editable           = editing;
            regradingofgoodsitemsview.Sensitive = editing;

            ylabelDate.Binding.AddFuncBinding(Entity, e => e.TimeStamp.ToString("g"), w => w.LabelProp).InitializeFromSource();

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

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

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

            warehouseEntry.SetEntityAutocompleteSelectorFactory(new WarehouseSelectorFactory(warehouseFilter));
            warehouseEntry.Binding.AddBinding(Entity, e => e.Warehouse, w => w.Subject).InitializeFromSource();
            ytextviewCommnet.Binding.AddBinding(Entity, e => e.Comment, w => w.Buffer.Text).InitializeFromSource();

            regradingofgoodsitemsview.DocumentUoW = UoWGeneric;
            if (Entity.Items.Count > 0)
            {
                warehouseEntry.Sensitive = false;
            }

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

            Entity.CanEdit = permmissionValidator.Validate(typeof(RegradingOfGoodsDocument), _userRepository.GetCurrentUser(UoW).Id, nameof(RetroactivelyClosePermission));
            if (!Entity.CanEdit && Entity.TimeStamp.Date != DateTime.Now.Date)
            {
                ytextviewCommnet.Binding.AddFuncBinding(Entity, e => e.CanEdit, w => w.Sensitive).InitializeFromSource();
                warehouseEntry.Binding.AddFuncBinding(Entity, e => e.CanEdit, w => w.Sensitive).InitializeFromSource();
                regradingofgoodsitemsview.Sensitive = false;

                buttonSave.Sensitive = false;
            }
            else
            {
                Entity.CanEdit = true;
            }
        }
Esempio n. 2
0
        public AdvanceReportDlg(int id, IPermissionService permissionService)
        {
            this.Build();
            UoWGeneric = UnitOfWorkFactory.CreateForRoot <AdvanceReport>(id);

            if (!accessfilteredsubdivisionselectorwidget.Configure(UoW, false, typeof(Income)))
            {
                MessageDialogHelper.RunErrorDialog(accessfilteredsubdivisionselectorwidget.ValidationErrorMessage);
                FailInitialize = true;
                return;
            }
            var userPermission = permissionService.ValidateUserPermission(typeof(AdvanceReport), UserSingletonRepository.GetInstance().GetCurrentUser(UoW).Id);

            if (!userPermission.CanRead)
            {
                MessageDialogHelper.RunErrorDialog("Отсутствуют права на просмотр приходного ордера");
                FailInitialize = true;
                return;
            }
            canEdit = userPermission.CanUpdate;

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

            canEditRectroactively = permmissionValidator.Validate(typeof(AdvanceReport), UserSingletonRepository.GetInstance().GetCurrentUser(UoW).Id, nameof(RetroactivelyClosePermission));

            //Отключаем отображение ненужных элементов.
            labelDebtTitle.Visible = labelTableTitle.Visible = hboxDebt.Visible = GtkScrolledWindow1.Visible = labelCreating.Visible = false;

            comboExpense.Sensitive = yspinMoney.Sensitive = yentryEmployee.Sensitive = specialListCmbOrganisation.Sensitive = false;

            ConfigureDlg();
        }
Esempio n. 3
0
        public CashExpenseDlg(int id, IPermissionService permissionService)
        {
            this.Build();
            UoWGeneric = UnitOfWorkFactory.CreateForRoot <Expense>(id);

            if (!accessfilteredsubdivisionselectorwidget.Configure(UoW, false, typeof(Expense)))
            {
                MessageDialogHelper.RunErrorDialog(accessfilteredsubdivisionselectorwidget.ValidationErrorMessage);
                FailInitialize = true;
                return;
            }

            var userPermission = permissionService.ValidateUserPermission(typeof(Expense), UserSingletonRepository.GetInstance().GetCurrentUser(UoW).Id);

            if (!userPermission.CanRead)
            {
                MessageDialogHelper.RunErrorDialog("Отсутствуют права на просмотр расходного ордера");
                FailInitialize = true;
                return;
            }
            canEdit = userPermission.CanUpdate;

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

            canEditRectroactively = permmissionValidator.Validate(typeof(Expense), UserSingletonRepository.GetInstance().GetCurrentUser(UoW).Id, nameof(RetroactivelyClosePermission));

            ConfigureDlg();
        }
Esempio n. 4
0
        public AdvanceReportDlg(int id)
        {
            Build();
            UoWGeneric = UnitOfWorkFactory.CreateForRoot <AdvanceReport>(id);

            if (!accessfilteredsubdivisionselectorwidget.Configure(UoW, false, typeof(Income)))
            {
                MessageDialogHelper.RunErrorDialog(accessfilteredsubdivisionselectorwidget.ValidationErrorMessage);
                FailInitialize = true;
                return;
            }

            _canEdit = permissionResult.CanUpdate;

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

            canEditRectroactively =
                permmissionValidator.Validate(
                    typeof(AdvanceReport), ServicesConfig.UserService.CurrentUserId, nameof(RetroactivelyClosePermission));

            //Отключаем отображение ненужных элементов.
            labelDebtTitle.Visible = labelTableTitle.Visible = hboxDebt.Visible = GtkScrolledWindow1.Visible = labelCreating.Visible = false;

            comboExpense.Sensitive = yspinMoney.Sensitive = evmeEmployee.Sensitive = specialListCmbOrganisation.Sensitive = false;

            ConfigureDlg();
        }
        void ConfigureDlg()
        {
            if (StoreDocumentHelper.CheckAllPermissions(UoW.IsNew, WarehousePermissions.RegradingOfGoodsEdit, Entity.Warehouse))
            {
                FailInitialize = true;
                return;
            }

            var editing = StoreDocumentHelper.CanEditDocument(WarehousePermissions.RegradingOfGoodsEdit, Entity.Warehouse);

            yentryrefWarehouse.IsEditable       = ytextviewCommnet.Editable = editing;
            regradingofgoodsitemsview.Sensitive = editing;

            ylabelDate.Binding.AddFuncBinding(Entity, e => e.TimeStamp.ToString("g"), w => w.LabelProp).InitializeFromSource();
            yentryrefWarehouse.ItemsQuery = StoreDocumentHelper.GetRestrictedWarehouseQuery(WarehousePermissions.RegradingOfGoodsEdit);
            yentryrefWarehouse.Binding.AddBinding(Entity, e => e.Warehouse, w => w.Subject).InitializeFromSource();
            ytextviewCommnet.Binding.AddBinding(Entity, e => e.Comment, w => w.Buffer.Text).InitializeFromSource();

            regradingofgoodsitemsview.DocumentUoW = UoWGeneric;
            if (Entity.Items.Count > 0)
            {
                yentryrefWarehouse.Sensitive = false;
            }

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

            Entity.CanEdit = permmissionValidator.Validate(typeof(RegradingOfGoodsDocument), UserSingletonRepository.GetInstance().GetCurrentUser(UoW).Id, nameof(RetroactivelyClosePermission));
            if (!Entity.CanEdit && Entity.TimeStamp.Date != DateTime.Now.Date)
            {
                ytextviewCommnet.Binding.AddFuncBinding(Entity, e => e.CanEdit, w => w.Sensitive).InitializeFromSource();
                yentryrefWarehouse.Binding.AddFuncBinding(Entity, e => e.CanEdit, w => w.Sensitive).InitializeFromSource();
                regradingofgoodsitemsview.Sensitive = false;

                buttonSave.Sensitive = false;
            }
            else
            {
                Entity.CanEdit = true;
            }
        }
Esempio n. 6
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 = referenceProduct.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();

			referenceProduct.SubjectType = typeof(Nomenclature);
			referenceProduct.Binding.AddBinding(Entity, e => e.Product, w => w.Subject).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();
				referenceProduct.Sensitive = false;
				referenceDstWarehouse.Sensitive = false;
				referenceSrcWarehouse.Sensitive = false;
				buttonFill.Sensitive = false;
				incomingwatermaterialview1.Sensitive = false;
				buttonSave.Sensitive = false;
			} else {
				Entity.CanEdit = true;
			}
		}
Esempio n. 7
0
        public CashExpenseSelfDeliveryDlg(int id)
        {
            Build();
            UoWGeneric = UnitOfWorkFactory.CreateForRoot <Expense>(id);

            if (!accessfilteredsubdivisionselectorwidget.Configure(UoW, false, typeof(Expense)))
            {
                MessageDialogHelper.RunErrorDialog(accessfilteredsubdivisionselectorwidget.ValidationErrorMessage);
                FailInitialize = true;
                return;
            }
            accessfilteredsubdivisionselectorwidget.OnSelected += Accessfilteredsubdivisionselectorwidget_OnSelected;

            _canEdit = permissionResult.CanUpdate;

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

            canEditRectroactively =
                permmissionValidator.Validate(typeof(Expense), ServicesConfig.UserService.CurrentUserId, nameof(RetroactivelyClosePermission));

            ConfigureDlg();
        }
        void ConfigureDlg()
        {
            if (StoreDocumentHelper.CheckAllPermissions(UoW.IsNew, WarehousePermissions.CarLoadEdit, Entity.Warehouse))
            {
                FailInitialize = true;
                return;
            }

            var currentUserId = ServicesConfig.CommonServices.UserService.CurrentUserId;
            var hasPermitionToEditDocWithClosedRL =
                ServicesConfig.CommonServices.PermissionService.ValidateUserPresetPermission(
                    "can_change_car_load_and_unload_docs", currentUserId);

            var editing = StoreDocumentHelper.CanEditDocument(WarehousePermissions.CarLoadEdit, Entity.Warehouse);

            editing &= Entity.RouteList?.Status != RouteListStatus.Closed || hasPermitionToEditDocWithClosedRL;
            yentryrefRouteList.IsEditable  = ySpecCmbWarehouses.Sensitive = ytextviewCommnet.Editable = editing;
            carloaddocumentview1.Sensitive = editing;

            ylabelDate.Binding.AddFuncBinding(Entity, e => e.TimeStamp.ToString("g"), w => w.LabelProp).InitializeFromSource();
            ySpecCmbWarehouses.ItemsList = StoreDocumentHelper.GetRestrictedWarehousesList(UoW, WarehousePermissions.CarLoadEdit);
            ySpecCmbWarehouses.Binding.AddBinding(Entity, e => e.Warehouse, w => w.SelectedItem).InitializeFromSource();
            ytextviewCommnet.Binding.AddBinding(Entity, e => e.Comment, w => w.Buffer.Text).InitializeFromSource();
            var filter = new RouteListsFilter(UoW);

            filter.SetAndRefilterAtOnce(x => x.RestrictedStatuses = new[] { RouteListStatus.InLoading });
            yentryrefRouteList.RepresentationModel = new ViewModel.RouteListsVM(filter);
            yentryrefRouteList.CanEditReference    = ServicesConfig.CommonServices.CurrentPermissionService.ValidatePresetPermission("can_delete");
            yentryrefRouteList.Binding.AddBinding(Entity, e => e.RouteList, w => w.Subject).InitializeFromSource();

            enumPrint.ItemsEnum = typeof(CarLoadPrintableDocuments);

            UpdateRouteListInfo();
            Entity.UpdateStockAmount(UoW, _stockRepository);
            Entity.UpdateAlreadyLoaded(UoW, _routeListRepository);
            Entity.UpdateInRouteListAmount(UoW, _routeListRepository);
            carloaddocumentview1.DocumentUoW = UoWGeneric;
            carloaddocumentview1.SetButtonEditing(editing);
            buttonSave.Sensitive = editing;
            if (!editing)
            {
                HasChanges = false;
            }
            if (UoW.IsNew && Entity.Warehouse != null)
            {
                carloaddocumentview1.FillItemsByWarehouse();
            }
            ySpecCmbWarehouses.ItemSelected += OnYSpecCmbWarehousesItemSelected;

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

            Entity.CanEdit =
                permmissionValidator.Validate(typeof(CarLoadDocument), currentUserId, nameof(RetroactivelyClosePermission));

            if (!Entity.CanEdit && Entity.TimeStamp.Date != DateTime.Now.Date)
            {
                ytextviewCommnet.Binding.AddFuncBinding(Entity, e => e.CanEdit, w => w.Sensitive).InitializeFromSource();
                yentryrefRouteList.Binding.AddFuncBinding(Entity, e => e.CanEdit, w => w.Sensitive).InitializeFromSource();
                ySpecCmbWarehouses.Binding.AddFuncBinding(Entity, e => e.CanEdit, w => w.Sensitive).InitializeFromSource();
                ytextviewRouteListInfo.Binding.AddFuncBinding(Entity, e => e.CanEdit, w => w.Sensitive).InitializeFromSource();
                carloaddocumentview1.Sensitive = false;

                buttonSave.Sensitive = false;
            }
            else
            {
                Entity.CanEdit = true;
            }
        }
Esempio n. 9
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();
        }
Esempio n. 10
0
        void ConfigureDlg()
        {
            if (StoreDocumentHelper.CheckAllPermissions(UoW.IsNew, WarehousePermissions.InventoryEdit, Entity.Warehouse))
            {
                FailInitialize = true;
                return;
            }

            var editing = StoreDocumentHelper.CanEditDocument(WarehousePermissions.InventoryEdit, Entity.Warehouse);

            ydatepickerDocDate.Sensitive = yentryrefWarehouse.IsEditable = ytextviewCommnet.Editable = editing;

            ytreeviewItems.Sensitive                   =
                buttonAdd.Sensitive                    =
                    buttonFillItems.Sensitive          =
                        buttonFine.Sensitive           =
                            buttonDeleteFine.Sensitive = editing;

            ydatepickerDocDate.Binding.AddBinding(Entity, e => e.TimeStamp, w => w.Date).InitializeFromSource();
            yentryrefWarehouse.ItemsQuery = StoreDocumentHelper.GetRestrictedWarehouseQuery(WarehousePermissions.InventoryEdit);
            yentryrefWarehouse.Binding.AddBinding(Entity, e => e.Warehouse, w => w.Subject).InitializeFromSource();

            ytextviewCommnet.Binding.AddBinding(Entity, e => e.Comment, w => w.Buffer.Text).InitializeFromSource();

            string errorMessage       = "Не установлены единицы измерения у следующих номенклатур :" + Environment.NewLine;
            int    wrongNomenclatures = 0;

            foreach (var item in UoWGeneric.Root.Items)
            {
                if (item.Nomenclature.Unit == null)
                {
                    errorMessage += string.Format("Номер: {0}. Название: {1}{2}",
                                                  item.Nomenclature.Id, item.Nomenclature.Name, Environment.NewLine);
                    wrongNomenclatures++;
                }
            }
            if (wrongNomenclatures > 0)
            {
                MessageDialogHelper.RunErrorDialog(errorMessage);
                FailInitialize = true;
                return;
            }

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

            Entity.CanEdit =
                permmissionValidator.Validate(
                    typeof(InventoryDocument), ServicesConfig.UserService.CurrentUserId, nameof(RetroactivelyClosePermission));

            if (!Entity.CanEdit && Entity.TimeStamp.Date != DateTime.Now.Date)
            {
                ydatepickerDocDate.Binding.AddFuncBinding(Entity, e => e.CanEdit, w => w.Sensitive).InitializeFromSource();
                yentryrefWarehouse.Binding.AddFuncBinding(Entity, e => e.CanEdit, w => w.Sensitive).InitializeFromSource();
                ytextviewCommnet.Binding.AddFuncBinding(Entity, e => e.CanEdit, w => w.Sensitive).InitializeFromSource();
                buttonSave.Sensitive                       = false;
                ytreeviewItems.Sensitive                   =
                    buttonAdd.Sensitive                    =
                        buttonFillItems.Sensitive          =
                            buttonFine.Sensitive           =
                                buttonDeleteFine.Sensitive = false;
            }
            else
            {
                Entity.CanEdit = true;
            }

            filter = new SelectableParametersReportFilter(UoW);

            var nomenclatureParam = filter.CreateParameterSet(
                "Номенклатуры",
                "nomenclature",
                new ParametersFactory(UoW, (filters) => {
                SelectableEntityParameter <Nomenclature> resultAlias = null;
                var query = UoW.Session.QueryOver <Nomenclature>()
                            .Where(x => !x.IsArchive);
                if (filters != null && filters.Any())
                {
                    foreach (var f in filters)
                    {
                        var filterCriterion = f();
                        if (filterCriterion != null)
                        {
                            query.Where(filterCriterion);
                        }
                    }
                }

                query.SelectList(list => list
                                 .Select(x => x.Id).WithAlias(() => resultAlias.EntityId)
                                 .Select(x => x.OfficialName).WithAlias(() => resultAlias.EntityTitle)
                                 );
                query.TransformUsing(Transformers.AliasToBean <SelectableEntityParameter <Nomenclature> >());
                return(query.List <SelectableParameter>());
            })
                );

            var nomenclatureTypeParam = filter.CreateParameterSet(
                "Типы номенклатур",
                "nomenclature_type",
                new ParametersEnumFactory <NomenclatureCategory>()
                );

            nomenclatureParam.AddFilterOnSourceSelectionChanged(nomenclatureTypeParam,
                                                                () => {
                var selectedValues = nomenclatureTypeParam.GetSelectedValues();
                if (!selectedValues.Any())
                {
                    return(null);
                }
                return(Restrictions.On <Nomenclature>(x => x.Category).IsIn(nomenclatureTypeParam.GetSelectedValues().ToArray()));
            }
                                                                );

            //Предзагрузка. Для избежания ленивой загрузки
            UoW.Session.QueryOver <ProductGroup>().Fetch(SelectMode.Fetch, x => x.Childs).List();

            filter.CreateParameterSet(
                "Группы товаров",
                "product_group",
                new RecursiveParametersFactory <ProductGroup>(UoW,
                                                              (filters) => {
                var query = UoW.Session.QueryOver <ProductGroup>();
                if (filters != null && filters.Any())
                {
                    foreach (var f in filters)
                    {
                        query.Where(f());
                    }
                }
                return(query.List());
            },
                                                              x => x.Name,
                                                              x => x.Childs)
                );

            var filterViewModel = new SelectableParameterReportFilterViewModel(filter);
            var filterWidget    = new SelectableParameterReportFilterView(filterViewModel);

            vboxParameters.Add(filterWidget);
            filterWidget.Show();

            ConfigNomenclatureColumns();
        }
        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();
        }
Esempio n. 12
0
        void ConfigureDlg()
        {
            callTaskWorker = new CallTaskWorker(
                CallTaskSingletonFactory.GetInstance(),
                new CallTaskRepository(),
                OrderSingletonRepository.GetInstance(),
                EmployeeSingletonRepository.GetInstance(),
                new BaseParametersProvider(),
                ServicesConfig.CommonServices.UserService,
                SingletonErrorReporter.Instance);

            if (StoreDocumentHelper.CheckAllPermissions(UoW.IsNew, WarehousePermissions.CarUnloadEdit, Entity.Warehouse))
            {
                FailInitialize = true;
                return;
            }

            var currentUserId = QS.Project.Services.ServicesConfig.CommonServices.UserService.CurrentUserId;
            var hasPermitionToEditDocWithClosedRL = QS.Project.Services.ServicesConfig.CommonServices.PermissionService.ValidateUserPresetPermission("can_change_car_load_and_unload_docs", currentUserId);
            var editing = StoreDocumentHelper.CanEditDocument(WarehousePermissions.CarUnloadEdit, Entity.Warehouse);

            editing &= Entity.RouteList?.Status != RouteListStatus.Closed || hasPermitionToEditDocWithClosedRL;
            Entity.InitializeDefaultValues(UoW, new NomenclatureRepository(new NomenclatureParametersProvider()));
            yentryrefRouteList.IsEditable  = ySpecCmbWarehouses.Sensitive = ytextviewCommnet.Editable = editing;
            returnsreceptionview.Sensitive =
                hbxTareToReturn.Sensitive  =
                    nonserialequipmentreceptionview1.Sensitive =
                        defectiveitemsreceptionview1.Sensitive = editing;

            defectiveitemsreceptionview1.UoW =
                returnsreceptionview.UoW     = UoW;

            ylabelDate.Binding.AddFuncBinding(Entity, e => e.TimeStamp.ToString("g"), w => w.LabelProp).InitializeFromSource();
            ySpecCmbWarehouses.ItemsList = StoreDocumentHelper.GetRestrictedWarehousesList(UoW, WarehousePermissions.CarUnloadEdit);
            ySpecCmbWarehouses.Binding.AddBinding(Entity, e => e.Warehouse, w => w.SelectedItem).InitializeFromSource();
            ytextviewCommnet.Binding.AddBinding(Entity, e => e.Comment, w => w.Buffer.Text).InitializeFromSource();
            var filter = new RouteListsFilter(UoW);

            filter.SetAndRefilterAtOnce(x => x.RestrictedStatuses = new[] { RouteListStatus.EnRoute });
            yentryrefRouteList.RepresentationModel = new ViewModel.RouteListsVM(filter);
            yentryrefRouteList.Binding.AddBinding(Entity, e => e.RouteList, w => w.Subject).InitializeFromSource();
            yentryrefRouteList.CanEditReference = ServicesConfig.CommonServices.CurrentPermissionService.ValidatePresetPermission("can_delete");

            Entity.PropertyChanged += (sender, e) => {
                if (e.PropertyName == nameof(Entity.Warehouse))
                {
                    OnWarehouseChanged();
                }
                if (e.PropertyName == nameof(Entity.RouteList))
                {
                    UpdateWidgetsVisible();
                }
            };

            lblTareReturnedBefore.Binding.AddFuncBinding(Entity, e => e.ReturnedTareBeforeText, w => w.Text).InitializeFromSource();
            spnTareToReturn.Binding.AddBinding(Entity, e => e.TareToReturn, w => w.ValueAsInt).InitializeFromSource();

            defectiveitemsreceptionview1.Warehouse = returnsreceptionview.Warehouse = Entity.Warehouse;

            UpdateWidgetsVisible();
            buttonSave.Sensitive = editing;
            if (!editing)
            {
                HasChanges = false;
            }
            if (!UoW.IsNew)
            {
                LoadReception();
            }

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

            Entity.CanEdit = permmissionValidator.Validate(typeof(CarUnloadDocument), UserSingletonRepository.GetInstance().GetCurrentUser(UoW).Id, nameof(RetroactivelyClosePermission));
            if (!Entity.CanEdit && Entity.TimeStamp.Date != DateTime.Now.Date)
            {
                ytextviewCommnet.Binding.AddFuncBinding(Entity, e => e.CanEdit, w => w.Sensitive).InitializeFromSource();
                yentryrefRouteList.Binding.AddFuncBinding(Entity, e => e.CanEdit, w => w.Sensitive).InitializeFromSource();
                ySpecCmbWarehouses.Binding.AddFuncBinding(Entity, e => e.CanEdit, w => w.Sensitive).InitializeFromSource();
                ytextviewRouteListInfo.Binding.AddFuncBinding(Entity, e => e.CanEdit, w => w.Sensitive).InitializeFromSource();
                spnTareToReturn.Binding.AddFuncBinding(Entity, e => e.CanEdit, w => w.Sensitive).InitializeFromSource();
                defectiveitemsreceptionview1.Sensitive     = false;
                nonserialequipmentreceptionview1.Sensitive = false;
                returnsreceptionview.Sensitive             = false;

                buttonSave.Sensitive = false;
            }
            else
            {
                Entity.CanEdit = true;
            }
        }
Esempio n. 13
0
        void ConfigureDlg()
        {
            if (StoreDocumentHelper.CheckAllPermissions(UoW.IsNew, WarehousePermissions.WriteoffEdit, Entity.WriteoffWarehouse))
            {
                FailInitialize = true;
                return;
            }

            var editing = StoreDocumentHelper.CanEditDocument(WarehousePermissions.WriteoffEdit, Entity.WriteoffWarehouse);

            evmeEmployee.IsEditable = textComment.Editable = editing;
            writeoffdocumentitemsview1.Sensitive = editing && (Entity.WriteoffWarehouse != null || Entity.Client != null);

            textComment.Binding.AddBinding(Entity, e => e.Comment, w => w.Buffer.Text).InitializeFromSource();
            labelTimeStamp.Binding.AddBinding(Entity, e => e.DateString, w => w.LabelProp).InitializeFromSource();

            var clientFactory = new CounterpartyJournalFactory();

            evmeCounterparty.SetEntityAutocompleteSelectorFactory(clientFactory.CreateCounterpartyAutocompleteSelectorFactory());
            evmeCounterparty.Binding.AddBinding(Entity, e => e.Client, w => w.Subject).InitializeFromSource();
            evmeCounterparty.Changed += OnReferenceCounterpartyChanged;

            ySpecCmbWarehouses.ItemsList = StoreDocumentHelper.GetRestrictedWarehousesList(UoW, WarehousePermissions.WriteoffEdit);
            ySpecCmbWarehouses.Binding.AddBinding(Entity, e => e.WriteoffWarehouse, w => w.SelectedItem).InitializeFromSource();
            ySpecCmbWarehouses.ItemSelected += (sender, e) => {
                writeoffdocumentitemsview1.Sensitive = editing && (Entity.WriteoffWarehouse != null || Entity.Client != null);
            };

            var dpFactory = new DeliveryPointJournalFactory(_deliveryPointJournalFilterViewModel);

            evmeDeliveryPoint.SetEntityAutocompleteSelectorFactory(dpFactory.CreateDeliveryPointByClientAutocompleteSelectorFactory());
            evmeDeliveryPoint.CanEditReference = false;
            evmeDeliveryPoint.Binding.AddBinding(Entity, e => e.DeliveryPoint, w => w.Subject).InitializeFromSource();

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

            if (userHasOnlyAccessToWarehouseAndComplaints)
            {
                evmeEmployee.CanEditReference = false;
            }

            var employeeFactory = new EmployeeJournalFactory();

            evmeEmployee.SetEntityAutocompleteSelectorFactory(employeeFactory.CreateWorkingEmployeeAutocompleteSelectorFactory());
            evmeEmployee.Binding.AddBinding(Entity, e => e.ResponsibleEmployee, w => w.Subject).InitializeFromSource();
            comboType.ItemsEnum         = typeof(WriteoffType);
            evmeDeliveryPoint.Sensitive = evmeCounterparty.Sensitive = (UoWGeneric.Root.Client != null);
            comboType.EnumItemSelected += (object sender, Gamma.Widgets.ItemSelectedEventArgs e) => {
                ySpecCmbWarehouses.Sensitive = WriteoffType.warehouse.Equals(comboType.SelectedItem);
                evmeDeliveryPoint.Sensitive  = WriteoffType.counterparty.Equals(comboType.SelectedItem) && UoWGeneric.Root.Client != null;
                evmeCounterparty.Sensitive   = WriteoffType.counterparty.Equals(comboType.SelectedItem);
            };
            //FIXME Списание с контрагента не реализовано. Поэтому блокирует выбор типа списания.
            comboType.Sensitive    = false;
            comboType.SelectedItem = UoWGeneric.Root.Client != null ?
                                     WriteoffType.counterparty :
                                     WriteoffType.warehouse;

            writeoffdocumentitemsview1.DocumentUoW = UoWGeneric;

            Entity.ObservableItems.ElementAdded   += (aList, aIdx) => ySpecCmbWarehouses.Sensitive = !Entity.ObservableItems.Any();
            Entity.ObservableItems.ElementRemoved += (aList, aIdx, aObject) => ySpecCmbWarehouses.Sensitive = !Entity.ObservableItems.Any();
            ySpecCmbWarehouses.Sensitive           = editing && !Entity.Items.Any();

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

            Entity.CanEdit =
                permmissionValidator.Validate(
                    typeof(WriteoffDocument), ServicesConfig.UserService.CurrentUserId, nameof(RetroactivelyClosePermission));

            if (!Entity.CanEdit && Entity.TimeStamp.Date != DateTime.Now.Date)
            {
                ySpecCmbWarehouses.Binding.AddFuncBinding(Entity, e => e.CanEdit, w => w.Sensitive).InitializeFromSource();
                evmeCounterparty.Sensitive           = false;
                evmeDeliveryPoint.Sensitive          = false;
                comboType.Sensitive                  = false;
                evmeEmployee.Sensitive               = false;
                textComment.Sensitive                = false;
                writeoffdocumentitemsview1.Sensitive = false;

                buttonSave.Sensitive = false;
            }
            else
            {
                Entity.CanEdit = true;
            }
        }
Esempio n. 14
0
        void ConfigureDlg()
        {
            if (StoreDocumentHelper.CheckAllPermissions(UoW.IsNew, WarehousePermissions.SelfDeliveryEdit, Entity.Warehouse))
            {
                FailInitialize = true;
                return;
            }

            Entity.InitializeDefaultValues(UoW, _nomenclatureRepository);
            vbxMain.Sensitive      = canEditDocument;
            buttonCancel.Sensitive = true;

            var editing = StoreDocumentHelper.CanEditDocument(WarehousePermissions.SelfDeliveryEdit, Entity.Warehouse);

            yentryrefOrder.IsEditable = lstWarehouse.Sensitive = ytextviewCommnet.Editable = editing && canEditDocument;
            selfdeliverydocumentitemsview1.Sensitive = hbxTareToReturn.Sensitive = editing && canEditDocument;

            ylabelDate.Binding.AddFuncBinding(Entity, e => e.TimeStamp.ToString("g"), w => w.LabelProp).InitializeFromSource();
            lstWarehouse.ItemsList = StoreDocumentHelper.GetRestrictedWarehousesList(UoW, WarehousePermissions.SelfDeliveryEdit);
            lstWarehouse.Binding.AddBinding(Entity, e => e.Warehouse, w => w.SelectedItem).InitializeFromSource();
            lstWarehouse.ItemSelected += OnWarehouseSelected;
            ytextviewCommnet.Binding.AddBinding(Entity, e => e.Comment, w => w.Buffer.Text).InitializeFromSource();
            var filter = new OrdersFilter(UoW);

            filter.SetAndRefilterAtOnce(
                x => x.RestrictSelfDelivery = true,
                x => x.RestrictStatus       = OrderStatus.OnLoading
                );
            yentryrefOrder.RepresentationModel = new ViewModel.OrdersVM(filter);
            yentryrefOrder.Binding.AddBinding(Entity, e => e.Order, w => w.Subject).InitializeFromSource();
            yentryrefOrder.CanEditReference = ServicesConfig.CommonServices.CurrentPermissionService.ValidatePresetPermission("can_delete");
            yentryrefOrder.ChangedByUser   += (sender, e) => { FillTrees(); };

            UpdateOrderInfo();
            Entity.UpdateStockAmount(UoW, _stockRepository);
            Entity.UpdateAlreadyUnloaded(UoW, _nomenclatureRepository, _bottlesRepository);
            selfdeliverydocumentitemsview1.DocumentUoW = UoWGeneric;
            //bottlereceptionview1.UoW = UoW;
            UpdateWidgets();
            lblTareReturnedBefore.Binding.AddFuncBinding(Entity, e => e.ReturnedTareBeforeText, w => w.Text).InitializeFromSource();
            spnTareToReturn.Binding.AddBinding(Entity, e => e.TareToReturn, w => w.ValueAsInt).InitializeFromSource();

            IColumnsConfig goodsColumnsConfig = FluentColumnsConfig <GoodsReceptionVMNode> .Create()
                                                .AddColumn("Номенклатура").AddTextRenderer(node => node.Name)
                                                .AddColumn("Кол-во").AddNumericRenderer(node => node.Amount)
                                                .Adjustment(new Gtk.Adjustment(0, 0, 9999, 1, 100, 0))
                                                .Editing(true)
                                                .AddColumn("Ожидаемое кол-во").AddNumericRenderer(node => node.ExpectedAmount)
                                                .AddColumn("Категория").AddTextRenderer(node => node.Category.GetEnumTitle())
                                                .AddColumn("Направление").AddTextRenderer(node => node.Direction != null ? node.Direction.GetEnumTitle() : "")
                                                .AddColumn("Принадлежность").AddEnumRenderer(node => node.OwnType, true, new Enum[] { OwnTypes.None })
                                                .AddSetter((c, n) => {
                c.Editable = false;
                c.Editable = n.Category == NomenclatureCategory.equipment;
            })
                                                .AddColumn("Причина").AddEnumRenderer(
                node => node.DirectionReason
                , true
                ).AddSetter((c, n) =>
            {
                switch (n.DirectionReason)
                {
                case DirectionReason.Rent:
                    c.Text = "Закрытие аренды";
                    break;

                case DirectionReason.Repair:
                    c.Text = "В ремонт";
                    break;

                case DirectionReason.Cleaning:
                    c.Text = "На санобработку";
                    break;

                case DirectionReason.RepairAndCleaning:
                    c.Text = "В ремонт и санобработку";
                    break;

                default:
                    break;
                }
                c.Editable = false;
                c.Editable = n.Category == NomenclatureCategory.equipment;
            })


                                                .AddColumn("")
                                                .Finish();

            yTreeOtherGoods.ColumnsConfig   = goodsColumnsConfig;
            yTreeOtherGoods.ItemsDataSource = GoodsReceptionList;

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

            Entity.CanEdit =
                permmissionValidator.Validate(
                    typeof(SelfDeliveryDocument), ServicesConfig.UserService.CurrentUserId, nameof(RetroactivelyClosePermission));

            if (!Entity.CanEdit && Entity.TimeStamp.Date != DateTime.Now.Date)
            {
                yTreeOtherGoods.Binding.AddFuncBinding(Entity, e => e.CanEdit, w => w.Sensitive).InitializeFromSource();
                yentryrefOrder.Binding.AddFuncBinding(Entity, e => e.CanEdit, w => w.Sensitive).InitializeFromSource();
                ytextviewCommnet.Binding.AddFuncBinding(Entity, e => e.CanEdit, w => w.Sensitive).InitializeFromSource();
                ytextviewOrderInfo.Binding.AddFuncBinding(Entity, e => e.CanEdit, w => w.Sensitive).InitializeFromSource();
                lstWarehouse.Sensitive = false;
                selfdeliverydocumentitemsview1.Sensitive = false;
                spnTareToReturn.Sensitive  = false;
                btnAddOtherGoods.Sensitive = false;

                buttonSave.Sensitive = false;
            }
            else
            {
                Entity.CanEdit = true;
            }

            FillTrees();

            spnTareToReturn.ValueChanged          += (sender, e) => HasChanges = true;
            GoodsReceptionList.ListContentChanged += (sender, e) => HasChanges = true;
        }
Esempio n. 15
0
        void ConfigureDlg()
        {
            if (StoreDocumentHelper.CheckAllPermissions(UoW.IsNew, WarehousePermissions.WriteoffEdit, Entity.WriteoffWarehouse))
            {
                FailInitialize = true;
                return;
            }

            var editing = StoreDocumentHelper.CanEditDocument(WarehousePermissions.WriteoffEdit, Entity.WriteoffWarehouse);

            repEntryEmployee.IsEditable          = textComment.Editable = editing;
            writeoffdocumentitemsview1.Sensitive = editing && (Entity.WriteoffWarehouse != null || Entity.Client != null);

            textComment.Binding.AddBinding(Entity, e => e.Comment, w => w.Buffer.Text).InitializeFromSource();
            labelTimeStamp.Binding.AddBinding(Entity, e => e.DateString, w => w.LabelProp).InitializeFromSource();

            referenceCounterparty.RepresentationModel = new ViewModel.CounterpartyVM(new CounterpartyFilter(UoW));
            referenceCounterparty.Binding.AddBinding(Entity, e => e.Client, w => w.Subject).InitializeFromSource();

            ySpecCmbWarehouses.ItemsList = StoreDocumentHelper.GetRestrictedWarehousesList(UoW, WarehousePermissions.WriteoffEdit);
            ySpecCmbWarehouses.Binding.AddBinding(Entity, e => e.WriteoffWarehouse, w => w.SelectedItem).InitializeFromSource();
            ySpecCmbWarehouses.ItemSelected += (sender, e) => {
                writeoffdocumentitemsview1.Sensitive = editing && (Entity.WriteoffWarehouse != null || Entity.Client != null);
            };

            referenceDeliveryPoint.SubjectType      = typeof(DeliveryPoint);
            referenceDeliveryPoint.CanEditReference = false;
            referenceDeliveryPoint.Binding.AddBinding(Entity, e => e.DeliveryPoint, w => w.Subject).InitializeFromSource();
            repEntryEmployee.RepresentationModel = new EmployeesVM();
            repEntryEmployee.Binding.AddBinding(Entity, e => e.ResponsibleEmployee, w => w.Subject).InitializeFromSource();
            comboType.ItemsEnum = typeof(WriteoffType);
            referenceDeliveryPoint.Sensitive = referenceCounterparty.Sensitive = (UoWGeneric.Root.Client != null);
            comboType.EnumItemSelected      += (object sender, Gamma.Widgets.ItemSelectedEventArgs e) => {
                ySpecCmbWarehouses.Sensitive     = WriteoffType.warehouse.Equals(comboType.SelectedItem);
                referenceDeliveryPoint.Sensitive = WriteoffType.counterparty.Equals(comboType.SelectedItem) && UoWGeneric.Root.Client != null;
                referenceCounterparty.Sensitive  = WriteoffType.counterparty.Equals(comboType.SelectedItem);
            };
            //FIXME Списание с контрагента не реализовано. Поэтому блокирует выбор типа списания.
            comboType.Sensitive    = false;
            comboType.SelectedItem = UoWGeneric.Root.Client != null ?
                                     WriteoffType.counterparty :
                                     WriteoffType.warehouse;

            writeoffdocumentitemsview1.DocumentUoW = UoWGeneric;

            Entity.ObservableItems.ElementAdded   += (aList, aIdx) => ySpecCmbWarehouses.Sensitive = !Entity.ObservableItems.Any();
            Entity.ObservableItems.ElementRemoved += (aList, aIdx, aObject) => ySpecCmbWarehouses.Sensitive = !Entity.ObservableItems.Any();
            ySpecCmbWarehouses.Sensitive           = editing && !Entity.Items.Any();

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

            Entity.CanEdit = permmissionValidator.Validate(typeof(WriteoffDocument), UserSingletonRepository.GetInstance().GetCurrentUser(UoW).Id, nameof(RetroactivelyClosePermission));
            if (!Entity.CanEdit && Entity.TimeStamp.Date != DateTime.Now.Date)
            {
                ySpecCmbWarehouses.Binding.AddFuncBinding(Entity, e => e.CanEdit, w => w.Sensitive).InitializeFromSource();
                referenceCounterparty.Sensitive  = false;
                referenceDeliveryPoint.Sensitive = false;
                comboType.Sensitive                  = false;
                repEntryEmployee.Sensitive           = false;
                textComment.Sensitive                = false;
                writeoffdocumentitemsview1.Sensitive = false;

                buttonSave.Sensitive = false;
            }
            else
            {
                Entity.CanEdit = true;
            }
        }
Esempio n. 16
0
        void ConfigureDlg()
        {
            canEdit = !UoW.IsNew && StoreDocumentHelper.CanEditDocument(WarehousePermissions.ShiftChangeEdit, Entity.Warehouse);

            if (Entity.Id != 0 && Entity.TimeStamp < DateTime.Today)
            {
                var permissionValidator = new EntityExtendedPermissionValidator(PermissionExtensionSingletonStore.GetInstance(), EmployeeSingletonRepository.GetInstance());
                canEdit &= permissionValidator.Validate(typeof(ShiftChangeWarehouseDocument), UserSingletonRepository.GetInstance().GetCurrentUser(UoW).Id, nameof(RetroactivelyClosePermission));
            }

            canCreate = UoW.IsNew && !StoreDocumentHelper.CheckCreateDocument(WarehousePermissions.ShiftChangeCreate, Entity.Warehouse);

            if (!canCreate && UoW.IsNew)
            {
                FailInitialize = true;
                return;
            }

            if (!canEdit && !UoW.IsNew)
            {
                MessageDialogHelper.RunWarningDialog("У вас нет прав на изменение этого документа.");
            }

            ydatepickerDocDate.Sensitive = yentryrefWarehouse.IsEditable = ytextviewCommnet.Editable = canEdit || canCreate;

            ytreeviewNomenclatures.Sensitive =
                buttonFillItems.Sensitive    =
                    buttonAdd.Sensitive      = canEdit || canCreate;

            ytreeviewNomenclatures.ItemsDataSource = Entity.ObservableItems;
            ytreeviewNomenclatures.YTreeModel?.EmitModelChanged();

            ydatepickerDocDate.Binding.AddBinding(Entity, e => e.TimeStamp, w => w.Date).InitializeFromSource();
            if (UoW.IsNew)
            {
                yentryrefWarehouse.ItemsQuery = StoreDocumentHelper.GetRestrictedWarehouseQuery(WarehousePermissions.ShiftChangeCreate);
            }
            if (!UoW.IsNew)
            {
                yentryrefWarehouse.ItemsQuery = StoreDocumentHelper.GetRestrictedWarehouseQuery(WarehousePermissions.ShiftChangeEdit);
            }
            yentryrefWarehouse.Binding.AddBinding(Entity, e => e.Warehouse, w => w.Subject).InitializeFromSource();
            yentryrefWarehouse.Changed += OnWarehouseChanged;

            ytextviewCommnet.Binding.AddBinding(Entity, e => e.Comment, w => w.Buffer.Text).InitializeFromSource();

            string errorMessage       = "Не установлены единицы измерения у следующих номенклатур :" + Environment.NewLine;
            int    wrongNomenclatures = 0;

            foreach (var item in Entity.Items)
            {
                if (item.Nomenclature.Unit == null)
                {
                    errorMessage += string.Format("Номер: {0}. Название: {1}{2}",
                                                  item.Nomenclature.Id, item.Nomenclature.Name, Environment.NewLine);
                    wrongNomenclatures++;
                }
            }
            if (wrongNomenclatures > 0)
            {
                MessageDialogHelper.RunErrorDialog(errorMessage);
                FailInitialize = true;
                return;
            }

            filter = new SelectableParametersReportFilter(UoW);

            var nomenclatureParam = filter.CreateParameterSet(
                "Номенклатуры",
                "nomenclature",
                new ParametersFactory(UoW, (filters) => {
                SelectableEntityParameter <Nomenclature> resultAlias = null;
                var query = UoW.Session.QueryOver <Nomenclature>()
                            .Where(x => !x.IsArchive);
                if (filters != null && filters.Any())
                {
                    foreach (var f in filters)
                    {
                        var filterCriterion = f();
                        if (filterCriterion != null)
                        {
                            query.Where(filterCriterion);
                        }
                    }
                }

                query.SelectList(list => list
                                 .Select(x => x.Id).WithAlias(() => resultAlias.EntityId)
                                 .Select(x => x.OfficialName).WithAlias(() => resultAlias.EntityTitle)
                                 );
                query.TransformUsing(Transformers.AliasToBean <SelectableEntityParameter <Nomenclature> >());
                return(query.List <SelectableParameter>());
            })
                );

            var nomenclatureTypeParam = filter.CreateParameterSet(
                "Типы номенклатур",
                "nomenclature_type",
                new ParametersEnumFactory <NomenclatureCategory>()
                );

            nomenclatureParam.AddFilterOnSourceSelectionChanged(nomenclatureTypeParam,
                                                                () => {
                var selectedValues = nomenclatureTypeParam.GetSelectedValues();
                if (!selectedValues.Any())
                {
                    return(null);
                }
                return(Restrictions.On <Nomenclature>(x => x.Category).IsIn(nomenclatureTypeParam.GetSelectedValues().ToArray()));
            }
                                                                );

            //Предзагрузка. Для избежания ленивой загрузки
            UoW.Session.QueryOver <ProductGroup>().Fetch(SelectMode.Fetch, x => x.Childs).List();

            filter.CreateParameterSet(
                "Группы товаров",
                "product_group",
                new RecursiveParametersFactory <ProductGroup>(UoW,
                                                              (filters) => {
                var query = UoW.Session.QueryOver <ProductGroup>();
                if (filters != null && filters.Any())
                {
                    foreach (var f in filters)
                    {
                        query.Where(f());
                    }
                }
                return(query.List());
            },
                                                              x => x.Name,
                                                              x => x.Childs)
                );

            var filterViewModel = new SelectableParameterReportFilterViewModel(filter);
            var filterWidget    = new SelectableParameterReportFilterView(filterViewModel);

            vboxParameters.Add(filterWidget);
            filterWidget.Show();

            ConfigureNomenclaturesView();
        }