private void btnDelete_Click(object sender, EventArgs e) { if (MessageBox.Show("Are you sure you want to delete this profile?", "Delete Profile", MessageBoxButtons.YesNo) == DialogResult.Yes) { context.Users.Remove(selectedUser); context.SaveChanges(); } resetForm(); }
private void btnReturn_Click(object sender, EventArgs e) { int movieId = (int)dataGridView1.CurrentRow.Cells[0].Value; BorrowHistory borrowHistory = context.BorrowHistories.Where(b => b.UserId == returningUser.UserId && b.MovieId == movieId && DateTime.Compare(b.ReturnDate, new DateTime(1910, 1, 1, 0, 0, 0)) < 0).FirstOrDefault(); borrowHistory.ReturnDate = DateTime.Now; // Removing movie from the form (Auto update) Movie returnedMovie = context.Movies.Where(m => m.MovieId == movieId).FirstOrDefault(); movieList.Remove(returnedMovie); // Save to DB context.SaveChanges(); MessageBox.Show("Movie Returned Successfully!"); }