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

            dao.Insert(obj);
        }
示例#2
0
        /// <summary>
        /// 删除一条数据
        /// </summary>
        public void Remove(Wuyiju.Model.Links 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.Links model)
        {
            StringBuilder sql = new StringBuilder();

            sql.Append("update ec_links set ");

            sql.Append(" company = @company , ");
            sql.Append(" name = @name , ");
            sql.Append(" url = @url , ");
            sql.Append(" sort = @sort , ");
            sql.Append(" status = @status , ");
            sql.Append(" start_time = @start_time , ");
            sql.Append(" end_time = @end_time , ");
            sql.Append(" keyword = @keyword , ");
            sql.Append(" brief = @brief , ");
            sql.Append(" contact = @contact , ");
            sql.Append(" phone = @phone , ");
            sql.Append(" qq = @qq , ");
            sql.Append(" add_time = @add_time , ");
            sql.Append(" category = @category , ");
            sql.Append(" img = @img , ");
            sql.Append(" recommend = @recommend  ");
            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.Links model)
        {
            StringBuilder sql = new StringBuilder();

            sql.Append("insert into ec_links(");
            sql.Append("company,name,url,sort,status,start_time,end_time,keyword,brief,contact,phone,qq,add_time,category,img,recommend");
            sql.Append(") values (");
            sql.Append("@company,@name,@url,@sort,@status,@start_time,@end_time,@keyword,@brief,@contact,@phone,@qq,@add_time,@category,@img,@recommend");
            sql.Append(") ");

            DynamicParameters param = new DynamicParameters();

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

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

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