private void btnXoa_Click(object sender, EventArgs e) { int r = dgvQLSach.CurrentCell.RowIndex; int rSelected = (int)dgvQLSach.Rows[r].Cells[0].Value; DialogResult traloi; traloi = MessageBox.Show("Ban co muon xoa mau tin nay ko?", "Tra loi" , MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (traloi == DialogResult.Yes) { db.Configuration.LazyLoadingEnabled = false; string Tensach = txtTenSach.Text; db.sp_Delete_Book(Tensach); //using (var db = new Model1()) //{ // db.Configuration.LazyLoadingEnabled = false; // var query = from d in db.SACHes // where d.MASACH == rSelected // select d; // foreach (var MASACH in query) // { // db.SACHes.Remove(MASACH); // } // db.SaveChanges(); //} db.SaveChanges(); LoadData(); MessageBox.Show("Da Xoa Xong!"); } //else //{ // MessageBox.Show("Ban Da Bam Khong!"); //} }