コード例 #1
0
ファイル: ManageMember.aspx.cs プロジェクト: kimch2/Arsenalcn
        protected void gvClubMemberList_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            try
            {
                if (e.CommandName == "KickUser")
                {
                    var _kickUserID = Convert.ToInt32(e.CommandArgument.ToString());

                    var club     = ClubLogic.GetClubInfo(ClubID);
                    var userClub = ClubLogic.GetActiveUserClub(userid, ClubID);

                    if (userClub != null && club != null)
                    {
                        if (userClub.Responsibility.HasValue &&
                            (userClub.Responsibility.Equals((int)Responsibility.Manager) ||
                             userClub.Responsibility.Equals((int)Responsibility.Executor)))
                        {
                            if (club.ManagerUid == _kickUserID)
                            {
                                throw new Exception("您没有权限解约此会员");
                            }

                            //kick user logic
                            UserClubLogic.LeaveClub(_kickUserID, ClubID, true, username);

                            ClientScript.RegisterClientScriptBlock(typeof(string), "success", "alert('球会已与此会员成功解约');",
                                                                   true);

                            BindData();
                        }
                        else
                        {
                            throw new Exception("您没有权限解约此会员");
                        }
                    }
                    else
                    {
                        throw new Exception("该用户已不是该球会会员");
                    }
                }
            }
            catch (Exception ex)
            {
                ClientScript.RegisterClientScriptBlock(typeof(string), "failed",
                                                       $"alert('{ex.Message}');", true);
            }
        }
コード例 #2
0
        protected void LoadPageData()
        {
            // Administrators could enter this page
            if (ConfigAdmin.IsPluginAdmin(userid))
            {
                pnlInaccessible.Visible = false;
                phContent.Visible       = true;

                //init gridview
                BindMemberList();
            }
            else
            {
                var userClub = ClubLogic.GetActiveUserClub(userid, ClubID);

                if (userClub != null && userClub.Responsibility.HasValue)
                {
                    if (userClub.Responsibility.Value.Equals((int)Responsibility.Executor) ||
                        userClub.Responsibility.Value.Equals((int)Responsibility.Manager))
                    {
                        pnlInaccessible.Visible = false;
                        phContent.Visible       = true;

                        //init gridview
                        BindMemberList();
                    }
                    else
                    {
                        pnlInaccessible.Visible = true;
                        phContent.Visible       = false;
                    }
                }
                else
                {
                    pnlInaccessible.Visible = true;
                    phContent.Visible       = false;
                }
            }
        }
コード例 #3
0
ファイル: ManageClub.aspx.cs プロジェクト: kimch2/Arsenalcn
        protected void linkButtonSave_Click(object sender, EventArgs e)
        {
            if (fuLogo.PostedFile.ContentLength != 0)
            {
                var logoName = fuLogo.FileName;

                if (logoName.ToLower().LastIndexOf(".gif") != logoName.Length - 4 &&
                    logoName.ToLower().LastIndexOf(".jpg") != logoName.Length - 4 &&
                    logoName.ToLower().LastIndexOf(".png") != logoName.Length - 4)
                {
                    //invalid logo file
                    var invalidAlert = "alert('请上传扩展名为gif,jpg或png的文件!');";
                    ClientScript.RegisterClientScriptBlock(typeof(string), "invalid_logo_file", invalidAlert, true);

                    LoadPageData();

                    return;
                }

                if (fuLogo.FileBytes.LongLength > 100 * 1024)
                {
                    var fileLengthAlert = "alert('请上传小于100K的文件!');";
                    ClientScript.RegisterClientScriptBlock(typeof(string), "file_too_large", fileLengthAlert, true);

                    LoadPageData();

                    return;
                }
            }

            //validate assignment
            var club = ClubLogic.GetClubInfo(ClubID);

            //check manager
            if (tbManager.Text != club.ManagerUserName)
            {
                //check new manager existance in discuz
                if (Users.GetUserId(tbManager.Text) <= 0)
                {
                    //alert
                    var script = "alert('会长用户在系统中不存在!');";
                    ClientScript.RegisterClientScriptBlock(typeof(string), "user_not_exist", script, true);

                    LoadPageData();

                    return;
                }

                var managerID = Users.GetUserId(tbManager.Text);
                //check if the new manager is a member of the club, if not, alert
                if (ClubLogic.GetActiveUserClub(managerID, ClubID) == null)
                {
                    var script = "alert('新会长必须为该球会成员!');";
                    ClientScript.RegisterClientScriptBlock(typeof(string), "user_not_member", script, true);

                    LoadPageData();

                    return;
                }
            }

            //check executor
            if (tbExecutor.Text == string.Empty)
            {
                //change current executor to normal member
                var users = ClubLogic.GetClubLeads(ClubID);
                foreach (var userClub in users)
                {
                    if (userClub.Responsibility == (int)Responsibility.Executor)
                    {
                        //save no executor
                        UserClubLogic.ChangeResponsibility(userClub.Userid.Value, userClub.UserName, ClubID,
                                                           Responsibility.Member, username);
                    }
                }
            }
            else
            {
                //check each executor existance
                var executors = tbExecutor.Text.Split('|');

                //check club max executor count
                if (executors.Length > ClubLogic.GetClubExecutorQuota(ClubID))
                {
                    //alert
                    var script = "alert('干事数超过限额!');";
                    ClientScript.RegisterClientScriptBlock(typeof(string), "executor_count_exceed", script, true);

                    LoadPageData();

                    return;
                }

                foreach (var executor in executors)
                {
                    var executorName = executor.Trim();

                    if (executorName == club.ManagerUserName)
                    {
                        //alert
                        var script = "alert('干事不能为该球会会长!');";
                        ClientScript.RegisterClientScriptBlock(typeof(string), "user_not_manager", script, true);

                        LoadPageData();

                        return;
                    }

                    if (Users.GetUserId(executorName) <= 0)
                    {
                        //alert
                        var script = "alert('干事用户在系统中不存在!');";
                        ClientScript.RegisterClientScriptBlock(typeof(string), "user_not_exist", script, true);

                        LoadPageData();

                        return;
                    }

                    var executorID = Users.GetUserId(executorName);

                    if (ClubLogic.GetActiveUserClub(executorID, ClubID) == null)
                    {
                        var script = "alert('干事必须为该球会成员!');";
                        ClientScript.RegisterClientScriptBlock(typeof(string), "user_not_member", script, true);

                        LoadPageData();

                        return;
                    }
                }

                var leaders = ClubLogic.GetClubLeads(ClubID);

                //save executor
                foreach (var executor in executors)
                {
                    var executorName = executor.Trim();
                    var executorID   = Users.GetUserId(executorName);

                    if (leaders.Exists(delegate(UserClub uc) { return(uc.Userid == executorID); }))
                    {
                        // current executor has been an executor already
                    }
                    else
                    {
                        UserClubLogic.ChangeResponsibility(executorID, executorName, ClubID, Responsibility.Executor,
                                                           username);
                    }
                }

                foreach (var leader in leaders)
                {
                    if (leader.Responsibility.Value != (int)Responsibility.Manager)
                    {
                        if (Array.Exists(executors, delegate(string executor) { return(executor == leader.UserName); }))
                        {
                            //current leader is in the new leader list
                        }
                        else
                        {
                            UserClubLogic.ChangeResponsibility(leader.Userid.Value, leader.UserName, ClubID,
                                                               Responsibility.Member, username);
                        }
                    }
                }
            }

            //update info
            ClubLogic.UpdateClubInfo(ClubID, fuLogo.PostedFile, tbSlogan.Text, tbDesc.Text,
                                     bool.Parse(rblAppliable.SelectedValue), null);

            var scriptSaved = "alert('信息已保存');";

            ClientScript.RegisterClientScriptBlock(typeof(string), "saved", scriptSaved, true);

            LoadPageData();
        }
コード例 #4
0
ファイル: ManageMember.aspx.cs プロジェクト: kimch2/Arsenalcn
        protected void Page_Load(object sender, EventArgs e)
        {
            var club = ClubLogic.GetClubInfo(ClubID);

            if (club != null && Title.IndexOf("{0}") >= 0)
            {
                Title = string.Format(Title, club.FullName);
            }

            #region SetControlProperty

            ctrlLeftPanel.UserID   = userid;
            ctrlLeftPanel.UserName = username;
            ctrlLeftPanel.UserKey  = userkey;

            ctrlFieldToolBar.UserID   = userid;
            ctrlFieldToolBar.UserName = username;

            ctrlManageMenuTabBar.CurrentMenu = ManageClubMenuItem.ManageMember;
            ctrlManageMenuTabBar.UserID      = userid;

            #endregion

            if (!IsPostBack)
            {
                #region Bind ddlGroup

                var list = ClubLogic.GetActiveClubs();
                if (list != null && list.Count > 0)
                {
                    ddlClub.DataSource     = list;
                    ddlClub.DataTextField  = "FullName";
                    ddlClub.DataValueField = "ID";
                    ddlClub.DataBind();

                    var item = new ListItem("--请选择球会--", string.Empty);
                    ddlClub.Items.Insert(0, item);
                }
                else
                {
                    ddlClub.Visible = false;
                }

                #endregion

                // Administrators could enter this page
                if (ConfigAdmin.IsPluginAdmin(userid))
                {
                    pnlInaccessible.Visible = false;
                    phContent.Visible       = true;

                    //init gridview
                    BindData();
                }
                else
                {
                    var userClub = ClubLogic.GetActiveUserClub(userid, ClubID);

                    if (userClub != null && userClub.Responsibility.HasValue)
                    {
                        if (userClub.Responsibility.Value.Equals((int)Responsibility.Executor) ||
                            userClub.Responsibility.Value.Equals((int)Responsibility.Manager))
                        {
                            pnlInaccessible.Visible = false;
                            phContent.Visible       = true;

                            //init gridview
                            BindData();
                        }
                        else
                        {
                            pnlInaccessible.Visible = true;
                            phContent.Visible       = false;
                        }
                    }
                    else
                    {
                        pnlInaccessible.Visible = true;
                        phContent.Visible       = false;
                    }
                }
            }
        }
コード例 #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (clubID > 0)
            {
                if (aManageClub.HRef.IndexOf("{0}") >= 0)
                {
                    aManageClub.HRef = string.Format(aManageClub.HRef, clubID);
                }

                var currentClub = ClubLogic.GetClubInfo(clubID);

                if (currentClub != null)
                {
                    imgClubLogo.ImageUrl = $"../UploadFiles/{currentClub.LogoName}";
                    imgClubLogo.ToolTip  = currentClub.FullName;

                    ltrlClubFullName.Text = currentClub.FullName;

                    var clubDesc = HttpUtility.HtmlEncode(currentClub.Description);
                    if (clubDesc.Length > 80)
                    {
                        ltrlClubDesc.Text = $"<span title=\"{clubDesc}\">{clubDesc.Substring(0, 80)}...</span>";
                    }
                    else
                    {
                        ltrlClubDesc.Text = clubDesc;
                    }

                    divClubRank.Style.Add("Width", $"{currentClub.RankLevel*20}px");
                    divClubRank.Attributes.Add("Title", currentClub.RankScore.ToString());

                    if (userID == -1)
                    {
                        //anonymous user

                        aManageClub.Visible = false;

                        btnCancelApply.Visible = false;
                        btnJoinClub.Visible    = false;
                        btnLeaveClub.Visible   = false;

                        btnGetStrip.Visible = false;
                    }
                    else
                    {
                        var ucs = ClubLogic.GetUserClubStatus(userID, clubID);
                        switch (ucs)
                        {
                        case UserClubStatus.Applied:
                            btnCancelApply.Visible = true;
                            btnJoinClub.Visible    = false;
                            btnLeaveClub.Visible   = false;
                            break;

                        case UserClubStatus.Member:
                            btnCancelApply.Visible = false;
                            btnJoinClub.Visible    = false;
                            btnLeaveClub.Visible   = true;
                            break;

                        case UserClubStatus.No:
                            btnCancelApply.Visible = false;
                            btnJoinClub.Visible    = true;
                            btnLeaveClub.Visible   = false;
                            break;

                        default:
                            btnCancelApply.Visible = false;
                            btnJoinClub.Visible    = false;
                            btnLeaveClub.Visible   = false;
                            break;
                        }

                        //manager can not leave a club
                        if (currentClub.ManagerUid.Value == userID)
                        {
                            btnLeaveClub.Visible = false;
                        }

                        // the count of clubs which current user has joined exceed max quota, hide join action
                        if (ClubLogic.GetActiveUserClubs(userID).Count >= ConfigGlobal.SingleUserMaxClubCount &&
                            ucs != UserClubStatus.Member)
                        {
                            btnJoinClub.Visible    = false;
                            btnCancelApply.Visible = false;
                        }

                        if (!currentClub.IsAppliable.Value ||
                            ClubLogic.GetClubMemberCount(clubID) >= ClubLogic.GetClubMemberQuota(clubID))
                        {
                            btnJoinClub.Visible = false;
                        }

                        var userClub = ClubLogic.GetActiveUserClub(userID, clubID);

                        if (userClub != null)
                        {
                            //current user is a member of the club

                            if (userClub.Responsibility == (int)Responsibility.Manager ||
                                userClub.Responsibility == (int)Responsibility.Executor)
                            {
                                aManageClub.Visible = true;
                            }
                            else
                            {
                                aManageClub.Visible = false;
                            }
                        }
                        else
                        {
                            //user is not a member of the club
                            aManageClub.Visible = false;

                            btnGetStrip.Visible = false;
                        }
                    }
                }
                else
                {
                    Response.Redirect("ClubPortal.aspx");
                }
            }
            else
            {
                Response.Redirect("ClubPortal.aspx");
            }
        }