private void DersKayitAc(int DersAdi)
 {
     try
     {
         edit = true;
         ogrenciIsleriDataContext db  = new ogrenciIsleriDataContext();
         tblDersKayit             drs = db.tblDersKayits.First(x => x.Id == DersId);
         txtDersAdi.Text = drs.DersAdi;
         cbBolumAdi.Text = drs.tblBolum.BolumAdi;
         cbOgretmen.Text = drs.tblOgrtGorevlisi.OgrtAdi;
     }
     catch (Exception)
     {
     }
 }
 void Kaydet()
 {
     try
     {
         tblDersKayit drs = new tblDersKayit();
         drs.DersAdi = txtDersAdi.Text;
         drs.BolumId = cbBolumAdi.Text != "" ? db.tblBolums.First(x => x.BolumAdi == cbBolumAdi.Text).Id : -1;
         drs.OgrtId  = cbOgretmen.Text != "" ? db.tblOgrtGorevlisis.First(x => x.OgrtAdi == cbOgretmen.Text).Id : -1;
         db.tblDersKayits.InsertOnSubmit(drs);
         db.SubmitChanges();
         MessageBox.Show("Ders Kaydı Tamamlandı");
         temizle();
     }
     catch (Exception e)
     {
         MessageBox.Show("Hata" + e);
     }
 }
 private void Guncelle()
 {
     try
     {
         ogrenciIsleriDataContext db       = new ogrenciIsleriDataContext();
         tblDersKayit             drsKayit = db.tblDersKayits.First(x => x.Id == DersId);
         drsKayit.DersAdi = txtDersAdi.Text;
         drsKayit.BolumId = cbBolumAdi.Text != "" ? db.tblBolums.First(x => x.BolumAdi == cbBolumAdi.Text).Id : -1;
         drsKayit.OgrtId  = cbOgretmen.Text != "" ? db.tblOgrtGorevlisis.First(x => x.OgrtAdi == cbOgretmen.Text).Id : -1;
         db.SubmitChanges();
         MessageBox.Show("Guncelleme Basarılı");
         temizle();
         Close();
         F.DersKayit();
     }
     catch (Exception)
     {
         MessageBox.Show("Guncelleme Hatası");
     }
 }