public static string GetTypesHtml(SelectedType type, string arg)
    {
        Organization organization = Organizations.GetOrganization(UserSession.LoginUser, UserSession.LoginUser.OrganizationID);
        DataTable    table        = new DataTable();

        table.Columns.Add("ID");
        table.Columns.Add("Name");
        table.Columns.Add("Description");
        string result = "";

        switch (type)
        {
        case SelectedType.ActionTypes:
            ActionTypes actionTypes = new ActionTypes(UserSession.LoginUser);
            actionTypes.LoadAllPositions(UserSession.LoginUser.OrganizationID);
            table.Columns.Add("Is Timed");
            foreach (ActionType actionType in actionTypes)
            {
                table.Rows.Add(new string[] { actionType.ActionTypeID.ToString(), actionType.Name, actionType.Description, actionType.IsTimed.ToString() });
            }
            break;

        case SelectedType.PhoneTypes:
            PhoneTypes phoneTypes = new PhoneTypes(UserSession.LoginUser);
            phoneTypes.LoadAllPositions(UserSession.LoginUser.OrganizationID);
            foreach (PhoneType phoneType in phoneTypes)
            {
                table.Rows.Add(new string[] { phoneType.PhoneTypeID.ToString(), phoneType.Name, phoneType.Description });
            }
            break;

        case SelectedType.ProductVersionStatuses:
            ProductVersionStatuses productVersionStatuses = new ProductVersionStatuses(UserSession.LoginUser);
            productVersionStatuses.LoadAllPositions(UserSession.LoginUser.OrganizationID);
            table.Columns.Add("Is Shipping");
            table.Columns.Add("Is Discontinued");
            foreach (ProductVersionStatus productVersionStatus in productVersionStatuses)
            {
                table.Rows.Add(new string[] { productVersionStatus.ProductVersionStatusID.ToString(), productVersionStatus.Name, productVersionStatus.Description, productVersionStatus.IsShipping.ToString(), productVersionStatus.IsDiscontinued.ToString() });
            }
            break;

        case SelectedType.TicketSeverities:
            table.Columns.Add("Visible on Portal");
            TicketSeverities ticketSeverities = new TicketSeverities(UserSession.LoginUser);
            ticketSeverities.LoadAllPositions(UserSession.LoginUser.OrganizationID);
            foreach (TicketSeverity ticketSeverity in ticketSeverities)
            {
                table.Rows.Add(new string[] { ticketSeverity.TicketSeverityID.ToString(), ticketSeverity.Name, ticketSeverity.Description, ticketSeverity.VisibleOnPortal.ToString() });
            }
            break;

        case SelectedType.TicketStatuses:
            TicketStatuses ticketStatuses = new TicketStatuses(UserSession.LoginUser);
            ticketStatuses.LoadAllPositions(int.Parse(arg));

            table.Columns.Add("Is Closed");
            table.Columns.Add("Closed Email");
            table.Columns.Add("Email Response");
            table.Columns.Add("Pause SLA");

            foreach (TicketStatus ticketStatus in ticketStatuses)
            {
                table.Rows.Add(new string[] { ticketStatus.TicketStatusID.ToString(), ticketStatus.Name, ticketStatus.Description, ticketStatus.IsClosed.ToString(), ticketStatus.IsClosedEmail.ToString(), ticketStatus.IsEmailResponse.ToString(), ticketStatus.PauseSLA.ToString() });
            }
            break;

        case SelectedType.TicketTypes:
            table.Columns.Add("Icon");
            table.Columns.Add("Visible on Portal");
            string icon = "<img src=\"../{0}\" />";
            if (organization.UseProductFamilies)
            {
                TicketTypesView ticketTypes = new TicketTypesView(UserSession.LoginUser);
                ticketTypes.LoadAllPositions(UserSession.LoginUser.OrganizationID);
                table.Columns.Add("Product Line");
                table.Columns.Add("Active");
                foreach (TicketTypesViewItem ticketType in ticketTypes)
                {
                    table.Rows.Add(new string[] { ticketType.TicketTypeID.ToString(), ticketType.Name, ticketType.Description, string.Format(icon, ticketType.IconUrl), ticketType.IsVisibleOnPortal.ToString(), ticketType.ProductFamilyName });
                }
            }
            else
            {
                TicketTypes ticketTypes = new TicketTypes(UserSession.LoginUser);
                ticketTypes.LoadAllPositions(UserSession.LoginUser.OrganizationID);
                table.Columns.Add("Active");
                foreach (TicketType ticketType in ticketTypes)
                {
                    table.Rows.Add(new string[] { ticketType.TicketTypeID.ToString(), ticketType.Name, ticketType.Description, string.Format(icon, ticketType.IconUrl), ticketType.IsVisibleOnPortal.ToString() });
                }
            }
            break;

        case SelectedType.ActivityTypes:
            ActivityTypes activityTypes = new ActivityTypes(UserSession.LoginUser);
            activityTypes.LoadAllPositions(UserSession.LoginUser.OrganizationID);
            foreach (ActivityType activityType in activityTypes)
            {
                table.Rows.Add(new string[] { activityType.ActivityTypeID.ToString(), activityType.Name, activityType.Description });
            }
            break;

        default:
            break;
        }

        return(BuildTable(table));
    }
        private void LoadCustomProperties()
        {
            int oldID = GetSelectedPropertyID();

            ReferenceType refType = GetSelectedPropertyType();

            DataTable table = new DataTable();

            table.Columns.Add("ID", System.Type.GetType("System.Int32"));
            table.Columns.Add("Name");
            table.Columns.Add("Description");
            table.Columns.Add("IsClosed", System.Type.GetType("System.Boolean"));
            table.Columns.Add("IsShipping", System.Type.GetType("System.Boolean"));
            table.Columns.Add("IsDiscontinued", System.Type.GetType("System.Boolean"));

            gridProperties.Columns["IsShipping"].IsVisible     = false;
            gridProperties.Columns["IsDiscontinued"].IsVisible = false;
            gridProperties.Columns["IsClosed"].IsVisible       = false;

            switch (refType)
            {
            case ReferenceType.ActionTypes:
                ActionTypes actionTypes = new ActionTypes(LoginSession.LoginUser);
                actionTypes.LoadAllPositions(OrganizationID);
                foreach (ActionType actionType in actionTypes)
                {
                    DataRow row = table.NewRow();
                    row[0] = actionType.ActionTypeID;
                    row[1] = actionType.Name;
                    row[2] = actionType.Description;
                    row[3] = false;
                    row[4] = false;
                    row[5] = false;
                    table.Rows.Add(row);
                }

                break;

            case ReferenceType.PhoneTypes:
                PhoneTypes phoneTypes = new PhoneTypes(LoginSession.LoginUser);
                phoneTypes.LoadAllPositions(OrganizationID);
                foreach (PhoneType phoneType in phoneTypes)
                {
                    DataRow row = table.NewRow();
                    row[0] = phoneType.PhoneTypeID;
                    row[1] = phoneType.Name;
                    row[2] = phoneType.Description;
                    row[3] = false;
                    row[4] = false;
                    row[5] = false;
                    table.Rows.Add(row);
                }
                break;

            case ReferenceType.ProductVersionStatuses:
                ProductVersionStatuses productVersionStatuses = new ProductVersionStatuses(LoginSession.LoginUser);
                productVersionStatuses.LoadAllPositions(OrganizationID);
                foreach (ProductVersionStatus productVersionStatus in productVersionStatuses)
                {
                    DataRow row = table.NewRow();
                    row[0] = productVersionStatus.ProductVersionStatusID;
                    row[1] = productVersionStatus.Name;
                    row[2] = productVersionStatus.Description;
                    row[3] = false;
                    row[4] = productVersionStatus.IsShipping;
                    row[5] = productVersionStatus.IsDiscontinued;
                    table.Rows.Add(row);
                }
                gridProperties.Columns["IsShipping"].IsVisible     = true;
                gridProperties.Columns["IsDiscontinued"].IsVisible = true;
                break;

            case ReferenceType.TicketSeverities:
                TicketSeverities ticketSeverities = new TicketSeverities(LoginSession.LoginUser);
                ticketSeverities.LoadAllPositions(OrganizationID);
                foreach (TicketSeverity ticketSeverity in ticketSeverities)
                {
                    DataRow row = table.NewRow();
                    row[0] = ticketSeverity.TicketSeverityID;
                    row[1] = ticketSeverity.Name;
                    row[2] = ticketSeverity.Description;
                    row[3] = false;
                    row[4] = false;
                    row[5] = false;
                    table.Rows.Add(row);
                }
                break;

            case ReferenceType.TicketStatuses:
                TicketStatuses ticketStatuses = new TicketStatuses(LoginSession.LoginUser);
                ticketStatuses.LoadAllPositions(GetSelectedTicketType());
                foreach (TicketStatus ticketStatus in ticketStatuses)
                {
                    DataRow row = table.NewRow();
                    row[0] = ticketStatus.TicketStatusID;
                    row[1] = ticketStatus.Name;
                    row[2] = ticketStatus.Description;
                    row[3] = ticketStatus.IsClosed;
                    row[4] = false;
                    row[5] = false;
                    table.Rows.Add(row);
                }
                gridProperties.Columns["IsClosed"].IsVisible = true;
                break;

            default:
                break;
            }



            gridProperties.DataSource = table;
            if (gridProperties.Rows.Count > 0)
            {
                gridProperties.Rows[0].IsCurrent = true;
            }
            SetSelectedPropertyID(oldID);
        }
    public static RadComboBoxItemData[] GetReplaceTypeComboData(int id, SelectedType type, int ticketTypeID)
    {
        //IDictionary<string, object> contextDictionary = (IDictionary<string, object>)context;
        List <RadComboBoxItemData> list = new List <RadComboBoxItemData>();

        /*string[] s = context["FilterString"].ToString().Split(',');
         * SelectedType type = (SelectedType)int.Parse(s[0]);
         * int ticketTypeID = int.Parse(s[1]);
         * int id = int.Parse(s[2]);*/

        BaseCollection collection  = null;
        string         nameColName = "Name";
        string         idColName   = "ID";

        switch (type)
        {
        case SelectedType.ActionTypes:
            ActionTypes actionTypes = new ActionTypes(UserSession.LoginUser);
            actionTypes.LoadAllPositions(UserSession.LoginUser.OrganizationID);
            collection = actionTypes;
            idColName  = "ActionTypeID";
            break;

        case SelectedType.PhoneTypes:
            PhoneTypes phoneTypes = new PhoneTypes(UserSession.LoginUser);
            phoneTypes.LoadAllPositions(UserSession.LoginUser.OrganizationID);
            collection = phoneTypes;
            idColName  = "PhoneTypeID";
            break;

        case SelectedType.ProductVersionStatuses:
            ProductVersionStatuses productVersionStatuses = new ProductVersionStatuses(UserSession.LoginUser);
            productVersionStatuses.LoadAllPositions(UserSession.LoginUser.OrganizationID);
            collection = productVersionStatuses;
            idColName  = "ProductVersionStatusID";
            break;

        case SelectedType.TicketSeverities:
            TicketSeverities ticketSeverities = new TicketSeverities(UserSession.LoginUser);
            ticketSeverities.LoadAllPositions(UserSession.LoginUser.OrganizationID);
            collection = ticketSeverities;
            idColName  = "TicketSeverityID";
            break;

        case SelectedType.TicketStatuses:
            TicketStatuses ticketStatuses = new TicketStatuses(UserSession.LoginUser);
            TicketType     ticketType     = TicketTypes.GetTicketType(UserSession.LoginUser, ticketTypeID);
            if (ticketType.OrganizationID == UserSession.LoginUser.OrganizationID)
            {
                ticketStatuses.LoadAllPositions(ticketTypeID);
                collection = ticketStatuses;
                idColName  = "TicketStatusID";
            }
            break;

        case SelectedType.TicketTypes:
            TicketTypes ticketTypes = new TicketTypes(UserSession.LoginUser);
            ticketTypes.LoadAllPositions(UserSession.LoginUser.OrganizationID);
            collection = ticketTypes;
            idColName  = "TicketTypeID";
            break;

        case SelectedType.ActivityTypes:
            ActivityTypes activityTypes = new ActivityTypes(UserSession.LoginUser);
            activityTypes.LoadAllPositions(UserSession.LoginUser.OrganizationID);
            //Load base items
            //Get default activity types
            foreach (ActivityTypeEnum activity in Enum.GetValues(typeof(ActivityTypeEnum)))
            {
                var value = Enum.Parse(typeof(ActivityTypeEnum), activity.ToString());
                //results.Add(new ActivityTypesDropDown() { Name = activity.ToString(), Value = (int)value });
                RadComboBoxItemData itemData = new RadComboBoxItemData();
                itemData.Text  = activity.ToString();
                itemData.Value = ((int)value).ToString();
                list.Add(itemData);
            }

            collection = activityTypes;
            idColName  = "ActivityTypeID";
            break;

        default:
            break;
        }

        foreach (DataRow row in collection.Table.Rows)
        {
            int i = (int)row[idColName];
            if (id != i)
            {
                RadComboBoxItemData itemData = new RadComboBoxItemData();
                itemData.Text  = row[nameColName].ToString();
                itemData.Value = i.ToString();
                list.Add(itemData);
            }
        }

        if (list.Count < 1)
        {
            RadComboBoxItemData noData = new RadComboBoxItemData();
            noData.Text  = "[No types to display.]";
            noData.Value = "-1";
            list.Add(noData);
        }

        return(list.ToArray());
    }