protected void ButtonFakulteEkle_Click(object sender, EventArgs e) { try { vtys6Entities db = new vtys6Entities(); tFakulte fakulte = new tFakulte(); fakulte.fakulteAd = TextBoxFakulteAdi.Text.ToString(); db.tFakultes.Add(fakulte); db.SaveChanges(); errorLabel.Text = "Kayıt Başarılı"; FakulteBilgileriniGetir(); } catch (Exception) { errorLabel.Text = "Kayıt Başarısız."; } }
protected void ButtonFakulteSil_Click(object sender, EventArgs e) { try { vtys6Entities db = new vtys6Entities(); tFakulte fakulte = new tFakulte(); int id = Convert.ToInt32(TextBoxFakulteId.Text); var sorgu = db.tFakultes.Where(w => w.fakulteID == id).FirstOrDefault(); db.tFakultes.Remove(sorgu); db.SaveChanges(); errorLabel.Text = "Başarılı"; FakulteBilgileriniGetir(); } catch (Exception) { errorLabel.Text = " Başarısız."; } }
protected void ButtonBolumEkle_Click(object sender, EventArgs e) { try { vtys6Entities db = new vtys6Entities(); tBolum bolum = new tBolum(); bolum.bolumAd = TextBoxBolumAdi.Text; bolum.fakulteID = Int32.Parse(DropDownListFakulte.SelectedValue); db.tBolums.Add(bolum); db.SaveChanges(); errorLabel.Text = "Kayıt Başarılı"; BolumBilgileriniGetir(); } catch (Exception) { errorLabel.Text = "Kayıt Başarısız."; } }
protected void ButtonFakulteGuncelle_Click(object sender, EventArgs e) { try { vtys6Entities db = new vtys6Entities(); tFakulte fakulte = new tFakulte(); int id = Convert.ToInt32(TextBoxFakulteId.Text); tFakulte sorgu = (from f in db.tFakultes where f.fakulteID == id select f).First(); sorgu.fakulteAd = TextBoxFakulteAd.Text; db.SaveChanges(); errorLabel.Text = "Başarılı"; FakulteBilgileriniGetir(); } catch (Exception) { errorLabel.Text = " Başarısız."; } }
protected void ButtonOgrenciEkle_Click(object sender, EventArgs e) { try { vtys6Entities db = new vtys6Entities(); tOgrenci ogrenci = new tOgrenci(); ogrenci.ad = TextBoxOgrenciAd.Text; ogrenci.soyad = TextBoxOgrenciSoyad.Text; ogrenci.bolumID = Int32.Parse(DropDownListBolum.SelectedValue); db.tOgrencis.Add(ogrenci); db.SaveChanges(); errorLabel.Text = "Kayıt Başarılı"; OgrenciBilgileriniGetir(); } catch (Exception) { errorLabel.Text = "Kayıt Başarısız."; } }