Ejemplo n.º 1
0
        /// <summary>
        /// 判断当前节点是否已存在相同的
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public int  ExistNum(CGOrderSendEntity entity)
        {
            ///id=0,判断总数,ID>0判断除自己之外的总数
            string sql = @"Select count(1) from dbo.[CGOrderSend] 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));
        }
Ejemplo n.º 2
0
        public CGOrderSendEntity GetCGOrderSendByCode(long code, int memid)
        {
            string    sql = @"SELECT  [Id],[CGOrderCode],[CGMemId],[CreateTime],[HasRead],[ReadTime]
							FROM
							dbo.[CGOrderSend] WITH(NOLOCK)	
							WHERE [CGOrderCode]=@CGOrderCode and CGMemId=@CGMemId"                            ;
            DbCommand cmd = db.GetSqlStringCommand(sql);

            db.AddInParameter(cmd, "@CGOrderCode", DbType.Int64, code);
            db.AddInParameter(cmd, "@CGMemId", DbType.Int32, memid);
            CGOrderSendEntity entity = new CGOrderSendEntity();

            using (IDataReader reader = db.ExecuteReader(cmd))
            {
                if (reader.Read())
                {
                    entity.Id          = StringUtils.GetDbInt(reader["Id"]);
                    entity.CGOrderCode = StringUtils.GetDbLong(reader["CGOrderCode"]);
                    entity.CGMemId     = StringUtils.GetDbInt(reader["CGMemId"]);
                    entity.CreateTime  = StringUtils.GetDbDateTime(reader["CreateTime"]);
                    entity.HasRead     = StringUtils.GetDbInt(reader["HasRead"]);
                    entity.ReadTime    = StringUtils.GetDbDateTime(reader["ReadTime"]);
                }
            }
            return(entity);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 根据主键值更新记录的全部字段(注意:该方法不会对自增字段、timestamp类型字段以及主键字段更新!如果要更新主键字段,请使用Update方法)。
        /// 如果数据库有数据被更新了则返回True,否则返回False
        /// </summary>
        /// <param name="db">数据库操作对象</param>
        /// <param name="cGOrderSend">待更新的实体对象</param>
        public int UpdateCGOrderSend(CGOrderSendEntity entity)
        {
            string    sql = @" UPDATE dbo.[CGOrderSend] SET
                       [CGOrderCode]=@CGOrderCode,[CGMemId]=@CGMemId,[CreateTime]=@CreateTime,[HasRead]=@HasRead,[ReadTime]=@ReadTime
                       WHERE [Id]=@id";
            DbCommand cmd = db.GetSqlStringCommand(sql);

            db.AddInParameter(cmd, "@Id", DbType.Int32, entity.Id);
            db.AddInParameter(cmd, "@CGOrderCode", DbType.Int64, entity.CGOrderCode);
            db.AddInParameter(cmd, "@CGMemId", DbType.Int32, entity.CGMemId);
            db.AddInParameter(cmd, "@CreateTime", DbType.DateTime, entity.CreateTime);
            db.AddInParameter(cmd, "@HasRead", DbType.Int32, entity.HasRead);
            db.AddInParameter(cmd, "@ReadTime", DbType.DateTime, entity.ReadTime);
            return(db.ExecuteNonQuery(cmd));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 插入一条记录到表CGOrderSend,如果表中存在自增字段,则返回值为新记录的自增字段值,否则返回0。
        /// 该方法提供给界面等UI层调用
        /// </summary>
        /// <param name="cGOrderSend">要添加的CGOrderSend数据实体对象</param>
        public int AddCGOrderSend(CGOrderSendEntity cGOrderSend)
        {
            if (cGOrderSend.Id > 0)
            {
                return(UpdateCGOrderSend(cGOrderSend));
            }

            //else if (CGOrderSendBLL.Instance.IsExist(cGOrderSend))
            //{
            //    return (int)CommonStatus.ADD_Fail_Exist;
            //}
            else
            {
                return(CGOrderSendDA.Instance.AddCGOrderSend(cGOrderSend));
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 插入一条记录到表CGOrderSend,如果表中存在自增字段,则返回值为新记录的自增字段值,否则返回0
        /// </summary>
        /// <param name="db">数据库操作对象</param>
        /// <param name="cGOrderSend">待插入的实体对象</param>
        public int AddCGOrderSend(CGOrderSendEntity entity)
        {
            string    sql = @"insert into CGOrderSend( [CGOrderCode],[CGMemId],[CreateTime],[HasRead],[ReadTime],[IsClose],[HasSendSMS])VALUES
			            ( @CGOrderCode,@CGMemId,@CreateTime,@HasRead,@ReadTime,0,0);
			SELECT SCOPE_IDENTITY();"            ;
            DbCommand cmd = db.GetSqlStringCommand(sql);

            db.AddInParameter(cmd, "@CGOrderCode", DbType.Int64, entity.CGOrderCode);
            db.AddInParameter(cmd, "@CGMemId", DbType.Int32, entity.CGMemId);
            db.AddInParameter(cmd, "@CreateTime", DbType.DateTime, entity.CreateTime);
            db.AddInParameter(cmd, "@HasRead", DbType.Int32, entity.HasRead);
            db.AddInParameter(cmd, "@ReadTime", DbType.DateTime, entity.ReadTime);
            object identity = db.ExecuteScalar(cmd);

            if (identity == null || identity == DBNull.Value)
            {
                return(0);
            }
            return(Convert.ToInt32(identity));
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 读取记录列表。
        /// </summary>
        /// <param name="db">数据库操作对象</param>
        /// <param name="columns">需要返回的列,不提供任何列名时默认将返回所有列</param>
        public IList <CGOrderSendEntity> GetCGOrderSendAll()
        {
            string sql = @"SELECT    [Id],[CGOrderCode],[CGMemId],[CreateTime],[HasRead],[ReadTime] from dbo.[CGOrderSend] WITH(NOLOCK)	";
            IList <CGOrderSendEntity> entityList = new List <CGOrderSendEntity>();
            DbCommand cmd = db.GetSqlStringCommand(sql);

            using (IDataReader reader = db.ExecuteReader(cmd))
            {
                while (reader.Read())
                {
                    CGOrderSendEntity entity = new CGOrderSendEntity();
                    entity.Id          = StringUtils.GetDbInt(reader["Id"]);
                    entity.CGOrderCode = StringUtils.GetDbLong(reader["CGOrderCode"]);
                    entity.CGMemId     = StringUtils.GetDbInt(reader["CGMemId"]);
                    entity.CreateTime  = StringUtils.GetDbDateTime(reader["CreateTime"]);
                    entity.HasRead     = StringUtils.GetDbInt(reader["HasRead"]);
                    entity.ReadTime    = StringUtils.GetDbDateTime(reader["ReadTime"]);
                    entityList.Add(entity);
                }
            }
            return(entityList);
        }
Ejemplo n.º 7
0
 /// <summary>
 /// 更新一条CGOrderSend记录。
 /// 该方法提供给界面等UI层调用
 /// </summary>
 /// <param name="cGOrderSend">待更新的实体对象</param>
 /// <param name="columns">要更新的列名,不提供任何列名时默认将更新主键之外的所有列</param>
 public int UpdateCGOrderSend(CGOrderSendEntity cGOrderSend)
 {
     return(CGOrderSendDA.Instance.UpdateCGOrderSend(cGOrderSend));
 }
Ejemplo n.º 8
0
 /// <summary>
 /// 判断对象是否存在
 /// </summary>
 /// <param name="dicEnum"></param>
 /// <returns></returns>
 public bool IsExist(CGOrderSendEntity cGOrderSend)
 {
     return(CGOrderSendDA.Instance.ExistNum(cGOrderSend) > 0);
 }