using System;
using System.Data;
using CMS.FormControls;
using CMS.GlobalHelper;
using CMS.UIControls;
public partial class CMSModules_ContactManagement_FormControls_ActivityTypeSelector : FormEngineUserControl
{
#region "Variables"
private bool mShowAll = true;
#endregion
#region "Properties"
///
/// Gets or sets field value.
///
public override object Value
{
get
{
// Return null if "(all)" item is selected
if (ValidationHelper.GetInteger(ucType.Value, Int32.MinValue) == UniSelector.US_ALL_RECORDS)
{
return null;
}
return ucType.Value;
}
set
{
ucType.Value = ValidationHelper.GetString(value, null);
}
}
///
/// Gets selected value from dropdown list.
///
public string SelectedValue
{
get
{
return ValidationHelper.GetString(Value, null);
}
}
///
/// Inner UniSelector control.
///
public UniSelector UniSelector
{
get
{
return ucType;
}
}
///
/// If set to true, only custom activities will be shown.
///
public bool ShowCustomActivitiesOnly
{
get
{
return ValidationHelper.GetBoolean(GetValue("ShowCustomActivitiesOnly"), false);
}
set
{
SetValue("ShowCustomActivitiesOnly", value);
}
}
///
/// If set to true, only enabled activities will be shown.
///
public bool ShowEnabledActivitiesOnly
{
get
{
return ValidationHelper.GetBoolean(GetValue("ShowEnabledActivitiesOnly"), false);
}
set
{
SetValue("ShowEnabledActivitiesOnly", value);
}
}
///
/// If set to true, only manually creatable activities are shown.
///
public bool ShowManuallyCreatableActivities
{
get
{
return ValidationHelper.GetBoolean(GetValue("ShowManuallyCreatableActivities"), false);
}
set
{
SetValue("ShowManuallyCreatableActivities", value);
}
}
///
/// If set to true, "(all)" item will be included in the list.
///
public bool ShowAll
{
get
{
return ValidationHelper.GetBoolean(GetValue("ShowAll"), mShowAll);
}
set
{
SetValue("ShowAll", value);
}
}
///
/// Gets or sets AutoPostBack property of internal dropdown list.
///
public bool AutoPostBack
{
get
{
return ucType.DropDownSingleSelect.AutoPostBack;
}
set
{
ucType.DropDownSingleSelect.AutoPostBack = value;
}
}
#endregion
#region "Events"
public event EventHandler OnSelectedIndexChanged;
#endregion
#region "Methods"
protected void Page_Load(object sender, EventArgs e)
{
if (StopProcessing)
{
ucType.Visible = false;
return;
}
if (!String.IsNullOrEmpty(CssClass))
{
ucType.DropDownSingleSelect.CssClass = CssClass;
}
ucType.AllowAll = ShowAll;
string where = null;
if (ShowCustomActivitiesOnly)
{
where = "ActivityTypeIsCustom=1";
}
if (ShowManuallyCreatableActivities)
{
if (!String.IsNullOrEmpty(where))
{
where += " AND ";
}
where += "ActivityTypeManualCreationAllowed=1";
}
if (ShowEnabledActivitiesOnly)
{
if (!String.IsNullOrEmpty(where))
{
where += " AND ";
}
where += "ActivityTypeEnabled=1";
}
ucType.WhereCondition = where;
ucType.DropDownSingleSelect.SelectedIndexChanged += new EventHandler(DropDownSingleSelect_SelectedIndexChanged);
}
protected void DropDownSingleSelect_SelectedIndexChanged(object sender, EventArgs e)
{
if (OnSelectedIndexChanged != null)
{
OnSelectedIndexChanged(this, EventArgs.Empty);
}
}
#endregion
}