Ejemplo n.º 1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(Wuyiju.Model.Course model)
        {
            StringBuilder sql = new StringBuilder();

            sql.Append("update Course set ");

            sql.Append(" c_name = @c_name , ");
            sql.Append(" t_name = @t_name , ");
            sql.Append(" t_content = @t_content , ");
            sql.Append(" c_time = @c_time , ");
            sql.Append(" add_time = @add_time , ");
            sql.Append(" status = @status , ");
            sql.Append(" jz_time = @jz_time , ");
            sql.Append(" url = @url , ");
            sql.Append(" t_process = @t_process , ");
            sql.Append(" seo_title = @seo_title , ");
            sql.Append(" seo_keys = @seo_keys , ");
            sql.Append(" seo_desc = @seo_desc  ");
            sql.Append(" where cid=@cid ");

            DynamicParameters param = new DynamicParameters();

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

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

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

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

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

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

            dao.Delete(obj.Cid);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Insert(Wuyiju.Model.Course model)
        {
            StringBuilder sql = new StringBuilder();

            sql.Append("insert into ec_course(");
            sql.Append("c_name,t_name,t_content,c_time,add_time,status,jz_time,url,t_process,seo_title,seo_keys,seo_desc");
            sql.Append(") values (");
            sql.Append("@c_name,@t_name,@t_content,@c_time,@add_time,@status,@jz_time,@url,@t_process,@seo_title,@seo_keys,@seo_desc");
            sql.Append(") ");

            DynamicParameters param = new DynamicParameters();

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

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

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