/// <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.DeleteDataClass(classId);
                    CustomTableItemProvider.ClearCustomLicHash();
                }
            }
            else
            {
                // Display error on deleting
                ShowError(GetString("customtable.delete.hasdependencies"));
            }
        }
    }
Example #2
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);

                    ClassSiteInfoProvider.RemoveClassFromSite(this.ClassId, siteId);
                }
            }
        }


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

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

                    SiteInfo si = SiteInfoProvider.GetSiteInfo(siteId);
                    if (si != null)
                    {
                        // Check license
                        if (this.CheckLicense && !CustomTableItemProvider.LicenseVersionCheck(si.DomainName, FeatureEnum.CustomTables, VersionActionEnum.Insert))
                        {
                            if (ClassSiteInfoProvider.GetClassSiteInfo(this.ClassId, siteId) == null)
                            {
                                lblError.Visible = true;
                                lblError.Text    = GetString("LicenseVersion.CustomTables");
                                falseValues      = true;
                                continue;
                            }
                        }

                        try
                        {
                            ClassSiteInfoProvider.AddClassToSite(this.ClassId, siteId);
                        }
                        catch (Exception ex)
                        {
                            lblError.Visible = true;
                            lblError.Text    = ex.Message;
                            return;
                        }
                    }
                }

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

        if (this.CheckLicense)
        {
            CustomTableItemProvider.ClearCustomLicHash();
        }

        lblInfo.Visible = true;
        lblInfo.Text    = GetString("General.ChangesSaved");
    }