Пример #1
0
        public CreateMatch(string matchId)
        {
            InitializeComponent();
            var originMatchInfo = MatchDAL.GetMatchInfoById(matchId);

            thisProject = originMatchInfo;
            SetValueForPage(originMatchInfo);
            this.Text           = "更新选中的比赛";
            this.btnCreate.Text = "更新";
        }
        private void RecordScore_Load(object sender, EventArgs e)
        {
            // 修改人员的button是否显示
            if (RecordByGroup)
            {
                this.lbAddAthlete.Visible = false;
                this.lbDelete.Visible     = false;
            }

            // 初始化组别选择
            var allGroups = MatchGroupTableDAL.GetAllGroups(MatchId);

            this.cbGroupNames.DataSource = allGroups;

            // 初始化项目
            var projects = new string[] { "男子组", "女子组", "混双", "男双", "女双" };

            this.cbProjectNames.DataSource = projects;

            // 初始化比赛信息
            var matchInfo = MatchDAL.GetMatchInfoById(MatchId);

            MatchInfo = matchInfo;

            // 初始化轮数
            var rounds = new List <int>();

            for (int i = 1; i <= MatchInfo.PreRounds; i++)
            {
                rounds.Add(i);
            }

            this.cbRounds.DataSource = rounds;

            var preFinal = new List <string>()
            {
                "预赛", "决赛"
            };

            this.cbPreFinal.DataSource = preFinal;

            SetTable(IsFinal);
        }
Пример #3
0
        /// <summary>
        /// 打印女子团体成绩
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void lbWomenTeamScoreSummaryTable_Click(object sender, EventArgs e)
        {
            var selectedRow = dataGridViewX1.SelectedRows[0];

            if (selectedRow == null)
            {
                return;
            }
            var matchId   = selectedRow.Cells[0].Value.ToString();
            var matchName = selectedRow.Cells[1].Value.ToString();

            var matchInfo = MatchDAL.GetMatchInfoById(matchId);

            // 总合计
            if (matchInfo.ScoringMethod == "总合计")
            {
                // 获取所有分组
                var allGroupNames = AthletesDAL.GetAllGroupNames(matchId);

                // 遍历每组人员,获取所有运动员成绩
                foreach (var groupName in allGroupNames.OrderBy(x => x))
                {
                    var allPartInGroupMatchScore = AthletesDAL.GetTeamMatchAthletesScore(matchId, groupName, "女", 2);

                    // 分别挑出4人成绩最少杆数个人对team进行排序
                    var sortedTeamShortName = SortTeamShortNameByTeamPersonScore(allPartInGroupMatchScore);

                    // 遍历每个team, 对运动员按照总分数进行排序
                    var sortedAllPartInGroupMatchScore = new List <AthleteSocreModel>();
                    for (var i = 0; i < sortedTeamShortName.Count; i++)
                    {
                        var sortedTeamAthletesScore = allPartInGroupMatchScore
                                                      .Where(x => x.TeamShortName == sortedTeamShortName[i] && x.SumSocre > 0)
                                                      .OrderBy(x => x.SumSocre)
                                                      .ToList();
                        if (sortedTeamAthletesScore.Count >= 4) // 当团体赛人数少于4时,不计入团体赛成绩
                        {
                            sortedAllPartInGroupMatchScore.AddRange(sortedTeamAthletesScore);
                        }
                    }

                    // 导出文件
                    var fileName = $"{matchName}-{groupName}-女子团体成绩-{DateTime.Now.ToString("yyyyMMddHHmmss")}";
                    ExcelHelperPrintTeamScoreSummaryTable.GenerateTeamScoreSummaryPersonalTable(sortedAllPartInGroupMatchScore, matchName, groupName, "女", fileName);
                }
            }
            // 分开合计
            else
            {
                // 获取所有分组
                var allGroupNames = AthletesDAL.GetAllGroupNames(matchId);

                // 遍历每组人员,获取所有运动员成绩
                foreach (var groupName in allGroupNames.OrderBy(x => x))
                {
                    var allPartInGroupMatchScore = AthletesDAL.GetTeamMatchAthletesScore(matchId, groupName, "女", 2);

                    // 分别挑出4人成绩最少杆数一轮,二轮和对team进行排序
                    var sortedTeamShortName = SortTeamShortNameByTeamScore(allPartInGroupMatchScore);

                    // 遍历每个team, 对运动员按照总分数进行排序
                    var sortedAllPartInGroupMatchScore = new List <AthleteSocreModel>();
                    for (var i = 0; i < sortedTeamShortName.Count; i++)
                    {
                        var sortedTeamAthletesScore = allPartInGroupMatchScore.Where(x => x.TeamShortName == sortedTeamShortName[i] && x.SumSocre > 0).OrderBy(x => x.SumSocre).ToList();
                        if (sortedTeamAthletesScore.Count >= 4) // 当团体赛人数少于4时,不计入团体赛成绩
                        {
                            sortedAllPartInGroupMatchScore.AddRange(sortedTeamAthletesScore);
                        }
                    }

                    // 导出文件
                    var fileName = $"{matchName}-{groupName}-女子团体成绩-{DateTime.Now.ToString("yyyyMMddHHmmss")}";
                    ExcelHelperPrintTeamScoreSummaryTable.GenerateTeamScoreSummaryTable(sortedAllPartInGroupMatchScore, matchName, groupName, "女", fileName);
                }
            }
        }