private void BtnKaydet_Click(object sender, EventArgs e) { if (TbAd.Text == null || TbAd.Text == "" || TbAd.Text == " " || TbAdres.Text == null || TbAdres.Text == "" || TbAdres.Text == " " || TbSoyad.Text == null || TbSoyad.Text == "" || TbSoyad.Text == " " || TbTc.Text == null || TbTc.Text == "" || TbTel.Text == null || TbTel.Text == "") { MessageBox.Show("Boş Kutucuk Bırakmayınız"); } else { MusteriCrud mc = new MusteriCrud(); mc.ekle(TbTc.Text, TbAd.Text, TbSoyad.Text, TbTel.Text, TbAdres.Text); dataGridView1.DataSource = mc.tablolar(); } }
private void btnMusteriKaydet_Click(object sender, EventArgs e) { if (TbAd.Text == "" || TbAd.Text == " " || TbAdres.Text == "" || TbAdres.Text == " " || TbSoyad.Text == "" || TbSoyad.Text == " " || TbTc.Text == "" || TbTc.Text == null || TbTcEkle.Text == "" || TbTcEkle.Text == null || TbTel.Text == "" || TbTel.Text == " ") { MessageBox.Show("Lütfen Boş Kutucuk Bırakmayınız"); } else { if ((Cb_islem.SelectedItem).ToString() == "Ekle") { lblTc.Text = "TC:"; MusteriCrud mc = new MusteriCrud(); mc.ekle(TbTcEkle.Text, TbAd.Text, TbSoyad.Text, TbTel.Text, TbAdres.Text); } else if ((Cb_islem.SelectedItem).ToString() == "Güncelle") { Database db = new Database(); if (db.baglanti.State == ConnectionState.Open) { db.baglanti.Close(); } try { db.baglanti.Open(); SqlCommand musteriBul = new SqlCommand("select musteri.musteri_id from musteri where musteri_tc=@musteri_tc", db.baglanti); musteriBul.Parameters.AddWithValue("@musteri_tc", TbTc.Text); SqlDataReader idOku = musteriBul.ExecuteReader(); if (idOku.Read()) { string id = idOku["musteri_id"].ToString(); MusteriCrud mc = new MusteriCrud(); mc.musteriGuncelle(TbTcEkle.Text, id, TbAd.Text, TbSoyad.Text, TbTel.Text, TbAdres.Text); } db.baglanti.Close(); } catch (Exception) { MessageBox.Show("Kişi Bilgileri bulunamadı !"); } finally { lblTc.Text = "TC:"; db.baglanti.Close(); } } } }