コード例 #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Add(Wuyiju.Model.Title obj)
        {
            if (obj == null)
            {
                throw new ApplicationException("参数不能为空");
            }

            dao.Insert(obj);
        }
コード例 #2
0
        /// <summary>
        /// 删除一条数据
        /// </summary>
        public void Remove(Wuyiju.Model.Title obj)
        {
            if (obj == null)
            {
                throw new ApplicationException("参数不能为空");
            }

            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.Title model)
        {
            StringBuilder sql = new StringBuilder();

            sql.Append("update ec_title set ");

            sql.Append(" name = @name , ");
            sql.Append(" scname = @scname , ");
            sql.Append(" img = @img , ");
            sql.Append(" parent_id = @parent_id , ");
            sql.Append(" sort = @sort , ");
            sql.Append(" status = @status , ");
            sql.Append(" recommend = @recommend , ");
            sql.Append(" color = @color , ");
            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(" style_file = @style_file , ");
            sql.Append(" show_in_nav = @show_in_nav , ");
            sql.Append(" filter_attr = @filter_attr , ");
            sql.Append(" folder = @folder , ");
            sql.Append(" filename = @filename , ");
            sql.Append(" type = @type , ");
            sql.Append(" is_hots = @is_hots , ");
            sql.Append(" url_type = @url_type  ");
            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.Title model)
        {
            StringBuilder sql = new StringBuilder();

            sql.Append("insert into ec_title(");
            sql.Append("name,scname,img,parent_id,sort,status,recommend,color,seo_title,seo_keys,seo_desc,brief,content,style_file,show_in_nav,filter_attr,folder,filename,type,is_hots,url_type");
            sql.Append(") values (");
            sql.Append("@name,@scname,@img,@parent_id,@sort,@status,@recommend,@color,@seo_title,@seo_keys,@seo_desc,@brief,@content,@style_file,@show_in_nav,@filter_attr,@folder,@filename,@type,@is_hots,@url_type");
            sql.Append(") ");

            DynamicParameters param = new DynamicParameters();

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

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

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