Beispiel #1
0
 ///<summary>Inserts one UserOdPref into the database.  Returns the new priKey.</summary>
 public static long Insert(UserOdPref userOdPref)
 {
     if (DataConnection.DBtype == DatabaseType.Oracle)
     {
         userOdPref.UserOdPrefNum = DbHelper.GetNextOracleKey("userodpref", "UserOdPrefNum");
         int loopcount = 0;
         while (loopcount < 100)
         {
             try {
                 return(Insert(userOdPref, true));
             }
             catch (Oracle.ManagedDataAccess.Client.OracleException ex) {
                 if (ex.Number == 1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated"))
                 {
                     userOdPref.UserOdPrefNum++;
                     loopcount++;
                 }
                 else
                 {
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else
     {
         return(Insert(userOdPref, false));
     }
 }
Beispiel #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.");
        }
 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;
 }
        private void gridProvProperties_CellLeave(object sender, ODGridClickEventArgs e)
        {
            string     newDoseSpotID = PIn.String(gridUserProperties.ListGridRows[e.Row].Cells[e.Col].Text);
            UserOdPref userPref      = (UserOdPref)gridUserProperties.ListGridRows[e.Row].Tag;

            userPref.ValueString = newDoseSpotID;
        }
 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();
 }
Beispiel #6
0
        ///<summary>Updates one UserOdPref in the database.  Uses an old object to compare to, and only alters changed fields.  This prevents collisions and concurrency problems in heavily used tables.  Returns true if an update occurred.</summary>
        public static bool Update(UserOdPref userOdPref, UserOdPref oldUserOdPref)
        {
            string command = "";

            if (userOdPref.UserNum != oldUserOdPref.UserNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "UserNum = " + POut.Long(userOdPref.UserNum) + "";
            }
            if (userOdPref.Fkey != oldUserOdPref.Fkey)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "Fkey = " + POut.Long(userOdPref.Fkey) + "";
            }
            if (userOdPref.FkeyType != oldUserOdPref.FkeyType)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "FkeyType = " + POut.Int((int)userOdPref.FkeyType) + "";
            }
            if (userOdPref.ValueString != oldUserOdPref.ValueString)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ValueString = " + DbHelper.ParamChar + "paramValueString";
            }
            if (userOdPref.ClinicNum != oldUserOdPref.ClinicNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ClinicNum = " + POut.Long(userOdPref.ClinicNum) + "";
            }
            if (command == "")
            {
                return(false);
            }
            if (userOdPref.ValueString == null)
            {
                userOdPref.ValueString = "";
            }
            OdSqlParameter paramValueString = new OdSqlParameter("paramValueString", OdDbType.Text, POut.StringParam(userOdPref.ValueString));

            command = "UPDATE userodpref SET " + command
                      + " WHERE UserOdPrefNum = " + POut.Long(userOdPref.UserOdPrefNum);
            Db.NonQ(command, paramValueString);
            return(true);
        }
Beispiel #7
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
 }
Beispiel #8
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;
     }
 }
Beispiel #9
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();
 }
Beispiel #10
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);
 }
Beispiel #11
0
        private void butDoseSpotAdditional_Click(object sender, EventArgs e)
        {
            _doseSpotUserPrefDefault.ValueString = textDoseSpotUserID.Text;
            FormUserPrefAdditional FormUP = new FormUserPrefAdditional(_listDoseSpotUserPrefNew, UserCur);

            FormUP.ShowDialog();
            if (FormUP.DialogResult == DialogResult.OK)
            {
                _listDoseSpotUserPrefNew = FormUP.ListUserPrefOut;
                _doseSpotUserPrefDefault = _listDoseSpotUserPrefNew.Find(x => x.ClinicNum == 0);
                textDoseSpotUserID.Text  = _doseSpotUserPrefDefault.ValueString;
            }
        }
Beispiel #12
0
 ///<summary>Inserts one UserOdPref into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(UserOdPref userOdPref)
 {
     if (DataConnection.DBtype == DatabaseType.MySql)
     {
         return(InsertNoCache(userOdPref, false));
     }
     else
     {
         if (DataConnection.DBtype == DatabaseType.Oracle)
         {
             userOdPref.UserOdPrefNum = DbHelper.GetNextOracleKey("userodpref", "UserOdPrefNum");                  //Cacheless method
         }
         return(InsertNoCache(userOdPref, true));
     }
 }
Beispiel #13
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();
 }
Beispiel #14
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);
 }
Beispiel #15
0
        ///<summary>Goes through tree and sets up changes to the TaskList block preferences dictionary.</summary>
        private void SetDictPrefsRecursive(TreeNode node)
        {
            foreach (TreeNode child in node.Nodes)
            {
                SetDictPrefsRecursive(child);                   //Recursion
            }
            //Create preference
            UserOdPref pref = new UserOdPref();

            pref.Fkey        = (long)node.Tag;
            pref.FkeyType    = UserOdFkeyType.TaskListBlock;
            pref.UserNum     = Security.CurUser.UserNum;
            pref.ValueString = POut.Bool(node.Checked);
            //Add preference to dictionary of preferences
            _dictBlockedTaskPrefs[(long)node.Tag] = pref;
        }
Beispiel #16
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;
        }
 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;
     }
 }
 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);
 }
 ///<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);
     }
 }
Beispiel #21
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <UserOdPref> TableToList(DataTable table)
        {
            List <UserOdPref> retVal = new List <UserOdPref>();
            UserOdPref        userOdPref;

            foreach (DataRow row in table.Rows)
            {
                userOdPref = new UserOdPref();
                userOdPref.UserOdPrefNum = PIn.Long(row["UserOdPrefNum"].ToString());
                userOdPref.UserNum       = PIn.Long(row["UserNum"].ToString());
                userOdPref.Fkey          = PIn.Long(row["Fkey"].ToString());
                userOdPref.FkeyType      = (OpenDentBusiness.UserOdFkeyType)PIn.Int(row["FkeyType"].ToString());
                userOdPref.ValueString   = PIn.String(row["ValueString"].ToString());
                userOdPref.ClinicNum     = PIn.Long(row["ClinicNum"].ToString());
                retVal.Add(userOdPref);
            }
            return(retVal);
        }
Beispiel #22
0
        ///<summary>Updates one UserOdPref in the database.</summary>
        public static void Update(UserOdPref userOdPref)
        {
            string command = "UPDATE userodpref SET "
                             + "UserNum      =  " + POut.Long(userOdPref.UserNum) + ", "
                             + "Fkey         =  " + POut.Long(userOdPref.Fkey) + ", "
                             + "FkeyType     =  " + POut.Int((int)userOdPref.FkeyType) + ", "
                             + "ValueString  =  " + DbHelper.ParamChar + "paramValueString, "
                             + "ClinicNum    =  " + POut.Long(userOdPref.ClinicNum) + " "
                             + "WHERE UserOdPrefNum = " + POut.Long(userOdPref.UserOdPrefNum);

            if (userOdPref.ValueString == null)
            {
                userOdPref.ValueString = "";
            }
            OdSqlParameter paramValueString = new OdSqlParameter("paramValueString", OdDbType.Text, POut.StringParam(userOdPref.ValueString));

            Db.NonQ(command, paramValueString);
        }
 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();
 }
Beispiel #24
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);
     }
 }
        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;
        }
Beispiel #26
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);
        }
 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();
 }
Beispiel #28
0
        ///<summary>Inserts one UserOdPref into the database.  Provides option to use the existing priKey.  Doesn't use the cache.</summary>
        public static long InsertNoCache(UserOdPref userOdPref, bool useExistingPK)
        {
            bool   isRandomKeys = Prefs.GetBoolNoCache(PrefName.RandomPrimaryKeys);
            string command      = "INSERT INTO userodpref (";

            if (!useExistingPK && isRandomKeys)
            {
                userOdPref.UserOdPrefNum = ReplicationServers.GetKeyNoCache("userodpref", "UserOdPrefNum");
            }
            if (isRandomKeys || useExistingPK)
            {
                command += "UserOdPrefNum,";
            }
            command += "UserNum,Fkey,FkeyType,ValueString,ClinicNum) VALUES(";
            if (isRandomKeys || useExistingPK)
            {
                command += POut.Long(userOdPref.UserOdPrefNum) + ",";
            }
            command +=
                POut.Long(userOdPref.UserNum) + ","
                + POut.Long(userOdPref.Fkey) + ","
                + POut.Int((int)userOdPref.FkeyType) + ","
                + DbHelper.ParamChar + "paramValueString,"
                + POut.Long(userOdPref.ClinicNum) + ")";
            if (userOdPref.ValueString == null)
            {
                userOdPref.ValueString = "";
            }
            OdSqlParameter paramValueString = new OdSqlParameter("paramValueString", OdDbType.Text, POut.StringParam(userOdPref.ValueString));

            if (useExistingPK || isRandomKeys)
            {
                Db.NonQ(command, paramValueString);
            }
            else
            {
                userOdPref.UserOdPrefNum = Db.NonQ(command, true, "UserOdPrefNum", "userOdPref", paramValueString);
            }
            return(userOdPref.UserOdPrefNum);
        }
Beispiel #29
0
 ///<summary>Returns true if Update(UserOdPref,UserOdPref) would make changes to the database.
 ///Does not make any changes to the database and can be called before remoting role is checked.</summary>
 public static bool UpdateComparison(UserOdPref userOdPref, UserOdPref oldUserOdPref)
 {
     if (userOdPref.UserNum != oldUserOdPref.UserNum)
     {
         return(true);
     }
     if (userOdPref.Fkey != oldUserOdPref.Fkey)
     {
         return(true);
     }
     if (userOdPref.FkeyType != oldUserOdPref.FkeyType)
     {
         return(true);
     }
     if (userOdPref.ValueString != oldUserOdPref.ValueString)
     {
         return(true);
     }
     if (userOdPref.ClinicNum != oldUserOdPref.ClinicNum)
     {
         return(true);
     }
     return(false);
 }
 ///<summary>Inserts one UserOdPref into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(UserOdPref userOdPref)
 {
     return(InsertNoCache(userOdPref, false));
 }