Ejemplo n.º 1
0
    /// <summary>
    /// Returns string for ORDER BY clause and disables remembering unigrid state.
    /// </summary>
    private string GetOrderBy()
    {
        string orderBy = null;

        // OrderBy specified by drop-down list
        switch (OrderBy)
        {
        case ORDERBY_DATE_ASC:
            orderBy = SqlHelper.AddOrderBy(orderBy, ORDERBY_DATE_ASC);
            break;

        case ORDERBY_PRICE_ASC:
            orderBy = SqlHelper.AddOrderBy(orderBy, ORDERBY_PRICE_ASC);
            break;

        case ORDERBY_PRICE_DESC:
            orderBy = SqlHelper.AddOrderBy(orderBy, ORDERBY_PRICE_DESC);
            break;

        case ORDERBY_DATE_DESC:
        default:
            orderBy = SqlHelper.AddOrderBy(orderBy, ORDERBY_DATE_DESC);
            break;
        }

        // Disables remembering unigrid state
        gridElem.RememberState = false;
        return(orderBy);
    }
Ejemplo n.º 2
0
    /// <summary>
    /// Returns string for ORDER BY clause.
    /// </summary>
    private string GetOrderBy()
    {
        // OrderBy specified by drop-down list
        string column = null;

        switch (OrderBy)
        {
        case ORDER_BY_NAME_DESC:
            column = "SKUName DESC";
            break;

        case ORDER_BY_NUMBER_ASC:
            column = "SKUNumber ASC";
            break;

        case ORDER_BY_NUMBER_DESC:
            column = "SKUNumber DESC";
            break;

        case ORDER_BY_PRICE_ASC:
            column = "SKUPrice ASC";
            break;

        case ORDER_BY_PRICE_DESC:
            column = "SKUPrice DESC";
            break;

        case ORDER_BY_DATE_DESC:
            column = "SKUCreated DESC";
            break;

        case ORDER_BY_DATE_ASC:
            column = "SKUCreated ASC";
            break;

        case ORDER_BY_AVAILABLE_ITEMS_ASC:
            column = "SKUAvailableItems ASC";
            break;

        case ORDER_BY_REORDER_DESC:
            column = "(ISNULL(SKUReorderAt,0) - SKUAvailableItems) DESC";
            break;

        case ORDER_BY_NAME_ASC:
        default:
            column = "SKUName ASC";
            break;
        }

        // Disables remembering unigrid state
        gridElem.RememberState = false;

        return(SqlHelper.AddOrderBy("", column));
    }
Ejemplo n.º 3
0
 /// <summary>
 ///  DocumentQuery that mimics the Hierarchy Viewer webpart, with caching included.
 /// </summary>
 /// <param name="Path">The Path for the documents to select</param>
 /// <param name="ClassNames">Class Names to include, semicolon seperated.</param>
 /// <param name="CombineWithDefaultCulture"></param>
 /// <param name="CultureCode"></param>
 /// <param name="MaxRelativeLevel"></param>
 /// <param name="UseHierarchicalOrder">Ensures the NodeLevel, NodeOrder is set first as the order.</param>
 /// <param name="AdditionalOrderBy"></param>
 /// <param name="SelectOnlyPublished"></param>
 /// <param name="SiteName"></param>
 /// <param name="WhereCondition"></param>
 /// <param name="Columns"></param>
 /// <param name="FilterOutDuplicates"></param>
 /// <param name="RelationshipWithNodeGuid">The Relationship to use, defaults to the current page.</param>
 /// <param name="RelatedNodeIsOnTheLeftSide"></param>
 /// <param name="RelationshipName"></param>
 /// <param name="CheckPermission"></param>
 /// <param name="LoadPagesIndividually"></param>
 /// <param name="CacheItemName">The Cache Item Name, required if you wish to cache.</param>
 /// <param name="CacheMinutes">The Cache minutes, if not provided uses the site default.</param>
 /// <param name="CacheDependencies">Any cache dependencies</param>
 /// <returns></returns>
 public static CacheableDocumentQuery HierarchyViewerQuery(
     string Path       = "/%",
     string ClassNames = null,
     bool CombineWithDefaultCulture = false,
     string CultureCode             = null,
     int MaxRelativeLevel           = -1,
     bool UseHierarchicalOrder      = true,
     string AdditionalOrderBy       = null,
     bool SelectOnlyPublished       = true,
     string SiteName                 = null,
     string WhereCondition           = null,
     string Columns                  = null,
     bool FilterOutDuplicates        = false,
     Guid RelationshipWithNodeGuid   = new Guid(),
     bool RelatedNodeIsOnTheLeftSide = true,
     string RelationshipName         = null,
     bool CheckPermission            = false,
     bool LoadPagesIndividually      = false,
     string CacheItemName            = null,
     int CacheMinutes                = -1,
     string[] CacheDependencies      = null
     )
 {
     AdditionalOrderBy = !string.IsNullOrWhiteSpace(AdditionalOrderBy) ? AdditionalOrderBy : "1";
     if (UseHierarchicalOrder)
     {
         AdditionalOrderBy = SqlHelper.AddOrderBy(AdditionalOrderBy, "NodeLevel, NodeOrder");
     }
     return(RepeaterQuery(
                Path: Path,
                ClassNames: ClassNames,
                CombineWithDefaultCulture: CombineWithDefaultCulture,
                CultureCode: CultureCode,
                MaxRelativeLevel: MaxRelativeLevel,
                OrderBy: AdditionalOrderBy,
                SelectOnlyPublished: SelectOnlyPublished,
                SelectTopN: -1,
                SiteName: SiteName,
                WhereCondition: WhereCondition,
                Columns: Columns,
                FilterOutDuplicates: FilterOutDuplicates,
                RelationshipWithNodeGuid: RelationshipWithNodeGuid,
                RelatedNodeIsOnTheLeftSide: RelatedNodeIsOnTheLeftSide,
                RelationshipName: RelationshipName,
                CheckPermission: CheckPermission,
                LoadPagesIndividually: LoadPagesIndividually,
                CacheItemName: CacheItemName,
                CacheMinutes: CacheMinutes,
                CacheDependencies: CacheDependencies));
 }
Ejemplo n.º 4
0
        public IEnumerable <T> PagerList <T>(string sql, int pageindex, out int count, string defaultsort = "", IDbDataParameter[] paramters = null)
        {
            StringBuilder sqlcountbuilder  = new StringBuilder(sql);
            StringBuilder sqlrownumbuilder = new StringBuilder(sql);

            SqlHelper.Driver = this;
            SqlHelper.AddCounter(sqlcountbuilder);
            SqlHelper.AddPager(pageindex, pagesize, sqlrownumbuilder, defaultsort);

            if (OrderByName != null)
            {
                SqlHelper.AddOrderBy(OrderByName, OrderByOrder == OrderBy.Asc ? true : false, defaultsort, sqlrownumbuilder);
            }

            count = Int32.Parse(ExecuteScalar(sqlcountbuilder.ToString(), paramters).ToString());

            return(FindAll <T>(sqlrownumbuilder.ToString(), paramters));
        }