コード例 #1
0
        /// <summary>
        /// 获取标准车型有效品牌
        /// </summary>
        /// <returns></returns>
        public IList <VWTreeCTBrandEntity> GetStandardTreeCTB(int isstand)
        {
            string where = " where  IsActive=1  ";
            if (isstand != -1)
            {
                where = " where IsStandardBrand=@IsStandardBrand ";
            }
            string sql = @"SELECT    [Id], [BrandName],[PYFirst],[PicUrl],Sort,ParentId,IsStandardBrand from dbo.[CarTypeBrand] WITH(NOLOCK) " + where + " Order By Sort  	";
            IList <VWTreeCTBrandEntity> entityList = new List <VWTreeCTBrandEntity>();
            DbCommand cmd = db.GetSqlStringCommand(sql);

            if (isstand != -1)
            {
                db.AddInParameter(cmd, "@IsStandardBrand", DbType.Int32, isstand);
            }
            using (IDataReader reader = db.ExecuteReader(cmd))
            {
                while (reader.Read())
                {
                    VWTreeCTBrandEntity entity = new VWTreeCTBrandEntity();
                    entity.Id              = StringUtils.GetDbInt(reader["Id"]);
                    entity.Name            = StringUtils.GetDbString(reader["BrandName"]);
                    entity.PYFirst         = StringUtils.GetDbString(reader["PYFirst"]);
                    entity.Sort            = StringUtils.GetDbInt(reader["Sort"]);
                    entity.PicUrl          = StringUtils.GetDbString(reader["PicUrl"]);
                    entity.ParentId        = StringUtils.GetDbInt(reader["ParentId"]);
                    entity.IsStandardBrand = StringUtils.GetDbInt(reader["IsStandardBrand"]);

                    entityList.Add(entity);
                }
            }
            return(entityList);
        }
コード例 #2
0
        public IList <VWTreeCTBrandEntity> GetTreeCarTypeBrand(int isstand = 1)
        {
            IList <VWTreeCTBrandEntity> resultlist = new List <VWTreeCTBrandEntity>();
            string _cachekey = "GetTreeCarTypeBrand_" + isstand;
            object obj       = MemCache.GetCache(_cachekey);

            if (obj == null)
            {
                IList <VWTreeCTBrandEntity> list = null;
                list = CarTypeBrandDA.Instance.GetStandardTreeCTB(isstand);
                if (list != null && list.Count > 0)
                {
                    //string[] firstletter = new Array();
                    ArrayList firstletter = new ArrayList();
                    foreach (VWTreeCTBrandEntity entity in list)
                    {
                        if (!firstletter.Contains(entity.PYFirst))
                        {
                            firstletter.Add(entity.PYFirst);
                        }
                        firstletter.Sort();
                    }
                    foreach (string letter in firstletter)
                    {
                        VWTreeCTBrandEntity entity = new VWTreeCTBrandEntity();
                        entity.PYFirst = letter;
                        resultlist.Add(entity);
                    }
                    foreach (VWTreeCTBrandEntity entity in list)
                    {
                        foreach (VWTreeCTBrandEntity entity2 in resultlist)
                        {
                            if (entity.PYFirst == entity2.PYFirst)
                            {
                                if (entity2.Children == null)
                                {
                                    entity2.Children = new List <VWTreeCTBrandEntity>();
                                }
                                entity2.Children.Add(entity);
                                break;
                            }
                        }
                    }
                }
                MemCache.AddCache(_cachekey, resultlist);
            }
            else
            {
                resultlist = (IList <VWTreeCTBrandEntity>)obj;
            }
            return(resultlist);
        }