예제 #1
0
    /// <summary>
    /// Gets the custom table item and moves it up. Called when the "Get and move item up" button is pressed.
    /// Expects the CreateCustomTableItem method to be run first.
    /// </summary>
    private bool GetAndMoveCustomTableItemUp()
    {
        // Create new Custom table item provider
        CustomTableItemProvider customTableProvider = new CustomTableItemProvider(CMSContext.CurrentUser);

        string customTableClassName = "customtable.sampletable";

        // Check if Custom table 'Sample table' exists
        DataClassInfo customTable = DataClassInfoProvider.GetDataClass(customTableClassName);

        if (customTable != null)
        {
            // Prepare the parameters
            string where = "ItemText LIKE N'New text'";
            int    topN    = 1;
            string columns = "ItemID";

            // Get the data set according to the parameters
            DataSet dataSet = customTableProvider.GetItems(customTableClassName, where, null, topN, columns);

            if (!DataHelper.DataSourceIsEmpty(dataSet))
            {
                // Get the custom table item ID
                int itemID = ValidationHelper.GetInteger(dataSet.Tables[0].Rows[0][0], 0);

                // Move the item up
                customTableProvider.MoveItemUp(itemID, customTableClassName);

                return(true);
            }
        }

        return(false);
    }
예제 #2
0
    protected void gridData_OnAction(string actionName, object actionArgument)
    {
        switch (actionName.ToLowerCSafe())
        {
        // Delete item action
        case "delete":
            if (CheckPermissions("Delete"))
            {
                if (CustomTableClassInfo != null)
                {
                    CustomTableItem item = ctProvider.GetItem(ValidationHelper.GetInteger(actionArgument, 0), CustomTableClassInfo.ClassName);
                    if (item != null)
                    {
                        item.Delete();
                    }
                }

                URLHelper.Redirect(URLHelper.Url.ToString());
            }
            break;

        // Move item up action
        case "moveup":
            if (CheckPermissions("Modify"))
            {
                if (CustomTableClassInfo != null)
                {
                    ctProvider.MoveItemUp(ValidationHelper.GetInteger(actionArgument, 0), CustomTableClassInfo.ClassName);
                }

                URLHelper.Redirect(URLHelper.Url.ToString());
            }
            break;

        // Move item down action
        case "movedown":
            if (CheckPermissions("Modify"))
            {
                if (CustomTableClassInfo != null)
                {
                    ctProvider.MoveItemDown(ValidationHelper.GetInteger(actionArgument, 0), CustomTableClassInfo.ClassName);
                }

                URLHelper.Redirect(URLHelper.Url.ToString());
            }
            break;
        }
    }
    /// <summary>
    /// Gets the custom table item and moves it up. Called when the "Get and move item up" button is pressed.
    /// Expects the CreateCustomTableItem method to be run first.
    /// </summary>
    private bool GetAndMoveCustomTableItemUp()
    {
        // Create new Custom table item provider
        CustomTableItemProvider customTableProvider = new CustomTableItemProvider(CMSContext.CurrentUser);

        string customTableClassName = "customtable.sampletable";

        // Check if Custom table 'Sample table' exists
        DataClassInfo customTable = DataClassInfoProvider.GetDataClass(customTableClassName);
        if (customTable != null)
        {
            // Prepare the parameters
            string where = "ItemText LIKE N'New text'";
            int topN = 1;
            string columns = "ItemID";

            // Get the data set according to the parameters
            DataSet dataSet = customTableProvider.GetItems(customTableClassName, where, null, topN, columns);

            if (!DataHelper.DataSourceIsEmpty(dataSet))
            {
                // Get the custom table item ID
                int itemID = ValidationHelper.GetInteger(dataSet.Tables[0].Rows[0][0], 0);

                // Move the item up
                customTableProvider.MoveItemUp(itemID, customTableClassName);

                return true;
            }
        }

        return false;
    }