private void BtnEkle_Click(object sender, EventArgs e) { FrmStokSec form = new FrmStokSec(true); form.ShowDialog(); if (form.Secildi) { foreach (var itemStok in form.secilen) { Entities.Tables.Indirim _entity = new Entities.Tables.Indirim(); _entity = StokEkle(itemStok); var count = context.Indirimler.Count(c => c.KullaniciID == RoleTool.kullaniciEntity.KullaniciID && c.StokKodu == itemStok.StokKodu); if (count != 0) { if (XtraMessageBox.Show("Seçili olan stoğa daha önceden eklenmiş bir indirim bulunmaktadır./n Var olan indirimi güncellemek ister misiniz ?", "Uyarı", MessageBoxButtons.YesNo) == DialogResult.Yes) { var secilenId = context.Indirimler.SingleOrDefault(c => c.KullaniciID == RoleTool.kullaniciEntity.KullaniciID && c.StokKodu == itemStok.StokKodu); _entity.Id = secilenId.Id; _entity.KullaniciID = RoleTool.kullaniciEntity.KullaniciID; ındirimDal.AddOrUpDate(context, _entity); } } else { _entity.KullaniciID = RoleTool.kullaniciEntity.KullaniciID; ındirimDal.AddOrUpDate(context, _entity); } } } }
private void btnEkle_Click(object sender, EventArgs e) { FrmStokSec frm = new FrmStokSec(true); frm.ShowDialog(); if (frm.secildi) { foreach (var item in frm._Secilen) { Entities.Tables.Indirim _entity = new Entities.Tables.Indirim(); _entity = StokEkle(item); var count = context.Indirimler.Count(c => c.StokKodu == item.StokKodu); if (count != 0) { if (MessageBox.Show("Seçili Ürüne Daha Önceden Eklenmiş İndirim Bulunmaktadır. Var olan İndirimi Güncellemek İstermisiniz.?", "Uyarı", MessageBoxButtons.YesNo) == DialogResult.Yes) { var secilenId = context.Indirimler.SingleOrDefault(c => c.StokKodu == item.StokKodu); _entity.Id = secilenId.Id; indirimdal.AddOrUpdate(context, _entity); } } else { indirimdal.AddOrUpdate(context, _entity); } } } }
private BenimSalonum.Entities.Tables.Indirim StokEkle(Entities.Tables.Stok entity) { Entities.Tables.Indirim _entity = new Entities.Tables.Indirim(); _entity.StokKodu = entity.StokKodu; _entity.StokAdi = entity.StokAdi; _entity.Barkod = entity.Barkod; return(_entity); }