Esempio n. 1
0
        private void butOK_Click(object sender, System.EventArgs e)
        {
            Userod selectedUser = null;

            if (IsMiddleTierSync)
            {
                selectedUser              = new Userod();
                selectedUser.UserName     = textUser.Text;
                selectedUser.LoginDetails = Authentication.GenerateLoginDetails(textPassword.Text, HashTypes.SHA3_512);
                Security.CurUser          = selectedUser;
                Security.PasswordTyped    = textPassword.Text;
            }
            else
            {
                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)
                    {
                        MessageBox.Show(this, "Login failed");
                        return;
                    }
                }
                else
                {
                    selectedUser = (Userod)listUser.SelectedItem;
                }
                try {
                    Userods.CheckUserAndPassword(selectedUser.UserName, textPassword.Text, false);
                }
                catch (Exception ex) {
                    MessageBox.Show(ex.Message);
                    return;
                }
                if (RemotingClient.RemotingRole == RemotingRole.ClientWeb && selectedUser.PasswordHash == "" && textPassword.Text == "")
                {
                    MessageBox.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();
                Security.PasswordTyped = textPassword.Text;
                UserOdPrefs.SetThemeForUserIfNeeded();
            }
            //if(RemotingClient.RemotingRole==RemotingRole.ClientWeb){//Not sure we need this when connecting to CEMT, but not sure enough to delete.
            //	string password=textPassword.Text;
            //	if(Programs.UsingEcwTightOrFullMode()) {//ecw requires hash, but non-ecw requires actual password
            //		password=Userods.EncryptPassword(password,true);
            //	}
            //	Security.PasswordTyped=password;
            //}
            DialogResult = DialogResult.OK;
        }
Esempio n. 2
0
        private void menuItemHomePageSave_Click(object sender, EventArgs e)
        {
            if (WikiPageCur == null)
            {
                MsgBox.Show(this, "Invalid wiki page selected.");
                return;
            }
            List <UserOdPref> listUserOdPrefs = UserOdPrefs.GetByUserAndFkeyType(Security.CurUser.UserNum, UserOdFkeyType.WikiHomePage);

            if (listUserOdPrefs.Count > 0)
            {
                //User is updating their current home page to a new one.
                listUserOdPrefs[0].ValueString = WikiPageCur.PageTitle;
                UserOdPrefs.Update(listUserOdPrefs[0]);
            }
            else
            {
                //User is saving a custom home page for the first time.
                UserOdPref userOdPref = new UserOdPref();
                userOdPref.UserNum     = Security.CurUser.UserNum;
                userOdPref.ValueString = WikiPageCur.PageTitle;
                userOdPref.FkeyType    = UserOdFkeyType.WikiHomePage;
                UserOdPrefs.Insert(userOdPref);
            }
            MsgBox.Show(this, "Home page saved.");
        }
Esempio n. 3
0
 private void butOK_Click(object sender, EventArgs e)
 {
     if (!(textStartDate.errorProvider1.GetError(textStartDate) == ""))
     {
         if (checkShowFinished.Checked)
         {
             MsgBox.Show(this, "Invalid finished task start date");
             return;
         }
         else
         {
             //We are not going to be using the textStartDate so not reason to warn the user, just reset it back to the default value.
             textStartDate.Text = DateTimeOD.Today.AddDays(-7).ToShortDateString();
         }
     }
     if (_taskCollapsedPref == null)
     {
         _taskCollapsedPref             = new UserOdPref();
         _taskCollapsedPref.Fkey        = 0;
         _taskCollapsedPref.FkeyType    = UserOdFkeyType.TaskCollapse;
         _taskCollapsedPref.UserNum     = Security.CurUser.UserNum;
         _taskCollapsedPref.ValueString = POut.Bool(checkCollapsed.Checked);
         UserOdPrefs.Insert(_taskCollapsedPref);
     }
     else
     {
         _taskCollapsedPref.ValueString = POut.Bool(checkCollapsed.Checked);
         UserOdPrefs.Update(_taskCollapsedPref);
     }
     IsShowFinishedTasks       = checkShowFinished.Checked;
     IsShowArchivedTaskLists   = checkShowArchivedTaskLists.Checked;
     DateTimeStartShowFinished = PIn.Date(textStartDate.Text);          //Note that this may have not been enabled but we'll pass it back anyway, won't be used.
     IsSortApptDateTime        = checkTaskSortApptDateTime.Checked;
     DialogResult = DialogResult.OK;
 }
Esempio n. 4
0
 private void FormAutoNoteCompose_Load(object sender, EventArgs e)
 {
     _listAutoNoteCatDefs = Defs.GetDefsForCategory(DefCat.AutoNoteCats, true);
     _listAutoNotePrompts = new List <AutoNoteListItem>();
     _userOdCurPref       = UserOdPrefs.GetByUserAndFkeyType(Security.CurUser.UserNum, UserOdFkeyType.AutoNoteExpandedCats).FirstOrDefault();
     FillListTree();
 }
Esempio n. 5
0
 private void SavePreferences()
 {
     #region Logoff After Minutes
     if (textLogOffAfterMinutes.Text.IsNullOrEmpty() && !_logOffAfterMinutesInitialValue.IsNullOrEmpty())
     {
         UserOdPrefs.Delete(_logOffAfterMinutes.UserOdPrefNum);
     }
     else if (textLogOffAfterMinutes.Text != _logOffAfterMinutesInitialValue)            //Only do this if the value has changed
     {
         if (_logOffAfterMinutes == null)
         {
             _logOffAfterMinutes = new UserOdPref()
             {
                 Fkey = 0, FkeyType = UserOdFkeyType.LogOffTimerOverride, UserNum = Security.CurUser.UserNum
             };
         }
         _logOffAfterMinutes.ValueString = textLogOffAfterMinutes.Text;
         UserOdPrefs.Upsert(_logOffAfterMinutes);
         if (!PrefC.GetBool(PrefName.SecurityLogOffAllowUserOverride))
         {
             MsgBox.Show(this, "User logoff overrides will not take effect until the Global Security setting \"Allow user override for automatic logoff\" is checked");
         }
     }
     #endregion
     #region Suppress Logoff Message
     if (checkSuppressMessage.Checked && _suppressLogOffMessage == null)
     {
         UserOdPrefs.Insert(new UserOdPref()
         {
             UserNum  = Security.CurUser.UserNum,
             FkeyType = UserOdFkeyType.SuppressLogOffMessage
         });
     }
     else if (!checkSuppressMessage.Checked && _suppressLogOffMessage != null)
     {
         UserOdPrefs.Delete(_suppressLogOffMessage.UserOdPrefNum);
     }
     #endregion
     #region Theme Change
     if (_themePref == null)
     {
         _themePref = new UserOdPref()
         {
             UserNum = Security.CurUser.UserNum, FkeyType = UserOdFkeyType.UserTheme
         };
     }
     _themePref.Fkey = comboTheme.SelectedIndex;
     UserOdPrefs.Upsert(_themePref);
     if (PrefC.GetBool(PrefName.ThemeSetByUser))
     {
         UserOdPrefs.SetThemeForUserIfNeeded();
     }
     else
     {
         //No need to return, just showing a warning so they know why the theme will not change.
         MsgBox.Show("Theme will not take effect until the miscellaneous preference has been set for users can set their own theme.");
     }
     #endregion
 }
Esempio n. 6
0
 private void FormUserSetting_Load(object sender, EventArgs e)
 {
     _suppressLogOffMessage = UserOdPrefs.GetByUserAndFkeyType(Security.CurUser.UserNum, UserOdFkeyType.SuppressLogOffMessage).FirstOrDefault();
     if (_suppressLogOffMessage != null)           //Does exist in the database
     {
         checkSuppressMessage.Checked = true;
     }
 }
Esempio n. 7
0
 private void FormTaskListBlock_Load(object sender, EventArgs e)
 {
     _dictAllTaskLists             = TaskLists.GetAll().ToDictionary(x => x.TaskListNum);//Used so we don't need to acces the database multiple times
     _listUserOdPrefTaskListBlocks = UserOdPrefs.GetByUserAndFkeyType(Security.CurUser.UserNum, UserOdFkeyType.TaskListBlock);
     //We pull the list then save it so the sync moethod is able to run correctly.
     //This correctly fixes users having duplicate task list preferences in the databse.
     _listUserDBPrefs = _listUserOdPrefTaskListBlocks.Select(x => x.Clone()).ToList();
     _listUserOdPrefTaskListBlocks = _listUserOdPrefTaskListBlocks.GroupBy(x => x.Fkey).Select(x => x.First()).ToList();
     InitializeTree();
 }
Esempio n. 8
0
 private void RefreshUserOdPrefs()
 {
     if (Security.CurUser == null || Security.CurUser.UserNum < 1)
     {
         return;
     }
     _userOdPrefClearNote            = UserOdPrefs.GetByUserAndFkeyType(Security.CurUser.UserNum, UserOdFkeyType.CommlogPersistClearNote).FirstOrDefault();
     _userOdPrefEndDate              = UserOdPrefs.GetByUserAndFkeyType(Security.CurUser.UserNum, UserOdFkeyType.CommlogPersistClearEndDate).FirstOrDefault();
     _userOdPrefUpdateDateTimeNewPat = UserOdPrefs.GetByUserAndFkeyType(Security.CurUser.UserNum, UserOdFkeyType.CommlogPersistUpdateDateTimeWithNewPatient).FirstOrDefault();
 }
Esempio n. 9
0
 private void FormAutoNotes_Load(object sender, System.EventArgs e)
 {
     if (IsSelectionMode)
     {
         butAdd.Visible         = false;
         labelSelection.Visible = true;
     }
     _userOdCurPref = UserOdPrefs.GetByUserAndFkeyType(Security.CurUser.UserNum, UserOdFkeyType.AutoNoteExpandedCats).FirstOrDefault();
     AutoNoteL.FillListTree(treeNotes, _userOdCurPref);
 }
Esempio n. 10
0
        ///<summary>Loads the user's home page or the wiki page with the title of "Home" if a custom home page has not been set before.</summary>
        private void LoadWikiPageHome()
        {
            historyNavBack--;            //We have to decrement historyNavBack to tell whether or not we need to branch our page history or add to page history
            List <UserOdPref> listUserOdPrefs = UserOdPrefs.GetByUserAndFkeyType(Security.CurUser.UserNum, UserOdFkeyType.WikiHomePage);

            if (listUserOdPrefs.Count > 0)
            {
                LoadWikiPage(listUserOdPrefs[0].ValueString);
            }
            else
            {
                LoadWikiPage("Home");
            }
        }
Esempio n. 11
0
 private void FormUserSetting_Load(object sender, EventArgs e)
 {
     //Logoff After Minutes
     _logOffAfterMinutes             = UserOdPrefs.GetByUserAndFkeyType(Security.CurUser.UserNum, UserOdFkeyType.LogOffTimerOverride).FirstOrDefault();
     _logOffAfterMinutesInitialValue = (_logOffAfterMinutes == null) ? "" : _logOffAfterMinutes.ValueString;
     textLogOffAfterMinutes.Text     = _logOffAfterMinutesInitialValue;
     //Suppress Logoff Message
     _suppressLogOffMessage = UserOdPrefs.GetByUserAndFkeyType(Security.CurUser.UserNum, UserOdFkeyType.SuppressLogOffMessage).FirstOrDefault();
     if (_suppressLogOffMessage != null)           //Does exist in the database
     {
         checkSuppressMessage.Checked = true;
     }
     //Theme Combo
     FillThemeCombo();
 }
Esempio n. 12
0
 ///<summary>Attempts to find a UserOdPref indicating to the the most recently loaded layout for user, defaulting to the practice default if not
 ///found, then defaulting to the first SheetDef in listLayoutSheetDefs.  Returns null if listLayoutSheetDefs is null or empty.</summary>
 public SheetDef GetLayoutForUser()
 {
     //Avoid changing the layout when user is simply navigating and switching view modes.
     //If this user is using the practice default and then the practice default is changed by another user
     //we want to continue to use the same layout the user is currently viewing.
     //If the user logs off/exits for the day the next time they log in they will get the new practice default layout.
     if (!_hasUserLoggedOff &&
         _userNumCur == Security.CurUser.UserNum &&
         _clinicNumCur == Clinics.ClinicNum &&
         _sheetDefDynamicLayoutCur != null &&
         ListSheetDefsLayout.Any(x => x.SheetDefNum == _sheetDefDynamicLayoutCur.SheetDefNum))
     {
         return(ListSheetDefsLayout.First(x => x.SheetDefNum == _sheetDefDynamicLayoutCur.SheetDefNum));
     }
     #region UserOdPref based layout selection. If no UserOdPref use practice default or first item in list as last line of defense.
     SheetDef          def       = null;
     List <UserOdPref> listPrefs = UserOdPrefs.GetByUserAndFkeyType(Security.CurUser.UserNum, UserOdFkeyType.DynamicChartLayout);
     UserOdPref        userPref  = listPrefs.FirstOrDefault();                          //There is only at most a single link per user.
     if (userPref != null &&      //User has viewed the chart module before
         ListSheetDefsLayout.Any(x => x.SheetDefNum == userPref.Fkey))                  //Layout still exists in the list of options
     {
         def = ListSheetDefsLayout.FirstOrDefault(x => x.SheetDefNum == userPref.Fkey); //Use previous layout when not practice or Clinic default.
     }
     else                                                                               //Try to use the practice default.
                                                                                        //If there is a Clinic default, get it.
     {
         if (!PrefC.HasClinicsEnabled || Clinics.ClinicNum == 0 ||
             !ClinicPrefs.TryGetLong(PrefName.SheetsDefaultChartModule, Clinics.ClinicNum, out long sheetDefNum))
         {
             //Either, clinics are off, HQ is selected, or ClinicPref did not exist.
             if (_hasUserLoggedOff)                     //Currently the cache is not loaded fast enough after logging back on to trust.
             {
                 sheetDefNum = PIn.Long(PrefC.GetStringNoCache(PrefName.SheetsDefaultChartModule));
             }
             else
             {
                 sheetDefNum = PrefC.GetLong(PrefName.SheetsDefaultChartModule);                      //Serves as our HQ default.
             }
         }
         def = ListSheetDefsLayout.FirstOrDefault(x => x.SheetDefNum == sheetDefNum); //Can be null
     }
     if (def == null)                                                                 //Just in case.
     {
         def = ListSheetDefsLayout[0];                                                //Use first in the list.
     }
     #endregion
     return(def);
 }
Esempio n. 13
0
        public FormTaskOptions(bool isShowFinishedTasks, DateTime dateTimeStartShowFinished, bool isAptDateTimeSort)
        {
            InitializeComponent();
            Lan.F(this);
            checkShowFinished.Checked         = isShowFinishedTasks;
            textStartDate.Text                = dateTimeStartShowFinished.ToShortDateString();
            checkTaskSortApptDateTime.Checked = isAptDateTimeSort;
            List <UserOdPref> listPrefs = UserOdPrefs.GetByUserAndFkeyType(Security.CurUser.UserNum, UserOdFkeyType.TaskCollapse);

            _taskCollapsedPref     = listPrefs.Count == 0? null : listPrefs[0];
            checkCollapsed.Checked = _taskCollapsedPref == null ? false : PIn.Bool(_taskCollapsedPref.ValueString);
            if (!isShowFinishedTasks)
            {
                labelStartDate.Enabled = false;
                textStartDate.Enabled  = false;
            }
        }
        private void FillGrid()
        {
            Cursor = Cursors.WaitCursor;
            gridUserProperties.BeginUpdate();
            gridUserProperties.ListGridColumns.Clear();
            GridColumn col = new GridColumn(Lan.g("TableUserPrefProperties", "Clinic"), 120);

            gridUserProperties.ListGridColumns.Add(col);
            col = new GridColumn(Lan.g("TableUserPrefProperties", "DoseSpot User ID"), 120, true);
            gridUserProperties.ListGridColumns.Add(col);
            gridUserProperties.ListGridRows.Clear();
            GridRow    row;
            UserOdPref userPrefDefault = _listUserPref.Find(x => x.ClinicNum == 0);

            //Doesn't exist in Db, create one
            if (userPrefDefault == null)
            {
                userPrefDefault = UserOdPrefs.GetByCompositeKey(_userCur.UserNum, Programs.GetCur(ProgramName.eRx).ProgramNum, UserOdFkeyType.Program, 0);
                //Doesn't exist in db, add to list to be synced later
                _listUserPref.Add(userPrefDefault);
            }
            row = new GridRow();
            row.Cells.Add("Default");
            row.Cells.Add(userPrefDefault.ValueString);
            row.Tag = userPrefDefault;
            gridUserProperties.ListGridRows.Add(row);
            foreach (Clinic clinicCur in Clinics.GetForUserod(Security.CurUser))
            {
                row = new GridRow();
                UserOdPref userPrefCur = _listUserPref.Find(x => x.ClinicNum == clinicCur.ClinicNum);
                //wasn't in list, check Db and create a new one if needed
                if (userPrefCur == null)
                {
                    userPrefCur = UserOdPrefs.GetByCompositeKey(_userCur.UserNum, Programs.GetCur(ProgramName.eRx).ProgramNum, UserOdFkeyType.Program, clinicCur.ClinicNum);
                    //Doesn't exist in db, add to list to be synced later
                    _listUserPref.Add(userPrefCur);
                }
                row.Cells.Add(clinicCur.Abbr);
                row.Cells.Add(userPrefCur.ValueString);
                row.Tag = userPrefCur;
                gridUserProperties.ListGridRows.Add(row);
            }
            gridUserProperties.EndUpdate();
            Cursor = Cursors.Default;
        }
Esempio n. 15
0
 ///<summary>Helper method to update or insert the passed in UserOdPref utilizing the specified valueString and keyType.
 ///If the user pref passed in it null then a new user pref will be inserted.  Otherwise the user pref is updated.</summary>
 private void UpsertUserOdPref(UserOdPref userOdPref, UserOdFkeyType keyType, string valueString)
 {
     if (userOdPref == null)
     {
         UserOdPref userOdPrefTemp = new UserOdPref();
         userOdPrefTemp.Fkey        = 0;
         userOdPrefTemp.FkeyType    = keyType;
         userOdPrefTemp.UserNum     = _userNumCur;
         userOdPrefTemp.ValueString = valueString;
         UserOdPrefs.Insert(userOdPrefTemp);
     }
     else
     {
         userOdPref.FkeyType    = keyType;
         userOdPref.ValueString = valueString;
         UserOdPrefs.Update(userOdPref);
     }
 }
Esempio n. 16
0
 private void FormUserSetting_Load(object sender, EventArgs e)
 {
     _progOryx     = Programs.GetCur(ProgramName.Oryx);
     _userNamePref = UserOdPrefs.GetByUserFkeyAndFkeyType(Security.CurUser.UserNum, _progOryx.ProgramNum, UserOdFkeyType.ProgramUserName)
                     .FirstOrDefault();
     _passwordPref = UserOdPrefs.GetByUserFkeyAndFkeyType(Security.CurUser.UserNum, _progOryx.ProgramNum, UserOdFkeyType.ProgramPassword)
                     .FirstOrDefault();
     if (_userNamePref != null)
     {
         textUsername.Text = _userNamePref.ValueString;
     }
     if (_passwordPref != null)
     {
         string passwordPlain;
         CDT.Class1.Decrypt(_passwordPref.ValueString, out passwordPlain);
         textPassword.Text = passwordPlain;
     }
 }
Esempio n. 17
0
 private void butOK_Click(object sender, EventArgs e)
 {
     if (checkSuppressMessage.Checked && _suppressLogOffMessage == null)
     {
         //insert
         UserOdPrefs.Insert(new UserOdPref()
         {
             UserNum  = Security.CurUser.UserNum,
             FkeyType = UserOdFkeyType.SuppressLogOffMessage
         });
     }
     else if (!checkSuppressMessage.Checked && _suppressLogOffMessage != null)
     {
         //delete
         UserOdPrefs.Delete(_suppressLogOffMessage.UserOdPrefNum);
     }
     DialogResult = DialogResult.OK;
 }
Esempio n. 18
0
 private void FormCommItemUserPrefs_Load(object sender, EventArgs e)
 {
     if (Security.CurUser == null || Security.CurUser.UserNum < 1)
     {
         MsgBox.Show(this, "Invalid user currently logged in.  No user preferences can be saved.");
         DialogResult = DialogResult.Abort;
         return;
     }
     _userNumCur = Security.CurUser.UserNum;
     //Add the user name of the user currently logged in to the title of this window much like we do for FormOpenDental.
     this.Text                              += " {" + Security.CurUser.UserName + "}";
     _userOdPrefClearNote                    = UserOdPrefs.GetByUserAndFkeyType(_userNumCur, UserOdFkeyType.CommlogPersistClearNote).FirstOrDefault();
     _userOdPrefEndDate                      = UserOdPrefs.GetByUserAndFkeyType(_userNumCur, UserOdFkeyType.CommlogPersistClearEndDate).FirstOrDefault();
     _userOdPrefUpdateDateTimeNewPat         = UserOdPrefs.GetByUserAndFkeyType(_userNumCur, UserOdFkeyType.CommlogPersistUpdateDateTimeWithNewPatient).FirstOrDefault();
     checkCommlogPersistClearNote.Checked    = (_userOdPrefClearNote == null) ? true : PIn.Bool(_userOdPrefClearNote.ValueString);
     checkCommlogPersistClearEndDate.Checked = (_userOdPrefEndDate == null) ? true : PIn.Bool(_userOdPrefEndDate.ValueString);
     checkCommlogPersistUpdateDateTimeWithNewPatient.Checked = (_userOdPrefUpdateDateTimeNewPat == null) ? true : PIn.Bool(_userOdPrefUpdateDateTimeNewPat.ValueString);
 }
Esempio n. 19
0
 private void butOK_Click(object sender, EventArgs e)
 {
     _userNamePref = _userNamePref ?? new UserOdPref {
         Fkey     = _progOryx.ProgramNum,
         FkeyType = UserOdFkeyType.ProgramUserName,
         UserNum  = Security.CurUser.UserNum,
     };
     _passwordPref = _passwordPref ?? new UserOdPref {
         Fkey     = _progOryx.ProgramNum,
         FkeyType = UserOdFkeyType.ProgramPassword,
         UserNum  = Security.CurUser.UserNum,
     };
     _userNamePref.ValueString = textUsername.Text;
     CDT.Class1.Encrypt(textPassword.Text, out _passwordPref.ValueString);
     UserOdPrefs.Upsert(_userNamePref);
     UserOdPrefs.Upsert(_passwordPref);
     DialogResult = DialogResult.OK;
     Close();
 }
Esempio n. 20
0
 //~15ms with 8 TaskLists, about 1 frame @ 60fps
 ///<summary>Gets the changed preferences for the tree, then updates the database with the changes.</summary>
 private void butOK_Click(object sender, EventArgs e)
 {
     //Setup all the changed preferences
     foreach (TreeNode node in treeSubscriptions.Nodes)
     {
         SetDictPrefsRecursive(node);
     }
     //Add new preferences and changes to database
     foreach (UserOdPref editPref in _dictBlockedTaskPrefs.Values)
     {
         if (_listUserOdPrefTaskListBlocks.Exists(x => x.Fkey == editPref.Fkey))
         {
             editPref.UserOdPrefNum = _listUserOdPrefTaskListBlocks.Find(x => x.Fkey == editPref.Fkey).UserOdPrefNum;
         }
     }
     UserOdPrefs.Sync(_dictBlockedTaskPrefs.Select(x => x.Value).ToList(), _listUserDBPrefs);
     DialogResult = DialogResult.OK;
     this.Close();
 }
Esempio n. 21
0
 private void FillThemeCombo()
 {
     foreach (OdTheme theme in Enum.GetValues(typeof(OdTheme)))
     {
         if (theme == OdTheme.None)
         {
             continue;
         }
         comboTheme.Items.Add(theme);
     }
     _themePref = UserOdPrefs.GetByUserAndFkeyType(Security.CurUser.UserNum, UserOdFkeyType.UserTheme).FirstOrDefault();
     if (_themePref != null)           //user has chosen a theme before. Display their currently chosen theme.
     {
         comboTheme.SelectedIndex = comboTheme.Items.IndexOf((OdTheme)_themePref.Fkey);
     }
     else              //user has not chosen a theme before. Show them the current default.
     {
         comboTheme.SelectedIndex = PrefC.GetInt(PrefName.ColorTheme);
     }
 }
Esempio n. 22
0
 private void butClose_Click(object sender, EventArgs e)
 {
     if (_userPrefShowReceived == null)
     {
         UserOdPrefs.Insert(new UserOdPref()
         {
             UserNum     = Security.CurUser.UserNum,
             FkeyType    = UserOdFkeyType.ReceivedSupplyOrders,
             ValueString = POut.Bool(checkShowReceived.Checked)
         });
     }
     else
     {
         if (_userPrefShowReceived.ValueString != POut.Bool(checkShowReceived.Checked))               //The user preference has changed.
         {
             _userPrefShowReceived.ValueString = POut.Bool(checkShowReceived.Checked);
             UserOdPrefs.Update(_userPrefShowReceived);
         }
     }
     Close();
 }
Esempio n. 23
0
 private void FormSupplyOrders_Load(object sender, EventArgs e)
 {
     Height                   = SystemInformation.WorkingArea.Height; //max height
     Location                 = new Point(Location.X, 0);             //move to top of screen
     _listSupplyOrders        = new List <SupplyOrder>();
     _listSuppliers           = Suppliers.GetAll();
     comboSupplier.IncludeAll = true;
     comboSupplier.Items.AddList(_listSuppliers, x => x.Name);
     comboSupplier.IsAllSelected = true;
     _userPrefShowReceived       = UserOdPrefs.GetByUserAndFkeyType(Security.CurUser.UserNum, UserOdFkeyType.ReceivedSupplyOrders).FirstOrDefault();
     if (_userPrefShowReceived != null && PIn.Bool(_userPrefShowReceived.ValueString))
     {
         checkShowReceived.Checked = true;
     }
     else
     {
         checkShowReceived.Checked = false;
     }
     FillGridOrders();
     gridOrders.ScrollToEnd();
 }
        private void butOK_Click(object sender, EventArgs e)
        {
            if (_selectedUserNum == 0)
            {
                MsgBox.Show(this, "Please select a user.");
                return;
            }
            UserOdPref userDosePref = UserOdPrefs.GetByCompositeKey(_selectedUserNum, _programErx.ProgramNum, UserOdFkeyType.Program);

            userDosePref.ValueString = _providerErxCur.UserId.ToString();
            if (userDosePref.IsNew)
            {
                userDosePref.Fkey = _programErx.ProgramNum;
                UserOdPrefs.Insert(userDosePref);
            }
            else
            {
                UserOdPrefs.Update(userDosePref);
            }
            DialogResult = DialogResult.OK;
        }
Esempio n. 25
0
        ///<summary>Updates or inserts (if necessary) the user's preference dictating which chart layout sheet def the user last viewed.
        ///Should only be called when a user selects a specific layout.</summary>
        private void UpdateChartLayoutUserPref()
        {
            UserOdPref userPref = UserOdPrefs.GetFirstOrNewByUserAndFkeyType(Security.CurUser.UserNum, UserOdFkeyType.DynamicChartLayout);

            userPref.Fkey = _sheetDefDynamicLayoutCur.SheetDefNum;
            if (!PrefC.HasClinicsEnabled || Clinics.ClinicNum == 0 ||
                !ClinicPrefs.TryGetLong(PrefName.SheetsDefaultChartModule, Clinics.ClinicNum, out long defaultSheetDefNum))
            {
                defaultSheetDefNum = PrefC.GetLong(PrefName.SheetsDefaultChartModule);
            }
            if (userPref.Fkey == defaultSheetDefNum)
            {
                if (!userPref.IsNew)
                {
                    UserOdPrefs.Delete(userPref.UserOdPrefNum);                    //Delete old entry, this will cause user to view any newly selected practice or clinic defaults.
                }
                //User selected the practice or clinic default, flag so that this user continues to get the appropriate default.
                return;
            }
            UserOdPrefs.Upsert(userPref);
        }
Esempio n. 26
0
        private void FormAutoNoteCompose_FormClosing(object sender, FormClosingEventArgs e)
        {
            //store the current node expanded state for this user
            List <long> listExpandedDefNums = treeListMain.Nodes.OfType <TreeNode>().SelectMany(x => GetNodeAndChildren(x))
                                              .Where(x => x.Tag is Def && x.IsExpanded).Select(x => ((Def)x.Tag).DefNum).Where(x => x > 0).ToList();

            if (_userOdCurPref == null)
            {
                UserOdPrefs.Insert(new UserOdPref()
                {
                    UserNum     = Security.CurUser.UserNum,
                    FkeyType    = UserOdFkeyType.AutoNoteExpandedCats,
                    ValueString = string.Join(",", listExpandedDefNums)
                });
            }
            else
            {
                _userOdCurPref.ValueString = string.Join(",", listExpandedDefNums);
                UserOdPrefs.Update(_userOdCurPref);
            }
        }
        private List <Userod> GetListDoseSpotUsers(bool includeProv, string provNpi = "")
        {
            List <Userod>     retVal                  = new List <Userod>();
            List <Provider>   listProviders           = Providers.GetWhere(x => x.NationalProvID == provNpi, true);
            List <UserOdPref> listUserPrefDoseSpotIds = UserOdPrefs.GetAllByFkeyAndFkeyType(_programErx.ProgramNum, UserOdFkeyType.Program);

            listUserPrefDoseSpotIds = listUserPrefDoseSpotIds.FindAll(x => string.IsNullOrWhiteSpace(x.ValueString));
            if (includeProv)
            {
                retVal = Userods.GetWhere(
                    (x => listProviders.Exists(y => y.ProvNum == x.ProvNum) &&                //Find users that have a link to the NPI that has been passed in
                     !listUserPrefDoseSpotIds.Exists(y => y.UserNum == x.UserNum)) //Also, these users shouldn't already have a DoseSpot User ID.
                    , true);                                                       //Only consider non-hidden users.
            }
            else
            {
                retVal = Userods.GetWhere(
                    (x => !listUserPrefDoseSpotIds.Exists(y => y.UserNum == x.UserNum)) //All users that don't already have a DoseSpot User ID.
                    , true);                                                            //Only consider non-hidden users.
            }
            return(retVal);
        }
Esempio n. 28
0
        private void butOK_Click(object sender, System.EventArgs e)
        {
            if (checkHidden.Checked)
            {
                if (Defs.IsDefinitionInUse(DefCur))
                {
                    if (!MsgBox.Show(this, MsgBoxButtons.OKCancel, "Warning: This definition is currently in use within the program."))
                    {
                        return;
                    }
                }
            }
            if (textName.Text == "")
            {
                MsgBox.Show(this, "Name required.");
                return;
            }
            DefCur.ItemName = textName.Text;
            string itemVal = "";

            if (checkChartModule.Checked)
            {
                itemVal += "X";
            }
            if (checkPatientForms.Checked)
            {
                itemVal += "F";
            }
            if (checkPatientPortal.Checked)
            {
                itemVal += "L";
            }
            if (checkPatientPictures.Checked)
            {
                itemVal += "P";
            }
            if (checkStatements.Checked)
            {
                itemVal += "S";
            }
            if (checkToothCharts.Checked)
            {
                itemVal += "T";
            }
            if (checkTreatmentPlans.Checked)
            {
                itemVal += "R";
            }
            if (checkExpanded.Checked)
            {
                itemVal += "E";
            }
            if (checkPaymentPlans.Checked)
            {
                itemVal += "A";
            }
            if (!IsNew && checkExpanded.Checked != DefCur.ItemValue.Contains("E"))           //If checkbox has been changed since opening form.
            {
                if (MsgBox.Show(this, true, "Expanded by default option changed.  This change will affect all users.  Continue?"))
                {
                    //Remove all user specific preferences to enforce the new default.
                    UserOdPrefs.DeleteForFkey(0, UserOdFkeyType.Definition, DefCur.DefNum);
                }
            }
            if (checkClaimAttachments.Checked)
            {
                itemVal += "C";
            }
            if (checkLabCases.Checked)
            {
                itemVal += "B";
            }
            DefCur.ItemValue = itemVal;
            DefCur.IsHidden  = checkHidden.Checked;
            if (IsNew)
            {
                Defs.Insert(DefCur);
            }
            else
            {
                Defs.Update(DefCur);
            }
            DialogResult = DialogResult.OK;
        }
Esempio n. 29
0
        private void FormUserEdit_Load(object sender, System.EventArgs e)
        {
            checkIsHidden.Checked = UserCur.IsHidden;
            if (UserCur.UserNum != 0)
            {
                textUserNum.Text = UserCur.UserNum.ToString();
            }
            textUserName.Text   = UserCur.UserName;
            textDomainUser.Text = UserCur.DomainUser;
            if (!PrefC.GetBool(PrefName.DomainLoginEnabled))
            {
                labelDomainUser.Visible   = false;
                textDomainUser.Visible    = false;
                butPickDomainUser.Visible = false;
            }
            checkRequireReset.Checked = UserCur.IsPasswordResetRequired;
            _listUserGroups           = UserGroups.GetList();
            _isFillingList            = true;
            for (int i = 0; i < _listUserGroups.Count; i++)
            {
                listUserGroup.Items.Add(new ODBoxItem <UserGroup>(_listUserGroups[i].Description, _listUserGroups[i]));
                if (!_isFromAddUser && UserCur.IsInUserGroup(_listUserGroups[i].UserGroupNum))
                {
                    listUserGroup.SetSelected(i, true);
                }
                if (_isFromAddUser && _listUserGroups[i].UserGroupNum == PrefC.GetLong(PrefName.DefaultUserGroup))
                {
                    listUserGroup.SetSelected(i, true);
                }
            }
            if (listUserGroup.SelectedIndex == -1)          //never allowed to delete last group, so this won't fail
            {
                listUserGroup.SelectedIndex = 0;
            }
            _isFillingList = false;
            securityTreeUser.FillTreePermissionsInitial();
            RefreshUserTree();
            listEmployee.Items.Clear();
            listEmployee.Items.Add(Lan.g(this, "none"));
            listEmployee.SelectedIndex = 0;
            _listEmployees             = Employees.GetDeepCopy(true);
            for (int i = 0; i < _listEmployees.Count; i++)
            {
                listEmployee.Items.Add(Employees.GetNameFL(_listEmployees[i]));
                if (UserCur.EmployeeNum == _listEmployees[i].EmployeeNum)
                {
                    listEmployee.SelectedIndex = i + 1;
                }
            }
            listProv.Items.Clear();
            listProv.Items.Add(Lan.g(this, "none"));
            listProv.SelectedIndex = 0;
            _listProviders         = Providers.GetDeepCopy(true);
            for (int i = 0; i < _listProviders.Count; i++)
            {
                listProv.Items.Add(_listProviders[i].GetLongDesc());
                if (UserCur.ProvNum == _listProviders[i].ProvNum)
                {
                    listProv.SelectedIndex = i + 1;
                }
            }
            _listClinics           = Clinics.GetDeepCopy(true);
            _listUserAlertTypesOld = AlertSubs.GetAllForUser(UserCur.UserNum);
            List <long> listSubscribedClinics;
            bool        isAllClinicsSubscribed = false;

            if (_listUserAlertTypesOld.Select(x => x.ClinicNum).Contains(-1))             //User subscribed to all clinics
            {
                isAllClinicsSubscribed = true;
                listSubscribedClinics  = _listClinics.Select(x => x.ClinicNum).Distinct().ToList();
            }
            else
            {
                listSubscribedClinics = _listUserAlertTypesOld.Select(x => x.ClinicNum).Distinct().ToList();
            }
            List <long> listAlertCatNums = _listUserAlertTypesOld.Select(x => x.AlertCategoryNum).Distinct().ToList();

            listAlertSubMulti.Items.Clear();
            _listAlertCategories = AlertCategories.GetDeepCopy();
            List <long> listUserAlertCatNums = _listUserAlertTypesOld.Select(x => x.AlertCategoryNum).ToList();

            foreach (AlertCategory cat in _listAlertCategories)
            {
                int index = listAlertSubMulti.Items.Add(Lan.g(this, cat.Description));
                listAlertSubMulti.SetSelected(index, listUserAlertCatNums.Contains(cat.AlertCategoryNum));
            }
            if (!PrefC.HasClinicsEnabled)
            {
                tabClinics.Enabled = false;              //Disables all controls in the clinics tab.  Tab is still selectable.
                listAlertSubsClinicsMulti.Visible = false;
                labelAlertClinic.Visible          = false;
            }
            else
            {
                listClinic.Items.Clear();
                listClinic.Items.Add(Lan.g(this, "All"));
                listAlertSubsClinicsMulti.Items.Add(Lan.g(this, "All"));
                listAlertSubsClinicsMulti.Items.Add(Lan.g(this, "Headquarters"));
                if (UserCur.ClinicNum == 0)               //Unrestricted
                {
                    listClinic.SetSelected(0, true);
                    checkClinicIsRestricted.Enabled = false; //We don't really need this checkbox any more but it's probably better for users to keep it....
                }
                if (isAllClinicsSubscribed)                  //They are subscribed to all clinics
                {
                    listAlertSubsClinicsMulti.SetSelected(0, true);
                }
                else if (listSubscribedClinics.Contains(0))                 //They are subscribed to Headquarters
                {
                    listAlertSubsClinicsMulti.SetSelected(1, true);
                }
                List <UserClinic> listUserClinics = UserClinics.GetForUser(UserCur.UserNum);
                for (int i = 0; i < _listClinics.Count; i++)
                {
                    listClinic.Items.Add(_listClinics[i].Abbr);
                    listClinicMulti.Items.Add(_listClinics[i].Abbr);
                    listAlertSubsClinicsMulti.Items.Add(_listClinics[i].Abbr);
                    if (UserCur.ClinicNum == _listClinics[i].ClinicNum)
                    {
                        listClinic.SetSelected(i + 1, true);
                    }
                    if (UserCur.ClinicNum != 0 && listUserClinics.Exists(x => x.ClinicNum == _listClinics[i].ClinicNum))
                    {
                        listClinicMulti.SetSelected(i, true);                       //No "All" option, don't select i+1
                    }
                    if (!isAllClinicsSubscribed && _listUserAlertTypesOld.Exists(x => x.ClinicNum == _listClinics[i].ClinicNum))
                    {
                        listAlertSubsClinicsMulti.SetSelected(i + 2, true);                     //All+HQ
                    }
                }
                checkClinicIsRestricted.Checked = UserCur.ClinicIsRestricted;
            }
            if (string.IsNullOrEmpty(UserCur.PasswordHash))
            {
                butPassword.Text = Lan.g(this, "Create Password");
            }
            if (!PrefC.IsODHQ)
            {
                butJobRoles.Visible = false;
            }
            if (IsNew)
            {
                butUnlock.Visible = false;
            }
            _listDoseSpotUserPrefOld = UserOdPrefs.GetByUserAndFkeyAndFkeyType(UserCur.UserNum,
                                                                               Programs.GetCur(ProgramName.eRx).ProgramNum, UserOdFkeyType.Program,
                                                                               Clinics.GetForUserod(Security.CurUser, true).Select(x => x.ClinicNum)
                                                                               .Union(new List <long>()
            {
                0
            })                                                //Always include 0 clinic, this is the default, NOT a headquarters only value.
                                                                               .Distinct()
                                                                               .ToList());
            _listDoseSpotUserPrefNew = _listDoseSpotUserPrefOld.Select(x => x.Clone()).ToList();
            _doseSpotUserPrefDefault = _listDoseSpotUserPrefNew.Find(x => x.ClinicNum == 0);
            if (_doseSpotUserPrefDefault == null)
            {
                _doseSpotUserPrefDefault = DoseSpot.GetDoseSpotUserIdFromPref(UserCur.UserNum, 0);
                _listDoseSpotUserPrefNew.Add(_doseSpotUserPrefDefault);
            }
            textDoseSpotUserID.Text = _doseSpotUserPrefDefault.ValueString;
            if (_isFromAddUser && !Security.IsAuthorized(Permissions.SecurityAdmin, true))
            {
                butPassword.Visible       = false;
                checkRequireReset.Checked = true;
                checkRequireReset.Enabled = false;
                butUnlock.Visible         = false;
                butJobRoles.Visible       = false;
            }
            if (!PrefC.HasClinicsEnabled)
            {
                butDoseSpotAdditional.Visible = false;
            }
        }
Esempio n. 30
0
        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;
        }