private void txtBarkod_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { MyContext db = new MyContext(); long barkod; if (!long.TryParse(txtBarkod.Text, out barkod)) { MessageBox.Show("Barkod Numarası Geçerli Aralıkt Değildir"); } //lstUrun.SelectedValue = long.Parse(txtBarkod.Text); lstUrun.SelectedValue = barkod; if (lstUrun.SelectedItem == null) { txtBarkod.Text = ""; MessageBox.Show("Böyle Bir Ürün Yoktur Önce Ürünü Kayıt Yaptırınız"); return; } var seciliUrun = lstUrun.SelectedItem as Urun; bool kontrol = StokKontrol(seciliUrun); if (!kontrol) { MessageBox.Show("Stokta olandan fazlasını sepete ekleyemezsiniz"); return; } bool varmi = false; sepetList.ForEach(x => { if (x.UrunId == seciliUrun.UrunId) { varmi = true; x.Adet += (short)nAdet.Value; } }); if (!varmi) { var model = new SepetView_Model() { UrunId = seciliUrun.UrunId, Indirim = nIndirim.Value, UrunAdi = seciliUrun.UrunAdi, fiyat = seciliUrun.SatisFiyat, KdvOrani = seciliUrun.Kategori.KdvOrani ?? 0, BarkodId = seciliUrun.BarkodNumarasi, Adet = (short)nAdet.Value }; sepetList.Add(model); } SepetGuncelle(); txtBarkod.Text = ""; wmp.URL = "C:\\Users\\Bireysel\\Desktop\\Sesler\\Bleep-SoundBible.com-1927126940.mp3"; wmp.controls.play(); } }
private void btnSepeteEkle_Click(object sender, EventArgs e) { if (lstUrun.SelectedItem == null) { return; } var seciliUrun = lstUrun.SelectedItem as Urun; bool kontrol = StokKontrol(seciliUrun); if (!kontrol) { MessageBox.Show("Stokta olandan fazlasını sepete ekleyemezsiniz"); return; } bool varmi = false; sepetList.ForEach(x => { if (x.UrunId == seciliUrun.UrunId) { varmi = true; x.Adet += (short)nAdet.Value; } }); if (!varmi) { var model = new SepetView_Model() { UrunId = seciliUrun.UrunId, Indirim = nIndirim.Value, UrunAdi = seciliUrun.UrunAdi, fiyat = seciliUrun.SatisFiyat, KdvOrani = seciliUrun.Kategori.KdvOrani ?? 0, BarkodId = seciliUrun.BarkodNumarasi, Adet = (short)nAdet.Value }; sepetList.Add(model); } SepetGuncelle(); }