private void FillUsers() { UserGroups.Refresh(); Userods.Refresh(); SelectedGroupNum = 0; gridMain.BeginUpdate(); gridMain.Columns.Clear(); ODGridColumn col = new ODGridColumn(Lan.g("TableSecurity", "Username"), 90); gridMain.Columns.Add(col); col = new ODGridColumn(Lan.g("TableSecurity", "Group"), 90); gridMain.Columns.Add(col); col = new ODGridColumn(Lan.g("TableSecurity", "Employee"), 90); gridMain.Columns.Add(col); col = new ODGridColumn(Lan.g("TableSecurity", "Provider"), 90); gridMain.Columns.Add(col); col = new ODGridColumn(Lan.g("TableSecurity", "Clinic"), 90); gridMain.Columns.Add(col); gridMain.Rows.Clear(); ODGridRow row; string usertype = "all"; if (comboUsers.SelectedIndex == 1) { usertype = "prov"; } if (comboUsers.SelectedIndex == 2) { usertype = "emp"; } if (comboUsers.SelectedIndex == 3) { usertype = "other"; } int classNum = 0; if (comboSchoolClass.Visible && comboSchoolClass.SelectedIndex > 0) { classNum = SchoolClasses.List[comboSchoolClass.SelectedIndex - 1].SchoolClassNum; } table = Userods.RefreshSecurity(usertype, classNum); string userdesc; for (int i = 0; i < table.Rows.Count; i++) { row = new ODGridRow(); userdesc = table.Rows[i]["UserName"].ToString(); if (table.Rows[i]["IsHidden"].ToString() == "1") { userdesc += Lan.g(this, "(hidden)"); } row.Cells.Add(userdesc); row.Cells.Add(UserGroups.GetGroup(PIn.PInt(table.Rows[i]["UserGroupNum"].ToString())).Description); row.Cells.Add(Employees.GetNameFL(PIn.PInt(table.Rows[i]["EmployeeNum"].ToString()))); row.Cells.Add(Providers.GetNameLF(PIn.PInt(table.Rows[i]["ProvNum"].ToString()))); row.Cells.Add(Clinics.GetDesc(PIn.PInt(table.Rows[i]["ClinicNum"].ToString()))); gridMain.Rows.Add(row); } gridMain.EndUpdate(); }
private void butOK_Click(object sender, System.EventArgs e) { if (textDate.errorProvider1.GetError(textDate) != "" || textDays.errorProvider1.GetError(textDays) != "") { MsgBox.Show(this, "Please fix data entry errors first."); return; } int newerDays = PIn.Int(textDays.Text); if (newerDays > GroupPermissions.NewerDaysMax) { MsgBox.Show(this, $"Days must be less than {GroupPermissions.NewerDaysMax.ToString()}."); return; } Cur.NewerDays = newerDays; Cur.NewerDate = PIn.Date(textDate.Text); try{ if (Cur.IsNew) { GroupPermissions.Insert(Cur); } else { GroupPermissions.Update(Cur); } SecurityLogs.MakeLogEntry(Permissions.SecurityAdmin, 0, $"Permission '{Cur.PermType}' granted to " + $"'{UserGroups.GetGroup(Cur.UserGroupNum).Description}'"); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } DialogResult = DialogResult.OK; }
private void FillTreePerm() { GroupPermissions.Refresh(); labelPerm.Text = Lan.g(this, "Permissions for group:") + " " + UserGroups.GetGroup(SelectedGroupNum).Description; for (int i = 0; i < treePermissions.Nodes.Count; i++) { FillNodes(treePermissions.Nodes[i], SelectedGroupNum); } }
private void FormDentalSchoolSetup_Load(object sender, EventArgs e) { if (!Security.IsAuthorized(Permissions.Setup)) { return; } UserGroup studentGroup = UserGroups.GetGroup(PrefC.GetLong(PrefName.SecurityGroupForStudents)); UserGroup instructorGroup = UserGroups.GetGroup(PrefC.GetLong(PrefName.SecurityGroupForInstructors)); if (studentGroup != null) { textStudents.Text = studentGroup.Description; } if (instructorGroup != null) { textInstructors.Text = instructorGroup.Description; } }
private void FillTreePerm() { GroupPermissions.Refresh(); if (SelectedGroupNum == 0) { labelPerm.Text = ""; treePermissions.Enabled = false; } else { labelPerm.Text = Lan.g(this, "Permissions for group:") + " " + UserGroups.GetGroup(SelectedGroupNum).Description; treePermissions.Enabled = true; } for (int i = 0; i < treePermissions.Nodes.Count; i++) { FillNodes(treePermissions.Nodes[i], SelectedGroupNum); } }
private void FillUsers() { UserGroups.RefreshCache(); Cache.Refresh(InvalidType.Security); SelectedGroupNum = 0; gridMain.BeginUpdate(); gridMain.Columns.Clear(); ODGridColumn col = new ODGridColumn(Lan.g("TableSecurity", "Username"), 90); gridMain.Columns.Add(col); col = new ODGridColumn(Lan.g("TableSecurity", "Group"), 90); gridMain.Columns.Add(col); col = new ODGridColumn(Lan.g("TableSecurity", "Employee"), 90); gridMain.Columns.Add(col); col = new ODGridColumn(Lan.g("TableSecurity", "Provider"), 90); gridMain.Columns.Add(col); col = new ODGridColumn(Lan.g("TableSecurity", "Clinic"), 80); gridMain.Columns.Add(col); col = new ODGridColumn(Lan.g("TableSecurity", "ClinicRestricted"), 100, HorizontalAlignment.Center); gridMain.Columns.Add(col); col = new ODGridColumn(Lan.g("TableSecurity", "Strong"), 80, HorizontalAlignment.Center); gridMain.Columns.Add(col); gridMain.Rows.Clear(); ODGridRow row; string usertype = "all"; if (comboUsers.SelectedIndex == 1) { usertype = "prov"; } if (comboUsers.SelectedIndex == 2) { usertype = "emp"; } if (comboUsers.SelectedIndex == 3) { usertype = "other"; } long classNum = 0; if (comboSchoolClass.Visible && comboSchoolClass.SelectedIndex > 0) { classNum = SchoolClasses.List[comboSchoolClass.SelectedIndex - 1].SchoolClassNum; } ListUser = Userods.RefreshSecurity(usertype, classNum); string userdesc; for (int i = 0; i < ListUser.Count; i++) { row = new ODGridRow(); userdesc = ListUser[i].UserName; if (ListUser[i].IsHidden) { userdesc += Lan.g(this, "(hidden)"); } row.Cells.Add(userdesc); row.Cells.Add(UserGroups.GetGroup(ListUser[i].UserGroupNum).Description); row.Cells.Add(Employees.GetNameFL(ListUser[i].EmployeeNum)); row.Cells.Add(Providers.GetLongDesc(ListUser[i].ProvNum)); row.Cells.Add(Clinics.GetDesc(ListUser[i].ClinicNum)); row.Cells.Add(ListUser[i].ClinicIsRestricted?"X":""); row.Cells.Add(ListUser[i].PasswordIsStrong?"X":""); gridMain.Rows.Add(row); } gridMain.EndUpdate(); }
///<summary>Toggles permissions based on the node the user has clicked. ///Will do nothing if in Read-Only mode or more than one usergroup is selected.</summary> private void treePermissions_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) { if (ReadOnly || _listUserGroupNums.Count != 1) { return; } _clickedPermNode = treePermissions.GetNodeAt(e.X, e.Y); if (_clickedPermNode == null) { return; } //Do nothing if the user didn't click on a check box. if (_clickedPermNode.Parent == null) //level 1 { if (e.X < 5 || e.X > 17) { return; } } else if (_clickedPermNode.Parent.Parent == null) //level 2 { if (e.X < 24 || e.X > 36) { return; } } else if (_clickedPermNode.Parent.Parent.Parent == null) //level 3 { if (e.X < 43 || e.X > 55) { return; } } //User clicked on a check box. Do stuff. if (_clickedPermNode.ImageIndex == 1) //unchecked, so need to add a permission { GroupPermission perm = new GroupPermission(); perm.PermType = (Permissions)_clickedPermNode.Tag; perm.UserGroupNum = _listUserGroupNums.First(); if (GroupPermissions.PermTakesDates(perm.PermType)) { perm.IsNew = true; //Call an event that bubbles back up to the calling Form. The event returns a dialog result so we know how to continue here. DialogResult result = GroupPermissionChecked?.Invoke(sender, new SecurityEventArgs(perm)) ?? DialogResult.Cancel; if (result == DialogResult.Cancel) { treePermissions.EndUpdate(); return; } } else if (perm.PermType == Permissions.Reports) //Reports permission is being checked. //Call an event that bubbles back up to the calling Form. The event returns a dialog result so we know how to continue here. { DialogResult result = ReportPermissionChecked?.Invoke(sender, new SecurityEventArgs(perm)) ?? DialogResult.Cancel; if (result == DialogResult.Cancel) { treePermissions.EndUpdate(); return; } } else { try { GroupPermissions.Insert(perm); SecurityLogs.MakeLogEntry(Permissions.SecurityAdmin, 0, "Permission '" + perm.PermType + "' granted to '" + UserGroups.GetGroup(perm.UserGroupNum).Description + "'"); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } } if (perm.PermType.In(Permissions.ProcComplEdit, Permissions.ProcExistingEdit)) { //Adding ProcComplEdit full, so add ProcComplEditlimited too. //Do the same for EO and EC procs GroupPermission permLimited = GroupPermissions.GetPerm(_listUserGroupNums.First(), Permissions.ProcComplEditLimited); if (permLimited == null) { GroupPermissions.RefreshCache(); //refresh NewerDays/Date to add the same for ProcComplEditLimited perm = GroupPermissions.GetPerm(_listUserGroupNums.First(), perm.PermType); permLimited = new GroupPermission(); permLimited.NewerDate = perm.NewerDate; permLimited.NewerDays = perm.NewerDays; permLimited.UserGroupNum = perm.UserGroupNum; permLimited.PermType = Permissions.ProcComplEditLimited; try { GroupPermissions.Insert(permLimited); SecurityLogs.MakeLogEntry(Permissions.SecurityAdmin, 0, "Permission '" + perm.PermType + "' granted to '" + UserGroups.GetGroup(perm.UserGroupNum).Description + "'"); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } } } } else if (_clickedPermNode.ImageIndex == 2) //checked, so need to delete the perm { try { GroupPermissions.RemovePermission(_listUserGroupNums.First(), (Permissions)_clickedPermNode.Tag); SecurityLogs.MakeLogEntry(Permissions.SecurityAdmin, 0, "Permission '" + _clickedPermNode.Tag + "' revoked from '" + UserGroups.GetGroup(_listUserGroupNums.First()).Description + "'"); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } if ((Permissions)_clickedPermNode.Tag == Permissions.ProcComplEditLimited) { //Deselecting ProcComplEditLimted, deselect ProcComplEdit and ProcExistingEdit permissions if present. List <Permissions> listPermissions = new List <Permissions>(); if (GroupPermissions.HasPermission(_listUserGroupNums.First(), Permissions.ProcComplEdit, 0)) { listPermissions.Add(Permissions.ProcComplEdit); } if (GroupPermissions.HasPermission(_listUserGroupNums.First(), Permissions.ProcExistingEdit, 0)) { listPermissions.Add(Permissions.ProcExistingEdit); } listPermissions.ForEach(x => { try { GroupPermissions.RemovePermission(_listUserGroupNums.First(), x); SecurityLogs.MakeLogEntry(Permissions.SecurityAdmin, 0, "Permission '" + _clickedPermNode.Tag + "' revoked from '" + UserGroups.GetGroup(_listUserGroupNums.First()).Description + "'"); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } }); } } else if (_clickedPermNode.ImageIndex == 3) //Partially checked (currently only applies to Reports permission) { try { GroupPermissions.RemovePermission(_listUserGroupNums.First(), (Permissions)_clickedPermNode.Tag); SecurityLogs.MakeLogEntry(Permissions.SecurityAdmin, 0, "Permission '" + _clickedPermNode.Tag + "' revoked from '" + UserGroups.GetGroup(_listUserGroupNums.First()).Description + "'"); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } } if ((Permissions)_clickedPermNode.Tag == Permissions.AccountProcsQuickAdd) { string programName = PrefC.GetString(PrefName.SoftwareName); MsgBox.Show(this, programName + " needs to be restarted on workstations before the changes will take place."); } FillTreePerm(); }