Example #1
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;
        }
Example #2
0
        void ConfigureDlg()
        {
            if (StoreDocumentHelper.CheckAllPermissions(UoW.IsNew, WarehousePermissions.IncomingInvoiceEdit, Entity.Warehouse))
            {
                FailInitialize = true;
                return;
            }

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

            entryInvoiceNumber.IsEditable = entryWaybillNumber.IsEditable = ytextviewComment.Editable
                                                                                = referenceContractor.IsEditable = referenceWarehouse.IsEditable = editing;
            incominginvoiceitemsview1.Sensitive = editing;

            entryInvoiceNumber.Binding.AddBinding(Entity, e => e.InvoiceNumber, w => w.Text).InitializeFromSource();
            entryWaybillNumber.Binding.AddBinding(Entity, e => e.WaybillNumber, w => w.Text).InitializeFromSource();
            labelTimeStamp.Binding.AddBinding(Entity, e => e.DateString, w => w.LabelProp).InitializeFromSource();

            referenceWarehouse.ItemsQuery = StoreDocumentHelper.GetRestrictedWarehouseQuery(WarehousePermissions.IncomingInvoiceEdit);
            referenceWarehouse.Binding.AddBinding(Entity, e => e.Warehouse, w => w.Subject).InitializeFromSource();

            referenceContractor.RepresentationModel = new CounterpartyVM(new CounterpartyFilter(UoW));
            referenceContractor.Binding.AddBinding(Entity, e => e.Contractor, w => w.Subject).InitializeFromSource();

            incominginvoiceitemsview1.DocumentUoW = UoWGeneric;
            ytextviewComment.Binding.AddBinding(Entity, e => e.Comment, w => w.Buffer.Text).InitializeFromSource();
        }
        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;
            }
        }
Example #4
0
        void ConfigureDlg()
        {
            if (StoreDocumentHelper.CheckAllPermissions(UoW.IsNew, WarehousePermissions.MovementEdit, Entity.FromWarehouse, Entity.ToWarehouse))
            {
                FailInitialize = true;
                return;
            }

            var editing = StoreDocumentHelper.CanEditDocument(WarehousePermissions.MovementEdit, Entity.FromWarehouse, Entity.ToWarehouse);

            enumMovementType.Sensitive = referenceEmployee.IsEditable = referenceWarehouseTo.Sensitive
                                                                            = yentryrefWagon.IsEditable = textComment.Sensitive = editing;
            movementdocumentitemsview1.Sensitive = editing;

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

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

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

            referenceWarehouseTo.ItemsQuery = StoreDocumentHelper.GetWarehouseQuery();
            referenceWarehouseTo.Binding.AddBinding(Entity, e => e.ToWarehouse, w => w.Subject).InitializeFromSource();
            referenceWarehouseFrom.ItemsQuery = StoreDocumentHelper.GetRestrictedWarehouseQuery(WarehousePermissions.MovementEdit);
            referenceWarehouseFrom.Binding.AddBinding(Entity, e => e.FromWarehouse, w => w.Subject).InitializeFromSource();
            referenceWarehouseFrom.IsEditable         = StoreDocumentHelper.CanEditDocument(WarehousePermissions.MovementEdit, Entity.FromWarehouse);
            referenceDeliveryPointTo.CanEditReference = false;
            referenceDeliveryPointTo.SubjectType      = typeof(DeliveryPoint);
            referenceDeliveryPointTo.Binding.AddBinding(Entity, e => e.ToDeliveryPoint, w => w.Subject).InitializeFromSource();
            referenceDeliveryPointFrom.CanEditReference = false;
            referenceDeliveryPointFrom.SubjectType      = typeof(DeliveryPoint);
            referenceDeliveryPointFrom.Binding.AddBinding(Entity, e => e.FromDeliveryPoint, w => w.Subject).InitializeFromSource();
            var filterEmployee = new EmployeeFilter(UoW);

            referenceEmployee.RepresentationModel = new EmployeesVM(filterEmployee);
            referenceEmployee.Binding.AddBinding(Entity, e => e.ResponsiblePerson, w => w.Subject).InitializeFromSource();

            yentryrefWagon.SubjectType = typeof(MovementWagon);
            yentryrefWagon.Binding.AddBinding(Entity, e => e.MovementWagon, w => w.Subject).InitializeFromSource();

            ylabelTransportationStatus.Binding.AddBinding(Entity, e => e.TransportationDescription, w => w.LabelProp).InitializeFromSource();

            MovementDocumentCategory[] filteredDoctypeList = { MovementDocumentCategory.counterparty };
            object[] MovementDocumentList = Array.ConvertAll(filteredDoctypeList, x => (object)x);
            enumMovementType.ItemsEnum = typeof(MovementDocumentCategory);
            enumMovementType.AddEnumToHideList(MovementDocumentList);
            enumMovementType.Binding.AddBinding(Entity, e => e.Category, w => w.SelectedItem).InitializeFromSource();
            if (Entity.Id == 0)
            {
                Entity.Category = MovementDocumentCategory.Transportation;
            }

            buttonDelivered.Sensitive = Entity.TransportationStatus == TransportationStatus.Submerged &&
                                        CurrentPermissions.Warehouse[WarehousePermissions.MovementEdit, Entity.ToWarehouse];

            movementdocumentitemsview1.DocumentUoW = UoWGeneric;
        }
Example #5
0
        void ConfigureDlg()
        {
            if (StoreDocumentHelper.CheckAllPermissions(UoW.IsNew, WarehousePermissions.SelfDeliveryEdit, Entity.Warehouse))
            {
                FailInitialize = true;
                return;
            }

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

            yentryrefOrder.IsEditable = yentryrefWarehouse.IsEditable = ytextviewCommnet.Editable = editing;
            selfdeliverydocumentitemsview1.Sensitive = vBoxBottles.Sensitive = editing;

            ylabelDate.Binding.AddFuncBinding(Entity, e => e.TimeStamp.ToString("g"), w => w.LabelProp).InitializeFromSource();
            yentryrefWarehouse.ItemsQuery = StoreDocumentHelper.GetRestrictedWarehouseQuery(WarehousePermissions.SelfDeliveryEdit);
            yentryrefWarehouse.Binding.AddBinding(Entity, e => e.Warehouse, w => w.Subject).InitializeFromSource();
            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.Accepted
                );
            yentryrefOrder.RepresentationModel = new ViewModel.OrdersVM(filter);
            yentryrefOrder.Binding.AddBinding(Entity, e => e.Order, w => w.Subject).InitializeFromSource();
            yentryrefOrder.CanEditReference = QSMain.User.Permissions["can_delete"];

            UpdateOrderInfo();
            Entity.UpdateStockAmount(UoW);
            Entity.UpdateAlreadyUnloaded(UoW);
            selfdeliverydocumentitemsview1.DocumentUoW = UoWGeneric;
            //bottlereceptionview1.UoW = UoW;
            UpdateWidgets();

            IColumnsConfig bottlesColumnsConfig = FluentColumnsConfig <GoodsReceptionVMNode> .Create()
                                                  .AddColumn("Номенклатура").AddTextRenderer(node => node.Name)
                                                  .AddColumn("Кол-во").AddNumericRenderer(node => node.Amount).WidthChars(3)
                                                  .Adjustment(new Gtk.Adjustment(0, 0, 9999, 1, 100, 0))
                                                  .Editing(true)
                                                  .AddColumn("")
                                                  .Finish();

            yTreeBottles.ColumnsConfig = bottlesColumnsConfig;
            FillTrees();

            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("Категория").AddTextRenderer(node => node.Category.GetEnumTitle())
                                                .AddColumn("")
                                                .Finish();

            yTreeOtherGoods.ColumnsConfig   = goodsColumnsConfig;
            yTreeOtherGoods.ItemsDataSource = GoodsReceptionList;
        }
Example #6
0
        void ConfigureDlg()
        {
            if (StoreDocumentHelper.CheckAllPermissions(UoW.IsNew, WarehousePermissions.WriteoffEdit, Entity.WriteoffWarehouse))
            {
                FailInitialize = true;
                return;
            }

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

            referenceEmployee.IsEditable         = referenceWarehouse.IsEditable = textComment.Editable = editing;
            writeoffdocumentitemsview1.Sensitive = editing;

            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();

            referenceWarehouse.ItemsQuery = StoreDocumentHelper.GetRestrictedWarehouseQuery(WarehousePermissions.WriteoffEdit);
            referenceWarehouse.Binding.AddBinding(Entity, e => e.WriteoffWarehouse, w => w.Subject).InitializeFromSource();
            referenceDeliveryPoint.SubjectType      = typeof(DeliveryPoint);
            referenceDeliveryPoint.CanEditReference = false;
            referenceDeliveryPoint.Binding.AddBinding(Entity, e => e.DeliveryPoint, w => w.Subject).InitializeFromSource();
            referenceEmployee.RepresentationModel = new EmployeesVM(new EmployeeFilter(UoW));
            referenceEmployee.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) => {
                referenceWarehouse.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;
        }
        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;
            }
        }
Example #8
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;
            inventoryitemsview.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)
            {
                MessageDialogWorks.RunErrorDialog(errorMessage);
                FailInitialize = true;
                return;
            }

            inventoryitemsview.DocumentUoW = UoWGeneric;
        }
Example #9
0
        void ConfigureDlg()
        {
            if (StoreDocumentHelper.CheckAllPermissions(UoW.IsNew, WarehousePermissions.CarUnloadEdit, Entity.Warehouse))
            {
                FailInitialize = true;
                return;
            }

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

            yentryrefRouteList.IsEditable      = yentryrefWarehouse.IsEditable = ytextviewCommnet.Editable = editing;
            returnsreceptionview1.Sensitive    =
                bottlereceptionview1.Sensitive =
                    nonserialequipmentreceptionview1.Sensitive =
                        defectiveitemsreceptionview1.Sensitive = editing;

            bottlereceptionview1.UoW             =
                defectiveitemsreceptionview1.UoW =
                    returnsreceptionview1.UoW    = UoW;

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

            filter.SetAndRefilterAtOnce(x => x.RestrictStatus = RouteListStatus.EnRoute);
            yentryrefRouteList.RepresentationModel            = new ViewModel.RouteListsVM(filter);
            yentryrefRouteList.Binding.AddBinding(Entity, e => e.RouteList, w => w.Subject).InitializeFromSource();
            yentryrefRouteList.CanEditReference = QSMain.User.Permissions["can_delete"];

            defectiveitemsreceptionview1.Warehouse = returnsreceptionview1.Warehouse = Entity.Warehouse;

            UpdateWidgetsVisible();
            if (!UoW.IsNew)
            {
                LoadReception();
            }
        }
Example #10
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;
			}
		}
Example #11
0
        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;
            }
        }
Example #12
0
        void ConfigureDlg()
        {
            if (StoreDocumentHelper.CheckAllPermissions(UoW.IsNew, WarehousePermissions.CarLoadEdit, Entity.Warehouse))
            {
                FailInitialize = true;
                return;
            }

            editing = StoreDocumentHelper.CanEditDocument(WarehousePermissions.CarLoadEdit, Entity.Warehouse);
            yentryrefRouteList.IsEditable  = yentryrefWarehouse.IsEditable = ytextviewCommnet.Editable = editing;
            carloaddocumentview1.Sensitive = editing;

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

            filter.SetAndRefilterAtOnce(x => x.RestrictStatus = RouteListStatus.InLoading);
            yentryrefRouteList.RepresentationModel            = new ViewModel.RouteListsVM(filter);
            yentryrefRouteList.Binding.AddBinding(Entity, e => e.RouteList, w => w.Subject).InitializeFromSource();
            yentryrefRouteList.CanEditReference = QSMain.User.Permissions["can_delete"];

            enumPrint.ItemsEnum = typeof(CarLoadPrintableDocuments);

            UpdateRouteListInfo();
            Entity.UpdateStockAmount(UoW);
            Entity.UpdateAlreadyLoaded(UoW);
            Entity.UpdateInRouteListAmount(UoW);
            carloaddocumentview1.DocumentUoW = UoWGeneric;
            carloaddocumentview1.SetButtonEditing(editing);
            if (UoW.IsNew && Entity.Warehouse != null)
            {
                carloaddocumentview1.FillItemsByWarehouse();
            }
        }
        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;
            }
        }
Example #14
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;
            }
        }
Example #15
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();
        }
Example #16
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();
        }
        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;
            }
        }
Example #19
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;
            }
        }
Example #20
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;
        }