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()); } }
//往数据库中添加球员,返回是否添加成功的信息 public static bool addNewPlayer(FootballPlayer player) { DBUtility dbutility = new DBUtility(); string SQL = "insert into player(playerName,postion,teamName,number,playerIDnum) values('"; SQL = SQL + player.getName() + "','" + player.getPostion() + "','" + player.getBelongTeam() + "'," + player.getNumber() + ",'" +player.getIDnum() + "')"; try { dbutility.openConnection(); dbutility.ExecuteUpdate(SQL); return true; } catch (MySqlException ex) { Console.WriteLine(ex.ToString()); return false; } finally { dbutility.Close(); } }
//显示赛事的基本信息 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()); } }
/* * 更新某一个赛事的信息 */ 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 showAlterPlayerInfo(FootballPlayer player) { textBox_teamName.Text = player.getName(); textBox_teamLeader.Text = player.getNumber().ToString(); textBox_teamManager.Text = player.getPostion(); comboBox_teamName.Text = player.getBelongTeam(); }
//显示未分配球队信息 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()); } }