private void btn_bul_Click(object sender, EventArgs e) { Baglanti.Baglan(); if (cbox_ara.SelectedIndex == 0) { komut = new SqlCommand("SELECT * FROM Musteriler WHERE MusteriNo='" + tbox_ara.Text + "'", Baglanti.baglanti); } else if (cbox_ara.SelectedIndex == 1) { komut = new SqlCommand("SELECT * FROM Musteriler WHERE TCKimlik='" + tbox_ara.Text + "'", Baglanti.baglanti); } else { komut = new SqlCommand("SELECT * FROM Musteriler WHERE Ad+' '+Soyad='" + tbox_ara.Text + "'", Baglanti.baglanti); } MusteriSorgula(); Baglanti.Kapat(); }
void Kaydet() { komut = new SqlCommand("INSERT INTO Musteriler(MusteriNo,TCKimlik,Ad,Soyad,Yas,MedeniHal,Cinsiyet) VALUES (@musteri_no,@tc_kimlik,@ad,@soyad,@yas,@medeni_hal,@cinsiyet) SELECT scope_identity()", Baglanti.baglanti); Baglanti.Baglan(); komut.Parameters.AddWithValue("@musteri_no", textBox_musteri_no.Text); komut.Parameters.AddWithValue("@tc_kimlik", textBox_tc.Text); komut.Parameters.AddWithValue("@ad", textBox_ad.Text); komut.Parameters.AddWithValue("@soyad", textBox_soyad.Text); komut.Parameters.AddWithValue("@yas", int.Parse(textBox_yas.Text)); komut.Parameters.AddWithValue("@medeni_hal", comboBox_medeni.Text); komut.Parameters.AddWithValue("@cinsiyet", comboBox_cinsiyet.Text); int musteri_id = Convert.ToInt32(komut.ExecuteScalar()); komut = new SqlCommand("INSERT INTO Iletisim_bilgileri(Telefon,Email,Adres,Musteri_id) VALUES (@telefon,@mail,@adres,@musteri_id)", Baglanti.baglanti); komut.Parameters.AddWithValue("@telefon", textBox_telefon.Text); komut.Parameters.AddWithValue("@mail", textBox_mail.Text); komut.Parameters.AddWithValue("@adres", textBox_adres.Text); komut.Parameters.AddWithValue("@musteri_id", musteri_id); komut.ExecuteNonQuery(); Baglanti.Kapat(); }
private void cBox_tip_SelectedIndexChanged(object sender, EventArgs e) { Baglanti.Baglan(); SqlCommand komut = new SqlCommand("SELECT Isim FROM Odalar WHERE Limit='" + (cBox_tip.SelectedIndex + 1) + "' AND Durum='Boş'", Baglanti.baglanti); SqlDataReader oku; try { oku = komut.ExecuteReader(); comboBox_oda_no.Items.Clear(); while (oku.Read()) { comboBox_oda_no.Items.Add(oku["Isim"].ToString()); } oku.Close(); oku.Dispose(); Baglanti.Kapat(); } catch (Exception) { throw; } }