コード例 #1
0
    /// <summary>
    /// Handles the SelectedIndexChanged event of the cboTemplates 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 cboTemplates_SelectedIndexChanged(object sender, EventArgs e)
    {
        ImportManager importManager = Page.Session["importManager"] as ImportManager;

        if (!cboTemplates.SelectedValue.ToString().Equals(GetLocalResourceObject("cboTemplates.None.Item").ToString()))
        {
            string errorMessage = String.Empty;
            //Owner and Lead Source values are saved into the template and we don't necessarily want to overwrite these values so we'll
            //reassign them after the template is done loading.
            ImportTargetProperty tpOwner = importManager.EntityManager.GetEntityProperty("Owner");
            String ownerId = tpOwner.DefaultValue.ToString();
            ImportTargetProperty tpLeadSource = importManager.EntityManager.GetEntityProperty("LeadSource");
            String leadSourceId = tpLeadSource.DefaultValue.ToString();
            if (!importManager.AddImportMapsFromTemplate(importManager, cboTemplates.SelectedItem.Value, out errorMessage))
            {
                DialogService.ShowMessage(errorMessage);
            }
            else
            {
                importManager.Options.Template = cboTemplates.SelectedItem.Text;
                SetDefaultTargetPropertyValue("Owner", ownerId, importManager);
                SetDefaultTargetPropertyValue("LeadSource", leadSourceId, importManager);
                Page.Session["importManager"] = importManager;
            }
        }
    }