예제 #1
0
        /// <summary>
        /// 判断当前节点是否已存在相同的
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public int  ExistNum(StatisticCommentNumEntity entity)
        {
            ///id=0,判断总数,ID>0判断除自己之外的总数
            string sql = @"Select count(1) from dbo.[StatisticCommentNum] WITH(NOLOCK) ";

            string where = "where ";
            if (entity.Id == 0)
            {
            }
            else
            {
            }
            sql = sql + where;
            DbCommand cmd = db.GetSqlStringCommand(sql);

            if (entity.Id > 0)
            {
                db.AddInParameter(cmd, "@Id", DbType.Int32, entity.Id);
            }
            object identity = db.ExecuteScalar(cmd);

            if (identity == null || identity == DBNull.Value)
            {
                return(0);
            }
            return(Convert.ToInt32(identity));
        }
예제 #2
0
        public StatisticCommentNumEntity GetCommentNumByProductId(int productid)
        {
            string    sql = @"SELECT top 1 [Id],[ProductId],[StyleId],[FavNum],[GeneralNum],[BadNum],[FavRate],[GeneralRate],[BadRate],AllNum,CommentContent
							FROM
							dbo.[StatisticCommentNum] WITH(NOLOCK)	
							WHERE [ProductId]=@ProductId order by id desc"                            ;
            DbCommand cmd = db.GetSqlStringCommand(sql);

            db.AddInParameter(cmd, "@ProductId", DbType.Int32, productid);
            StatisticCommentNumEntity entity = new StatisticCommentNumEntity();

            using (IDataReader reader = db.ExecuteReader(cmd))
            {
                if (reader.Read())
                {
                    entity.Id             = StringUtils.GetDbInt(reader["Id"]);
                    entity.ProductId      = StringUtils.GetDbInt(reader["ProductId"]);
                    entity.StyleId        = StringUtils.GetDbInt(reader["StyleId"]);
                    entity.AllNum         = StringUtils.GetDbInt(reader["AllNum"]);
                    entity.FavNum         = StringUtils.GetDbInt(reader["FavNum"]);
                    entity.GeneralNum     = StringUtils.GetDbInt(reader["GeneralNum"]);
                    entity.BadNum         = StringUtils.GetDbInt(reader["BadNum"]);
                    entity.FavRate        = StringUtils.GetDbInt(reader["FavRate"]);
                    entity.GeneralRate    = StringUtils.GetDbInt(reader["GeneralRate"]);
                    entity.BadRate        = StringUtils.GetDbInt(reader["BadRate"]);
                    entity.CommentContent = StringUtils.GetDbString(reader["CommentContent"]);
                }
            }
            return(entity);
        }
예제 #3
0
        /// <summary>
        /// 根据主键值读取记录。如果数据库不存在这条数据将返回null
        /// </summary>
        /// <param name="db">数据库操作对象</param>
        /// <param name="columns">需要返回的列,不提供任何列名时默认将返回所有列</param>
        public StatisticCommentNumEntity GetStatisticCommentNum(int id)
        {
            string    sql = @"SELECT  [Id],[ProductId],[StyleId],[FavNum],[GeneralNum],[BadNum]
							FROM
							dbo.[StatisticCommentNum] WITH(NOLOCK)	
							WHERE [Id]=@id"                            ;
            DbCommand cmd = db.GetSqlStringCommand(sql);

            db.AddInParameter(cmd, "@Id", DbType.Int32, id);
            StatisticCommentNumEntity entity = new StatisticCommentNumEntity();

            using (IDataReader reader = db.ExecuteReader(cmd))
            {
                if (reader.Read())
                {
                    entity.Id         = StringUtils.GetDbInt(reader["Id"]);
                    entity.ProductId  = StringUtils.GetDbInt(reader["ProductId"]);
                    entity.StyleId    = StringUtils.GetDbInt(reader["StyleId"]);
                    entity.FavNum     = StringUtils.GetDbInt(reader["FavNum"]);
                    entity.GeneralNum = StringUtils.GetDbInt(reader["GeneralNum"]);
                    entity.BadNum     = StringUtils.GetDbInt(reader["BadNum"]);
                }
            }
            return(entity);
        }
예제 #4
0
        public int UpdateStatisticCommentNum(StatisticCommentNumEntity entity)
        {
            string    sql = @" UPDATE dbo.[StatisticCommentNum] SET
                       [ProductId]=@ProductId,[StyleId]=@StyleId,[FavNum]=@FavNum,[GeneralNum]=@GeneralNum,[BadNum]=@BadNum
                       WHERE [Id]=@id";
            DbCommand cmd = db.GetSqlStringCommand(sql);

            db.AddInParameter(cmd, "@Id", DbType.Int32, entity.Id);
            db.AddInParameter(cmd, "@ProductId", DbType.Int32, entity.ProductId);
            db.AddInParameter(cmd, "@StyleId", DbType.Int32, entity.StyleId);
            db.AddInParameter(cmd, "@FavNum", DbType.Int32, entity.FavNum);
            db.AddInParameter(cmd, "@GeneralNum", DbType.Int32, entity.GeneralNum);
            db.AddInParameter(cmd, "@BadNum", DbType.Int32, entity.BadNum);
            return(db.ExecuteNonQuery(cmd));
        }
예제 #5
0
        /// <summary>
        /// 插入一条记录到表StatisticCommentNum,如果表中存在自增字段,则返回值为新记录的自增字段值,否则返回0。
        /// 该方法提供给界面等UI层调用
        /// </summary>
        /// <param name="statisticCommentNum">要添加的StatisticCommentNum数据实体对象</param>
        public int AddStatisticCommentNum(StatisticCommentNumEntity statisticCommentNum)
        {
            if (statisticCommentNum.Id > 0)
            {
                return(UpdateStatisticCommentNum(statisticCommentNum));
            }

            else if (StatisticCommentNumBLL.Instance.IsExist(statisticCommentNum))
            {
                return((int)CommonStatus.ADD_Fail_Exist);
            }
            else
            {
                return(StatisticCommentNumDA.Instance.AddStatisticCommentNum(statisticCommentNum));
            }
        }
예제 #6
0
        public StatisticCommentNumEntity GetCommentNumByProductId(int productid)
        {
            string _cachekey = "GetCommentNumByProductId_" + productid;// SysCacheKey.StatisticCommentNumListKey;
            object obj       = MemCache.GetCache(_cachekey);
            StatisticCommentNumEntity entity = new StatisticCommentNumEntity();

            if (obj == null)
            {
                entity = StatisticCommentNumDA.Instance.GetCommentNumByProductId(productid);
            }
            else
            {
                entity = (StatisticCommentNumEntity)obj;
            }
            return(entity);
        }
예제 #7
0
        /// <summary>
        /// 读取记录列表。
        /// </summary>
        /// <param name="db">数据库操作对象</param>
        /// <param name="columns">需要返回的列,不提供任何列名时默认将返回所有列</param>
        public IList <StatisticCommentNumEntity> GetStatisticCommentNumList(int pagesize, int pageindex, ref int recordCount)
        {
            string sql = @"SELECT   [Id],[ProductId],[StyleId],[FavNum],[GeneralNum],[BadNum]
						FROM
						(SELECT ROW_NUMBER() OVER (ORDER BY Id desc) AS ROWNUMBER,
						 [Id],[ProductId],[StyleId],[FavNum],[GeneralNum],[BadNum] from dbo.[StatisticCommentNum] WITH(NOLOCK)	
						WHERE  1=1 ) as temp 
						where rownumber BETWEEN ((@PageIndex - 1) * @PageSize + 1) AND @PageIndex * @PageSize"                        ;

            string sql2 = @"Select count(1) from dbo.[StatisticCommentNum] with (nolock) ";
            IList <StatisticCommentNumEntity> entityList = new List <StatisticCommentNumEntity>();
            DbCommand cmd = db.GetSqlStringCommand(sql);

            db.AddInParameter(cmd, "@PageIndex", DbType.Int32, pageindex);
            db.AddInParameter(cmd, "@PageSize", DbType.Int32, pagesize);

            using (IDataReader reader = db.ExecuteReader(cmd))
            {
                while (reader.Read())
                {
                    StatisticCommentNumEntity entity = new StatisticCommentNumEntity();
                    entity.Id         = StringUtils.GetDbInt(reader["Id"]);
                    entity.ProductId  = StringUtils.GetDbInt(reader["ProductId"]);
                    entity.StyleId    = StringUtils.GetDbInt(reader["StyleId"]);
                    entity.FavNum     = StringUtils.GetDbInt(reader["FavNum"]);
                    entity.GeneralNum = StringUtils.GetDbInt(reader["GeneralNum"]);
                    entity.BadNum     = StringUtils.GetDbInt(reader["BadNum"]);
                    entityList.Add(entity);
                }
            }
            cmd = db.GetSqlStringCommand(sql2);
            using (IDataReader reader = db.ExecuteReader(cmd))
            {
                if (reader.Read())
                {
                    recordCount = StringUtils.GetDbInt(reader[0]);
                }
                else
                {
                    recordCount = 0;
                }
            }
            return(entityList);
        }
예제 #8
0
        /// <summary>
        /// 插入一条记录到表StatisticCommentNum,如果表中存在自增字段,则返回值为新记录的自增字段值,否则返回0
        /// </summary>
        /// <param name="db">数据库操作对象</param>
        /// <param name="statisticCommentNum">待插入的实体对象</param>
        public int AddStatisticCommentNum(StatisticCommentNumEntity entity)
        {
            string    sql = @"insert into StatisticCommentNum( [ProductId],[StyleId],[FavNum],[GeneralNum],[BadNum])VALUES
			            ( @ProductId,@StyleId,@FavNum,@GeneralNum,@BadNum);
			SELECT SCOPE_IDENTITY();"            ;
            DbCommand cmd = db.GetSqlStringCommand(sql);

            db.AddInParameter(cmd, "@ProductId", DbType.Int32, entity.ProductId);
            db.AddInParameter(cmd, "@StyleId", DbType.Int32, entity.StyleId);
            db.AddInParameter(cmd, "@FavNum", DbType.Int32, entity.FavNum);
            db.AddInParameter(cmd, "@GeneralNum", DbType.Int32, entity.GeneralNum);
            db.AddInParameter(cmd, "@BadNum", DbType.Int32, entity.BadNum);
            object identity = db.ExecuteScalar(cmd);

            if (identity == null || identity == DBNull.Value)
            {
                return(0);
            }
            return(Convert.ToInt32(identity));
        }
예제 #9
0
        /// <summary>
        /// 读取记录列表。
        /// </summary>
        /// <param name="db">数据库操作对象</param>
        /// <param name="columns">需要返回的列,不提供任何列名时默认将返回所有列</param>
        public IList <StatisticCommentNumEntity> GetStatisticCommentNumAll()
        {
            string sql = @"SELECT    [Id],[ProductId],[StyleId],[FavNum],[GeneralNum],[BadNum] from dbo.[StatisticCommentNum] WITH(NOLOCK)	";
            IList <StatisticCommentNumEntity> entityList = new List <StatisticCommentNumEntity>();
            DbCommand cmd = db.GetSqlStringCommand(sql);

            using (IDataReader reader = db.ExecuteReader(cmd))
            {
                while (reader.Read())
                {
                    StatisticCommentNumEntity entity = new StatisticCommentNumEntity();
                    entity.Id         = StringUtils.GetDbInt(reader["Id"]);
                    entity.ProductId  = StringUtils.GetDbInt(reader["ProductId"]);
                    entity.StyleId    = StringUtils.GetDbInt(reader["StyleId"]);
                    entity.FavNum     = StringUtils.GetDbInt(reader["FavNum"]);
                    entity.GeneralNum = StringUtils.GetDbInt(reader["GeneralNum"]);
                    entity.BadNum     = StringUtils.GetDbInt(reader["BadNum"]);
                    entityList.Add(entity);
                }
            }
            return(entityList);
        }
예제 #10
0
 /// <summary>
 /// 更新一条StatisticCommentNum记录。
 /// 该方法提供给界面等UI层调用
 /// </summary>
 /// <param name="statisticCommentNum">待更新的实体对象</param>
 /// <param name="columns">要更新的列名,不提供任何列名时默认将更新主键之外的所有列</param>
 public int UpdateStatisticCommentNum(StatisticCommentNumEntity statisticCommentNum)
 {
     return(StatisticCommentNumDA.Instance.UpdateStatisticCommentNum(statisticCommentNum));
 }
예제 #11
0
 /// <summary>
 /// 判断对象是否存在
 /// </summary>
 /// <param name="dicEnum"></param>
 /// <returns></returns>
 public bool IsExist(StatisticCommentNumEntity statisticCommentNum)
 {
     return(StatisticCommentNumDA.Instance.ExistNum(statisticCommentNum) > 0);
 }