private void ControlSurvey_Load(object sender, EventArgs e) { cboSeason.SelectedIndexChanged -= new EventHandler(cboSeason_SelectedIndexChanged); using (sda = new TBL_SEASON_DATA_ACCESS()) { cboSeason.DataSource = sda.ShowAllSeason(); cboSeason.DisplayMember = "SEASON_NAME"; cboSeason.ValueMember = "SEASON_ID"; dataGridViewSurvey.DataSource = sda.ShowSurvey(Convert.ToInt32(cboSeason.SelectedValue)); } cboSeason.SelectedIndexChanged += new EventHandler(cboSeason_SelectedIndexChanged); }
public void ckShowAllSeason_CheckedChanged(object sender, EventArgs e) { // by Sieng Sotheara 2016-4-28 if (ckShowAllSeason.Checked == true) { using (TBL_SEASON_DATA_ACCESS sda = new TBL_SEASON_DATA_ACCESS()) { DataTable dt = new DataTable(); dt.Columns.Add("SEASON_ID"); dt.Columns.Add("SEASON_NAME"); DataRow row1 = dt.NewRow(); row1[0] = 0; row1[1] = Properties.Resources.ALL_SEASON; dt.Rows.Add(row1); foreach (var item in sda.ShowAllSeason()) { DataRow row = dt.NewRow(); row[0] = item.SEASON_ID; row[1] = item.SEASON_NAME; dt.Rows.Add(row); } cboSeason.DataSource = dt; cboSeason.DisplayMember = "SEASON_NAME"; cboSeason.ValueMember = "SEASON_ID"; }; } else { using (TBL_SEASON_DATA_ACCESS sda = new TBL_SEASON_DATA_ACCESS()) { cboSeason.DataSource = sda.ShowSeason(); }; } GC.Collect(); }