Esempio n. 1
0
        /// <summary>
        /// 更新用户组信息
        /// </summary>
        /// <param name="__usergroupinfo"></param>
        /// <returns></returns>
        public static bool UpdateUserGroupInfo(UserGroupInfo __usergroupinfo)
        {
            int Creditshigher = __usergroupinfo.Creditshigher;
            int Creditslower  = __usergroupinfo.Creditslower;

            if ((__usergroupinfo.Groupid >= 9) && (__usergroupinfo.Radminid == 0))
            {
                //当已存在的用户组积分上下限不是当前组的时候,则不允许编辑
                DataTable dt = DatabaseProvider.GetInstance().GetUserGroupByCreditsHigherAndLower(Creditshigher, Creditslower);
                if (dt.Rows.Count > 0)
                {
                    if (__usergroupinfo.Groupid.ToString() != dt.Rows[0][0].ToString())
                    {
                        return(false);
                    }
                }

                if (!SystemCheckCredits("update", ref Creditshigher, ref Creditslower, __usergroupinfo.Groupid))
                {
                    return(false);
                }
            }

            DatabaseProvider.GetInstance().UpdateUserGroup(__usergroupinfo, Creditshigher, Creditslower);

            DatabaseProvider.GetInstance().UpdateOnlineList(__usergroupinfo);

            AdminCaches.ReSetAdminGroupList();

            AdminCaches.ReSetUserGroupList();

            return(true);
        }
Esempio n. 2
0
        /// <summary>
        /// 添加用户组信息
        /// </summary>
        /// <param name="__usergroupinfo"></param>
        /// <returns></returns>
        public static bool AddUserGroupInfo(UserGroupInfo __usergroupinfo)
        {
            try
            {
                int       Creditshigher = __usergroupinfo.Creditshigher;
                int       Creditslower  = __usergroupinfo.Creditslower;
                DataTable dt            = DatabaseProvider.GetInstance().GetUserGroupByCreditsHigherAndLower(Creditshigher, Creditslower);
                if (dt.Rows.Count > 0)
                {
                    return(false);
                }

                if (__usergroupinfo.Radminid == 0)
                {
                    if (!SystemCheckCredits("add", ref Creditshigher, ref Creditslower, 0))
                    {
                        return(false);
                    }
                }

                DatabaseProvider.GetInstance().AddUserGroup(__usergroupinfo, Creditshigher, Creditslower);

                DatabaseProvider.GetInstance().AddOnlineList(__usergroupinfo.Grouptitle);

                AdminCaches.ReSetAdminGroupList();

                AdminCaches.ReSetUserGroupList();

                return(true);
            }
            catch
            {
                return(false);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 删除指定用户组
        /// </summary>
        /// <param name="groupid"></param>
        /// <returns></returns>
        public static bool DeleteUserGroupInfo(int groupid)
        {
            try
            {
                if (DatabaseProvider.GetInstance().IsSystemOrTemplateUserGroup(groupid))
                {
                    //当为系统初始组或模板组时,则不允许删除
                    return(false);
                }

                //当为用户组时
                if (groupid >= 9)
                {
                    DataTable dt = DatabaseProvider.GetInstance().GetOthersCommonUserGroup(groupid);
                    if (dt.Rows.Count > 1)
                    {
                        if (DatabaseProvider.GetInstance().GetUserGroupRAdminId(groupid) == "0")
                        {
                            dt = DatabaseProvider.GetInstance().GetUserGroupCreditsLowerAndHigher(groupid);
                            int creditshigher = Convert.ToInt32(dt.Rows[0]["creditshigher"].ToString());
                            int creditslower  = Convert.ToInt32(dt.Rows[0]["creditslower"].ToString());
                            SystemCheckCredits("delete", ref creditshigher, ref creditslower, groupid);
                        }
                    }
                    else
                    {
                        if (dt.Rows.Count == 1)
                        {
                            //当系统删除当前组后只有一个组存在时则直接设置唯一组下限,但不修改唯一组上限的值
                            DatabaseProvider.GetInstance().UpdateUserGroupLowerAndHigherToLimit(Utils.StrToInt(dt.Rows[0][0], 0));
                        }
                        else
                        {                         //系统中用户组只有一个时
                            opresult = "当前用户组为系统中唯一的用户组,因此系统无法删除";
                            return(false);
                        }
                    }
                }
                DatabaseProvider.GetInstance().DeleteUserGroup(groupid);

                DatabaseProvider.GetInstance().DeleteAdminGroup(groupid);

                DatabaseProvider.GetInstance().DeleteOnlineList(groupid);

                AdminCaches.ReSetAdminGroupList();

                AdminCaches.ReSetUserGroupList();

                return(true);
            }
            catch
            {
                return(false);
            }
        }