//获取某一球员在某一赛事中所有停赛记录的总和
 public static int getPlayerSuspendedQuantity(int matchID, int playerID)
 {
     int quantity = 0;
     DBUtility dbutility = new DBUtility();
     //查询某个球员所有停赛记录,同一场球赛不能被停赛两次或两次以上
     string sql = "select COUNT(DISTINCT gameNum) from suspendedrecord where matchID=" + matchID;
     sql = sql + " and playerID=" + playerID;
     try
     {
         dbutility.openConnection();
         MySqlDataReader rd = dbutility.ExecuteQuery(sql);
         while (rd.Read())
         {
             quantity = Convert.ToInt32(rd[0]);
         }
     }
     catch (MySqlException ex)
     {
         Console.Write(ex.ToString());
     }
     finally
     {
         dbutility.Close();
     }
     return quantity;
 }
Exemple #2
0
 //检查赛事名称是否存在
 public static bool checkMatchNameExist(string name)
 {
     bool flag = false;
     //执行查询数据库操作
     DBUtility dbutility = new DBUtility();
     string SQL = "select ID,seasonName,description from matchinfo where seasonName='" + name + "'";
     try
     {
         dbutility.openConnection();
         MySqlDataReader rd = dbutility.ExecuteQuery(SQL);
         while (rd.Read())
         {
             flag = true;
         }
     }
     catch (MySqlException ex)
     {
         Console.WriteLine(ex.ToString());
     }
     finally
     {
         dbutility.Close();
     }
     return flag;
 }
 //检查某一赛事中某一比赛序号是否存在
 public static bool checkGameNumExist(int matchID, int gameNum)
 {
     bool flag = false;
     DBUtility dbutility = new DBUtility();
     string sql = "select uniqueID,matchID,matchGameNum,gameName,homeTeam,guestTeam,gameWinner,";
     sql = sql + "gameResult,gameAddress,gameDate from gameInfo where matchGameNum=" + gameNum + "";
     sql = sql + " and matchID=" + matchID;
     try
     {
         dbutility.openConnection();
         MySqlDataReader rd = dbutility.ExecuteQuery(sql);
         while (rd.Read())
         {
             flag = true;
         }
     }
     catch (MySqlException ex)
     {
         Console.WriteLine(ex.ToString());
     }
     finally
     {
         dbutility.Close();
     }
     return flag;
 }
        public static List<SeasonOfMatch> AllSeasons()
        {
            List<SeasonOfMatch> list = new List<SeasonOfMatch>();
            //执行查询数据库操作
            DBUtility dbutility = new DBUtility();
            string SQL = "select id,matchname,seasondescription,numofseason,numOfTurn from gameseason order by id";
            try
            {
                dbutility.openConnection();
                MySqlDataReader rd = dbutility.ExecuteQuery(SQL);
                while (rd.Read())
                {
                    list.Add(new SeasonOfMatch(Convert.ToInt32(rd[0]), Convert.ToString(rd[1]), Convert.ToString(rd[2]), Convert.ToInt32(rd[3]), Convert.ToInt32(rd[4])));
                }
            }
            catch (MySqlException ex)
            {
                Console.WriteLine(ex.ToString());
            }
            finally
            {
                dbutility.Close();
            }

            return list;
        }
        //检查赛季表特定赛事的赛季是否为空,不为空返回false
        public static bool checkSeasonOfCertainMatchIsNull(string matchName)
        {
            //执行查询数据库操作
            DBUtility dbutility = new DBUtility();
            string SQL = "select count(ID) from gameseason where matchname = '" + matchName + "' ";
            try
            {
                dbutility.openConnection();
                MySqlDataReader rd = dbutility.ExecuteQuery(SQL);
                while (rd.Read())
                {
                    if (Convert.ToInt32(rd[0]) != 0)
                        return false;
                }
            }
            catch (MySqlException ex)
            {
                Console.WriteLine(ex.ToString());
            }
            finally
            {
                dbutility.Close();
            }

            return true;
        }
 public static void getDefaultSet()
 {
     DBUtility dbutility = new DBUtility();
     string sql = "select * from defaultset;";
     try
     {
         dbutility.openConnection();
         MySqlDataReader rd = dbutility.ExecuteQuery(sql);
         while (rd.Read())
         {
             DefaultSet.setDefaultSeason(Convert.ToString(rd[0]));
             DefaultSet.setDedaultMatch(Convert.ToString(rd[1]));
             DefaultSet.setDefaultTurn(Convert.ToInt32(rd[2]));
         }
     }
     catch (MySqlException ex)
     {
         Console.WriteLine(ex.ToString());
         //  MessageBox.Show(ex.ToString());
     }
     finally
     {
         dbutility.Close();
     }
 }
 //检查某一个赛事中,比赛数量是否满足条件
 public static bool checkGameNumLegal(int matchID,int gameNum)
 {
     bool flag = false;
     //执行查询数据库操作
     DBUtility dbutility = new DBUtility();
     string SQL = "select serialNum from matchinfo where ID=" + matchID + "";
     int _gameNum = -1;
     try
     {
         dbutility.openConnection();
         MySqlDataReader rd = dbutility.ExecuteQuery(SQL);
         while (rd.Read())
         {
             _gameNum = Convert.ToInt32(rd[0]);
         }
         //判断某一赛事中比赛的总量是否是大于新添加的比赛的比赛序号
         if (gameNum <= _gameNum)
         {
             flag = true;
         }
     }
     catch (MySqlException ex)
     {
         Console.WriteLine(ex.ToString());
     }
     finally
     {
         dbutility.Close();
     }
     return flag;
 }
 ///
 ///<Summary> 用来处理球员停赛信息的数据库操作</Summary>
 ///
 //检查某一场比赛中,某一个球员是否已经有停赛记录
 public static bool checkPlayerSuspended(int playerID,int matchID,int gameNum)
 {
     bool flag = false;
     DBUtility dbutility = new DBUtility();
     string sql = "select * from suspendedrecord where matchID=" + matchID + " and gameNum=" + gameNum;
     sql = sql + " and playerID=" + playerID;
     try
     {
         dbutility.openConnection();
         MySqlDataReader rd = dbutility.ExecuteQuery(sql);
         while (rd.Read())
         {
             flag = true;
         }
     }
     catch (MySqlException ex)
     {
         Console.Write(ex.ToString());
     }
     finally
     {
         dbutility.Close();
     }
     return flag;
 }
 ////////获取当前赛事的球队信息
 /*
 * 查询数据库中的球队的基本信息,并且返回到一个线性表中
 */
 public static List<Schedule> getScheduleInfo(SeasonOfMatch season)
 {
     //声明实例
     List<Schedule> list = new List<Schedule>();
     //执行查询数据库操作
     DBUtility dbutility = new DBUtility();
     string SQL = "select seasonId,matchId,turn,gameDate,homeTeamName,guestTeamName from schedule where seasonId= " + season.getNumOfSeason();
     try
     {
         dbutility.openConnection();
         MySqlDataReader rd = dbutility.ExecuteQuery(SQL);
         while (rd.Read())
         {
             Schedule s = new Schedule();
             s.setSeasonId(Convert.ToInt32(rd[0]));
             s.setMatchId(Convert.ToInt32(rd[1]));
             s.setTurn(Convert.ToInt32(rd[2]));
             s.setGameDate(Convert.ToString(rd[3]));
             s.setHomeTeam(Convert.ToString(rd[4]));
             s.setGuestTeam(Convert.ToString(rd[5]));
             list.Add(s);
         }
     }
     catch (MySqlException ex)
     {
         Console.WriteLine(ex.ToString());
     }
     finally
     {
         dbutility.Close();
     }
     return list;
 }
 //查询某一赛事的所有罚牌记录信息
 public static List<PlayerCardRecord> getMatchCardRecord(int matchID)
 {
     List<PlayerCardRecord> list = new List<PlayerCardRecord>();
     DBUtility dbutility = new DBUtility();
     string sql = "select playergetcardrecord.uniqueID,playergetcardrecord.matchID,matchinfo.seasonName,";
     sql = sql + "playergetcardrecord.playerID,player.playerName,playergetcardrecord.yellowCardNum,";
     sql = sql + "playergetcardrecord.redCardNum,playergetcardrecord.serialNum,playergetcardrecord.getDate,gameinfo.gameName from ";
     sql = sql + "playergetcardrecord,player,matchinfo,gameinfo where playergetcardrecord.matchID=matchinfo.ID and ";
     sql = sql + "gameinfo.matchID=playergetcardrecord.matchID and playergetcardrecord.serialNum=gameinfo.matchGameNum and ";
     sql = sql + "playergetcardrecord.playerID=player.ID and playergetcardrecord.matchID=" + matchID;
     sql = sql + " order by playergetcardrecord.serialNum";
     try
     {
         dbutility.openConnection();
         MySqlDataReader rd = dbutility.ExecuteQuery(sql);
         while (rd.Read())
         {
             PlayerCardRecord playerCardRecord = new PlayerCardRecord();
             playerCardRecord.setUniqueID(Convert.ToInt32(rd[0]));
             playerCardRecord.setMatchID(Convert.ToInt32(rd[1]));
             playerCardRecord.setMatchName(Convert.ToString(rd[2]));
             playerCardRecord.setPlayerID(Convert.ToInt32(rd[3]));
             playerCardRecord.setPlayerName(Convert.ToString(rd[4]));
             playerCardRecord.setYellowCardNum(Convert.ToInt32(rd[5]));
             playerCardRecord.setRedCardNum(Convert.ToInt32(rd[6]));
             playerCardRecord.setSerialNum(Convert.ToInt32(rd[7]));
             playerCardRecord.setDateTime(Convert.ToDateTime(rd[8]));
             playerCardRecord.setGameName(Convert.ToString(rd[9]));
             list.Add(playerCardRecord);
         }
     }
     catch (MySqlException ex)
     {
         Console.WriteLine(ex.ToString());
     }
     finally
     {
         dbutility.Close();
     }
     return list;
 }
Exemple #11
0
        //自定义下拉列表的列表项
        public void InitHomeTeamColumnsSet(string team)
        {
            DataTable teamTable = new DataTable();
            DBUtility dbutility = new DBUtility();
            string SQL = "select teamName from team where matchName='"+SystemParam.getMatch().getName()+"' order by ID";
            try
            {
                dbutility.openConnection();
                MySqlDataReader rd = dbutility.ExecuteQuery(SQL);
                 teamTable.Load(rd);
            }
            catch (MySqlException ex)
            {
              Console.WriteLine(ex.ToString());
            }
            finally
            {
                dbutility.Close();
            }

            ((DataGridViewComboBoxColumn)this.dataGridView1.Columns[team]).DataSource =teamTable;
            ((DataGridViewComboBoxColumn)this.dataGridView1.Columns[team]).DataPropertyName = "teamName";
            ((DataGridViewComboBoxColumn)this.dataGridView1.Columns[team]).DisplayMember = "teamName";
        }
 //获取某一球员在某一赛事中所有的停赛记录
 public static List<SuspendedRecord> getPlayerSuspendedRecord(int matchID,int playerID)
 {
     List<SuspendedRecord> list = new List<SuspendedRecord>();
     DBUtility dbutility = new DBUtility();
     string sql = "select uniqueID,matchID,playerID,gameNum,Date from suspendedrecord where matchID=" + matchID;
     sql = sql + " and playerID=" + playerID;
     try
     {
         dbutility.openConnection();
         MySqlDataReader rd = dbutility.ExecuteQuery(sql);
         while (rd.Read())
         {
             //添加记录信息
             list.Add(new SuspendedRecord(Convert.ToInt32(rd[0]),Convert.ToInt32(rd[1]),Convert.ToInt32(rd[2]),Convert.ToInt32(rd[3]),Convert.ToDateTime(rd[4])));
         }
     }
     catch (MySqlException ex)
     {
         Console.Write(ex.ToString());
     }
     finally
     {
         dbutility.Close();
     }
     return list;
 }
        public static int getMaxSeasonNumOfMatch(string matchName)
        {
            int maxSeasonNum=0;
            //执行查询数据库操作
            DBUtility dbutility = new DBUtility();
            string SQL = "select max(numofseason) from gameseason where matchname = '" + matchName + "' ";
            try
            {
                dbutility.openConnection();
                MySqlDataReader rd = dbutility.ExecuteQuery(SQL);
                while (rd.Read())
                {

                    maxSeasonNum = Convert.ToInt32(Convert.ToString(rd[0]));

                }
            }
            catch (MySqlException ex)
            {
                Console.WriteLine(ex.ToString()+"在这里出错!");

            }
            finally
            {
                dbutility.Close();
            }

            return maxSeasonNum;
        }
 /*
  * 查询不属于某一个赛事的球员信息,但是这些球员信息必须是满足其所在球队已经在赛事球队表里面,
  * 最终返回到一个线性表中
  */
 public static List<FootballPlayer> getNotAssignedPlayerInfo(int matchID)
 {
     DBUtility dbutility = new DBUtility();
     List<FootballPlayer> _list = new List<FootballPlayer>();
     try
     {
         dbutility.openConnection();
         string sql = "SELECT ID,playerName,number,postion,teamName,playerIDnum FROM player WHERE ID NOT IN";
         sql=sql+"(SELECT playerID FROM matchplayerinfo WHERE matchID = "+matchID+")";
         sql=sql+" AND teamName IN ( SELECT team.teamName FROM team,matchteaminfo WHERE";
         sql=sql+" matchteaminfo.matchID = "+matchID+" AND team.ID = matchteaminfo.teamID)";
         MySqlDataReader rd = dbutility.ExecuteQuery(sql);
         while (rd.Read())
         {
             _list.Add(new FootballPlayer(Convert.ToInt32(rd[0]), Convert.ToString(rd[1]), Convert.ToInt32(rd[2]), Convert.ToString(rd[3]), Convert.ToString(rd[4]), Convert.ToString(rd[5])));
         }
     }
     catch (MySqlException ex)
     {
         Console.WriteLine(ex.ToString());
     }
     finally
     {
         dbutility.Close();
     }
     return _list;
 }
        //获取当前库中id值最大的一项,返回其id
        public static int getMaxId()
        {
            int maxId = 0;
            DBUtility dbutility = new DBUtility();
            string sql = "select max(id) from gameseason;";

            try
            {
                dbutility.openConnection();
                MySqlDataReader rd = dbutility.ExecuteQuery(sql);

                while (rd.Read())
                {
                    if (Convert.ToString(rd[0]) != "")
                    {
                        maxId = Convert.ToInt32(rd[0]);
                    }
                }
            }

            catch (MySqlException ex)
            {
                Console.WriteLine(ex.ToString());
            }
            finally
            {
                dbutility.Close();
            }

            return maxId;
        }
 //取出不属于某一个赛事的所有球队信息,并且返回到一个线性表中
 public static List<Team> getNotAssignedMatchTeamInfo(int matchID)
 {
     DBUtility dbutility = new DBUtility();
     List<Team> _teamList = new List<Team>();
     string sql = "SELECT ID,teamName,teamLeader,teamManager,teamCoach FROM team WHERE ID ";
     sql = sql + "NOT IN (SELECT teamID FROM matchteaminfo WHERE matchID = " + matchID + ")";
     try
     {
         dbutility.openConnection();
         MySqlDataReader rd = dbutility.ExecuteQuery(sql);
         while (rd.Read())
         {
             _teamList.Add(new Team(Convert.ToInt32(rd[0]), Convert.ToString(rd[1]), Convert.ToString(rd[2]), Convert.ToString(rd[3]), Convert.ToString(rd[4])));
         }
     }
     catch (MySqlException ex)
     {
         Console.WriteLine(ex.ToString());
     }
     finally
     {
         dbutility.Close();
     }
     return _teamList;
 }
Exemple #17
0
 //获取球队信息
 public static Team getTeamInfo(string teamName)
 {
     Team team = new Team();
     //执行查询数据库操作
     DBUtility dbutility = new DBUtility();
     string SQL = "select ID,teamName,teamLeader,teamManager,teamCoach from player where teamName='" + teamName+"'";
     try
     {
         dbutility.openConnection();
         MySqlDataReader rd = dbutility.ExecuteQuery(SQL);
         while (rd.Read())
         {
             team.setID(Convert.ToInt32(rd[0]));
             team.setName(Convert.ToString(rd[1]));
             team.setLeader(Convert.ToString(rd[2]));
             team.setManager(Convert.ToString(rd[3]));
             team.setCoach(Convert.ToString(rd[4]));
         }
     }
     catch (MySqlException ex)
     {
         Console.WriteLine(ex.ToString());
     }
     finally
     {
         dbutility.Close();
     }
     return team;
 }
Exemple #18
0
 //查询球队信息
 public static List<Team> getTeamInfo()
 {
     //声明实例
     List<Team> list = new List<Team>();
     //执行查询数据库操作
     DBUtility dbutility = new DBUtility();
     string SQL = "select ID,teamName,teamLeader,teamManager,teamCoach from team order by ID";
     try
     {
         dbutility.openConnection();
         MySqlDataReader rd = dbutility.ExecuteQuery(SQL);
         while (rd.Read())
         {
             list.Add(new Team(Convert.ToInt32(rd[0]), Convert.ToString(rd[1]), Convert.ToString(rd[2]), Convert.ToString(rd[3]), Convert.ToString(rd[4])));
         }
     }
     catch (MySqlException ex)
     {
         Console.WriteLine(ex.ToString());
     }
     finally
     {
         dbutility.Close();
     }
     return list;
 }
Exemple #19
0
 //依据球员的姓名,返回球员信息
 public static FootballPlayer getPlayerInfo(string playerName)
 {
     FootballPlayer player = new FootballPlayer();
     //执行查询数据库操作
     DBUtility dbutility = new DBUtility();
     string SQL = "select ID,playerName,number,postion,teamName from player where playerName='" + playerName+"'";
     try
     {
         dbutility.openConnection();
         MySqlDataReader rd = dbutility.ExecuteQuery(SQL);
         while (rd.Read())
         {
             player.setPlayerID(Convert.ToInt32(rd[0]));
             player.setPlayerName(Convert.ToString(rd[1]));
             player.setPlayNumber(Convert.ToInt32(rd[2]));
             player.setPostion(Convert.ToString(rd[3]));
             player.setBelongTeam(Convert.ToString(rd[4]));
         }
     }
     catch (MySqlException ex)
     {
         Console.WriteLine(ex.ToString());
     }
     finally
     {
         dbutility.Close();
     }
     return player;
 }
Exemple #20
0
 //查询某球队球员信息
 public static List<FootballPlayer> getPlayerInfoOfCertainTeam(string teamName)
 {
     //声明实例
     List<FootballPlayer> list = new List<FootballPlayer>();
     //执行查询数据库操作
     DBUtility dbutility = new DBUtility();
     string SQL = "select ID,playerName,number,postion,teamName ,playerIDnum from player where teamName ='"+teamName+"' order by ID";
     try
     {
         dbutility.openConnection();
         MySqlDataReader rd = dbutility.ExecuteQuery(SQL);
         while (rd.Read())
         {
             list.Add(new FootballPlayer(Convert.ToInt32(rd[0]), Convert.ToString(rd[1]), Convert.ToInt32(rd[2]), Convert.ToString(rd[3]), Convert.ToString(rd[4]), Convert.ToString(rd[5])));
         }
     }
     catch (MySqlException ex)
     {
         Console.WriteLine(ex.ToString());
     }
     finally
     {
         dbutility.Close();
     }
     return list;
 }
Exemple #21
0
        //依据赛事名称,返回赛事信息
        public static SeasonMatch getMatchInfo(string matchName)
        {
            SeasonMatch match = new SeasonMatch();
            //执行查询数据库操作
            DBUtility dbutility = new DBUtility();
            string SQL = "select ID,seasonName,description,switchNum,serialNum from matchinfo where seasonName='" + matchName + "'";
            try
            {
                dbutility.openConnection();
                MySqlDataReader rd = dbutility.ExecuteQuery(SQL);
                while (rd.Read())
                {
                    match.setID(Convert.ToInt32(rd[0]));
                    match.setName(Convert.ToString(rd[1]));
                    match.setDescription(Convert.ToString(rd[2]));
                    match.setSwitchNum(Convert.ToInt32(rd[3]));
                    match.setSerialNum(Convert.ToInt32(rd[4]));

                }
            }
            catch (MySqlException ex)
            {
                Console.WriteLine(ex.ToString());
            }
            finally
            {
                dbutility.Close();
            }
            return match;
        }
 //获取某一赛事中黄牌转红牌的数量
 public static int getMatchSwitchNum(int matchID)
 {
     int switchNum = 0;
     //执行查询数据库操作
     DBUtility dbutility = new DBUtility();
     string SQL = "select switchNum from matchinfo where ID=" + matchID;
     try
     {
         dbutility.openConnection();
         MySqlDataReader rd = dbutility.ExecuteQuery(SQL);
         while (rd.Read())
         {
             switchNum = Convert.ToInt32(rd[0]);
         }
     }
     catch (MySqlException ex)
     {
         Console.WriteLine(ex.ToString());
     }
     finally
     {
         dbutility.Close();
     }
     return switchNum;
 }
Exemple #23
0
        //查询特定赛事所属的球队
        public static List<Team> getTeamInfoOfCertainMatch(SeasonMatch match)
        {
            //声明实例
            List<Team> list = new List<Team>();
            //执行查询数据库操作
            DBUtility dbutility = new DBUtility();
            // string SQL = "select ID,teamName,teamLeader,teamManager,teamCoach from team order by ID";
            string SQL = "select * from team where matchName= '"+match.getName()+"' order by ID";
            try
            {
                dbutility.openConnection();
                MySqlDataReader rd = dbutility.ExecuteQuery(SQL);
                while (rd.Read())
                {
                    Team team = new Team(Convert.ToInt32(rd[0]), Convert.ToString(rd[1]), Convert.ToString(rd[2]),
                              Convert.ToString(rd[3]), Convert.ToString(rd[4]), Convert.ToString(rd[5]),
                              Convert.ToString(rd[6]), Convert.ToString(rd[7]), Convert.ToString(rd[8]),
                              Convert.ToString(rd[9]));

                    list.Add(team);
                }
            }
            catch (MySqlException ex)
            {
                Console.WriteLine(ex.ToString());
            }
            finally
            {
                dbutility.Close();
            }
            return list;
        }
Exemple #24
0
 //查询某一场比赛的信息
 public static Game getGameInfo(int matchID,string gameName)
 {
     DBUtility dbutility = new DBUtility();
     Game game = new Game();
     string sql = "select uniqueID,matchID,matchGameNum,gameName,homeTeam,guestTeam,gameWinner,";
     sql = sql + "gameResult,gameAddress,gameDate from gameInfo where gameName='" + gameName+"'";
     sql = sql + " and matchID=" + matchID;
     try
     {
         dbutility.openConnection();
         MySqlDataReader rd = dbutility.ExecuteQuery(sql);
         while (rd.Read())
         {
             game = new Game(Convert.ToInt32(rd[0]), Convert.ToInt32(rd[1]), Convert.ToInt32(rd[2]),
                 Convert.ToString(rd[3]), Convert.ToString(rd[4]), Convert.ToString(rd[5]), Convert.ToString(rd[6]),
                 Convert.ToString(rd[7]), Convert.ToString(rd[8]), Convert.ToDateTime(rd[9]));
         }
     }
     catch (MySqlException ex)
     {
         Console.WriteLine(ex.ToString());
     }
     finally
     {
         dbutility.Close();
     }
     return game;
 }
 //查询参加某个比赛的球员信息列表
 public static List<FootballPlayer> getPlayerInfo(Game game)
 {
     //声明实例
     List<FootballPlayer> list = new List<FootballPlayer>();
     //执行查询数据库操作
     DBUtility dbutility = new DBUtility();
     string SQL="";
     try
     {
         dbutility.openConnection();
         //取出比赛的参与球队,若两个球队相同时,只查询一次球队,然后返回到球员列表中
         if (game.getHomeTeam() == game.getGuestTeam())
         {
             SQL = "select ID,playerName,number,postion,teamName,playerIDnum from player where teamName='" + game.getHomeTeam();
             SQL = SQL + "' order by ID";
             MySqlDataReader rd = dbutility.ExecuteQuery(SQL);
             while (rd.Read())
             {
                 list.Add(new FootballPlayer(Convert.ToInt32(rd[0]), Convert.ToString(rd[1]), Convert.ToInt32(rd[2]), Convert.ToString(rd[3]), Convert.ToString(rd[4]), Convert.ToString(rd[5])));
             }
         }
         else  //当参加比赛的两个球队不相同时
         {
             SQL = "select ID,playerName,number,postion,teamName,playerIDnum from player where teamName='" + game.getHomeTeam();
             SQL = SQL + "' order by ID";
             MySqlDataReader rd = dbutility.ExecuteQuery(SQL);
             while (rd.Read())
             {
                 list.Add(new FootballPlayer(Convert.ToInt32(rd[0]), Convert.ToString(rd[1]), Convert.ToInt32(rd[2]), Convert.ToString(rd[3]), Convert.ToString(rd[4]), Convert.ToString(rd[5])));
             }
             //查询客队球员信息
             SQL = "select ID,playerName,number,postion,teamName,playerIDnum from player where teamName='" + game.getGuestTeam();
             SQL = SQL + "' order by ID";
             MySqlDataReader rds = dbutility.ExecuteQuery(SQL);
             while (rds.Read())
             {
                 list.Add(new FootballPlayer(Convert.ToInt32(rds[0]), Convert.ToString(rds[1]), Convert.ToInt32(rds[2]), Convert.ToString(rds[3]), Convert.ToString(rds[4]), Convert.ToString(rd[5])));
             }
         }
     }
     catch (MySqlException ex)
     {
         Console.WriteLine(ex.ToString());
     }
     finally
     {
         dbutility.Close();
     }
     return list;
 }
Exemple #26
0
 //获取某一赛事中其最大的比赛序号的记录
 public static int getMatchMaxGameNum(int matchID)
 {
     int _maxGameNum = 0;  //记录最大的比赛序号
     DBUtility dbutility = new DBUtility();
     string sql = "select max(matchGameNum) from gameInfo where matchID=" + matchID;
     try
     {
         dbutility.openConnection();
         MySqlDataReader rd = dbutility.ExecuteQuery(sql);
         while (rd.Read())
         {
             if (Convert.ToString(rd[0]) != "")
             {
                 _maxGameNum = Convert.ToInt32(rd[0]);
             }
         }
     }
     catch (MySqlException ex)
     {
         Console.WriteLine(ex.ToString());
     }
     finally
     {
         dbutility.Close();
     }
     return _maxGameNum;
 }
Exemple #27
0
 ///
 ///记录一些基本的数据库查询事件
 ///
 /*
  * 查询数据库中的赛事的基本信息,并且返回到一个线性表中
  */
 public static List<SeasonMatch> getMatchInfo()
 {
     //声明实例
     List<SeasonMatch> list = new List<SeasonMatch>();
     //执行查询数据库操作
     DBUtility dbutility = new DBUtility();
     string SQL = "select ID,seasonName,description,switchNum,serialNum from matchinfo order by ID";
     try
     {
         dbutility.openConnection();
         MySqlDataReader rd = dbutility.ExecuteQuery(SQL);
         while (rd.Read())
         {
             list.Add(new SeasonMatch(Convert.ToInt32(rd[0]),Convert.ToString(rd[1]),Convert.ToString(rd[2]),Convert.ToInt32(rd[3]),Convert.ToInt32(rd[4])));
         }
     }
     catch (MySqlException ex)
     {
         Console.WriteLine(ex.ToString());
     }
     finally
     {
         dbutility.Close();
     }
     return list;
 }
Exemple #28
0
 //取出所有比赛信息
 public static List<Game> getAllGameInfo()
 {
     DBUtility dbutility = new DBUtility();
     List<Game> list = new List<Game>();
     string sql = "select uniqueID,matchID,matchGameNum,gameName,homeTeam,guestTeam,gameWinner,";
     sql = sql + "gameResult,gameAddress,gameDate from gameInfo ORDER BY uniqueID";
     try
     {
         dbutility.openConnection();
         MySqlDataReader rd = dbutility.ExecuteQuery(sql);
         while (rd.Read())
         {
             list.Add(new Game(Convert.ToInt32(rd[0]), Convert.ToInt32(rd[1]), Convert.ToInt32(rd[2]),
                 Convert.ToString(rd[3]), Convert.ToString(rd[4]), Convert.ToString(rd[5]), Convert.ToString(rd[6]),
                 Convert.ToString(rd[7]), Convert.ToString(rd[8]), Convert.ToDateTime(rd[9])));
         }
     }
     catch (MySqlException ex)
     {
         Console.WriteLine(ex.ToString());
     }
     finally
     {
         dbutility.Close();
     }
     return list;
 }
        //检查赛事表中是否为空,不为空返回true
        public static bool checkMatchTableIsNull()
        {
            //执行查询数据库操作
            DBUtility dbutility = new DBUtility();
            string SQL = "select count(ID) from matchinfo ";
            try
            {
                dbutility.openConnection();
                MySqlDataReader rd = dbutility.ExecuteQuery(SQL);
                while (rd.Read())
                {
                    if (Convert.ToInt32(rd[0]) != 0)
                        return true;
                }
            }
            catch (MySqlException ex)
            {
                Console.WriteLine(ex.ToString());
            }
            finally
            {
                dbutility.Close();
            }

            return false;
        }