/// <summary>
    /// Handles OnClick event of btnOk.
    /// </summary>
    /// <param name="sender">Asp Button instance</param>
    /// <param name="e">EventArgs instance</param>
    protected void btnOk_Click(object sender, EventArgs e)
    {
        if (IsValid())
        {
            // Get category by name
            SettingsCategoryInfo categoryObj = SettingsCategoryInfoProvider.GetSettingsCategoryInfoByName(txtCategoryName.Text.Trim());
            // If name is unique OR ids are same
            if ((categoryObj == null) || (categoryObj.CategoryID == mSettingsCategoryId))
            {
                SettingsCategoryInfo sci = SettingsCategoryObj;
                if (sci == null)
                {
                    sci = new SettingsCategoryInfo();
                    sci.CategoryOrder = mCategoryOrder;
                }

                if (sci.CategoryParentID != drpCategory.SelectedCategory)
                {
                    // When parent has been changed set the order for the category as the last possible order
                    sci.CategoryOrder = SettingsCategoryInfoProvider.GetLastSettingsCategoryOrder(drpCategory.SelectedCategory) + 1;
                }
                sci.CategoryName        = txtCategoryName.Text.Trim();
                sci.CategoryDisplayName = txtCategoryDisplayName.Text.Trim();
                sci.CategoryIconPath    = txtIconPath.Text.Trim();
                sci.CategoryParentID    = drpCategory.SelectedCategory;
                sci.CategoryIsGroup     = mIsGroupEdit;
                sci.CategoryIsCustom    = mIsCustom || chkIsCustom.Checked;

                SettingsCategoryInfoProvider.SetSettingsCategoryInfo(sci);
                SettingsCategoryObj = sci;
                RaiseOnSaved();

                // Set the info message
                if (ContentRefreshUrl == null)
                {
                    ShowChangesSaved();
                }

                // Reload header and content after save
                int           categoryIdToShow = sci.CategoryIsGroup ? sci.CategoryParentID : sci.CategoryID;
                StringBuilder sb = new StringBuilder();
                sb.Append("if (window.parent != null) {");
                if (HeaderRefreshUrl != null)
                {
                    sb.Append("if (window.parent.parent.frames['customsettingscategorytabs'] != null) {");
                    sb.Append("window.parent.parent.frames['customsettingscategorytabs'].location = '" + ResolveUrl(HeaderRefreshUrl) + "categoryid=" + categoryIdToShow + "';");
                    sb.Append("}");
                    sb.Append("if (window.parent.frames['customsettingscategorytabs'] != null) {");
                    sb.Append("window.parent.frames['customsettingscategorytabs'].location = '" + ResolveUrl(HeaderRefreshUrl) + "categoryid=" + categoryIdToShow + "';");
                    sb.Append("}");
                }
                if (TreeRefreshUrl != null)
                {
                    sb.Append("if (window.parent.parent.frames['customsettingstree'] != null) {");
                    sb.Append("window.parent.parent.frames['customsettingstree'].location = '" + ResolveUrl(TreeRefreshUrl) + "categoryid=" + categoryIdToShow + "';");
                    sb.Append("}");
                    sb.Append("if (window.parent.frames['customsettingstree'] != null) {");
                    sb.Append("window.parent.frames['customsettingstree'].location =  '" + ResolveUrl(TreeRefreshUrl) + "categoryid=" + categoryIdToShow + "';");
                    sb.Append("}");
                }
                if (ContentRefreshUrl != null)
                {
                    sb.Append("window.location =  '" + ResolveUrl(ContentRefreshUrl) + "categoryid=" + sci.CategoryID + "';");
                }
                sb.Append("}");
                ltlScript.Text = ScriptHelper.GetScript(sb.ToString());
            }
            else
            {
                ShowError(GetString("general.codenameexists"));
            }
        }
    }
示例#2
0
    /// <summary>
    /// Handles OnClick event of btnOk.
    /// </summary>
    /// <param name="sender">Asp Button instance</param>
    /// <param name="e">EventArgs instance</param>
    protected void btnOk_Click(object sender, EventArgs e)
    {
        if (IsValid())
        {
            // Get category by name
            SettingsCategoryInfo categoryObj = SettingsCategoryInfoProvider.GetSettingsCategoryInfoByName(txtCategoryName.Text.Trim());
            // If name is unique OR ids are same
            if ((categoryObj == null) || (categoryObj.CategoryID == SettingsCategoryID))
            {
                SettingsCategoryInfo sci = SettingsCategoryObj;
                if (sci == null)
                {
                    sci = new SettingsCategoryInfo();
                    sci.CategoryOrder = CategoryOrder;
                }

                if (sci.CategoryParentID != drpCategory.SelectedCategory)
                {
                    // When parent has been changed set the order for the category as the last possible order
                    sci.CategoryOrder = SettingsCategoryInfoProvider.GetLastSettingsCategoryOrder(drpCategory.SelectedCategory) + 1;
                }

                sci.CategoryName        = txtCategoryName.Text.Trim();
                sci.CategoryDisplayName = txtCategoryDisplayName.Text.Trim();
                sci.CategoryIconPath    = txtIconPath.Text.Trim();
                sci.CategoryParentID    = SelectedParentCategory;
                sci.CategoryIsGroup     = IsGroupEdit;
                sci.CategoryResourceID  = ValidationHelper.GetInteger(ucSelectModule.Value, ModuleID);

                SettingsCategoryInfoProvider.SetSettingsCategoryInfo(sci);
                SettingsCategoryObj = sci;
                RaiseOnSaved();

                // Set the info message
                if (ContentRefreshUrl == null)
                {
                    ShowChangesSaved();
                }

                // Reload header and content after save
                int categoryIdToShow = sci.CategoryIsGroup ? sci.CategoryParentID : sci.CategoryID;

                StringBuilder sb = new StringBuilder();
                sb.Append("if (window.parent != null) {");
                if (!String.IsNullOrEmpty(TreeRefreshUrl))
                {
                    sb.AppendFormat(@"if (window.parent.parent.frames['settingstree'] != null) {{
   window.parent.parent.frames['settingstree'].location = '{0}&categoryid={1}';
}}
if (window.parent.frames['settingstree'] != null) {{
   window.parent.frames['settingstree'].location = '{0}&categoryid={1}';
}}", ResolveUrl(TreeRefreshUrl), categoryIdToShow);
                }
                if (!String.IsNullOrEmpty(ContentRefreshUrl))
                {
                    sb.AppendFormat("window.location = '{0}&categoryid={1}';", ResolveUrl(ContentRefreshUrl), sci.CategoryID);
                }

                sb.Append("}");
                ltlScript.Text = ScriptHelper.GetScript(sb.ToString());
            }
            else
            {
                ShowError(GetString("general.codenameexists"));
            }
        }
    }