private void btnXoa_Click(object sender, EventArgs e) { DialogResult xoa = MessageBox.Show("Đồng ý xóa?", "Cảnh báo", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (xoa == DialogResult.Yes) { try { var context = new Dtb_NhaSachContext(); var delete = new Sach() { //Stt = int.Parse(this.dgvBook.CurrentRow.Cells[0].Value.ToString().Trim()), MaSach = this.dgvBook.CurrentRow.Cells[1].Value.ToString().Trim(), }; context.Remove <Sach>(delete); context.SaveChanges(); refreshControl(); sapXep(); loadDgvBook(); MessageBox.Show("Xóa thành công!!!!"); } catch { MessageBox.Show("đã xảy ra lỗi. vui lòng thử lại!"); return; } } }
public void delCthd() { var context = new Dtb_NhaSachContext(); var list = context.Chitiethoadons.Where(s => s.SoHd == int.Parse(this.txtMahd.Text.Trim())).ToList(); foreach (var item in list) { context.Remove <Chitiethoadon>(item); context.SaveChanges(); } }
public void delHd() { var context = new Dtb_NhaSachContext(); var hd = new Hoadon() { SoHd = int.Parse(this.txtMahd.Text.Trim()), }; context.Remove <Hoadon>(hd); context.SaveChanges(); }
private void btnXoa_Click(object sender, EventArgs e) { DialogResult xoa = MessageBox.Show("Đồng ý xóa?", "Cảnh báo", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (xoa == DialogResult.Yes) { var context = new Dtb_NhaSachContext(); var delete = new Thanhvien() { MaTv = int.Parse(this.dgvMember.CurrentRow.Cells[0].Value.ToString().Trim()), }; context.Remove <Thanhvien>(delete); context.SaveChanges(); refreshControl(); loadMember(); } }