Example #1
0
    /// <summary>
    /// Handles the PreRender event of the Page control.
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
    protected void Page_PreRender(object sender, EventArgs e)
    {
        GeneralSearchOptions options;

        options = GeneralSearchOptions.Load(Server.MapPath(_optionsMapPath));
        // set defaults
        Utility.SetSelectedValue(_showOnStartup, GetStartupValFromUrl(options.ShowOnStartup));
        if (options.DefaultOwnerTeam != string.Empty)
        {
            _defaultOwnerTeam.LookupResultValue = EntityFactory.GetById <IOwner>(options.DefaultOwnerTeam);
        }
        Utility.SetSelectedValue(_logToHistory, "T");
        const string falseValues = "F,FALSE,N,NO,0";

        if (falseValues.IndexOf(options.LogToHistory.ToUpperInvariant()) > -1)
        {
            Utility.SetSelectedValue(_logToHistory, "F");
        }
        //Defect 1-80914
        //  DThompson - "Please only hide the options for now.  We may re-enable them in Sawgrass depending on the direction we choose to take."
        //_promptDuplicateContacts.Checked = options.PromptForDuplicateContacts;
        //_promptContactNotFound.Checked = options.PromptForContactNotFound;
        _useActiveReporting.Checked = options.UseActiveReporting;
        _autoLogoff.Checked         = options.AutoLogoff;
        _logoffDuration.Text        = options.LogoffDuration.ToString();
        Utility.SetSelectedValue(_logoffUnits, options.LogoffUnits);
        txtEmailBaseTemplateId.Text     = options.EmailBaseTemplate;
        txtLetterBaseTemplateId.Text    = options.LetterBaseTemplate;
        txtFaxBaseTemplateId.Text       = options.FaxBaseTemplate;
        txtRecentTemplates.Text         = options.RecentTemplates;
        txtFaxProvider.Text             = options.FaxProvider;
        chkPromptForUnsavedData.Checked = options.PromptForUnsavedData;

        txtEmailBaseTemplate.Text  = Utility.GetSingleValue("Name", "Plugin", "PluginId", txtEmailBaseTemplateId.Text);
        txtLetterBaseTemplate.Text = Utility.GetSingleValue("Name", "Plugin", "PluginId", txtLetterBaseTemplateId.Text);
        txtFaxBaseTemplate.Text    = Utility.GetSingleValue("Name", "Plugin", "PluginId", txtFaxBaseTemplateId.Text);

        var systemInfo = Sage.Platform.Application.ApplicationContext.Current.Services.Get <Sage.SalesLogix.Services.ISystemOptionsService>(true);

        if (systemInfo.MultiCurrency)
        {
            lblMyCurrency.Visible = true;
            luMyCurrency.Visible  = true;
            if (!String.IsNullOrEmpty(options.MyCurrencyCode))
            {
                luMyCurrency.LookupResultValue = EntityFactory.GetById <IExchangeRate>(options.MyCurrencyCode);
            }
        }
        else
        {
            lblMyCurrency.Visible = false;
            luMyCurrency.Visible  = false;
        }
        txtEmailBaseTemplateId.Attributes.Add("style", "display:none");
        txtLetterBaseTemplateId.Attributes.Add("style", "display:none");
        txtFaxBaseTemplateId.Attributes.Add("style", "display:none");
        txtRecentTemplates.Attributes.Add("onchange", "javascript:checkMenuRange()");

        var       optionSvc = ApplicationContext.Current.Services.Get <Sage.SalesLogix.Services.ISystemOptionsService>(true);
        int       dbType    = optionSvc.DbType;
        const int dbRemote  = 2;

        if (dbType != dbRemote)
        {
            // If this is *not* a remote database then hide the "Use ActiveReporting" option.
            _useActiveReporting.Attributes.Add("style", "display:none");
        }

        IUserOptionsService _UserOptions = ApplicationContext.Current.Services.Get <IUserOptionsService>();
        string _group = _UserOptions.GetCommonOption("SyncGroup", "Intellisync");

        _defaultOwnerTeam.Enabled = !_UserOptions.GetCommonOptionLocked("InsertSecCodeID", "General");

        if (!string.IsNullOrEmpty(_group))
        {
            Utility.SetSelectedValue(_intellisyncGroup, _group);
            _intellisyncGroup.Enabled = false;
        }
        else
        {
            _intellisyncGroup.Enabled = true;
        }

        bool AllowUserToChange = !_UserOptions.GetCommonOptionLocked("DefaultMemoTemplate", "General");

        txtEmailBaseTemplate.Enabled  = AllowUserToChange;
        txtLetterBaseTemplate.Enabled = AllowUserToChange;
        txtFaxBaseTemplate.Enabled    = AllowUserToChange;
        if (!AllowUserToChange)
        {
            txtEmailBaseTemplateImg.Attributes.Add("onclick", "");
            txtLetterBaseTemplateImg.Attributes.Add("onclick", "");
            txtFaxBaseTemplateImg.Attributes.Add("onclick", "");
        }
        LoadScript();
    }