private void btnXoa_Click(object sender, EventArgs e) { int r = dgvQLNXB.CurrentCell.RowIndex; int rSelected = (int)dgvQLNXB.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; int MaNXB = int.Parse(txtNXB.Text); db.sp_Delete_Publisher(MaNXB); //using (var db = new Model1()) //{ // db.Configuration.LazyLoadingEnabled = false; // var query = from d in db.NXBs // where d.MANXB == rSelected // select d; // foreach (var MANXB in query) // { // db.NXBs.Remove(MANXB); // } // db.SaveChanges(); //} db.SaveChanges(); LoadData(); MessageBox.Show("Da Xoa Xong!"); } ClearData(); }