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

            sql.Append("update ec_node set ");

            sql.Append(" name = @name , ");
            sql.Append(" title = @title , ");
            sql.Append(" status = @status , ");
            sql.Append(" remark = @remark , ");
            sql.Append(" sort = @sort , ");
            sql.Append(" pid = @pid , ");
            sql.Append(" level = @level , ");

            sql.Append(" controler = @controler , ");
            sql.Append(" action = @action , ");
            sql.Append(" isallowednoneroles = @isallowednoneroles , ");
            sql.Append(" iscontroler = @iscontroler ");
            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("更新数据无效");
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Node GetNode(Wuyiju.Model.Node obj)
        {
            if (obj == null)
            {
                throw new ApplicationException("参数不能为空");
            }

            return(dao.Get(obj));
        }
Exemplo n.º 3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Add(Wuyiju.Model.Node obj)
        {
            if (obj == null)
            {
                throw new ApplicationException("参数不能为空");
            }

            dao.Insert(obj);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Wuyiju.Model.Node Get(Wuyiju.Model.Node obj)
        {
            StringBuilder sql = new StringBuilder();

            sql.Append("select id, name, title, status, remark, sort, pid, level,controler,action,isallowednoneroles,iscontroler");
            sql.Append("  from ec_node ");
            sql.Append(" where action=@action and controler=@controler ");

            DynamicParameters param = new DynamicParameters();

            param.Add("action", obj.Action);
            param.Add("controler", obj.Controler);
            return(db.Get <Wuyiju.Model.Node>(sql, param));
        }
Exemplo n.º 5
0
        /// <summary>
        /// 删除一条数据
        /// </summary>
        public void Remove(Wuyiju.Model.Node obj)
        {
            if (obj == null)
            {
                throw new ApplicationException("参数不能为空");
            }

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

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

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

            sql.Append("insert into ec_node(");
            sql.Append("name,title,status,remark,sort,pid,level,controler,action,isallowednoneroles,iscontroler");
            sql.Append(") values (");
            sql.Append("@name,@title,@status,@remark,@sort,@pid,@level,@controler,@action,@isallowednoneroles,@iscontroler");
            sql.Append(") ");

            DynamicParameters param = new DynamicParameters();

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

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

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