private void IsYeriEkle(string isim, string isyerituru, long telefonnumarasi, string il, string ilce, string cadde, string mahalle, string sokak) { IsYeriDBEntity IsYeriDB = new IsYeriDBEntity(); IsYeri isyeri = new IsYeri { Isim = isim, IsYeriTuru = isyerituru, TelefonNumarasi = telefonnumarasi }; isyeri.adres.Il = il; isyeri.adres.Ilce = ilce; isyeri.adres.Cadde = cadde; isyeri.adres.Mahalle = mahalle; isyeri.adres.Sokak = sokak; IsYeriDB.Ekle(isyeri); EkranTemizle(tabIsYeriIslemleri); IsYeriListele(); }
public void Ekle(IsYeri isyeri) { try { SqlConnection Connection = new SqlConnection(ConnectionString); SqlCommand Command = new SqlCommand("Insert Into tbl_IsYeri (Isim, IsYeriTuru," + "TelefonNumarasi, il, ilce, Cadde, Mahalle, " + "Sokak) values (@parIsim, @parIsyeriTuru, " + "@parTelefonNumarasi, @paril, @parilce, " + "@parCadde, @parMahalle, @parSokak)", Connection); Command.Parameters.AddWithValue("parIsim", isyeri.Isim); Command.Parameters.AddWithValue("parIsyeriTuru", isyeri.IsYeriTuru); Command.Parameters.AddWithValue("parTelefonNumarasi", isyeri.TelefonNumarasi); Command.Parameters.AddWithValue("paril", isyeri.adres.Il); Command.Parameters.AddWithValue("parilce", isyeri.adres.Ilce); Command.Parameters.AddWithValue("parCadde", isyeri.adres.Cadde); Command.Parameters.AddWithValue("parMahalle", isyeri.adres.Mahalle); Command.Parameters.AddWithValue("parSokak", isyeri.adres.Sokak); Connection.Open(); Command.ExecuteNonQuery(); Connection.Close(); } catch (Exception ex) { throw ex; } }