示例#1
0
        /// <summary>
        /// 读取记录列表。
        /// </summary>
        /// <param name="db">数据库操作对象</param>
        /// <param name="columns">需要返回的列,不提供任何列名时默认将返回所有列</param>
        public IList <OrderMsgMemEntity> GetOrderMsgMemAll()
        {
            string sql = @"SELECT    [Id],[MemId],[TotalNum],[WaitPayNum],WaitSellerDeliverNum,[WaitReciveNum],[WaitCommentNum],[CancelNum] from dbo.[OrderMsgMem] WITH(NOLOCK)	";
            IList <OrderMsgMemEntity> entityList = new List <OrderMsgMemEntity>();
            DbCommand cmd = db.GetSqlStringCommand(sql);

            using (IDataReader reader = db.ExecuteReader(cmd))
            {
                while (reader.Read())
                {
                    OrderMsgMemEntity entity = new OrderMsgMemEntity();
                    entity.Id                   = StringUtils.GetDbInt(reader["Id"]);
                    entity.MemId                = StringUtils.GetDbInt(reader["MemId"]);
                    entity.TotalNum             = StringUtils.GetDbInt(reader["TotalNum"]);
                    entity.WaitPayNum           = StringUtils.GetDbInt(reader["WaitPayNum"]);
                    entity.WaitSellerDeliverNum = StringUtils.GetDbInt(reader["WaitSellerDeliverNum"]);

                    entity.WaitReciveNum  = StringUtils.GetDbInt(reader["WaitReciveNum"]);
                    entity.WaitCommentNum = StringUtils.GetDbInt(reader["WaitCommentNum"]);
                    entity.CancelNum      = StringUtils.GetDbInt(reader["CancelNum"]);
                    entityList.Add(entity);
                }
            }
            return(entityList);
        }
示例#2
0
        /// <summary>
        /// 判断当前节点是否已存在相同的
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public int  ExistNum(OrderMsgMemEntity entity)
        {
            ///id=0,判断总数,ID>0判断除自己之外的总数
            string sql = @"Select count(1) from dbo.[OrderMsgMem] 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));
        }
示例#3
0
        /// <summary>
        /// 根据主键值读取记录。如果数据库不存在这条数据将返回null
        /// </summary>
        /// <param name="db">数据库操作对象</param>
        /// <param name="columns">需要返回的列,不提供任何列名时默认将返回所有列</param>
        public OrderMsgMemEntity GetOrderMsgMem(int id)
        {
            string    sql = @"SELECT  [Id],[MemId],[TotalNum],[WaitPayNum],WaitSellerDeliverNum,[WaitReciveNum],[WaitCommentNum],[CancelNum]
							FROM
							dbo.[OrderMsgMem] WITH(NOLOCK)	
							WHERE [Id]=@id"                            ;
            DbCommand cmd = db.GetSqlStringCommand(sql);

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

            using (IDataReader reader = db.ExecuteReader(cmd))
            {
                if (reader.Read())
                {
                    entity.Id                   = StringUtils.GetDbInt(reader["Id"]);
                    entity.MemId                = StringUtils.GetDbInt(reader["MemId"]);
                    entity.TotalNum             = StringUtils.GetDbInt(reader["TotalNum"]);
                    entity.WaitPayNum           = StringUtils.GetDbInt(reader["WaitPayNum"]);
                    entity.WaitSellerDeliverNum = StringUtils.GetDbInt(reader["WaitSellerDeliverNum"]);
                    entity.WaitReciveNum        = StringUtils.GetDbInt(reader["WaitReciveNum"]);
                    entity.WaitCommentNum       = StringUtils.GetDbInt(reader["WaitCommentNum"]);
                    entity.CancelNum            = StringUtils.GetDbInt(reader["CancelNum"]);
                }
            }
            return(entity);
        }
示例#4
0
        /// <summary>
        /// 插入一条记录到表OrderMsgMem,如果表中存在自增字段,则返回值为新记录的自增字段值,否则返回0。
        /// 该方法提供给界面等UI层调用
        /// </summary>
        /// <param name="orderMsgMem">要添加的OrderMsgMem数据实体对象</param>
        public int AddOrderMsgMem(OrderMsgMemEntity orderMsgMem)
        {
            if (orderMsgMem.Id > 0)
            {
                return(UpdateOrderMsgMem(orderMsgMem));
            }

            else if (OrderMsgMemBLL.Instance.IsExist(orderMsgMem))
            {
                return((int)CommonStatus.ADD_Fail_Exist);
            }
            else
            {
                return(OrderMsgMemDA.Instance.AddOrderMsgMem(orderMsgMem));
            }
        }
示例#5
0
        /// <summary>
        /// 根据主键值更新记录的全部字段(注意:该方法不会对自增字段、timestamp类型字段以及主键字段更新!如果要更新主键字段,请使用Update方法)。
        /// 如果数据库有数据被更新了则返回True,否则返回False
        /// </summary>
        /// <param name="db">数据库操作对象</param>
        /// <param name="orderMsgMem">待更新的实体对象</param>
        public int UpdateOrderMsgMem(OrderMsgMemEntity entity)
        {
            string    sql = @" UPDATE dbo.[OrderMsgMem] SET
                       [MemId]=@MemId,[TotalNum]=@TotalNum,[WaitPayNum]=@WaitPayNum,[WaitSellerDeliverNum]=@WaitSellerDeliverNum,[WaitReciveNum]=@WaitReciveNum,[WaitCommentNum]=@WaitCommentNum,[CancelNum]=@CancelNum
                       WHERE [Id]=@id";
            DbCommand cmd = db.GetSqlStringCommand(sql);

            db.AddInParameter(cmd, "@Id", DbType.Int32, entity.Id);
            db.AddInParameter(cmd, "@MemId", DbType.Int32, entity.MemId);
            db.AddInParameter(cmd, "@TotalNum", DbType.Int32, entity.TotalNum);
            db.AddInParameter(cmd, "@WaitPayNum", DbType.Int32, entity.WaitPayNum);
            db.AddInParameter(cmd, "@WaitSellerDeliverNum", DbType.Int32, entity.WaitSellerDeliverNum);
            db.AddInParameter(cmd, "@WaitReciveNum", DbType.Int32, entity.WaitReciveNum);
            db.AddInParameter(cmd, "@WaitCommentNum", DbType.Int32, entity.WaitCommentNum);
            db.AddInParameter(cmd, "@CancelNum", DbType.Int32, entity.CancelNum);
            return(db.ExecuteNonQuery(cmd));
        }
示例#6
0
        /// <summary>
        /// 读取记录列表。
        /// </summary>
        /// <param name="db">数据库操作对象</param>
        /// <param name="columns">需要返回的列,不提供任何列名时默认将返回所有列</param>
        public IList <OrderMsgMemEntity> GetOrderMsgMemList(int pagesize, int pageindex, ref int recordCount)
        {
            string sql = @"SELECT   [Id],[MemId],[TotalNum],[WaitPayNum],WaitSellerDeliverNum,[WaitReciveNum],[WaitCommentNum],[CancelNum]
						FROM
						(SELECT ROW_NUMBER() OVER (ORDER BY Id desc) AS ROWNUMBER,
						 [Id],[MemId],[TotalNum],[WaitPayNum],WaitSellerDeliverNum,[WaitReciveNum],[WaitCommentNum],[CancelNum] from dbo.[OrderMsgMem] WITH(NOLOCK)	
						WHERE  1=1 ) as temp 
						where rownumber BETWEEN ((@PageIndex - 1) * @PageSize + 1) AND @PageIndex * @PageSize"                        ;

            string sql2 = @"Select count(1) from dbo.[OrderMsgMem] with (nolock) ";
            IList <OrderMsgMemEntity> entityList = new List <OrderMsgMemEntity>();
            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())
                {
                    OrderMsgMemEntity entity = new OrderMsgMemEntity();
                    entity.Id                   = StringUtils.GetDbInt(reader["Id"]);
                    entity.MemId                = StringUtils.GetDbInt(reader["MemId"]);
                    entity.TotalNum             = StringUtils.GetDbInt(reader["TotalNum"]);
                    entity.WaitPayNum           = StringUtils.GetDbInt(reader["WaitPayNum"]);
                    entity.WaitSellerDeliverNum = StringUtils.GetDbInt(reader["WaitSellerDeliverNum"]);
                    entity.WaitReciveNum        = StringUtils.GetDbInt(reader["WaitReciveNum"]);
                    entity.WaitCommentNum       = StringUtils.GetDbInt(reader["WaitCommentNum"]);
                    entity.CancelNum            = StringUtils.GetDbInt(reader["CancelNum"]);
                    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);
        }
示例#7
0
        /// <summary>
        /// 插入一条记录到表OrderMsgMem,如果表中存在自增字段,则返回值为新记录的自增字段值,否则返回0
        /// </summary>
        /// <param name="db">数据库操作对象</param>
        /// <param name="orderMsgMem">待插入的实体对象</param>
        public int AddOrderMsgMem(OrderMsgMemEntity entity)
        {
            string    sql = @"insert into OrderMsgMem( [MemId],[TotalNum],[WaitPayNum],WaitSellerDeliverNum,[WaitReciveNum],[WaitCommentNum],[CancelNum])VALUES
			            ( @MemId,@TotalNum,@WaitPayNum,@WaitSellerDeliverNum,@WaitReciveNum,@WaitCommentNum,@CancelNum);
			SELECT SCOPE_IDENTITY();"            ;
            DbCommand cmd = db.GetSqlStringCommand(sql);

            db.AddInParameter(cmd, "@MemId", DbType.Int32, entity.MemId);
            db.AddInParameter(cmd, "@TotalNum", DbType.Int32, entity.TotalNum);
            db.AddInParameter(cmd, "@WaitPayNum", DbType.Int32, entity.WaitPayNum);
            db.AddInParameter(cmd, "@WaitSellerDeliverNum", DbType.Int32, entity.WaitSellerDeliverNum);
            db.AddInParameter(cmd, "@WaitReciveNum", DbType.Int32, entity.WaitReciveNum);
            db.AddInParameter(cmd, "@WaitCommentNum", DbType.Int32, entity.WaitCommentNum);
            db.AddInParameter(cmd, "@CancelNum", DbType.Int32, entity.CancelNum);
            object identity = db.ExecuteScalar(cmd);

            if (identity == null || identity == DBNull.Value)
            {
                return(0);
            }
            return(Convert.ToInt32(identity));
        }
示例#8
0
 /// <summary>
 /// 更新一条OrderMsgMem记录。
 /// 该方法提供给界面等UI层调用
 /// </summary>
 /// <param name="orderMsgMem">待更新的实体对象</param>
 /// <param name="columns">要更新的列名,不提供任何列名时默认将更新主键之外的所有列</param>
 public int UpdateOrderMsgMem(OrderMsgMemEntity orderMsgMem)
 {
     return(OrderMsgMemDA.Instance.UpdateOrderMsgMem(orderMsgMem));
 }
示例#9
0
 /// <summary>
 /// 判断对象是否存在
 /// </summary>
 /// <param name="dicEnum"></param>
 /// <returns></returns>
 public bool IsExist(OrderMsgMemEntity orderMsgMem)
 {
     return(OrderMsgMemDA.Instance.ExistNum(orderMsgMem) > 0);
 }