Exemplo n.º 1
0
    /// <summary>
    /// Returns correct WHERE condition.
    /// </summary>
    private string GetWhere()
    {
        UniGrid parent = ControlsHelper.GetParentControl(this, typeof(UniGrid)) as UniGrid;

        if (parent != null)
        {
            string resourceName = ValidationHelper.GetString(parent.GetValue("ResourceName"), "");
            if (resourceName == String.Empty)
            {
                // Check special parameter first
                resourceName = ValidationHelper.GetString(UIContext["MacroRuleResourceName"], String.Empty);
                if (resourceName == String.Empty)
                {
                    // If not set, use element's resource name
                    resourceName = ValidationHelper.GetString(UIContext["resourcename"], String.Empty);
                }
            }

            if (!string.IsNullOrEmpty(resourceName))
            {
                string where = "MacroRuleResourceName = N'" + SqlHelper.GetSafeQueryString(resourceName, false) + "'";

                // Show also global rules for global administrator if requested
                if (drpOptions.SelectedIndex == 1)
                {
                    where = SqlHelper.AddWhereCondition(where, "MacroRuleResourceName = '' OR MacroRuleResourceName IS NULL", "OR");
                }
                return(where);
            }
        }

        // Only global rules should be displayed
        return("MacroRuleResourceName = '' OR MacroRuleResourceName IS NULL");
    }