//显示赛事的基本信息 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()); } }
//显示数据方法 private void showData(SeasonMatch match) { textBox_name.Text = match.getName(); textBox_switchNum.Text = match.getSwitchNum().ToString(); textBox_serialNum.Text = match.getSerialNum().ToString(); richTextBox_description.Text = match.getDescription(); }
//单击表格的单元格 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 { } }
private void dataGridView_match_KeyUp(object sender, KeyEventArgs e) { try { matchID = Convert.ToInt32(dataGridView_match.SelectedRows[0].Cells["match_ID"].Value); rowIndex = dataGridView_match.SelectedRows[0].Index; match = ContentDAO.getMatchInfo(matchID); textBox_Name.Text = match.getName(); // seasonList = SeasonInfoDAO.getSeasonsOfCertainMatch(match.getName()); listBox_Seasons.Items.Clear(); richTextBox_SeasonDescription.Text = ""; foreach (SeasonOfMatch s in seasonList) { listBox_Seasons.Items.Add("第" + s.getNumOfSeason() + "赛季"); } richTextBox_MatchDescription.Text = match.getDescription(); } catch (NullReferenceException ex) { Console.WriteLine(ex.ToString()); } }
/// ///本类针对赛事信息的数据库处理 /// /* * 更新某一个赛事的信息 */ 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(); } }