public List <Kullanici> ListeGetir() { List <Kullanici> kullanici = new List <Kullanici>(); try { using (CskHelper h = new CskHelper()) { SqlDataReader rd = h.GetData("Select * from Kullanici"); if (rd.HasRows) { if (rd.Read()) { Kullanici kul = new Kullanici(); kul.KullaniciAdi = rd["KullaniciAdi"].ToString(); kul.Ad = rd["Ad"].ToString(); kul.Soyad = rd["Soyad"].ToString(); kul.Sifre = rd["Sifre"].ToString(); kullanici.Add(kul);// eklediğim tüm (kul) leri (kullanici) listeme ekliyorum.. } } } } catch (Exception) { throw; } return(kullanici); }
public Kullanici Getir(int id) { Kullanici kul = new Kullanici(); try { using (CskHelper h = new CskHelper()) { SqlParameter[] p = { new SqlParameter("@id", id) }; SqlDataReader rd = h.GetData("Select * from Kullanici where @id=id", p); if (rd.HasRows) { if (rd.Read()) { kul.KullaniciAdi = rd["KullaniciAdi"].ToString(); kul.Ad = rd["Ad"].ToString(); kul.Soyad = rd["Soyad"].ToString(); kul.Sifre = rd["Sifre"].ToString(); } } } } catch (Exception) { throw; } return(kul); }
public bool Guncelle(Kullanici knesne) { bool result = false; try { using (CskHelper h = new CskHelper())//bağlantıyı kuruyorum burda.. { SqlParameter[] p = { new SqlParameter("@id", knesne.Id), new SqlParameter("@KullaniciAdi", knesne.KullaniciAdi), new SqlParameter("@Ad", knesne.Ad), new SqlParameter("Soyad", knesne.Soyad), new SqlParameter("Sifre", knesne.Sifre) }; result = h.ExecuteCommand("Update Kullanici Set KullaniciAdi=@KullaniciAdi,Ad=@Ad,Soyad=@Soyad,Sifre=@Sifre", p) > 0; } } catch (Exception) { throw; } return(result); }
public bool Ekle(Kullanici kNesne) { bool result = false; try { using (CskHelper h = new CskHelper())//bağlantıyı kuruyorum burda.. { SqlParameter[] p = { new SqlParameter("@KullaniciAdi", kNesne.KullaniciAdi), new SqlParameter("@Ad", kNesne.Ad), new SqlParameter("@Soyad", kNesne.Soyad), new SqlParameter("@Sifre", kNesne.Sifre) }; result = h.ExecuteCommand("Insert into Kullanici values(@KullaniciAdi,@Ad,@Soyad,@Sifre)", p) > 0; } } catch (Exception) { throw; } return(result); }
public Kullanici KullaniciDogrula(string KullaniciAdi, string Sifre) { Kullanici kullanici = null; try { using (CskHelper h = new CskHelper()) { SqlParameter[] p = { new SqlParameter("@KullaniciAdi", kullanici.KullaniciAdi), new SqlParameter("@Sifre", kullanici.Sifre) }; SqlDataReader rd = h.GetData("KullaniciDogrula", p); if (rd.HasRows) { rd.Read(); kullanici = new Kullanici(); kullanici.Id = Convert.ToInt32(rd["Id"]); kullanici.Ad = rd["Ad"].ToString(); kullanici.Soyad = rd["Soyad"].ToString(); kullanici.KullaniciAdi = rd["KullaniciAdi"].ToString(); kullanici.Sifre = rd["Sifre"].ToString(); } } } catch (Exception ex) { throw; } return(kullanici); }
public bool Guncelle(Musteri nesne)//Ekle metodu gibi ama Id eklenerek geliyor sadece.. { bool result = false; try { using (CskHelper h = new CskHelper()) { SqlParameter[] p = { new SqlParameter("@Id", nesne.Id), new SqlParameter("@Ad", nesne.Ad), new SqlParameter("@Soyad", nesne.Soyad), new SqlParameter("@Tc", nesne.Tc), new SqlParameter("@Telefon", nesne.Telefon), new SqlParameter("@Adres", nesne.Adres), new SqlParameter("@KayitTarihi", nesne.KayitTarihi), new SqlParameter("@GuncellenmeTarihi", nesne.GuncellenmeTarihi) }; result = h.ExecuteCommand("Update Musteri Set Ad=@Ad,Soyad=@Soyad,Tc=@Tc,Telefon=@Telefon,Adres=@Adres,KayitTarihi=@KayitTarihi,GuncellenmeTarihi=@GuncellenmeTarihi where Id=@Id", p) > 0; } } catch (Exception ex) { throw; } return(result); }
public bool Ekle(Musteri nesne) { bool result = false; try { using (CskHelper h = new CskHelper()) { SqlParameter[] p = { new SqlParameter("@Ad", nesne.Ad), new SqlParameter("@Soyad", nesne.Soyad), new SqlParameter("@Tc", nesne.Tc), new SqlParameter("@Telefon", nesne.Telefon), new SqlParameter("@Adres", nesne.Adres), new SqlParameter("@KaydiOlusturan", nesne.KaydiOlusturan), new SqlParameter("@GuncelleyenKisi", nesne.GuncelleyenKisi), new SqlParameter("@KayitTarihi", nesne.KayitTarihi), new SqlParameter("@GuncellenmeTarihi", nesne.GuncellenmeTarihi) }; result = h.ExecuteCommand("Insert into Musteri values(@Ad,@Soyad,@Tc,@Telefon,@Adres,@KaydiOlusturan,@GuncelleyenKisi,@KayitTarihi,@GuncellenmeTarihi)", p) > 0;// executecommand int döndüğü için sonucun 0'dan büyük olup olmadığı kontrol edilir. } } catch (Exception ex) { throw; } return(result); }
public List <Musteri> ListeGetir()// getir metodu gibi..burda tek bir nesne dönmeyeceği için list<> döneceği için list<> kullanılır.. { List <Musteri> clients = new List <Musteri>(); try { using (CskHelper h = new CskHelper()) //bağlantıyı kuruyorum burda.. { SqlDataReader rd = h.GetData("Select * from Musteri"); //bütün müsteri listemi okuyor.."Select * from Musteri" getdatanın parametresidir. if (rd.HasRows) //tabloda satır varsa.. { while (rd.Read()) // if değil bu sefer 1 satır yok cünkü birden fazla satır oldugu için satırları okudukca dönsün diyoruz.. { Musteri clnt = new Musteri(); // okunan satır için bir tane clnt nesnesi olustur, onların değerlerini data baseden al,bunu listeye ekle ardından tekrar yeni satırı oku.. clnt.Id = Convert.ToInt32(rd["Id"]); clnt.Ad = rd["Ad"].ToString(); clnt.Soyad = rd["Soyad"].ToString(); clnt.Tc = rd["Tc"].ToString(); clnt.Telefon = rd["Telefon"].ToString(); clnt.Adres = rd["Adres"].ToString(); clnt.KaydiOlusturan = rd["KaydiOlusturan"].ToString(); clnt.GuncelleyenKisi = rd["GuncelleyenKisi"].ToString(); clnt.KayitTarihi = Convert.ToDateTime(rd["KayitTarihi"]); clnt.GuncellenmeTarihi = Convert.ToDateTime(rd["GuncellenmeTarihi"]); clients.Add(clnt);// eklediğim tüm (clnt) leri (clients) listeme ekliyorum.. } } } } catch (Exception ex) { throw; } return(clients); }
public bool Sil(int Id) { bool result = false; try { using (CskHelper h = new CskHelper()) { SqlParameter[] p = { new SqlParameter("@id", Id) }; result = h.ExecuteCommand("Delete from Musteri where id=@id", p) > 0; } } catch (Exception ex) { throw; } return(result); }
public Musteri Getir(int id) { Musteri mus = new Musteri();//propertyleri almak için newledik.. try { using (CskHelper h = new CskHelper()) { SqlParameter[] p = { new SqlParameter("@id", id) }; SqlDataReader rd = h.GetData("Select * from Musteri where Id=@id", p); if (rd.HasRows) { if (rd.Read()) { mus.Ad = rd["Ad"].ToString(); mus.Soyad = rd["Soyad"].ToString(); mus.Tc = rd["Tc"].ToString(); mus.Telefon = rd["Telefon"].ToString(); mus.Adres = rd["Adres"].ToString(); mus.KaydiOlusturan = rd["KaydiOlusturan"].ToString(); mus.GuncelleyenKisi = rd["GuncelleyenKisi"].ToString(); mus.KayitTarihi = Convert.ToDateTime(rd["KayitTarihi"]); mus.GuncellenmeTarihi = Convert.ToDateTime(rd["GuncellenmeTarihi"]); } } } } catch (Exception ex) { throw; } return(mus); }