public void SaveSeason(TBL_SEASON season) { using (_context = new LicenseDataContext()) { _context.TBL_SEASONs.InsertOnSubmit(season); _context.SubmitChanges(); }; }
private void btnSave_Click(object sender, EventArgs e) { if (!Invalid()) { try { using (TBL_SEASON_DATA_ACCESS sda = new TBL_SEASON_DATA_ACCESS()) { using (_context = new LicenseDataContext()) { TBL_SEASON season = new TBL_SEASON() { SEASON_NAME = txtSeasonName.Text, CREATE_BY = cboUser.Text, IS_ACTIVE = true, CREATE_DATE = DateTime.Now, NOTE = txtNote.Text.Trim() }; sda.SaveSeason(season); foreach (var item in sda.ShowSeasonNameByName(txtSeasonName.Text)) { SEASON_ID = item.SEASON_ID; } TBL_SCHEDULE schedule = new TBL_SCHEDULE(); foreach (var item in ListSchedule) { schedule.LICENSE_ID = item; schedule.SEASON_ID = SEASON_ID; sda.SaveSchedule(schedule); } this.Close(); }; } } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Error); } } else { } }
private void btnSave_Click(object sender, EventArgs e) { try { using (_context = new LicenseDataContext()) { TBL_SEASON season = (from s in _context.TBL_SEASONs where s.SEASON_ID == SEASON_ID select s).FirstOrDefault(); season.SEASON_NAME = txtSeasonName.Text.Trim().ToString(); season.NOTE = txtNote.Text.Trim().ToString(); if (ckUseAgain.Checked == true) { season.IS_ACTIVE = true; } _context.SubmitChanges(); } this.Close(); } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Error); } }
private void btnDelete_Click(object sender, EventArgs e) { SEASON_ID = 0; try { foreach (DataGridViewRow row in dataGridViewSeason.SelectedRows) { SEASON_ID = Convert.ToInt32(row.Cells[0].Value); } //MessageBox.Show(SEASON_ID.ToString()); if (SEASON_ID != 0) { using (LicenseDataContext _context = new LicenseDataContext()) { TBL_SEASON season = (from s in _context.TBL_SEASONs where s.SEASON_ID == SEASON_ID select s).FirstOrDefault(); season.IS_ACTIVE = false; _context.SubmitChanges(); }; } } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Error); GC.Collect(); } finally { using (TBL_SEASON_DATA_ACCESS sda = new TBL_SEASON_DATA_ACCESS()) { dataGridViewSeason.DataSource = sda.ShowAllSeasonIncludeInactive(); } } btnDelete.UseSelectable = false; }