Exemplo n.º 1
0
        private void CreateCustomEditAction()
        {
            var editAction = new JournalAction("Изменить",
                                               (selected) =>
            {
                var selectedNodes = selected.OfType <EmployeeJournalNode>();

                if (selectedNodes == null || selectedNodes.Count() != 1)
                {
                    return(false);
                }

                EmployeeJournalNode selectedNode = selectedNodes.First();

                if (!EntityConfigs.ContainsKey(selectedNode.EntityType))
                {
                    return(false);
                }

                var config = EntityConfigs[selectedNode.EntityType];

                return(config.PermissionResult.CanRead);
            },
                                               (selected) => true,
                                               (selected) =>
            {
                var selectedNodes = selected.OfType <EmployeeJournalNode>();

                if (selectedNodes == null || selectedNodes.Count() != 1)
                {
                    return;
                }

                EmployeeJournalNode selectedNode = selectedNodes.First();

                if (!EntityConfigs.ContainsKey(selectedNode.EntityType))
                {
                    return;
                }

                var config = EntityConfigs[selectedNode.EntityType];
                var foundDocumentConfig = config.EntityDocumentConfigurations.FirstOrDefault(x => x.IsIdentified(selectedNode));
                TabParent.OpenTab(() => foundDocumentConfig.GetOpenEntityDlgFunction().Invoke(selectedNode), this);

                if (foundDocumentConfig.JournalParameters.HideJournalForOpenDialog)
                {
                    HideJournal(TabParent);
                }
            }
                                               );

            if (SelectionMode == JournalSelectionMode.None)
            {
                RowActivatedAction = editAction;
            }

            NodeActionsList.Add(editAction);
        }
        void CreateDeleteAction()
        {
            var deleteAction = new JournalAction("Удалить",
                                                 (selected) => {
                var selectedNodes = selected.OfType <CashRequestJournalNode>();

                if (selectedNodes == null || selectedNodes.Count() != 1)
                {
                    return(false);
                }

                CashRequestJournalNode selectedNode = selectedNodes.First();

                if (selectedNode.State != CashRequest.States.New)
                {
                    return(false);
                }


                if (!EntityConfigs.ContainsKey(selectedNode.EntityType))
                {
                    return(false);
                }

                var config = EntityConfigs[selectedNode.EntityType];
                return(config.PermissionResult.CanDelete);
            },
                                                 (selected) => true,
                                                 (selected) => {
                var selectedNodes = selected.OfType <CashRequestJournalNode>();
                if (selectedNodes == null || selectedNodes.Count() != 1)
                {
                    return;
                }
                CashRequestJournalNode selectedNode = selectedNodes.First();
                if (!EntityConfigs.ContainsKey(selectedNode.EntityType))
                {
                    return;
                }
                var config = EntityConfigs[selectedNode.EntityType];
                if (config.PermissionResult.CanDelete)
                {
                    DeleteHelper.DeleteEntity(selectedNode.EntityType, selectedNode.Id);
                }
            },
                                                 "Delete"
                                                 );

            NodeActionsList.Add(deleteAction);
        }
        protected void CreateDeleteAction()
        {
            var deleteAction = new JournalAction("Удалить",
                                                 (selected) =>
            {
                var selectedNodes = selected.OfType <DeliveryPointJournalNode>().ToList();
                if (!selectedNodes.Any())
                {
                    return(false);
                }

                var selectedNode = selectedNodes.First();
                if (!EntityConfigs.ContainsKey(selectedNode.EntityType))
                {
                    return(false);
                }

                var config = EntityConfigs[selectedNode.EntityType];
                return(config.PermissionResult.CanDelete && _canDeleteClientAndDp);
            },
                                                 (selected) => true,
                                                 (selected) =>
            {
                var selectedNodes = selected.OfType <DeliveryPointJournalNode>().ToList();
                if (!selectedNodes.Any())
                {
                    return;
                }

                var selectedNode = selectedNodes.First();
                if (!EntityConfigs.ContainsKey(selectedNode.EntityType))
                {
                    return;
                }

                var config = EntityConfigs[selectedNode.EntityType];
                if (config.PermissionResult.CanDelete)
                {
                    DeleteHelper.DeleteEntity(selectedNode.EntityType, selectedNode.Id);
                }
            },
                                                 "Delete"
                                                 );

            NodeActionsList.Add(deleteAction);
        }
Exemplo n.º 4
0
        private void CreateCustomDeleteAction()
        {
            var deleteAction = new JournalAction("Удалить",
                                                 (selected) =>
            {
                var selectedNodes = selected.OfType <PremiumJournalNode>();
                if (selectedNodes == null || selectedNodes.Count() != 1)
                {
                    return(false);
                }
                PremiumJournalNode selectedNode = selectedNodes.First();
                if (selectedNode.EntityType == typeof(PremiumRaskatGAZelle))
                {
                    return(false);
                }
                if (!EntityConfigs.ContainsKey(selectedNode.EntityType))
                {
                    return(false);
                }
                var config = EntityConfigs[selectedNode.EntityType];
                return(config.PermissionResult.CanDelete);
            },
                                                 (selected) => true,
                                                 (selected) =>
            {
                var selectedNodes = selected.OfType <PremiumJournalNode>();
                if (selectedNodes == null || selectedNodes.Count() != 1)
                {
                    return;
                }
                PremiumJournalNode selectedNode = selectedNodes.First();
                if (!EntityConfigs.ContainsKey(selectedNode.EntityType))
                {
                    return;
                }
                var config = EntityConfigs[selectedNode.EntityType];
                if (config.PermissionResult.CanDelete)
                {
                    DeleteHelper.DeleteEntity(selectedNode.EntityType, selectedNode.Id);
                }
            },
                                                 "Delete"
                                                 );

            NodeActionsList.Add(deleteAction);
        }
        private void CreateCustomEditAction()
        {
            var editAction = new JournalAction("Изменить",
                                               (selected) =>
            {
                var selectedNodes = selected.OfType <UndeliveredOrderJournalNode>();
                var selectedNode  = selectedNodes.FirstOrDefault();

                if (selectedNode == null || !EntityConfigs.ContainsKey(selectedNode.EntityType))
                {
                    return(false);
                }

                var config = EntityConfigs[selectedNode.EntityType];
                return(config.PermissionResult.CanUpdate);
            },
                                               (selected) => true,
                                               (selected) =>
            {
                var selectedNodes = selected.OfType <UndeliveredOrderJournalNode>();
                var selectedNode  = selectedNodes.FirstOrDefault();

                if (selectedNode == null || !EntityConfigs.ContainsKey(selectedNode.EntityType))
                {
                    return;
                }

                var config = EntityConfigs[selectedNode.EntityType];
                var foundDocumentConfig = config.EntityDocumentConfigurations.FirstOrDefault(x => x.IsIdentified(selectedNode));
                foundDocumentConfig?.GetOpenEntityDlgFunction().Invoke(selectedNode);
            }
                                               );

            if (SelectionMode == JournalSelectionMode.None)
            {
                RowActivatedAction = editAction;
            }

            NodeActionsList.Add(editAction);
        }
        protected void CreateDeleteAction()
        {
            var deleteAction = new JournalAction("Удалить",
                                                 (selected) => {
                var selectedNodes = selected.OfType <DeliveryPointJournalNode>();
                if (selectedNodes == null || selectedNodes.Count() != 1)
                {
                    return(false);
                }
                DeliveryPointJournalNode selectedNode = selectedNodes.First();
                if (!EntityConfigs.ContainsKey(selectedNode.EntityType))
                {
                    return(false);
                }
                var config = EntityConfigs[selectedNode.EntityType];
                return(config.PermissionResult.CanDelete &&
                       commonServices.CurrentPermissionService.ValidatePresetPermission("can_delete_counterparty_and_deliverypoint"));
            },
                                                 (selected) => true,
                                                 (selected) => {
                var selectedNodes = selected.OfType <DeliveryPointJournalNode>();
                if (selectedNodes == null || selectedNodes.Count() != 1)
                {
                    return;
                }
                DeliveryPointJournalNode selectedNode = selectedNodes.First();
                if (!EntityConfigs.ContainsKey(selectedNode.EntityType))
                {
                    return;
                }
                var config = EntityConfigs[selectedNode.EntityType];
                if (config.PermissionResult.CanDelete)
                {
                    DeleteHelper.DeleteEntity(selectedNode.EntityType, selectedNode.Id);
                }
            }
                                                 );

            NodeActionsList.Add(deleteAction);
        }
Exemplo n.º 7
0
        protected override void CreatePopupActions()
        {
            base.CreatePopupActions();

            var resetPassAction = new JournalAction(
                "Сбросить пароль",
                (selected) =>
            {
                var selectedNodes = selected.OfType <EmployeeJournalNode>();

                if (selectedNodes == null || selectedNodes.Count() != 1)
                {
                    return(false);
                }

                EmployeeJournalNode selectedNode = selectedNodes.First();

                if (!EntityConfigs.ContainsKey(selectedNode.EntityType))
                {
                    return(false);
                }

                var config = EntityConfigs[selectedNode.EntityType];

                return(config.PermissionResult.CanUpdate);
            },
                x => true,
                selectedItems =>
            {
                var selectedNodes = selectedItems.Cast <EmployeeJournalNode>();
                var selectedNode  = selectedNodes.FirstOrDefault();
                if (selectedNode != null)
                {
                    using (var uow = UnitOfWorkFactory.CreateWithoutRoot("Сброс пароля пользователю"))
                    {
                        var employee = uow.GetById <Employee>(selectedNode.Id);

                        if (employee.User == null)
                        {
                            commonServices.InteractiveService.ShowMessage(ImportanceLevel.Error,
                                                                          "К сотруднику не привязан пользователь!");

                            return;
                        }

                        if (string.IsNullOrEmpty(employee.User.Login))
                        {
                            commonServices.InteractiveService.ShowMessage(ImportanceLevel.Error,
                                                                          "У пользователя не заполнен логин!");

                            return;
                        }

                        if (commonServices.InteractiveService.Question("Вы уверены?"))
                        {
                            ResetPasswordForEmployee(employee);
                        }
                    }
                }
            });

            PopupActionsList.Add(resetPassAction);
            NodeActionsList.Add(resetPassAction);
        }