示例#1
0
 //添加比赛信息
 public static void addNewGameInfo(Game game)
 {
     DBUtility dbutility = new DBUtility();
     string sql = "insert into gameInfo(matchID,matchGameNum,gameName,homeTeam,guestTeam,gameWinner,";
     sql = sql + "gameResult,gameAddress,gameDate) values(" + game.getMatchID() + "," + game.getMatchGameNum() + ",'";
     sql=sql+game.getGameName() + "','"+game.getHomeTeam()+"','"+game.getGuestTeam()+"','"+game.getGameWinner()+"','";
     sql = sql + game.getGameResult() + "','" + game.getGameAddress() + "','" + game.getGameDate() + "')";
     try
     {
         dbutility.openConnection();
         dbutility.ExecuteUpdate(sql);
     }
     catch (MySqlException ex)
     {
         Console.WriteLine(ex.ToString());
       //  MessageBox.Show(ex.ToString());
     }
     finally
     {
         dbutility.Close();
     }
 }
示例#2
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;
 }
示例#3
0
 //显示某一比赛中可上场成员的信息
 private void showAvaliableDataInfo(SeasonMatch match,Game game)
 {
     if (dataGridView_playerManage.Rows.Count > 0)  //清除表格行
     {
         dataGridView_playerManage.Rows.Clear();
     }
     //查询属于该场比赛的所有球员信息``
     if (game.getHomeTeam() == "" || game.getGuestTeam() == "")
     {
         MessageBox.Show("比赛中的主队或客队不能为空", "比赛球队空", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
     }
     else
     {
         //获取参加该比赛的球员信息
         List<FootballPlayer> list = PlayerInfoDAO.getPlayerInfo(game);
         FootballPlayer player;  //记录球员信息
      //   SuspendedRecord _suspendedRecord;  //记录球员的停赛记录
         PlayerCardRecord _playerCardRecord;  //记录球员的罚牌记录信息
         string label = "";  //记录球员可上场状态
         string leftYellowCardNum = "-";  //记录球员上场之后,可以被罚的黄牌数量
         for (int i = 0; i < list.Count; i++)  //循环查询每一个球员的信息,显示该球员在某一场比赛中是否能够上场
         {
             player = list[i];
             label = "";
             leftYellowCardNum = "-";
             //取出指定用户的所有停赛记录
         //    List<SuspendedRecord> suspendedList = SuspendedRecordDAO.getPlayerSuspendedRecord(match.getID(), player.getID());
             //取出指定用户在指定比赛前的所有停赛记录数量
             List<SuspendedRecord> _suspenedList = SuspendedRecordDAO.getPlayerSuspendedRecord_BeforeGame(match.getID(), player.getID(), game.getMatchGameNum());
             //判断用户是否在本次比赛中具有停赛信息记录
             if (SuspendedRecordDAO.checkPlayerSuspended(player.getID(), match.getID(), game.getMatchGameNum()))  //若具有停赛记录
             {
                 label = "停赛";
             }
             else  //若还没有记录到停赛信息时
             {
                 //取出该球员在这场比赛之前的所有罚牌记录
                 List<PlayerCardRecord> cardRecordList = MatchCardRecordDAO.getPlayerCardRecord_beforeGame(match.getID(), player.getID(), game.getMatchGameNum());
                 //统计该球员的所有黄牌和红牌数量
                 int yellowCardNum = 0;
                 int redCardNum = 0;
                 for (int k = 0; k < cardRecordList.Count; k++)
                 {
                     _playerCardRecord = cardRecordList[k];
                     //统计该球员在该场比赛前所有获得黄牌和红牌的数量
                     yellowCardNum = yellowCardNum + _playerCardRecord.getYellowCardNum();
                     redCardNum = redCardNum + _playerCardRecord.getRedCardNum();
                 }
                 //统计该球员所有黄牌和红牌总和可以得到的停赛次数
                 int attendedSuspendedQuantity = redCardNum + yellowCardNum / match.getSwitchNum();
                 //若应当停赛的次数比实际停赛次数多时,那么应当添加一次停赛,并且设置标签数据为停赛
                 if (attendedSuspendedQuantity > _suspenedList.Count)
                 {
                     //修改参赛标签
                     label = "停赛";
                     //添加一次停赛记录
                     SuspendedRecordDAO.addNewSuspendedRecord(match.getID(), game.getMatchGameNum(), player.getID(), game.getGameDate());
                 }
                 else  //当应当停赛次数没有实际停赛次数多时,比实际停赛次数少或等时,说明该球员在之前已经停赛过了
                 {
                     //设置标签为参赛
                     label = "可参赛";
                     //求得余下可被罚的黄牌数量
                     leftYellowCardNum = (match.getSwitchNum() - yellowCardNum % match.getSwitchNum()).ToString();
                 }
             }
             dataGridView_playerManage.Rows.Add(player.getID().ToString(), player.getName(), player.getNumber().ToString(), player.getPostion(), player.getBelongTeam(),label,leftYellowCardNum);
         }
         //设置表格颜色
         this.setDataRowColor();
     }
 }
示例#4
0
 //添加一个比赛的记录,
 private void addNewMatchGameInfo(SeasonMatch match)
 {
     if (textBox_GameName.Text != "") //检查比赛名字
     {
         //检查比赛名称是否合法
         string gameName = textBox_GameName.Text;
         if (GameInfoDAO.checkGameNameExist(match.getID(), gameName))
         {
             MessageBox.Show("比赛名字已经存在,请修改", "比赛名字重复", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
         }
         else
         {
             //检查比赛序号
             if (textBox_gameNum.Text != "")
             {
                 if (checkSwitchResult.checkStringSwitchInteger(textBox_gameNum.Text))
                 {
                     int gameNum = Convert.ToInt32(textBox_gameNum.Text);
                     //检查比赛序号是否存在
                     if (GameInfoDAO.checkGameNumExist(match.getID(), gameNum))
                     {
                         MessageBox.Show("比赛序号已经存在,请修改", "比赛序号重复", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
                     }
                     else
                     {
                         //判断比赛序号是否合法,即是否超过该赛事所限制的比赛次数
                         if (gameNum <= match.getSerialNum())
                         {
                             if (comboBox_homeTeam.Text != "")
                             {
                                 if (comboBox_guestTeam.Text != "")
                                 {
                                     Game _game = new Game();  //声明一个比赛类,并且赋值
                                     _game.setMatchID(match.getID());
                                     _game.setGameName(gameName);
                                     _game.setMatchGameNum(gameNum);
                                     _game.setHomeTeam(comboBox_homeTeam.Text);
                                     _game.setGuestTeam(comboBox_guestTeam.Text);
                                     _game.setGameWinner(comboBox_winner.Text);
                                     _game.setGameResult(textBox_gameResult.Text);
                                     _game.setGameAddress(textBox_gameAddress.Text);
                                     _game.setGameDate(Convert.ToDateTime(dateTimePicker_gameDate.Text));
                                     //执行更新操作
                                     GameInfoDAO.addNewGameInfo(_game);
                                     //弹出对话框,提示是否继续添加
                                     if (MessageBox.Show("添加比赛信息成功,是否继续添加?", "添加比赛成功", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                                     {
                                         //清空其他
                                         textBox_GameName.Text = "";
                                         textBox_gameNum.Text = "";
                                         textBox_gameResult.Text = "";
                                         textBox_gameAddress.Text = "";
                                     }
                                     else
                                     {
                                         this.Close();
                                     }
                                 }
                                 else
                                 {
                                     MessageBox.Show("客队名字不能为空", "球队空", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
                                 }
                             }
                             else
                             {
                                 MessageBox.Show("主队名字不能为空", "球队空", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
                             }
                         }
                         else
                         {
                             MessageBox.Show("比赛序号超过赛事比赛总数", "比赛序号溢出", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
                         }
                     }
                 }
                 else
                 {
                     MessageBox.Show("比赛序号必须填数字", "序号非数字", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
                 }
             }
             else
             {
                 MessageBox.Show("比赛序号不能为空", "比赛序号空", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
             }
         }
     }
     else
     {
         MessageBox.Show("比赛名称不能为空", "比赛名称空", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
     }
 }
示例#5
0
 //查询参加某个比赛的球员信息列表
 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;
 }