/// <summary> /// 更新一条数据 /// </summary> public void Update(Wuyiju.Model.Access model) { StringBuilder sql = new StringBuilder(); sql.Append("update Access set "); sql.Append(" role_id = @role_id , "); sql.Append(" node_id = @node_id , "); sql.Append(" level = @level , "); sql.Append(" module = @module "); sql.Append(" where role_id = @role_id and node_id = @node_id "); DynamicParameters param = new DynamicParameters(); if (model != null) { param.AddDynamicParams(model); } var rows = db.Execute(sql, param); if (rows < 1) { throw new ApplicationException("更新数据无效"); } }
/// <summary> /// 删除一条数据 /// </summary> public void Remove(Wuyiju.Model.Access obj) { if (obj == null) { throw new ApplicationException("非法操作记录不存在"); } dao.Delete(obj); }
/// <summary> /// 增加一条数据 /// </summary> public void Add(Wuyiju.Model.Access obj) { if (obj == null) { throw new ApplicationException("参数不能为空"); } dao.Insert(obj); }
/// <summary> /// 更新一条数据 /// </summary> public void Modify(Wuyiju.Model.Access obj) { if (obj == null) { throw new ApplicationException("参数不能为空"); } var old = dao.Get(obj.Role_Id, 0); if (old == null) { throw new ApplicationException("非法操作记录不存在"); } dao.Update(obj); }
/// <summary> /// 删除一条数据 /// </summary> public void Delete(Wuyiju.Model.Access model) { StringBuilder sql = new StringBuilder(); sql.Append("delete from ec_access "); sql.Append(" where role_id = @role_id"); DynamicParameters param = new DynamicParameters(); //param.Add("id", id); if (model != null) { param.AddDynamicParams(model); } var rows = db.Execute(sql, param); if (rows < 1) { throw new ApplicationException("删除数据无效"); } }
/// <summary> /// 增加一条数据 /// </summary> public void Insert(Wuyiju.Model.Access model) { StringBuilder sql = new StringBuilder(); sql.Append("insert into ec_access("); sql.Append("role_id,node_id,level,module"); sql.Append(") values ("); sql.Append("@role_id,@node_id,@level,@module"); sql.Append(") "); DynamicParameters param = new DynamicParameters(); if (model != null) { param.AddDynamicParams(model); } var rows = db.Execute(sql, param); if (rows < 1) { throw new ApplicationException("插入数据无效"); } }