public List <Doctor> QueryDoctorsByTeamAccount(string teamAccount)
 {
     using (var db = new GymCompetitionDB())
     {
         return(db.Tb_doctor.Where(m => m.TeamAccount == teamAccount).ToList());
     }
 }
 public List <Athlete> QueryAthletesByTeamAccount(string teamAccount)
 {
     using (var db = new GymCompetitionDB())
     {
         return(db.Tb_athlete.Where(m => m.TeamAccount == teamAccount).ToList());
     }
 }
 //通过 队账号 查找相应的成员
 public List <Team> QueryAllTeams()
 {
     using (var db = new GymCompetitionDB())
     {
         return(db.Team.ToList());
     }
 }
 public List <Leader> QueryLeadersByTeamAccout(string teamAccount)
 {
     using (var db = new GymCompetitionDB())
     {
         return(db.Tb_leader.Where(m => m.TeamAccount == teamAccount).ToList());
     }
 }
 public List <RefereeScore> QueryRefereeScore()
 {
     using (var db = new GymCompetitionDB())
     {
         return(db.Tb_refereeScore.ToList());
     }
 }
 public List <GameInformation> SearchGameInfosByItemIdAndGroupNum(string itemId, int groupNum)
 {
     using (var db = new GymCompetitionDB())
     {
         return(db.Tb_gameInformation.Where(m => (m.ItemId == itemId) && (m.GroupNumber == groupNum)).ToList());
     }
 }
 public List <Item> SearchItemById(string temp)
 {
     using (var db = new GymCompetitionDB())
     {
         return(db.Tb_item.Where(m => m.Id == temp).ToList());
     }
 }
 public List <GameInformation> QueryGameInformationById()
 {
     using (var db = new GymCompetitionDB())
     {
         return(db.Tb_gameInformation.ToList());
     }
 }
 public List <Referee> SearchRefereeByIdCard(string temp)
 {
     using (var db = new GymCompetitionDB())
     {
         return(db.Tb_referee.Where(m => m.Idcard == temp).ToList());
     }
 }
 public List <GameInformation> SearchGameInfoById(string temp)
 {
     using (var db = new GymCompetitionDB())
     {
         return(db.Tb_gameInformation.Where(m => m.Id == temp).ToList());
     }
 }
 public List <Coach> SearchCoachByIdCard(string temp)
 {
     using (var db = new GymCompetitionDB())
     {
         return(db.Tb_coach.Where(m => m.Idcard == temp).ToList());
     }
 }
 public List <Athlete> SearchAthleteByAthleteNum(string temp)
 {
     using (var db = new GymCompetitionDB())
     {
         return(db.Tb_athlete.Where(m => m.Athnum == temp).ToList());
     }
 }
 public List <Doctor> SearchDoctorByIdCard(string temp)
 {
     using (var db = new GymCompetitionDB())
     {
         return(db.Tb_doctor.Where(m => m.Idcard == temp).ToList());
     }
 }
 public List <Leader> SearchLeaderByIdCard(string temp)
 {
     using (var db = new GymCompetitionDB())
     {
         return(db.Tb_leader.Where(m => m.Idcard == temp).ToList());
     }
 }
 public List <RefereeScore> SearchRefereeScoreByGameInfoId(string temp)
 {
     using (var db = new GymCompetitionDB())
     {
         return(db.Tb_refereeScore.Where(item => item.GameInfoId == temp).ToList());
     }
 }
 public List <Referee> QueryRefereeByTeamAccount(string teamAccount)
 {
     using (var db = new GymCompetitionDB())
     {
         return(db.Tb_referee.Where(m => m.TeamAccount == teamAccount).ToList());
     }
 }
 public List <RefereeScore> SearchRefereeScoreByRefereeIdAndGameInfo(string gameInfo, string refereeId)
 {
     using (var db = new GymCompetitionDB())
     {
         return(db.Tb_refereeScore.Where(m => m.RefereeId == refereeId && m.GameInfoId == gameInfo).ToList());
     }
 }
 public List <Item> QueryItems()
 {
     using (var db = new GymCompetitionDB())
     {
         return(db.Tb_item.ToList());
     }
 }
 public List <Coach> QueryCoachByTeamAccount(string teamAccount)
 {
     using (var db = new GymCompetitionDB())
     {
         return(db.Tb_coach.Where(m => m.TeamAccount == teamAccount).ToList());
     }
 }
 //通过 成员账号/身份证号查找特定成员
 public List <Team> SearchTeamByAccount(string account)
 {
     using (var db = new GymCompetitionDB())
     {
         return(db.Team.Where(m => m.Account == account).ToList());
     }
 }
        //得到决赛名单
        public void GetFinalGameAthletes()
        {
            using (var db = new GymCompetitionDB())
            {
                IEnumerable <IGrouping <string, PersonalItemFinalScore> > finalScores = db.Tb_PersonalItemFinalScore
                                                                                        .OrderBy(n => n.FinalScore)
                                                                                        .GroupBy(m => m.ItemId)
                                                                                        .ToList();

                foreach (IGrouping <string, PersonalItemFinalScore> item in finalScores)
                {
                    int count = 0;
                    foreach (PersonalItemFinalScore finalScore in item)
                    {
                        if (count++ < 8)
                        {
                            db.Tb_gameInformation.Where(
                                info => info.ItemId == item.ToString() && info.AthleteNum == finalScore.AthleteNum)
                            .ToList()[0].FinalGame
                                = true;
                        }
                    }
                }
            }
        }
 //设置 组号 出场顺序
 public void ArrangeGroups()
 {
     using (var db = new GymCompetitionDB())
     {
         int count = 0;
         int tag   = 1;
         foreach (GameInformation gameInformation in db.Tb_gameInformation)
         {
             tag = 1;
             while (true)
             {
                 count = GetItemGroupCount(gameInformation.ItemId, tag);
                 if (count < 8)
                 {
                     gameInformation.GroupNumber = tag;
                     gameInformation.PlayOrder   = count + 1;
                     UpdateGameInfo(gameInformation);
                     break;
                 }
                 else
                 {
                     tag++;
                 }
             }
         }
     }
 }
 //查找 同一项目同一组号内的人数
 public int GetItemGroupCount(string itemId, int n)
 {
     using (var db = new GymCompetitionDB())
     {
         return(db.Tb_gameInformation.Where(m => m.ItemId == itemId && m.GroupNumber == n).ToList().Count);
     }
 }
 public void AddGameInformation(GameInformation gameInformation)
 {
     using (var db = new GymCompetitionDB())
     {
         db.Tb_gameInformation.Add(gameInformation);
         db.SaveChanges();
     }
 }
 public void AddItem(Item item)
 {
     using (var db = new GymCompetitionDB())
     {
         db.Tb_item.Add(item);
         db.SaveChanges();
     }
 }
 public void AddAthlete(Athlete athlete)
 {
     using (var db = new GymCompetitionDB())
     {
         db.Tb_athlete.Add(athlete);
         db.SaveChanges();
     }
 }
 public void AddReferee(Referee referee)
 {
     using (var db = new GymCompetitionDB())
     {
         db.Tb_referee.Add(referee);
         db.SaveChanges();
     }
 }
 public void AddCoach(Coach coach)
 {
     using (var db = new GymCompetitionDB())
     {
         db.Tb_coach.Add(coach);
         db.SaveChanges();
     }
 }
 public void AddDoctor(Doctor doctor)
 {
     using (var db = new GymCompetitionDB())
     {
         db.Tb_doctor.Add(doctor);
         db.SaveChanges();
     }
 }
 public void AddLeader(Leader leader)
 {
     using (var db = new GymCompetitionDB())
     {
         db.Tb_leader.Add(leader);
         db.SaveChanges();
     }
 }