예제 #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(Wuyiju.Model.Coupons model)
        {
            StringBuilder sql = new StringBuilder();

            sql.Append("update Coupons set ");

            sql.Append(" coupon_type_id = @coupon_type_id , ");
            sql.Append(" coupon_sn = @coupon_sn , ");
            sql.Append(" user_id = @user_id , ");
            sql.Append(" used_time = @used_time , ");
            sql.Append(" order_id = @order_id , ");
            sql.Append(" emailed = @emailed  ");
            sql.Append(" where coupon_id=@coupon_id ");

            DynamicParameters param = new DynamicParameters();

            if (model != null)
            {
                param.AddDynamicParams(model);
            }

            var rows = db.Execute(sql, param);

            if (rows < 1)
            {
                throw new ApplicationException("更新数据无效");
            }
        }
예제 #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Add(Wuyiju.Model.Coupons obj)
        {
            if (obj == null)
            {
                throw new ApplicationException("参数不能为空");
            }

            dao.Insert(obj);
        }
예제 #3
0
        /// <summary>
        /// 删除一条数据
        /// </summary>
        public void Remove(Wuyiju.Model.Coupons obj)
        {
            if (obj == null)
            {
                throw new ApplicationException("参数不能为空");
            }

            var old = dao.Get(obj.Coupon_Id);

            if (old == null)
            {
                throw new ApplicationException("非法操作记录不存在");
            }

            dao.Delete(obj.Coupon_Id);
        }
예제 #4
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Insert(Wuyiju.Model.Coupons model)
        {
            StringBuilder sql = new StringBuilder();

            sql.Append("insert into ec_coupons(");
            sql.Append("coupon_type_id,coupon_sn,user_id,used_time,order_id,emailed");
            sql.Append(") values (");
            sql.Append("@coupon_type_id,@coupon_sn,@user_id,@used_time,@order_id,@emailed");
            sql.Append(") ");

            DynamicParameters param = new DynamicParameters();

            if (model != null)
            {
                param.AddDynamicParams(model);
            }

            var rows = db.Execute(sql, param);

            if (rows < 1)
            {
                throw new ApplicationException("插入数据无效");
            }
        }