/// <summary> /// 添加 /// </summary> public bool Insert(Model_Resource resourceModel, CheckBoxList cbl) { bool b = false; using (TransactionScope tranScope = new TransactionScope()) { int id = dataFactory.ResourceDal.AddEntity(resourceModel).ResourceID; if (id > 0) { //添加到资源权限表Privilege foreach (ListItem li in cbl.Items) { if (li.Selected == true) { int operateId = Convert.ToInt32(li.Value); Owen.Model.Model_Privilege mPrivilege = new Model_Privilege(); mPrivilege.OperateID = operateId; mPrivilege.ResourceID = id; mPrivilege.Remark = string.Empty; new BLL_Privilege().AddEntity(mPrivilege); } } tranScope.Complete(); b = true; } } return b; }
/// <summary> /// 修改 /// </summary> public bool Update(Model_Resource resourceModel, CheckBoxList cbl) { bool b = false; using (TransactionScope tranScope = new TransactionScope()) { dataFactory.ResourceDal.UpdateEntity(resourceModel); foreach (ListItem li in cbl.Items) { int operateId = Convert.ToInt32(li.Value); if (li.Selected == true) { Owen.Model.Model_Privilege mPrivilege = new Model_Privilege(); mPrivilege.OperateID = operateId; mPrivilege.ResourceID = resourceModel.ResourceID; mPrivilege.Remark = string.Empty; new BLL_Privilege().AddEntity(mPrivilege); } else { //先删除授权表Authorize相关数据 new BLL_RolesAuthorize().DeleteEntity(resourceModel.ResourceID, operateId); //再Privilege相关数据 new BLL_Privilege().DeleteEntity(resourceModel.ResourceID, operateId); } } tranScope.Complete(); b = true; } return b; }