Example #1
0
        private async void btnChangeType_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Are you sure you want to change access type?", "Change user", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                try
                {
                    var selectedUser = users[lsvUsers.FocusedItem.Index];
                    selectedUser.AccessType = cboAccess.Text.Trim();
                    await user.ChangeAccess(selectedUser);
                    await LoadAllUsers();

                    Logger.WriteToFile(Logger.FullName, $"Changed {selectedUser.Name} access level to {selectedUser.AccessType}");
                    MessageBox.Show("Access Type has been successfully changed", "Change", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                catch (Exception ex)
                {
                    MessageBox.Show($"Sorry an error occured while changing access. \n {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }