private void btn_tumu_listele_Click(object sender, EventArgs e) { Baglanti.Baglan(); komut = new SqlCommand("SELECT * FROM Musteriler ", Baglanti.baglanti); MusteriSorgula(); Baglanti.Kapat(); }
private void button_kaydet_Click(object sender, EventArgs e) { Baglanti.Baglan(); Kaydet(); MessageBox.Show("Veri başarı ile kayedildi"); Baglanti.Kapat(); }
public void Oda_Getir(SqlCommand cmd, bool renk1, bool renk2) { int oda_sayisi;//oda sayısı kadar buton oluşturmak için(boş/dolu/tümü) Baglanti.Baglan(); oku = cmd.ExecuteReader(); while (oku.Read()) { odalar.Add(oku["Isim"].ToString());//odalar listesine oda isimlerini ekliyoruz oda_limit.Add(oku["Limit"].ToString()); oda_durum.Add(oku["Durum"].ToString()); } oku.Close(); oku.Dispose(); Baglanti.Kapat(); oda_sayisi = odalar.Count; if (oda_sayisi > 0) { int x = 10, y = 20;//for buton position for (int i = 0; i < oda_sayisi; i++) { var buton = new Button(); buton.Text = odalar[i].ToString() + "\n" + oda_limit[i] + " kişilik"; buton.Width = 140; buton.Height = 50; buton.Location = new Point(x, y); if (renk1 == true && renk2 == false) { buton.BackColor = Color.Red; } else if (renk1 == false && renk2 == true) { buton.BackColor = Color.GreenYellow; } else { if (oda_durum[i] == "Dolu") { buton.BackColor = Color.Red; } else { buton.BackColor = Color.YellowGreen; } } buton.Click += new EventHandler(BosOdalarKlik); x += 160; if (i > 0 && i % 4 == 3) { x = 10; y += 70; } gBox.Controls.Add(buton); //groupBox içinde düzgün görünüm için } } }
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; } }