Exemple #1
0
        /// <summary>
        /// Determines the children entities belonging to an entity
        /// </summary>
        /// <param name="EntityToLoad">The EntityType - Category|Manufacturer|Section|Distribotur|Genre|Vector - to find children of</param>
        /// <param name="ParentEntityID">The ID of the entity to retrieve children for</param>
        /// <returns>A GridEntity List containing the immediate children of an entity</returns>
        public static List <GridEntity> GetChildrenEntities(String EntityToLoad, int ParentEntityID)
        {
            String EntityType = LoadEntityType(EntityToLoad);

            List <GridEntity> eiList = new List <GridEntity>();

            using (SqlConnection conn = new SqlConnection(DB.GetDBConn()))
            {
                conn.Open();

                using (IDataReader rs = DB.GetRS("select * from dbo.{0} with(NOLOCK) where Parent{0}ID=".FormatWith(EntityType) + ParentEntityID.ToString(), conn))
                {
                    while (rs.Read())
                    {
                        GridEntity e = new GridEntity(rs, EntityType);
                        eiList.Add(e);
                    }
                }
            }

            return(eiList);
        }
Exemple #2
0
        /// <summary>
        /// Loads all entities of a given entity type
        /// </summary>
        /// <param name="EntityToLoad">The EntityType - Category|Manufacturer|Section|Distributor - to load</param>
        /// <returns>An Entity List containing all root-level entities</returns>
        public static List <GridEntity> GetAllEntitiesOfType(String EntityToLoad)
        {
            String EntityType = LoadEntityType(EntityToLoad);

            List <GridEntity> eiList = new List <GridEntity>();

            using (SqlConnection conn = new SqlConnection(DB.GetDBConn()))
            {
                conn.Open();

                using (IDataReader rs = DB.GetRS("select * from dbo.{0} with(NOLOCK) where Deleted=0".FormatWith(EntityType), conn))
                {
                    while (rs.Read())
                    {
                        GridEntity e = new GridEntity(rs, EntityType);
                        eiList.Add(e);
                    }
                }
            }

            return(eiList);
        }