Beispiel #1
0
        protected void btnLeaveClub_Click(object sender, EventArgs e)
        {
            var uct = ClubLogic.GetUserClubStatus(userID, clubID);

            if (uct != UserClubStatus.Member)
            {
                return;
            }

            var script = string.Empty;

            if (UserClubLogic.UserClubAction(userID, userName, clubID, uct))
            {
                script = "window.alert('您已离开该球会!');";
            }
            else
            {
                script = "window.alert('状态异常!');";
            }

            btnJoinClub.Visible  = true;
            btnLeaveClub.Visible = false;

            Page.ClientScript.RegisterClientScriptBlock(typeof(string), "leave", script, true);
        }
Beispiel #2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                var cash = 0f;

                var user    = Users.GetUserInfo(userid);
                var maxCash = user.Extcredits2 * 0.5f;

                if (float.TryParse(tbCash.Text.Trim(), out cash) && maxCash >= 1f)
                {
                    if (cash >= 1 && cash <= maxCash)
                    {
                        UserClubLogic.TransferMemberExtcredit(ClubID, userid, ToUserID, cash, 2);
                    }
                    else
                    {
                        throw new Exception("转账金额超过上下限");
                    }
                }
                else
                {
                    throw new Exception("转账金额无效");
                }

                ClientScript.RegisterClientScriptBlock(typeof(string), "succeed",
                                                       "alert('转账成功');window.location.href = window.location.href;", true);
            }
            catch
            {
                ClientScript.RegisterClientScriptBlock(typeof(string), "failed", "alert('转账失败');", true);
            }

            LoadPageData();
        }
Beispiel #3
0
        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);
            }
        }
        public string GetCallbackResult()
        {
            if (applyHistoryID > 0)
            {
                var ah = ClubLogic.GetApplyHistory(applyHistoryID);
                if (ah != null && ah.IsAccepted == null)
                {
                    var count = ClubLogic.GetClubMemberCount(ClubID);
                    var quota = ClubLogic.GetClubMemberQuota(ClubID);

                    if (!approved)
                    {
                        UserClubLogic.ApproveJoinClub(ah.ID.Value, approved, username);
                        return("false");
                    }
                    if (approved && count >= quota)
                    {
                        return(string.Empty);
                    }

                    UserClubLogic.ApproveJoinClub(ah.ID.Value, approved, username);

                    //check if user joined clubs count has reached max count, if true, cancel all applications of this user
                    var myClubs = ClubLogic.GetActiveUserClubs(userid);
                    if (myClubs.Count >= ConfigGlobal.SingleUserMaxClubCount)
                    {
                        //cancel
                        var applications = ClubLogic.GetActiveUserApplications(ah.Userid);

                        foreach (var apply in applications)
                        {
                            UserClubLogic.ApproveJoinClub(apply.ID.Value, false, ClubSysPrivateMessage.ClubSysAdminName);
                        }
                    }

                    return("true");
                }
                return(string.Empty);
            }
            return(string.Empty);
        }
Beispiel #5
0
        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();
        }