private void btnKaydet_Click(object sender, EventArgs e) { try { LinqTODataContext ctx = new LinqTODataContext(); Ogrenci ogr = ctx.Ogrencis.FirstOrDefault(t => t.TCKN == textTCKN.Text); if (ogr != null) { throw new Exception("Aynı tc ile ögrenci mevcut"); } ogr = new Ogrenci(); ogr.TCKN = textTCKN.Text; ogr.Adi = textAdi.Text; ogr.Soyadi = textSoyadi.Text; ogr.OkulNo = int.Parse(textOkulNo.Text); ogr.DogumTarihi = Convert.ToDateTime(dateTimePickerDogumTarihi.Value.Date); ogr.VeliID = (int)comboBoxVeliID.SelectedValue; ctx.Ogrencis.InsertOnSubmit(ogr); ctx.SubmitChanges(); //dataGridView1.DataSource = ctx.Ogrencis; LoadSonuc(); clear(); MessageBox.Show("Kayıt Eklenmiştir."); } catch (Exception ex) { MessageBox.Show(ex.Message, "Dikkat !!!"); } }
private void btnEkle_Click(object sender, EventArgs e) { LinqTODataContext ctx = new LinqTODataContext(); Ogretmen ogrt = new Ogretmen(); ogrt.Adi = textAdi.Text; ogrt.Soyadi = textSoyadi.Text; ogrt.DogumTarihi = Convert.ToDateTime(dateTimePickerDogumTarihi.Value.Date); ogrt.DersID = (int)comboBoxDersAdi.SelectedValue; ogrt.AktifMi = checkBoxAktifMi.Checked; ctx.Ogretmens.InsertOnSubmit(ogrt); ctx.SubmitChanges(); LoadSonuc(); Clear(); }
private void btnsil_Click(object sender, EventArgs e) { if (dataGridView1.CurrentRow == null) { return; } int ogrtID = (int)dataGridView1.CurrentRow.Cells["OgretmenId"].Value; LinqTODataContext ctx = new LinqTODataContext(); Ogretmen ogrt = ctx.Ogretmens.SingleOrDefault(og => og.OgretmenId == ogrtID); ctx.Ogretmens.DeleteOnSubmit(ogrt); ctx.SubmitChanges(); LoadSonuc(); Clear(); }
private void btnguncelle_Click(object sender, EventArgs e) { LinqTODataContext ctx = new LinqTODataContext(); int id = (int)textAdi.Tag; Ogretmen ogrt = ctx.Ogretmens.SingleOrDefault(og => og.OgretmenId == id); ogrt.Adi = textAdi.Text; ogrt.Soyadi = textSoyadi.Text; ogrt.DogumTarihi = Convert.ToDateTime(dateTimePickerDogumTarihi.Value.Date); ogrt.DersID = (int)comboBoxDersAdi.SelectedValue; ogrt.AktifMi = checkBoxAktifMi.Checked; ctx.SubmitChanges(); LoadSonuc(); Clear(); }
private void btnsil_Click(object sender, EventArgs e) { if (dataGridView1.CurrentRow == null) { return; } int ogrID = (int)dataGridView1.CurrentRow.Cells["OgrenciId"].Value; LinqTODataContext ctx = new LinqTODataContext(); Ogrenci o = ctx.Ogrencis.SingleOrDefault(ogr => ogr.OgrenciId == ogrID); ctx.Ogrencis.DeleteOnSubmit(o); ctx.SubmitChanges(); // dataGridView1.DataSource = ctx.Ogrencis; LoadSonuc(); clear(); MessageBox.Show("Kayıt Silinmiştir."); }
private void btnGuncelle_Click(object sender, EventArgs e) { LinqTODataContext ctx = new LinqTODataContext(); int id = (int)textAdi.Tag; Ogrenci o = ctx.Ogrencis.SingleOrDefault(x => x.OgrenciId == id); o.TCKN = textTCKN.Text; o.Adi = textAdi.Text; o.Soyadi = textSoyadi.Text; o.OkulNo = int.Parse(textOkulNo.Text); o.DogumTarihi = Convert.ToDateTime(dateTimePickerDogumTarihi.Value.Date); o.VeliID = (int)comboBoxVeliID.SelectedValue; ctx.SubmitChanges(); //dataGridView1.DataSource = ctx.Ogrencis; LoadSonuc(); clear(); MessageBox.Show("Kayıt Güncellenmiştir."); }