//显示赛事的基本信息 public void showMatchData() { //先清除DataGridView中的数据 if (dataGridView_match.Rows.Count > 0) { dataGridView_match.Rows.Clear(); } //取出数据 List<SeasonMatch> list = ContentDAO.getMatchInfo(); //往dataGridView中添加数据 for (int i = 0; i < list.Count; i++) { match = list[i]; //取出线性表中的赛事的信息 dataGridView_match.Rows.Add(match.getID().ToString(), match.getName(), match.getDescription(), match.getSwitchNum().ToString(), match.getSerialNum().ToString()); } }
//显示数据方法 private void showData(SeasonMatch match) { textBox_name.Text = match.getName(); textBox_switchNum.Text = match.getSwitchNum().ToString(); textBox_serialNum.Text = match.getSerialNum().ToString(); richTextBox_description.Text = match.getDescription(); }
//显示某一比赛中可上场成员的信息 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(); } }
/// ///本类针对赛事信息的数据库处理 /// /* * 更新某一个赛事的信息 */ public static void updateMatchInfo(SeasonMatch match) { DBUtility dbutility = new DBUtility(); string sql = "update matchinfo set seasonName='"+match.getName()+"' ,description='"+match.getDescription(); sql = sql + "' ,switchNum=" + match.getSwitchNum() + " ,serialNum=" + match.getSerialNum(); sql = sql + " where ID=" + match.getID(); try { dbutility.openConnection(); dbutility.ExecuteUpdate(sql); } catch (MySqlException ex) { Console.WriteLine(ex.ToString()); } finally { dbutility.Close(); } }