예제 #1
0
 //获取dataTable
 private DataTable getDataMatchChart(SeasonMatch match)
 {
     //新建一个datatable
     DataTable dataTable = new DataTable();
     //为datatable添加列
     dataTable.Columns.Add("gameName");
     dataTable.Columns.Add("yellowCardNum");
     dataTable.Columns.Add("redCardNum");
     //声明变量
     DataRow dataRow;
     PlayerCardRecord playerCardRecord;
     //取出比赛的所有罚牌记录
     List<PlayerCardRecord> list = MatchCardRecordDAO.getMatchCardRecord(match.getID());
     for (int i = 0; i < list.Count; i++)
     {
         playerCardRecord = list[i];
         dataRow = dataTable.NewRow();
         //设置数据内容
         dataRow["gameName"] = playerCardRecord.getGameName();
         dataRow["yellowCardNum"] = playerCardRecord.getYellowCardNum();
         dataRow["redCardNum"] = playerCardRecord.getRedCardNum();
         //添加数据行
         dataTable.Rows.Add(dataRow);
     }
         //为dataTable添加数据内容
         return dataTable;
 }
예제 #2
0
 //显示赛事的基本信息
 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());
     }
 }
예제 #3
0
 //显示数据到表格中
 private void showDataInfo(SeasonMatch match)
 {
     Game game;  //用来记录信息
     if (dataGridView_gameInfo.Rows.Count > 0)
     {
         dataGridView_gameInfo.Rows.Clear();  //清空表格
     }
     List<Game> list = GameInfoDAO.getMatchGameInfo(match.getID());
     for (int i=0; i < list.Count; i++)
     {
         game = list[i];
         //往表格中添加记录
         dataGridView_gameInfo.Rows.Add(game.getUniqueID().ToString(),game.getMatchID().ToString(),game.getGameName(),
             game.getMatchGameNum().ToString(),game.getHomeTeam(),game.getGuestTeam(),game.getGameWinner(),
             game.getGameResult(),game.getGameAddress(),game.getGameDate().ToLongDateString());
     }
 }
예제 #4
0
 //显示表格中的数据信息
 private void showDataInfo(SeasonMatch match)
 {
     //清空表格
     if (dataGridView_gameInfo.Rows.Count > 0)
     {
         dataGridView_gameInfo.Rows.Clear();
     }
     //声明一个变量
     PlayerCardRecord cardRecord;
     //获取某一赛事中的所有罚牌记录信息
     List<PlayerCardRecord> list = MatchCardRecordDAO.getMatchPlayerCardRecord(match.getID());
     for (int i = 0; i < list.Count; i++)
     {
         cardRecord = list[i];
         dataGridView_gameInfo.Rows.Add(cardRecord.getUniqueID().ToString(),cardRecord.getMatchID().ToString(),
             cardRecord.getMatchName(),cardRecord.getPlayerID().ToString(),cardRecord.getPlayerName(),
             cardRecord.getYellowCardNum().ToString(),cardRecord.getRedCardNum().ToString(),
             cardRecord.getSerialNum().ToString(),cardRecord.getDateTime().ToLongDateString());
     }
 }
예제 #5
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);
     }
 }
예제 #6
0
 //初始显示窗体时,调用已经打开的赛事信息
 private void showDataInfo(SeasonMatch match)
 {
     //读取赛事信息,并且在文本框中显示
     textBox_matchName.Text = match.getName();
     textBox_matchGameNum.Text = match.getSerialNum().ToString();
     //获取已经存放的比赛的最大序号
     int _maxGameNum = GameInfoDAO.getMatchMaxGameNum(match.getID());
     textBox_gameNum.Text = (_maxGameNum + 1).ToString();
 }
예제 #7
0
 //加载下拉列表信息
 private void loadBaseInfo(SeasonMatch match)
 {
     this.bingComboBox(match.getID());
 }
예제 #8
0
 //显示赛事的基本信息
 private void showPlayerData(SeasonMatch match)
 {
     //先清除DataGridView中的数据
     if (dataGridView_playerManage.Rows.Count > 0)
     {
         dataGridView_playerManage.Rows.Clear();
     }
     //取出数据
     List<FootballPlayer> list = MatchPlayerInfoDAO.getAssignedPlayerInfo(match.getID());
     //往dataGridView中添加数据
     for (int i = 0; i < list.Count; i++)
     {
         player = list[i];  //取出线性表中的赛事的信息
         dataGridView_playerManage.Rows.Add(player.getID().ToString(), player.getName(), player.getNumber().ToString(), player.getPostion(), player.getBelongTeam());
     }
 }
예제 #9
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();
     }
 }
예제 #10
0
 ///
 ///本类针对赛事信息的数据库处理
 ///
 /*
  * 更新某一个赛事的信息
  */
 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();
     }
 }