/*   protected void btnAddGroup_Click(object sender, EventArgs e)
     * {
     *     pnlNewGroupPopup = InputPageControls.GenerateNewNamePanel("Create new Model:");
     *     lblNewGroupName = pnlNewGroupPopup.FindControl(InputPageControls.LBL_NEW_NAME) as Label;
     *     String groupName = "";
     *     TextBox txtNewGroupName = pnlNewGroupPopup.FindControl(InputPageControls.TXT_NEW_NAME) as TextBox;
     *     String message;
     *     txtNewGroupName.Text = groupName;
     *     lblNewGroupName.Text = "Enter a name for the new group: ";
     *     int successCreate = cls_cd1.add_new_group(groupName);
     *     if (successCreate == 1)
     *     {
     *         message = "Gruop name is already in use. Please choose a new group name.";
     *         ShowErrorMessage(message);
     *     }
     * }
     */

    protected void btnSort_Click(object sender, EventArgs e)
    {
        StringBuilder sb    = new StringBuilder();
        string        value = dropListSorting.SelectedValue;

        if (!SortExpression.Equals(String.Empty))
        {
            string[] sortExpressions = SortExpression.Split(',');

            int index = -1;
            for (int i = 0; i < sortExpressions.Length; i++)
            {
                if (sortExpressions[i].IndexOf(value) >= 0)
                {
                    sortExpressions[i] = value + " " + lstRdbtnOrder.SelectedValue;
                    index = i;
                }
            }


            if (index >= 0)
            {
                for (int i = 0; i < sortExpressions.Length; i++)
                {
                    if (i == index)
                    {
                        continue;
                    }
                    if (i != 0)
                    {
                        sb.Append(",");
                    }
                    sb.Append(sortExpressions[i]);
                }
            }
            else
            {
                sb.Append(SortExpression);
            }
            if (sortExpressions.Length > 0 && index != 0)
            {
                sb.Append(",");
            }
        }
        sb.Append(value);
        sb.Append(" ");
        sb.Append(lstRdbtnOrder.SelectedValue);
        SortExpression = sb.ToString();

        string str1;

        str1 = DropDownList2.SelectedValue;

        SetGroupModelsData(Convert.ToInt32(str1));
    }
예제 #2
0
        /// <summary>
        /// Gets the current sort expression list
        /// </summary>
        public List <ISortExpression> GetSortExpressions()
        {
            List <ISortExpression> sortExpressions = new List <ISortExpression>();

            if (SortExpression != string.Empty)
            {
                // Don't split the sort expression when it contains "dbo.", as this means it is a function
                // and might have be taking multiple values.  This still needs improvement though, as it would
                // break if we're mixing sort expressions to use a function and a column name.
                // For example: dbo.MyFunction(Col1,Col2),Col3 wouldn't work correctly.
                string[] array = (SortExpression.Contains("dbo.")) ? new[] { SortExpression } : SortExpression.Split(',');

                foreach (string sortExpression in array)
                {
                    if (SortAscending)
                    {
                        sortExpressions.Add(new AscendingSort(sortExpression));
                    }
                    else
                    {
                        sortExpressions.Add(new DescendingSort(sortExpression));
                    }
                }
            }

            return(sortExpressions);
        }