private void AddRow(AeAccessKey ci) { if (dataGridView1.ColumnCount > 0) { int rowIndex = dataGridView1.Rows.Add(); ChangeRowData(rowIndex, ci); } }
private void ChangeRowData(int rowIndex, AeAccessKey ci) { // AE Title dataGridView1.Rows[rowIndex].Cells[AeTitleIndex].Value = ci.AeTitle; // Friendly Name dataGridView1.Rows[rowIndex].Cells[RoleIndex].Value = ci.AccessKey; // invalidate dataGridView1.InvalidateRow(rowIndex); }
private void DeleteClients() { foreach (DataGridViewRow row in dataGridView1.SelectedRows) { string aeTitle = row.Cells[0].Value.ToString(); string role = row.Cells[1].Value.ToString(); AeAccessKey aeAccessKey = new AeAccessKey { AeTitle = aeTitle, AccessKey = role }; if (aeRoleList.MyContains(aeAccessKey)) { dataGridView1.Rows.Remove(row); aeRoleList.MyRemoveAll(aeAccessKey); } } }
private bool InsertClient(InsertModifyAeRoleControlType dialogType) { bool ret = false; InsertModifyAeRoleDialog dialog = new InsertModifyAeRoleDialog() { DialogType = dialogType }; dialog.aeRoleList = aeRoleList; AeInfoExtended[] aeInfoExtended = Module.AeManagementDataAccessAgent.GetAeTitles(); dialog.aeList = aeInfoExtended.Select(x => x.AETitle).Distinct().ToList(); Role[] roles = Module.PermissionManagementDataAccessAgent.GetRoles(); dialog.roleList = roles.Select(x => x.Name).Distinct().ToList(); AeAccessKey aeAccessKey = new AeAccessKey(); if (dataGridView1.SelectedRows.Count > 0) { aeAccessKey.AeTitle = dataGridView1.SelectedRows[0].Cells[0].Value.ToString(); if (dialogType == InsertModifyAeRoleControlType.Modify) { aeAccessKey.AccessKey = dataGridView1.SelectedRows[0].Cells[1].Value.ToString(); } } dialog.aeRole = aeAccessKey; dialog.ValidateAeRoleData += Dialog_ValidateAeRoleData; if (DialogResult.OK == dialog.ShowDialog(this)) { AddRow(dialog.aeRole); aeRoleList.Add(dialog.aeRole); ret = true; } return(ret); }
public bool UpdateOptions(bool refresh) { PatientRestrictOptions options = new PatientRestrictOptions(); options.PageSize = _optionsDialog.PageSize; options.PatientRestrictEnabled = _optionsDialog.PatientRestrictEnabled; List <AeAccessKey> aeRoleListNew = _optionsDialog.aeRoleList; // Save AdvancedSettings settings; _AdvancedSettings.RefreshSettings(); _AdvancedSettings.SetAddInCustomData <PatientRestrictOptions>(Module.Source, Module.OptionsName, options); _AdvancedSettings.Save(); // Save Database Settings List <AeAccessKey> aeRoleListOriginal = Module.PatientRightsDataAccess.GetAllAeRoleRecords(); // We want to remove all items from each list that are IN BOTH LISTS // After this: // aeRoleListOriginal will contain elements to be deleted // aeRoleListNew will contain elements to be added for (int i = aeRoleListNew.Count - 1; i >= 0; i--) { AeAccessKey value = aeRoleListNew[i]; int countRemoved = aeRoleListOriginal.MyRemoveAll(value); if (countRemoved > 0) { aeRoleListNew.RemoveAt(i); } } int deletedCount = aeRoleListOriginal.Count; int addedCount = aeRoleListNew.Count; // aeRoleListOriginal now contains elements to be deleted foreach (AeAccessKey value in aeRoleListOriginal) { Module.PatientRightsDataAccess.DeleteAeRole(value.AeTitle, value.AccessKey); } // aeRoleListNew now contains elements to be added foreach (AeAccessKey value in aeRoleListNew) { Module.PatientRightsDataAccess.AddAeRole(value.AeTitle, value.AccessKey); } if ((addedCount != 0) || (deletedCount != 0)) { string message = string.Format("Records Added: {0}\r\nRecords Deleted: {1}", addedCount, deletedCount); MessageBox.Show(message, "Updated", MessageBoxButtons.OK, MessageBoxIcon.Information); } if (refresh) { aeRoleListNew = Module.PatientRightsDataAccess.GetAllAeRoleRecords(); _optionsDialog.aeRoleList = aeRoleListNew; } return(true); }
internal static int MyRemoveAll(this List <AeAccessKey> aeRoleList, AeAccessKey value) { int countRemoved = aeRoleList.RemoveAll(x => (x.AeTitle == value.AeTitle) && (x.AccessKey == value.AccessKey)); return(countRemoved); }
internal static bool MyContains(this List <AeAccessKey> aeRoleList, AeAccessKey value) { return(aeRoleList.Any(x => (x.AeTitle == value.AeTitle) && (x.AccessKey == value.AccessKey))); }