private void dataGridView_schedule_CellClick(object sender, DataGridViewCellEventArgs e) { try { if (e.RowIndex >= 0) { label_MatchName.Text = Convert.ToString(this.dataGridView_schedule.Rows[e.RowIndex].Cells["matchName"].Value); label_seasonNum.Text = Convert.ToString(this.dataGridView_schedule.Rows[e.RowIndex].Cells["seasonNum"].Value); label_turn.Text = Convert.ToString(this.dataGridView_schedule.Rows[e.RowIndex].Cells["numOfTurn"].Value); textBox_homeTeam.Text = Convert.ToString(this.dataGridView_schedule.Rows[e.RowIndex].Cells["homeTeam"].Value); textBox_guestTeam.Text = Convert.ToString(this.dataGridView_schedule.Rows[e.RowIndex].Cells["guestTeam"].Value); label_gameDate.Text = Convert.ToString(this.dataGridView_schedule.Rows[e.RowIndex].Cells["gameDate"].Value); } else { MessageBox.Show("您当前选中的赛事没有设置赛季,请至少添加一个赛季!", "无赛季信息"); CreateNewSeason newSeason = new CreateNewSeason(); newSeason.Show(); } } catch (NullReferenceException ex) { Console.WriteLine(ex.ToString()); } }
//单击表格的单元格 private void dataGridView_match_CellClick(object sender, DataGridViewCellEventArgs e) { try { if (e.RowIndex >= 0) { try { matchID = Convert.ToInt32(dataGridView_match.Rows[e.RowIndex].Cells["match_ID"].Value); rowIndex = e.RowIndex; match = ContentDAO.getMatchInfo(matchID); textBox_Name.Text = match.getName(); // seasonList= SeasonInfoDAO.getSeasonsOfCertainMatch(match.getName()); this.cleanListBox(); ////如果当前赛事没有创建赛季,则弹窗要求创建一个赛季 if (seasonList.Count != 0) //存在相应的赛季 { listBox_Seasons.Items.Clear(); richTextBox_SeasonDescription.Text = ""; foreach (SeasonOfMatch s in seasonList) { listBox_Seasons.Items.Add("第" + s.getNumOfSeason() + "赛季"); } richTextBox_MatchDescription.Text = match.getDescription(); } else { MessageBox.Show("您当前选中的赛事没有设置赛季,请至少添加一个赛季!","无赛季信息"); SystemParam.setMatch(match); CreateNewSeason newSeason = new CreateNewSeason(); newSeason.Show(); } } catch (NullReferenceException ex) { Console.WriteLine(ex.ToString()); } } } catch { } }