/// <summary> /// 添加权限组 /// </summary> /// <param name="model">权限组实体</param> /// <param name="L_UM_ManagerGroupFunctions">权限组功能</param> /// <returns></returns> public bool Add(ManagementCenter.Model.UM_ManagerGroup model, List <UM_ManagerGroupFunctions> L_UM_ManagerGroupFunctions) { Database db = DatabaseFactory.CreateDatabase(); DbConnection Conn = db.CreateConnection(); if (Conn.State != ConnectionState.Open) { Conn.Open(); } DbTransaction Tran = Conn.BeginTransaction(); try { ManagementCenter.DAL.UM_ManagerGroupDAL UM_ManagerGroup = new UM_ManagerGroupDAL(); ManagementCenter.DAL.UM_ManagerGroupFunctionsDAL UM_ManagerGroupFunctions = new UM_ManagerGroupFunctionsDAL(); int ManagerGroupID = UM_ManagerGroup.Add(model, Tran, db); if (ManagerGroupID != 0) { foreach (UM_ManagerGroupFunctions ManagerGroupFunction in L_UM_ManagerGroupFunctions) { ManagerGroupFunction.ManagerGroupID = ManagerGroupID; UM_ManagerGroupFunctions.Add(ManagerGroupFunction, Tran, db); } } Tran.Commit(); } catch (Exception ex) { string errCode = "GL-1300"; string errMsg = "添加权限组失败!"; VTException vte = new VTException(errCode, errMsg, ex); LogHelper.WriteError(vte.ToString(), vte.InnerException); Tran.Rollback(); return(false); } finally { if (Conn.State == ConnectionState.Open) { Conn.Close(); } } return(true); }
/// <summary> /// 删除权限组 /// </summary> /// <param name="ManagerGroupID">权限组ID</param> /// <returns></returns> public bool Delete(int ManagerGroupID) { Database db = DatabaseFactory.CreateDatabase(); DbConnection Conn = db.CreateConnection(); if (Conn.State != ConnectionState.Open) { Conn.Open(); } DbTransaction Tran = Conn.BeginTransaction(); try { ManagementCenter.DAL.UM_ManagerGroupDAL UM_ManagerGroup = new UM_ManagerGroupDAL(); ManagementCenter.DAL.UM_ManagerGroupFunctionsDAL UM_ManagerGroupFunctions = new UM_ManagerGroupFunctionsDAL(); UM_ManagerBeloneToGroupDAL UM_ManagerBeloneToGroup = new UM_ManagerBeloneToGroupDAL(); List <UM_ManagerBeloneToGroup> l = UM_ManagerBeloneToGroup.GetListArray(string.Format("ManagerGroupID={0}", ManagerGroupID)); if (l != null && l.Count == 0) { UM_ManagerGroupFunctions.DeleteByManagerGroupID(ManagerGroupID, Tran, db); UM_ManagerGroup.Delete(ManagerGroupID, Tran, db); Tran.Commit(); return(true); } return(false); } catch (Exception ex) { string errCode = "GL-1302"; string errMsg = "删除权限组失败!"; VTException vte = new VTException(errCode, errMsg, ex); LogHelper.WriteError(vte.ToString(), vte.InnerException); Tran.Rollback(); return(false); } finally { if (Conn.State == ConnectionState.Open) { Conn.Close(); } } }