private void btnEkle_Click(object sender, EventArgs e)
{
barkodkontrol();
if (durum==true)
{
baglanti.Open();
SqlCommand komut = new SqlCommand("insert into sepet(tc,adsoyad,telefon,barkodno,urunadi,miktari,satisfiyati,toplamfiyati,tarih)values(@tc,@adsoyad,@telefon,@barkodno,@urunadi,@miktari,@satisfiyati,@toplamfiyati,@tarih)", baglanti);
komut.Parameters.AddWithValue("@tc", txtTc.Text);
komut.Parameters.AddWithValue("@adsoyad", txtAdSoyad.Text);
komut.Parameters.AddWithValue("@telefon", txtTelefon.Text);
komut.Parameters.AddWithValue("@barkodno", txtBarkodNo.Text);
komut.Parameters.AddWithValue("@urunadi", txtÜrünAdi.Text);
komut.Parameters.AddWithValue("@miktari", int.Parse(txtMiktari.Text));
komut.Parameters.AddWithValue("@satisfiyati", double.Parse(txtSatisFiyati.Text));
komut.Parameters.AddWithValue("@toplamfiyati", double.Parse(txtToplamFiyati.Text));
komut.Parameters.AddWithValue("@tarih", DateTime.Now.ToString());
komut.ExecuteNonQuery();
baglanti.Close();
}
else
{
baglanti.Open();
SqlCommand komut2 = new SqlCommand("update sepet miktari=miktari+'"+ int.Parse(txtMiktari.Text )+ "'where barkodno='" + txtBarkodNo.Text + "'", baglanti);
komut2.ExecuteNonQuery();
SqlCommand komut3 = new SqlCommand("update sepet toplamfiyati=miktari*satisfiyati where barkodno='" + txtBarkodNo.Text + "'", baglanti);
komut3.ExecuteNonQuery();
baglanti.Close();
}
txtMiktari.Text = "0";
daset.Tables["sepet"].Clear();
sepetlistele();
hesapla();
foreach (Control item in groupBox2.Controls)
{
if (item is TextBox)
{
if (item != txtMiktari)
{
item.Text = "";
}
}
}
}
{
barkodkontrol();
if (durum==true)
{
baglanti.Open();
SqlCommand komut = new SqlCommand("insert into sepet(tc,adsoyad,telefon,barkodno,urunadi,miktari,satisfiyati,toplamfiyati,tarih)values(@tc,@adsoyad,@telefon,@barkodno,@urunadi,@miktari,@satisfiyati,@toplamfiyati,@tarih)", baglanti);
komut.Parameters.AddWithValue("@tc", txtTc.Text);
komut.Parameters.AddWithValue("@adsoyad", txtAdSoyad.Text);
komut.Parameters.AddWithValue("@telefon", txtTelefon.Text);
komut.Parameters.AddWithValue("@barkodno", txtBarkodNo.Text);
komut.Parameters.AddWithValue("@urunadi", txtÜrünAdi.Text);
komut.Parameters.AddWithValue("@miktari", int.Parse(txtMiktari.Text));
komut.Parameters.AddWithValue("@satisfiyati", double.Parse(txtSatisFiyati.Text));
komut.Parameters.AddWithValue("@toplamfiyati", double.Parse(txtToplamFiyati.Text));
komut.Parameters.AddWithValue("@tarih", DateTime.Now.ToString());
komut.ExecuteNonQuery();
baglanti.Close();
}
else
{
baglanti.Open();
SqlCommand komut2 = new SqlCommand("update sepet miktari=miktari+'"+ int.Parse(txtMiktari.Text )+ "'where barkodno='" + txtBarkodNo.Text + "'", baglanti);
komut2.ExecuteNonQuery();
SqlCommand komut3 = new SqlCommand("update sepet toplamfiyati=miktari*satisfiyati where barkodno='" + txtBarkodNo.Text + "'", baglanti);
komut3.ExecuteNonQuery();
baglanti.Close();
}
txtMiktari.Text = "0";
daset.Tables["sepet"].Clear();
sepetlistele();
hesapla();
foreach (Control item in groupBox2.Controls)
{
if (item is TextBox)
{
if (item != txtMiktari)
{
item.Text = "";
}
}
}
}