//显示赛事的基本信息 public void showSeasonData() { //先清除DataGridView中的数据 if (dataGridView_seasons.Rows.Count > 0) { dataGridView_seasons.Rows.Clear(); } //取出数据 //此处应该判断一下当前选择赛事与赛季没有 List<SeasonOfMatch> list = SeasonInfoDAO.getSeasonsOfCertainMatch(SystemParam.getMatch().getName()); //往dataGridView中添加数据 for (int i = 0; i < list.Count; i++) { season = list[i]; //取出线性表中的赛事的信息 dataGridView_seasons.Rows.Add(season.getId().ToString(), season.getmatchName(), season.getSeasonDescription(), season.getNumOfSeason().ToString() ); } }
/**** *** 新增某一个赛季的信息 ****/ public static void addNewSeasonInfo(SeasonOfMatch season) { DBUtility dbutility = new DBUtility(); string sql = "insert into gameseason(id,matchname,numofseason,seasondescription,isCurrentSeason,numOfTurn) values('" + season.getId() +"','" + season.getmatchName() + "','" + season.getNumOfSeason() + "','" + season.getSeasonDescription() + "',"+1+","+season.getNumOfTurn()+")"; try { dbutility.openConnection(); dbutility.ExecuteUpdate(sql); } catch (MySqlException ex) { Console.WriteLine(ex.ToString()); } finally { dbutility.Close(); } }
//选择的值改变,则下边的赛季描述改变 private void listBox_Seasons_SelectedIndexChanged(object sender, EventArgs e) { if(seasonList.Count>0){ foreach (SeasonOfMatch s in seasonList) { if (listBox_Seasons.SelectedItem.ToString().Trim() == ("第" + s.getNumOfSeason() + "赛季")) //此处仍然存在空值问题 { season = s; //作为选定的赛季 richTextBox_SeasonDescription.Text = season.getSeasonDescription(); } } } }