//显示单项小组内个人排名
        public object[][] GetGroupTotalScore(RefereeScore chiefRefereeScore)
        {
            object[][] totalScoreView = new object[8][];

            int    index    = 0;
            string itemId   = SearchGameInfoById(chiefRefereeScore.GameInfoId)[0].ItemId;
            int    groupNum = SearchGameInfoById(chiefRefereeScore.GameInfoId)[0].GroupNumber;
            List <GameInformation> gameInfos = SearchGameInfosByItemIdAndGroupNum(itemId, groupNum);

            foreach (GameInformation gameInfo in gameInfos)
            {
                List <RefereeScore> ts   = SearchRefereeScoreByGameInfoId(gameInfo.Id);
                object[]            line = new object[5];
                for (int i = 0; i < ts.Count; i++)
                {
                    if (ts[i].ChiefReferee)
                    {
                        line[2] = ts[i].P;
                        line[3] = ts[i].D;
                        ts.RemoveAt(i);
                        break;
                    }
                }
                double[] scores = ts.Select(item => item.Score).ToArray();
                Array.Sort(scores);
                double sum = 0;
                for (int i = 1; i <= ts.Count - 2; i++)
                {
                    sum += scores[i];
                }
                double average = sum / (ts.Count - 2);

                line[0] = gameInfo.AthleteNum;
                line[1] = average * ts.Count + Convert.ToDouble(line[3]) - Convert.ToDouble(line[2]);
                line[4] = 0;
                totalScoreView[index++] = line;

                PersonalItemFinalScore personalItemFinalScore = new PersonalItemFinalScore(
                    index.ToString(), itemId, line[0].ToString(), false, Convert.ToDouble(line[1]));
                AddPersonalItemFinalScore(personalItemFinalScore);
            }
            for (int i = 0; i < index - 1; i++)
            {
                for (int j = 1; j < index - i; j++)
                {
                    if (Convert.ToDouble(totalScoreView[j - 1][1]) < Convert.ToDouble(totalScoreView[j][1]))
                    {
                        object[] line = new object[5];
                        line = totalScoreView[j - 1];
                        totalScoreView[j - 1] = totalScoreView[j];
                        totalScoreView[j]     = line;
                    }
                }
            }
            for (int i = 0; i < index; i++)
            {
                totalScoreView[i][4] = i + 1;
            }
            return(totalScoreView);
        }
 public void AddRefereeScore(RefereeScore refereeScore)
 {
     using (var db = new GymCompetitionDB())
     {
         db.Tb_refereeScore.Add(refereeScore);
         db.SaveChanges();
     }
 }
 public void UpdateRefereeScore(RefereeScore refereeScore)
 {
     using (var db = new GymCompetitionDB())
     {
         db.Tb_refereeScore.Attach(refereeScore);
         db.Entry(refereeScore).State = EntityState.Modified;
         db.SaveChanges();
     }
 }