/// <summary>
    /// Handles the UniGrid's OnAction event.
    /// </summary>
    /// <param name="actionName">Name of item (button) that throws event</param>
    /// <param name="actionArgument">ID (value of Primary key) of corresponding data row</param>
    protected void uniGrid_OnAction(string actionName, object actionArgument)
    {
        if (actionName == "edit")
        {
            URLHelper.Redirect(UrlResolver.ResolveUrl("CustomTable_Edit.aspx?customtableid=" + actionArgument));
        }
        else if (actionName == "delete")
        {
            int classId = ValidationHelper.GetInteger(actionArgument, 0);
            var dci     = DataClassInfoProvider.GetDataClassInfo(classId);
            if (dci == null)
            {
                return;
            }

            try
            {
                // Delete the class
                DataClassInfoProvider.DeleteDataClassInfo(classId);
                CustomTableItemProvider.ClearLicensesCount();
            }
            catch (CheckDependenciesException)
            {
                var description = uniGrid.GetCheckDependenciesDescription(dci);
                ShowError(GetString("unigrid.deletedisabledwithoutenable"), description);
            }
            catch (Exception ex)
            {
                LogAndShowError("Custom table", "Delete", ex);
            }
        }
    }
Example #2
0
    /// <summary>
    /// Handles the UniGrid's OnAction event.
    /// </summary>
    /// <param name="actionName">Name of item (button) that throws event</param>
    /// <param name="actionArgument">ID (value of Primary key) of corresponding data row</param>
    protected void uniGrid_OnAction(string actionName, object actionArgument)
    {
        if (actionName == "edit")
        {
            URLHelper.Redirect("CustomTable_Edit.aspx?customtableid=" + actionArgument);
        }
        else if (actionName == "delete")
        {
            int classId = ValidationHelper.GetInteger(actionArgument, 0);

            if (classId > 0)
            {
                // If no item depends on the current class
                if (!DataClassInfoProvider.CheckDependencies(classId))
                {
                    // Delete the class
                    DataClassInfoProvider.DeleteDataClassInfo(classId);
                    CustomTableItemProvider.ClearLicensesCount();
                }
            }
            else
            {
                // Display error on deleting
                ShowError(GetString("customtable.delete.hasdependencies"));
            }
        }
    }
Example #3
0
    protected void SaveSites()
    {
        // Remove old items
        string newValues = ValidationHelper.GetString(usSites.Value, null);
        string items     = DataHelper.GetNewItemsInList(newValues, currentValues);

        if (!String.IsNullOrEmpty(items))
        {
            string[] newItems = items.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            if (newItems != null)
            {
                // Add all new items to site
                foreach (string item in newItems)
                {
                    int siteId = ValidationHelper.GetInteger(item, 0);

                    ClassSiteInfo.Provider.Remove(ClassId, siteId);
                }
            }
        }


        // Add new items
        items = DataHelper.GetNewItemsInList(currentValues, newValues);
        if (!String.IsNullOrEmpty(items))
        {
            string[] newItems    = items.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            bool     falseValues = false;

            // Add all new items to site
            foreach (string item in newItems)
            {
                int siteId = ValidationHelper.GetInteger(item, 0);

                SiteInfo si = SiteInfo.Provider.Get(siteId);
                if (si != null)
                {
                    // Check license
                    if (CheckLicense && !CustomTableItemProvider.LicenseVersionCheck(si.DomainName, ObjectActionEnum.Insert))
                    {
                        if (ClassSiteInfo.Provider.Get(ClassId, siteId) == null)
                        {
                            // Show error message
                            ShowError(GetString("LicenseVersion.CustomTables"));
                            falseValues = true;
                            continue;
                        }
                    }

                    try
                    {
                        ClassSiteInfo.Provider.Add(ClassId, siteId);
                    }
                    catch (Exception ex)
                    {
                        // Show error message
                        ShowError(ex.Message);

                        return;
                    }
                }
            }

            // If some of sites could not be assigned reload selector value
            if (falseValues)
            {
                usSites.Value = GetClassSites();
                usSites.Reload(true);
            }
        }

        if (CheckLicense)
        {
            CustomTableItemProvider.ClearLicensesCount(true);
        }

        // Show message
        ShowChangesSaved();
    }