private void btn_delete_Click(object sender, EventArgs e) { Toast toast = new Toast(); Dialog dialog = new Dialog(); id = Convert.ToInt32(gridView1.GetFocusedRowCellValue("ID")); if (id > 0) { try { var rs = MessageBox.Show("عملية حذف", "هل انت متاكد من هذه العملية", MessageBoxButtons.YesNo); if (rs == DialogResult.Yes) { tb_sell = db.TB_SELL.Where(x => x.ID == id).FirstOrDefault(); db.Entry(tb_sell).State = EntityState.Deleted; db.SaveChanges(); toast.txt_caption.Text = "تم حذف عملية البيع"; toast.Show(); update_data(); } } catch { } } else { dialog.txt_caption.Text = "لا توجد عملية لحذفها"; dialog.Width = this.Width; dialog.Show(); } }
private void btn_delete_Click(object sender, EventArgs e) { id = Convert.ToInt32(gridView1.GetFocusedRowCellValue("ID_SELL")); var res = MessageBox.Show("هل انت متأكد من حذف البیع ؟؟", "عملية الحذف", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (res == DialogResult.Yes) { tb_sell = dbs.TB_SELL.Where(x => x.ID_SELL == id).FirstOrDefault(); dbs.Entry(tb_sell).State = System.Data.Entity.EntityState.Deleted; dbs.SaveChanges(); MessageBox.Show("تم عملية الحذف بالنجاح", " تم عملية الحذف", MessageBoxButtons.OK, MessageBoxIcon.Information); update_data(); } else { return; } }