protected override void ConfigureWithUow() { var warehousesList = StoreDocumentHelper.GetRestrictedWarehousesList(UoW, new[] { WarehousePermissions.WarehouseView }) .OrderBy(w => w.Name).ToList(); bool accessToWarehouseAndComplaints = ServicesConfig.CommonServices.CurrentPermissionService.ValidatePresetPermission("user_have_access_only_to_warehouse_and_complaints") && !ServicesConfig.CommonServices.UserService.GetCurrentUser(UoW).IsAdmin; if (warehousesList.Count > 5) { entryWarehouses.Subject = CurrentUserSettings.Settings.DefaultWarehouse ?? null; entryWarehouses.SetEntityAutocompleteSelectorFactory(new WarehouseSelectorFactory()); entryWarehouses.Visible = true; comboWarehouses.Visible = false; } else { comboWarehouses.ItemsList = warehousesList; comboWarehouses.SelectedItem = CurrentUserSettings.Settings.DefaultWarehouse ?? null; entryWarehouses.Visible = false; comboWarehouses.Visible = true; } if (accessToWarehouseAndComplaints) { entryWarehouses.Sensitive = comboWarehouses.Sensitive = false; } }
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; } }
private IJournalAction CreateSendRouteListToLoadingAndPrintAction() { var cashSubdivisionIds = _subdivisionRepository.GetCashSubdivisions(UoW).Select(x => x.Id); var cashWarehouseIds = UoW.Session.QueryOver <Warehouse>() .WhereRestrictionOn(x => x.OwningSubdivision.Id).IsInG(cashSubdivisionIds) .Select(x => x.Id) .List <int>(); var defaultWarehouse = CurrentUserSettings.Settings.DefaultWarehouse; if (defaultWarehouse != null && !cashWarehouseIds.Contains(defaultWarehouse.Id) && CurrentPermissions.Warehouse[WarehousePermissions.CarLoadEdit, defaultWarehouse]) { return(new JournalAction( $"Отправить МЛ на погрузку со скалада\n'{defaultWarehouse.Name}' и распечатать", selectedItems => selectedItems.FirstOrDefault() is RouteListJournalNode node && node.StatusEnum == RouteListStatus.Confirmed, selectedItems => true, selectedItems => { if (selectedItems.FirstOrDefault() is RouteListJournalNode selectedNode) { SendToLoadingAndPrint(selectedNode, defaultWarehouse); } } )); } var warehousesAvailableForUser = StoreDocumentHelper.GetRestrictedWarehousesList(UoW, WarehousePermissions.CarLoadEdit) .Where(x => !cashWarehouseIds.Contains(x.Id)) .ToList(); if (!warehousesAvailableForUser.Any()) { return(new JournalAction( "Отправить МЛ на погрузку и распечатать", selectedItems => false, selectedItems => true, selectedItems => { } )); } var journalAction = new JournalAction( "Отправить МЛ на погрузку и распечатать", selectedItems => selectedItems.FirstOrDefault() is RouteListJournalNode node && node.StatusEnum == RouteListStatus.Confirmed, selectedItems => true, selectedItems => { } ); foreach (var warehouse in warehousesAvailableForUser) { journalAction.ChildActionsList.Add(new JournalAction( warehouse.Name, selectedItems => true, selectedItems => true, selectedItems => { if (selectedItems.FirstOrDefault() is RouteListJournalNode selectedNode) { SendToLoadingAndPrint(selectedNode, warehouse); } } )); } return(journalAction); }
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; } }
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; } }
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; }
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; } }