public void loadDataOfDatagridView()
 {
     //先清除dataGridView中的数据
     if (this.dataGridView_playerManage.Rows.Count > 0)
     {
         dataGridView_playerManage.Rows.Clear();
     }
     //取出数据
     List<FootballPlayer> list = ContentDAO.getPlayerInfoOfCertainTeam(selectedTeamName);
     for (int i = 0; i < list.Count;i++ )
     {
         player = list[i];
         dataGridView_playerManage.Rows.Add(player.getID(),player.getName(),player.getNumber(),player.getNumber().ToString(),player.getPostion(),player.getBelongTeam(),player.getIDnum());
     }
 }
 //显示赛事的基本信息
 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());
     }
 }
        private void addPlayerRecord()
        {
            //记录各个变量
            int matchID;  //比赛ID
            int playerID;  //球员ID
            int matchSerial;  //赛事轮次
            int yellowCardNum;  //黄牌数量
            int redCardNum;  //红牌数量
            DateTime dateTime;  //记录添加罚牌记录的日期

            if (textBox_matchName.Text == "" || textBox_playerName.Text == "")  //赛事名称和用户名称不能为空
            {
                MessageBox.Show("赛事名称或球员姓名不能为空","不能为空",MessageBoxButtons.OKCancel,MessageBoxIcon.Information);
            }
            else
            {
                matchID = _match.getID();  //记录赛事的编号
                //查询并获取球员信息
                _player = ContentDAO.getPlayerInfo(textBox_playerName.Text);
                playerID = _player.getID();
                if (textBox_matchSerial.Text != "")  //当比赛场次不是空时
                {
                    //检查是否是数字
                    if (!checkSwitchResult.checkStringSwitchInteger(textBox_matchSerial.Text))
                    {
                        MessageBox.Show("赛事轮次必须是数字", "非数字", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
                        return;
                    }
                    else //可以转换时
                    {
                        matchSerial = Convert.ToInt32(textBox_matchSerial.Text);
                    }
                }
                else  //比赛轮次是空时,记录其值为0
                {
                    matchSerial = 0;
                }
                if (textBox_yellowCardNum.Text != "")  //当黄牌数量不是空时
                {
                    //检查是否是数字
                    if (!checkSwitchResult.checkStringSwitchInteger(textBox_yellowCardNum.Text))
                    {
                        MessageBox.Show("黄牌数量必须是数字", "非数字", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
                        return;
                    }
                    else //可以转换时
                    {
                        yellowCardNum = Convert.ToInt32(textBox_yellowCardNum.Text);
                    }
                }
                else
                {
                    yellowCardNum = 0;
                }
                if (textBox_redCardNum.Text != "")  //红牌数量不是空时
                {
                    //检查是否是数字
                    if (!checkSwitchResult.checkStringSwitchInteger(textBox_redCardNum.Text))
                    {
                        MessageBox.Show("红牌数量必须是数字", "非数字", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
                        return;
                    }
                    else //可以转换时
                    {
                        redCardNum = Convert.ToInt32(textBox_redCardNum.Text);
                        if (yellowCardNum != 0 && yellowCardNum % SystemParam.getSwitchNum() == 0)
                        {
                            yellowCardNum = 0;
                        }
                    }
                }
                else
                {
                    redCardNum = 0;
                    if (yellowCardNum != 0 && yellowCardNum % SystemParam.getSwitchNum() == 0)  //若添加的黄牌数量可以转换成红牌时,直接将黄牌数变为0
                    {
                        yellowCardNum = 0;
                        redCardNum = 1;
                    }
                }
                //记录日期
                if (dateTimePicker_addCardRecord.Text != "")  //日期文本不是空时
                {
                    dateTime = dateTimePicker_addCardRecord.Value;
                }
                else  //日期文本是空时,直接设定当前日期为默认日期
                {
                    dateTime = DateTime.Today;
                }
                PlayerCardRecord _playerCardRecord = new PlayerCardRecord(matchID,playerID,matchSerial,yellowCardNum,redCardNum,dateTime);
                //往数据库中添加记录
                ContentDAO.addNewPlayerCardNum(_playerCardRecord);
                if (MessageBox.Show("添加罚牌信息成功,是否继续添加?", "添加罚牌成功", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                {
                    textBox_matchSerial.Text = "";
                    textBox_playerName.Text = "";
                    textBox_yellowCardNum.Text = "";
                    textBox_redCardNum.Text = "";
                }
                else
                {
                    this.Close();
                }
            }
        }
        /*
        * 更新某一个赛事的信息
        */
        public static bool updatePlayerInfo(FootballPlayer player)
        {
            DBUtility dbutility = new DBUtility();
            string sql = "update player set playerName='" + player.getName() + "',postion='" + player.getPostion()+ "' ,number=" + player.getNumber() +" ,teamName='" + player.getBelongTeam()+"' where ID =" + player.getID();

            try
            {
                dbutility.openConnection();
                dbutility.ExecuteUpdate(sql);
                return true;
            }
            catch (MySqlException ex)
            {
                Console.WriteLine(ex.ToString());
                return false;
            }
            finally
            {
                dbutility.Close();
            }
        }
 //显示未分配球队信息
 private void showNotAssignedPlayer()
 {
     if (dataGridView_notAssignedPlayer.Rows.Count > 0)  //若已经有记录,先清除记录
     {
         dataGridView_notAssignedPlayer.Rows.Clear();
     }
     //取出数据
     List<FootballPlayer> list = MatchPlayerInfoDAO.getNotAssignedPlayerInfo(SystemParam.getMatch().getID());
     //声明实例
     FootballPlayer player = new FootballPlayer();
     //往dataGridView中添加数据
     for (int i = 0; i < list.Count; i++)
     {
         player = list[i];  //取出线性表中的赛事的信息
         dataGridView_notAssignedPlayer.Rows.Add(player.getID().ToString(), player.getName(), player.getNumber().ToString(), player.getPostion(), player.getBelongTeam());
     }
 }