/// <summary> /// This grid event perform 'Update User' operation. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void UserList_CellClick(object sender, DataGridViewCellEventArgs e) { try { if (e.RowIndex != -1 && e.ColumnIndex == UserList.Columns["colEdit"].Index) { string userPrincipalName = UserList[UserList.Columns["colUserPrincipalName"].Index, e.RowIndex].Value.ToString(); // Opens 'Update User' page as a model dialog. UserOperations userOperations = new UserOperations(UserOperations.UserOpertaionType.Update, userPrincipalName); if (userOperations.ShowDialog() == DialogResult.OK) // If user updated successfully. { Cursor.Current = Cursors.WaitCursor; // Update user list with updated user details. Collection <PSObject> results = ExcutePowershellCommands(); if (results != null && results.Count > 0) { FillUserList(results); } Cursor.Current = Cursors.Default; } } } catch (Exception ex) { Cursor.Current = Cursors.Default; MessageBox.Show(ex.Message); } }
private void AddUser_Click(object sender, EventArgs e) { try { // Opens 'Add User' page as a model dialog. UserOperations userOperations = new UserOperations(UserOperations.UserOpertaionType.Save); if (userOperations.ShowDialog() == DialogResult.OK) // If user added successfully. { Cursor.Current = Cursors.WaitCursor; // Update user list with newly added user. Collection <PSObject> results = ExcutePowershellCommands(); if (results != null && results.Count > 0) { FillUserList(results); } Cursor.Current = Cursors.Default; } } catch (Exception ex) { Cursor.Current = Cursors.Default; MessageBox.Show(ex.Message); } }