namespace BusinessLayer { public class StudentData:IDataManagement<Ogrenci> { private List<Ogrenci> ogrenci = null; public int kimlikno { get; set; } public string ad { get; set; } public string soyad { get; set; } public DateTime dogumtarihi { get; set; } public string adres { get; set; } public void NextStudent() { if (kimlikno <= ogrenci.Count - 1) { kimlikno++; } } public void PriorStudent() { if (kimlikno > 0) { kimlikno--; } } public void AddStudent(Ogrenci t) { using (OgrenciDBEntities db = new OgrenciDBEntities()) { db.Ogrenci.Add(new Ogrenci { Ad=ad, Soyad = soyad, DogumTarihi = Convert.ToDateTime(dogumtarihi), Adres = adres }); db.SaveChanges(); } } public void DeleteStudent(Ogrenci t) { if (kimlikno != 0) { using (OgrenciDBEntities db = new OgrenciDBEntities()) { Ogrenci ogr = db.Ogrenci.Where(o => o.KimlikNumarasi == kimlikno).FirstOrDefault(); db.Ogrenci.Remove(ogr); db.SaveChanges(); } } } public void ListStudent() { using (OgrenciDBEntities db = new OgrenciDBEntities()) { var ogrenci = (from o in db.Ogrenci select new { kimlikno = o.KimlikNumarasi, ad = o.Ad, soyad = o.Soyad, dogumtarihi = o.DogumTarihi, adres = o.Adres } ).ToList(); } } public void UpdateStudent() { if (kimlikno != 0) { using (OgrenciDBEntities db = new OgrenciDBEntities()) { Ogrenci ogr = db.Ogrenci.Where(o => o.KimlikNumarasi == kimlikno).FirstOrDefault(); ogr.Ad = ad; ogr.KimlikNumarasi = Convert.ToInt16(kimlikno); ogr.Soyad = soyad; ogr.DogumTarihi = dogumtarihi; ogr.Adres = adres; db.SaveChanges(); } } } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)