public ActionResult Delete(Member Member) { Member.MemberID = (int)TempData["MemberID"]; MemberServices services = new MemberServices(); services.DeleteMember(Member); return(RedirectToAction("Index")); }
private void MemberRemoveButton_Click(object sender, RoutedEventArgs e) { MemberServices sr = new MemberServices(); int i = sr.DeleteMember(MemberIdTextBox.Text, MemberNameTextBox.Text); MembersListGrid.ItemsSource = sr.LoadData(); MemberIdTextBox.Text = ""; MemberNameTextBox.Text = ""; }
//Delete Member information private void btnDelete_Click(object sender, EventArgs e) { //Judgment if (dgvMember.Rows.Count == 0) { MessageBox.Show("No member information can be deleted!", "System Information", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } else if (dgvMember.CurrentCell.Selected == false) { MessageBox.Show("You must select a member's information before deleting it! ", "System Information", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } else { string memberId = dgvMember.CurrentRow.Cells[0].Value.ToString(); string memberName = dgvMember.CurrentRow.Cells[2].Value.ToString(); string info = "You are sure you want to delete membership information【Member Id:" + memberId + " Members Name:" + memberName + "】?"; DialogResult result = MessageBox.Show(info, "System Information", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { try { if (objMemberServices.DeleteMember(memberId) == 1) { //Notice Successful! MessageBox.Show("Delete Member information successful!", "System Information", MessageBoxButtons.OK, MessageBoxIcon.Information); //Refresh LoadMemberInfo(); } } catch (Exception ex) { MessageBox.Show("Abnormal deletion of membership information! Specific reasons:" + ex.Message, "System Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { return; } } }
public IActionResult Delete(string id) { if (!id.Equals("")) { var _member = _memberServices.GetMemberById(id); if (_member != null) { _memberServices.DeleteMember(_member); _memberServices.Commit(); return(Ok()); } else { return(NotFound()); } } else { return(BadRequest()); } }