Example #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Insert(Wuyiju.Model.Product model)
        {
            StringBuilder sql = new StringBuilder();

            sql.Append("insert into ec_product(");
            sql.Append("admin_id,name,subname,sn,category_id,market_price,price,member_price,promote_price,intro,integration,integration_buy,promote,promote_start,promote_end,recommend,click,stock,pay_status,warn_nums,sales,status,hot,new,best,sort,keywords,seo_title,seo_keys,seo_desc,brief,content,url,address_id,buyer_id,add_time,start_time,picture,log,del_time,filename,seller_id,user_return,type,video,praise_rate,collection_popularity,seller_credit,annual_turnover,protection_deposit,tech_fee,whether_goods,buyer_protection,virtual_proportion,old_customer_number,area,mall_type,trademark_type,trademark_no,tax_qualification,score,smallarea,company_level,guanlian_id,reason,weiscore");
            sql.Append(") values (");
            sql.Append("@admin_id,@name,@subname,@sn,@category_id,@market_price,@price,@member_price,@promote_price,@intro,@integration,@integration_buy,@promote,@promote_start,@promote_end,@recommend,@click,@stock,@pay_status,@warn_nums,@sales,@status,@hot,@new,@best,@sort,@keywords,@seo_title,@seo_keys,@seo_desc,@brief,@content,@url,@address_id,@buyer_id,@add_time,@start_time,@picture,@log,@del_time,@filename,@seller_id,@user_return,@type,@video,@praise_rate,@collection_popularity,@seller_credit,@annual_turnover,@protection_deposit,@tech_fee,@whether_goods,@buyer_protection,@virtual_proportion,@old_customer_number,@area,@mall_type,@trademark_type,@trademark_no,@tax_qualification,@score,@smallarea,@company_level,@guanlian_id,@reason,@weiscore");
            sql.Append(") ");

            DynamicParameters param = new DynamicParameters();

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

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


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

            return(db.ExecuteScalar <int>("SELECT LAST_INSERT_ID() from ec_product"));
        }
Example #2
0
        /// <summary>
        /// 删除根据产品Id
        /// </summary>
        public void DeletebyP(Wuyiju.Model.Product obj)
        {
            if (obj == null)
            {
                throw new ApplicationException("参数不能为空");
            }

            dao.DeletebyP(obj.Id);
        }
Example #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Wuyiju.Model.Product obj)
        {
            if (obj == null)
            {
                throw new ApplicationException("参数不能为空");
            }

            using (var db = new DataContext())
            {
                return(this.GetDao(db).Insert(obj));
            }
        }
Example #4
0
        /// <summary>
        /// 删除一条数据
        /// </summary>
        public void Remove(Wuyiju.Model.Product obj)
        {
            if (obj == null)
            {
                throw new ApplicationException("参数不能为空");
            }

            using (var db = new DataContext())
            {
                var _dao = this.GetDao(db);
                var old  = _dao.Get(obj.Id);

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

                _dao.Delete(obj.Id);
            }
        }
Example #5
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Modify(Wuyiju.Model.Product obj)
        {
            if (obj == null)
            {
                throw new ApplicationException("参数不能为空");
            }

            using (var db = new DataContext())
            {
                var productDao = this.GetDao(db);
                var old        = productDao.Get(obj.Id);

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

                productDao.Update(obj);
            }
        }
Example #6
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(Wuyiju.Model.Product model)
        {
            StringBuilder sql = new StringBuilder();

            sql.Append("update ec_product set ");

            sql.Append(" admin_id = @admin_id , ");
            sql.Append(" name = @name , ");
            sql.Append(" subname = @subname , ");
            sql.Append(" sn = @sn , ");
            sql.Append(" category_id = @category_id , ");
            sql.Append(" market_price = @market_price , ");
            sql.Append(" price = @price , ");
            sql.Append(" member_price = @member_price , ");
            sql.Append(" promote_price = @promote_price , ");
            sql.Append(" intro = @intro , ");
            sql.Append(" integration = @integration , ");
            sql.Append(" integration_buy = @integration_buy , ");
            sql.Append(" promote = @promote , ");
            sql.Append(" promote_start = @promote_start , ");
            sql.Append(" promote_end = @promote_end , ");
            sql.Append(" recommend = @recommend , ");
            sql.Append(" click = @click , ");
            sql.Append(" stock = @stock , ");
            sql.Append(" pay_status = @pay_status , ");
            sql.Append(" warn_nums = @warn_nums , ");
            sql.Append(" sales = @sales , ");
            sql.Append(" status = @status , ");
            sql.Append(" hot = @hot , ");
            sql.Append(" new = @new , ");
            sql.Append(" best = @best , ");
            sql.Append(" sort = @sort , ");
            sql.Append(" keywords = @keywords , ");
            sql.Append(" seo_title = @seo_title , ");
            sql.Append(" seo_keys = @seo_keys , ");
            sql.Append(" seo_desc = @seo_desc , ");
            sql.Append(" brief = @brief , ");
            sql.Append(" content = @content , ");
            sql.Append(" url = @url , ");
            sql.Append(" address_id = @address_id , ");
            sql.Append(" buyer_id = @buyer_id , ");
            sql.Append(" add_time = @add_time , ");
            sql.Append(" start_time = @start_time , ");
            sql.Append(" picture = @picture , ");
            sql.Append(" log = @log , ");
            sql.Append(" del_time = @del_time , ");
            sql.Append(" filename = @filename , ");
            sql.Append(" seller_id = @seller_id , ");
            sql.Append(" user_return = @user_return , ");
            sql.Append(" type = @type , ");
            sql.Append(" video = @video , ");
            sql.Append(" praise_rate = @praise_rate , ");
            sql.Append(" collection_popularity = @collection_popularity , ");
            sql.Append(" seller_credit = @seller_credit , ");
            sql.Append(" annual_turnover = @annual_turnover , ");
            sql.Append(" protection_deposit = @protection_deposit , ");
            sql.Append(" tech_fee = @tech_fee , ");
            sql.Append(" whether_goods = @whether_goods , ");
            sql.Append(" buyer_protection = @buyer_protection , ");
            sql.Append(" virtual_proportion = @virtual_proportion , ");
            sql.Append(" old_customer_number = @old_customer_number , ");
            sql.Append(" area = @area , ");
            sql.Append(" mall_type = @mall_type , ");
            sql.Append(" trademark_type = @trademark_type , ");
            sql.Append(" trademark_no = @trademark_no , ");
            sql.Append(" tax_qualification = @tax_qualification , ");
            sql.Append(" score = @score , ");
            sql.Append(" smallarea = @smallarea , ");
            sql.Append(" company_level = @company_level , ");
            sql.Append(" guanlian_id = @guanlian_id,  ");
            sql.Append(" reason = @reason,  ");
            sql.Append(" weiscore = @weiscore  ");
            sql.Append(" where id=@id ");

            DynamicParameters param = new DynamicParameters();

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

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

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