public FormUserPrefAdditional(List <UserOdPref> listUserPref, Userod userCur) { InitializeComponent(); Lan.F(this); _listUserPref = listUserPref.Select(x => x.Clone()).ToList(); _userCur = userCur.Copy(); }
///<summary></summary> public FormUserEdit(Userod userCur, bool isFromAddUser = false) { InitializeComponent(); Lan.F(this); UserCur = userCur.Copy(); _isFromAddUser = isFromAddUser; }
private void butOK_Click(object sender, System.EventArgs e) { Userod selectedUser = (Userod)listUser.SelectedItem; if (!Userods.CheckTypedPassword(textPassword.Text, selectedUser.Password)) { MsgBox.Show(this, "Incorrect password"); return; } if (RemotingClient.RemotingRole == RemotingRole.ClientWeb && selectedUser.Password == "" && textPassword.Text == "") { MsgBox.Show(this, "When using the web service, not allowed to log in with no password. A password should be added for this user."); return; } Security.CurUser = selectedUser.Copy(); if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { string password = textPassword.Text; if (Programs.UsingEcwTight()) //ecw requires hash, but non-ecw requires actual password { password = Userods.EncryptPassword(password, true); } Security.PasswordTyped = password; } if (PrefC.GetBool(PrefName.TasksCheckOnStartup)) { int taskcount = Tasks.UserTasksCount(Security.CurUser.UserNum); if (taskcount > 0) { MessageBox.Show(Lan.g(this, "There are ") + taskcount + Lan.g(this, " unread tasks on your tasklists.")); } } Plugins.HookAddCode(this, "FormLogOn.butOK_Click_end"); DialogResult = DialogResult.OK; }
///<summary></summary> public FormUserEdit(Userod userCur) { // // Required for Windows Form Designer support // InitializeComponent(); Lan.F(this); UserCur = userCur.Copy(); }
private void butOK_Click(object sender, System.EventArgs e) { Userod selectedUser = (Userod)listUser.SelectedItem; if (selectedUser.Password != "") { if (!UserodB.CheckPassword(textPassword.Text, selectedUser.Password)) { MsgBox.Show(this, "Incorrect password"); return; } } Security.CurUser = selectedUser.Copy(); DialogResult = DialogResult.OK; }
private void butOK_Click(object sender, System.EventArgs e) { bool usingEcw = Programs.UsingEcwTightOrFullMode(); Userod selectedUser = null; if (PrefC.GetBool(PrefName.UserNameManualEntry)) { for (int i = 0; i < listUser.Items.Count; i++) { //Check the user name typed in using ToLower and Trim because Open Dental is case insensitive and does not allow white-space in regards to user names. if (textUser.Text.Trim().ToLower() == listUser.Items[i].ToString().Trim().ToLower()) { selectedUser = (Userod)listUser.Items[i]; //Found the typed username break; } } if (selectedUser == null) { MsgBox.Show(this, "Login failed"); return; } } else { selectedUser = (Userod)listUser.SelectedItem; } string password = textPassword.Text; if (usingEcw) //ecw requires hash, but non-ecw requires actual password { password = Userods.HashPassword(password, true); } if (selectedUser.UserName == "Stay Open" && IsSimpleSwitch && PrefC.IsODHQ) { // No need to check password when changing task users at HQ to user "Stay Open". } else { try { Userods.CheckUserAndPassword(selectedUser.UserName, password, usingEcw); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } } if (RemotingClient.RemotingRole == RemotingRole.ClientWeb && selectedUser.Password == "" && textPassword.Text == "") { MsgBox.Show(this, "When using the web service, not allowed to log in with no password. A password should be added for this user."); return; } //successful login. if (!IsSimpleSwitch) { Security.CurUser = selectedUser.Copy(); Security.IsUserLoggedIn = true; //Jason approved always storing the cleartext password that the user typed in //since this is necessary for Reporting Servers over middle tier and was already happening when a user logged in over middle tier. Security.PasswordTyped = password; if (PrefC.GetBool(PrefName.PasswordsMustBeStrong) && PrefC.GetBool(PrefName.PasswordsWeakChangeToStrong)) { if (Userods.IsPasswordStrong(textPassword.Text) != "") //Password is not strong { MsgBox.Show(this, "You must change your password to a strong password due to the current Security settings."); FormOpenDental FormOD = Application.OpenForms.OfType <FormOpenDental>().ToList()[0]; //There always should be exactly 1. if (!FormOD.ChangePassword(true)) //Failed password update. { return; } } } } else { CurUserSimpleSwitch = selectedUser.Copy(); } if (!IsSimpleSwitch) { SecurityLogs.MakeLogEntry(Permissions.UserLogOnOff, 0, "User: "******" has logged on."); } Plugins.HookAddCode(this, "FormLogOn.butOK_Click_end"); DialogResult = DialogResult.OK; }
public FormCentralUserEdit(Userod user) { InitializeComponent(); UserCur = user.Copy(); }
private void FormTreatPlanEdit_Load(object sender, System.EventArgs e) { //this window never comes up for new TP. Always saved ahead of time. if (!Security.IsAuthorized(Permissions.TreatPlanEdit, PlanCur.DateTP)) { butOK.Enabled = false; butDelete.Enabled = false; butPickResponsParty.Enabled = false; butClearResponsParty.Enabled = false; butSigClear.Enabled = false; butDocumentDetach.Enabled = false; textHeading.ReadOnly = true; textDateTP.ReadOnly = true; textNote.ReadOnly = true; if (Security.IsAuthorized(Permissions.TreatPlanSign, PlanCur.DateTP)) //User has permission to edit the heading field. { textHeading.ReadOnly = false; butOK.Enabled = true; } } if (!Security.IsAuthorized(Permissions.TreatPlanPresenterEdit, true)) { butPickPresenter.Visible = false; } if (PlanCur.UserNumPresenter > 0) { _presenterCur = Userods.GetUser(PlanCur.UserNumPresenter); _presenterOld = _presenterCur.Copy(); textPresenter.Text = _presenterCur.UserName; } textUserEntry.Text = Userods.GetName(PlanCur.SecUserNumEntry); textDateTP.Text = PlanCur.DateTP.ToShortDateString(); textHeading.Text = PlanCur.Heading; textNote.Text = PlanCur.Note; if (PrefC.GetBool(PrefName.EasyHidePublicHealth)) { labelResponsParty.Visible = false; textResponsParty.Visible = false; butPickResponsParty.Visible = false; butClearResponsParty.Visible = false; } if (PlanCur.ResponsParty != 0) { textResponsParty.Text = Patients.GetLim(PlanCur.ResponsParty).GetNameLF(); } if (PlanCur.Signature != "") //Per Nathan 01 OCT 2015: In addition to invalidating signature (old behavior) we will also block editing signed TPs. { butOK.Enabled = false; textHeading.ReadOnly = true; textDateTP.ReadOnly = true; textNote.ReadOnly = true; butClearResponsParty.Enabled = false; butPickResponsParty.Enabled = false; butSigClear.Visible = true; butDocumentDetach.Enabled = false; } else { butSigClear.Visible = false; butSigClear.Enabled = false; } if (PlanCur.DocNum > 0) //Was set at some point in the past. { Document doc = Documents.GetByNum(PlanCur.DocNum); if (doc.DocNum == 0) { textDocument.Text = "(" + Lan.g(this, "Missing Document") + ")"; //Invalid Fkey to document.DocNum butDocumentView.Enabled = false; } else { textDocument.Text = doc.Description; if (!Documents.DocExists(doc.DocNum)) { textDocument.Text += " (" + Lan.g(this, "Unreachable File") + ")"; //Document points to unreachable file butDocumentView.Enabled = false; } } } else //hide document controls because there is no attached document { labelDocument.Visible = false; textDocument.Visible = false; butDocumentView.Visible = false; butDocumentDetach.Visible = false; } }
private void butOK_Click(object sender, System.EventArgs e) { if (textUserName.Text == "") { MsgBox.Show(this, "Please enter a username."); return; } if (!_isFromAddUser && IsNew && PrefC.GetBool(PrefName.PasswordsMustBeStrong) && string.IsNullOrWhiteSpace(_passwordTyped)) { MsgBox.Show(this, "Password may not be blank when the strong password feature is turned on."); return; } if (PrefC.HasClinicsEnabled && listClinic.SelectedIndex == -1) { MsgBox.Show(this, "This user does not have a User Default Clinic set. Please choose one to continue."); return; } if (listUserGroup.SelectedIndices.Count == 0) { MsgBox.Show(this, "Users must have at least one user group associated. Please select a user group to continue."); return; } if (_isFromAddUser && !Security.IsAuthorized(Permissions.SecurityAdmin, true) && (listUserGroup.SelectedItems.Count != 1 || listUserGroup.GetSelected <UserGroup>().UserGroupNum != PrefC.GetLong(PrefName.DefaultUserGroup))) { MsgBox.Show(this, "This user must be assigned to the default user group."); for (int i = 0; i < listUserGroup.Items.Count; i++) { if (((ODBoxItem <UserGroup>)listUserGroup.Items[i]).Tag.UserGroupNum == PrefC.GetLong(PrefName.DefaultUserGroup)) { listUserGroup.SetSelected(i, true); } else { listUserGroup.SetSelected(i, false); } } return; } List <UserClinic> listUserClinics = new List <UserClinic>(); if (PrefC.HasClinicsEnabled && checkClinicIsRestricted.Checked) //They want to restrict the user to certain clinics or clinics are enabled. { for (int i = 0; i < listClinicMulti.SelectedIndices.Count; i++) { listUserClinics.Add(new UserClinic(_listClinics[listClinicMulti.SelectedIndices[i]].ClinicNum, UserCur.UserNum)); } //If they set the user up with a default clinic and it's not in the restricted list, return. if (!listUserClinics.Exists(x => x.ClinicNum == _listClinics[listClinic.SelectedIndex - 1].ClinicNum)) { MsgBox.Show(this, "User cannot have a default clinic that they are not restricted to."); return; } } if (!PrefC.HasClinicsEnabled || listClinic.SelectedIndex == 0) { UserCur.ClinicNum = 0; } else { UserCur.ClinicNum = _listClinics[listClinic.SelectedIndex - 1].ClinicNum; } UserCur.ClinicIsRestricted = checkClinicIsRestricted.Checked; //This is kept in sync with their choice of "All". UserCur.IsHidden = checkIsHidden.Checked; UserCur.IsPasswordResetRequired = checkRequireReset.Checked; UserCur.UserName = textUserName.Text; if (listEmployee.SelectedIndex == 0) { UserCur.EmployeeNum = 0; } else { UserCur.EmployeeNum = _listEmployees[listEmployee.SelectedIndex - 1].EmployeeNum; } if (listProv.SelectedIndex == 0) { Provider prov = Providers.GetProv(UserCur.ProvNum); if (prov != null) { prov.IsInstructor = false; //If there are more than 1 users associated to this provider, they will no longer be an instructor. Providers.Update(prov); } UserCur.ProvNum = 0; } else { Provider prov = Providers.GetProv(UserCur.ProvNum); if (prov != null) { if (prov.ProvNum != _listProviders[listProv.SelectedIndex - 1].ProvNum) { prov.IsInstructor = false; //If there are more than 1 users associated to this provider, they will no longer be an instructor. } Providers.Update(prov); } UserCur.ProvNum = _listProviders[listProv.SelectedIndex - 1].ProvNum; } try{ if (IsNew) { Userods.Insert(UserCur, listUserGroup.SelectedItems.OfType <ODBoxItem <UserGroup> >().Select(x => x.Tag.UserGroupNum).ToList()); //Set the userodprefs to the new user's UserNum that was just retreived from the database. _listDoseSpotUserPrefNew.ForEach(x => x.UserNum = UserCur.UserNum); listUserClinics.ForEach(x => x.UserNum = UserCur.UserNum); //Set the user clinic's UserNum to the one we just inserted. SecurityLogs.MakeLogEntry(Permissions.AddNewUser, 0, "New user '" + UserCur.UserName + "' added"); } else { List <UserGroup> listNewUserGroups = listUserGroup.SelectedItems.OfType <ODBoxItem <UserGroup> >().Select(x => x.Tag).ToList(); List <UserGroup> listOldUserGroups = UserCur.GetGroups(); Userods.Update(UserCur, listNewUserGroups.Select(x => x.UserGroupNum).ToList()); //if this is the current user, update the user, credentials, etc. if (UserCur.UserNum == Security.CurUser.UserNum) { Security.CurUser = UserCur.Copy(); if (_passwordTyped != null) { Security.PasswordTyped = _passwordTyped; //update the password typed for middle tier refresh } } //Log changes to the User's UserGroups. Func <List <UserGroup>, List <UserGroup>, List <UserGroup> > funcGetMissing = (listCur, listCompare) => { List <UserGroup> retVal = new List <UserGroup>(); foreach (UserGroup group in listCur) { if (listCompare.Exists(x => x.UserGroupNum == group.UserGroupNum)) { continue; } retVal.Add(group); } return(retVal); }; List <UserGroup> listRemovedGroups = funcGetMissing(listOldUserGroups, listNewUserGroups); List <UserGroup> listAddedGroups = funcGetMissing(listNewUserGroups, listOldUserGroups); if (listRemovedGroups.Count > 0) //Only log if there are items in the list { SecurityLogs.MakeLogEntry(Permissions.SecurityAdmin, 0, "User " + UserCur.UserName + " removed from User group(s): " + string.Join(", ", listRemovedGroups.Select(x => x.Description).ToArray()) + " by: " + Security.CurUser.UserName); } if (listAddedGroups.Count > 0) //Only log if there are items in the list. { SecurityLogs.MakeLogEntry(Permissions.SecurityAdmin, 0, "User " + UserCur.UserName + " added to User group(s): " + string.Join(", ", listAddedGroups.Select(x => x.Description).ToArray()) + " by: " + Security.CurUser.UserName); } } if (UserClinics.Sync(listUserClinics, UserCur.UserNum)) //Either syncs new list, or clears old list if no longer restricted. { DataValid.SetInvalid(InvalidType.UserClinics); } } catch (Exception ex) { MessageBox.Show(ex.Message); return; } //DoseSpot User ID Insert/Update/Delete if (_doseSpotUserPrefDefault.ValueString != textDoseSpotUserID.Text) { if (string.IsNullOrWhiteSpace(textDoseSpotUserID.Text)) { UserOdPrefs.DeleteMany(_doseSpotUserPrefDefault.UserNum, _doseSpotUserPrefDefault.Fkey, UserOdFkeyType.Program); } else { _doseSpotUserPrefDefault.ValueString = textDoseSpotUserID.Text.Trim(); UserOdPrefs.Upsert(_doseSpotUserPrefDefault); } } DataValid.SetInvalid(InvalidType.Security); //List of AlertTypes that are selected. List <long> listUserAlertCats = new List <long>(); foreach (int index in listAlertSubMulti.SelectedIndices) { listUserAlertCats.Add(_listAlertCategories[index].AlertCategoryNum); } List <long> listClinics = new List <long>(); foreach (int index in listAlertSubsClinicsMulti.SelectedIndices) { if (index == 0) //All { listClinics.Add(-1); //Add All break; } if (index == 1) //HQ { listClinics.Add(0); continue; } Clinic clinic = _listClinics[index - 2]; //Subtract 2 for 'All' and 'HQ' listClinics.Add(clinic.ClinicNum); } List <AlertSub> _listUserAlertTypesNew = _listUserAlertTypesOld.Select(x => x.Copy()).ToList(); //Remove AlertTypes that have been deselected through either deslecting the type or clinic. _listUserAlertTypesNew.RemoveAll(x => !listUserAlertCats.Contains(x.AlertCategoryNum)); if (PrefC.HasClinicsEnabled) { _listUserAlertTypesNew.RemoveAll(x => !listClinics.Contains(x.ClinicNum)); } foreach (long alertCatNum in listUserAlertCats) { if (!PrefC.HasClinicsEnabled) { if (!_listUserAlertTypesOld.Exists(x => x.AlertCategoryNum == alertCatNum)) //Was not subscribed to type. { _listUserAlertTypesNew.Add(new AlertSub(UserCur.UserNum, 0, alertCatNum)); } } else //Clinics enabled. { foreach (long clinicNumCur in listClinics) { if (!_listUserAlertTypesOld.Exists(x => x.ClinicNum == clinicNumCur && x.AlertCategoryNum == alertCatNum)) //Was not subscribed to type. { _listUserAlertTypesNew.Add(new AlertSub(UserCur.UserNum, clinicNumCur, alertCatNum)); continue; } } } } AlertSubs.Sync(_listUserAlertTypesNew, _listUserAlertTypesOld); UserOdPrefs.Sync(_listDoseSpotUserPrefNew, _listDoseSpotUserPrefOld); DialogResult = DialogResult.OK; }