コード例 #1
0
        public static PXAction GetDeleteAction(this PXGraph graph)
        {
            PXAction deleteAction = null;
            Type     primary      = !String.IsNullOrEmpty(graph.PrimaryView) ? graph.Views[graph.PrimaryView].GetItemType() : null;

            foreach (PXAction action in graph.Actions.Values)
            {
                PXButtonState state = action.GetState(null) as PXButtonState;

                if (state != null && state.SpecialType == PXSpecialButtonType.Delete)
                {
                    if (primary == null || state.ItemType == null || primary == state.ItemType || primary.IsSubclassOf(state.ItemType))
                    {
                        deleteAction = action;
                        break;
                    }
                }
            }

            if (deleteAction == null || deleteAction.GetEnabled() == false)
            {
                throw new PXException(TX.Error.APPOINTMENT_NOT_DELETABLE);
            }

            return(deleteAction);
        }