Пример #1
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public void Add(Wuyiju.Model.Category obj)
 {
     if (obj == null)
     {
         throw new ApplicationException("参数不能为空");
     }
     using (var db = new DataContext())
     {
         var _dao = this.GetDao(db);
         _dao.Insert(obj);
     }
 }
Пример #2
0
        /// <summary>
        /// 删除一条数据
        /// </summary>
        public void Remove(Wuyiju.Model.Category 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);
            }
        }
Пример #3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(Wuyiju.Model.Category model)
        {
            StringBuilder sql = new StringBuilder();

            sql.Append("update ec_category set ");

            sql.Append(" type = @type , ");
            sql.Append(" parent_id = @parent_id , ");
            sql.Append(" name = @name , ");
            sql.Append(" brief = @brief , ");
            sql.Append(" seo_title = @seo_title , ");
            sql.Append(" seo_keys = @seo_keys , ");
            sql.Append(" seo_desc = @seo_desc , ");
            sql.Append(" img = @img , ");
            sql.Append(" sort = @sort , ");
            sql.Append(" status = @status , ");
            sql.Append(" is_hot = @is_hot , ");
            sql.Append(" is_recommend = @is_recommend , ");
            sql.Append(" show_in_nav = @show_in_nav , ");
            sql.Append(" bank_id = @bank_id , ");
            sql.Append(" is_extend = @is_extend , ");
            sql.Append(" filter_attr = @filter_attr , ");
            sql.Append(" add_time = @add_time , ");
            sql.Append(" admin_id = @admin_id , ");
            sql.Append(" is_del = @is_del , ");
            sql.Append(" css_cla = @css_cla  ");
            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("更新数据无效");
            }
        }
Пример #4
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Insert(Wuyiju.Model.Category model)
        {
            StringBuilder sql = new StringBuilder();

            sql.Append("insert into ec_category(");
            sql.Append("type,parent_id,name,brief,seo_title,seo_keys,seo_desc,img,sort,status,is_hot,is_recommend,show_in_nav,bank_id,is_extend,filter_attr,add_time,admin_id,is_del,css_cla");
            sql.Append(") values (");
            sql.Append("@type,@parent_id,@name,@brief,@seo_title,@seo_keys,@seo_desc,@img,@sort,@status,@is_hot,@is_recommend,@show_in_nav,@bank_id,@is_extend,@filter_attr,@add_time,@admin_id,@is_del,@css_cla");
            sql.Append(") ");

            DynamicParameters param = new DynamicParameters();

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

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

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