private void btnChange_Click(object sender, EventArgs e) { if (XtraMessageBox.Show("Are you sure you would like to consolidate and delete?", "are you sure?", MessageBoxButtons.YesNo) == DialogResult.Yes) { int toUserID = Convert.ToInt32(lkAlternatives.EditValue); DirtyDBHelper.ConsolidateUser(_userID, toUserID); this.Close(); } }
private void repDelete_Click(object sender, EventArgs e) { var user = (UserViewModel)usersbindingSource[gridUserListView.FocusedRowHandle]; if (user != null) { if (XtraMessageBox.Show("Are you sure you would like to delete this User?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { try { int id = user.UserID; DirtyDBHelper.RemoveUserDependancies(id); repository.Users.DeleteBy(j => j.UserID == id); RefreshUsersList(); XtraMessageBox.Show("The User has been deleted", "Confirmation"); } catch { XtraMessageBox.Show( "This user cannot be deleted because it has been used in transactions. Either consolidate it or you will not be able to delete it."); } } } }