private void btnKaydet_Click(object sender, EventArgs e) { UrunBL ubl = new UrunBL(); foreach (DataRow item in dt.Rows) { Urun u = new Urun(); if (item.RowState != DataRowState.Deleted) { u.Urunadi = item["Urunadi"].ToString(); u.KategoriId = Convert.ToInt32(item["KategoriId"]); u.UrunId = Convert.ToInt32(item["UrunId"]); u.Stok = Convert.ToInt32(item["Stok"]); u.Urunfiyat = float.Parse(item["Urunfiyati"].ToString()); } switch (item.RowState) { case DataRowState.Added: ubl.UrunEkle(u); break; case DataRowState.Deleted: ubl.UrunSil((int)item["UrunId", DataRowVersion.Original]); break; case DataRowState.Modified: break; default: break; } } }
private void btnSil_Click(object sender, EventArgs e) { if (MessageBox.Show("Silme İşlemini Onaylıyor Musunuz?", "İşlem Onay", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { urunBL = new UrunBL(); if (urunBL.UrunSil(this.urunId)) { MessageBox.Show("Ürününüz Silindi", "İşlem Başarılı", MessageBoxButtons.OK, MessageBoxIcon.Information); Temizle(); Listele(); } } else { MessageBox.Show("İşlem İptal Edildi", "İşlem İptal", MessageBoxButtons.OK, MessageBoxIcon.Information); } }