Exemplo n.º 1
0
        ///<summary>Passing in a clinicNum of 0 will use the base default sheet def.  Otherwise returns the clinic specific default sheetdef.</summary>
        public static SheetDef GetSheetsDefault(SheetTypeEnum sheetType, long clinicNum = 0)
        {
            //No need to check RemotingRole; no call to db.
            ClinicPref clinicPrefCur = ClinicPrefs.GetPref(Prefs.GetSheetDefPref(sheetType), clinicNum);
            SheetDef   defaultSheetDef;

            if (clinicPrefCur == null)           //If there wasn't a row for the specific clinic, use the base default sheetdef
            {
                defaultSheetDef = GetSheetDef(PrefC.GetDefaultSheetDefNum(sheetType), false);
                if (defaultSheetDef == null)
                {
                    defaultSheetDef = SheetsInternal.GetSheetDef(sheetType);
                }
                return(defaultSheetDef);               //Return the base default sheetdef
            }
            //Clinic specific sheet def found
            if (PIn.Long(clinicPrefCur.ValueString) == 0)           //If ValueString is 0 then we want to keep it as the internal sheet def.
            {
                defaultSheetDef = SheetsInternal.GetSheetDef(sheetType);
            }
            else
            {
                defaultSheetDef = GetSheetDef(PIn.Long(clinicPrefCur.ValueString), false);
            }
            return(defaultSheetDef);
        }
Exemplo n.º 2
0
        ///<summary>Deletes the prefs for this clinic. If any pref does not exist, then nothing will be done with that pref.</summary>
        public static void DeletePrefs(long clinicNum, List <PrefName> listPrefs)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                Meth.GetVoid(MethodBase.GetCurrentMethod(), clinicNum, listPrefs);
                return;
            }
            List <ClinicPref> listClinicPrefs = new List <ClinicPref>();

            foreach (PrefName pref in listPrefs)
            {
                ClinicPref clinicPref = GetPref(pref, clinicNum);
                if (clinicPref != null)
                {
                    listClinicPrefs.Add(clinicPref);
                }
            }
            if (listClinicPrefs.Count == 0)
            {
                return;
            }
            string command = "DELETE FROM clinicpref WHERE ClinicPrefNum IN(" + string.Join(",", listClinicPrefs.Select(x => x.ClinicPrefNum)) + ")";

            Db.NonQ(command);
        }
Exemplo n.º 3
0
        ///<summary>Updates a pref of type long for the specified clinic.  Returns true if a change was required, or false if no change needed.</summary>
        public static bool UpdateLong(PrefName prefName, long clinicNum, long newValue)
        {
            //Very unusual.  Involves cache, so Meth is used further down instead of here at the top.
            ClinicPref clinicPref = GetFirstOrDefault(x => x.ClinicNum == clinicNum && x.PrefName == prefName);

            if (clinicPref == null)
            {
                throw new ApplicationException("The PrefName " + prefName + " does not exist for ClinicNum: " + clinicNum);
            }
            if (PIn.Long(clinicPref.ValueString) == newValue)
            {
                return(false);               //no change needed
            }
            string command = "UPDATE clinicpref SET ValueString='" + POut.Long(newValue) + "' "
                             + "WHERE PrefName='" + POut.String(prefName.ToString()) + "' "
                             + "AND ClinicNum='" + POut.Long(clinicNum) + "'";
            bool retVal = true;

            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                retVal = Meth.GetBool(MethodBase.GetCurrentMethod(), prefName, newValue);
            }
            else
            {
                Db.NonQ(command);
            }
            //Update local cache even though we should be invalidating the cache outside of this method.
            ClinicPref cachedClinicPref = clinicPref;

            cachedClinicPref.PrefName    = prefName;
            cachedClinicPref.ValueString = newValue.ToString();
            cachedClinicPref.ClinicNum   = clinicNum;
            return(retVal);
        }
Exemplo n.º 4
0
        ///<summary>Returns the SheetTypeEnum & Sheet Def defaults for a clinic, if clinics is not on/or user is altering HQ settings
        ///it will instead return user defaults, if neither is present then it will return the pratice default.</summary>
        public static Dictionary <SheetTypeEnum, SheetDef> GetDefaultSheetDefs(long clinicNum = 0, params SheetTypeEnum[] arrSheetTypes)
        {
            //No need to check RemotingRole; no call to db.
            Dictionary <SheetTypeEnum, SheetDef> retVal = new Dictionary <SheetTypeEnum, SheetDef>();

            foreach (SheetTypeEnum sheetTypeEnum in arrSheetTypes)
            {
                SheetDef defaultSheetDef = GetSheetDef(PrefC.GetDefaultSheetDefNum(sheetTypeEnum), false);
                if (clinicNum == 0)
                {
                    if (defaultSheetDef == null)
                    {
                        defaultSheetDef = SheetsInternal.GetSheetDef(sheetTypeEnum);
                    }
                    retVal.Add(sheetTypeEnum, defaultSheetDef);
                }
                else
                {
                    ClinicPref clinicPrefCur = ClinicPrefs.GetPref(Prefs.GetSheetDefPref(sheetTypeEnum), clinicNum);
                    defaultSheetDef = SheetsInternal.GetSheetDef(sheetTypeEnum);
                    if (clinicPrefCur != null && PIn.Long(clinicPrefCur.ValueString) != 0)                 //If ValueString is 0 then we want to keep it as the internal sheet def.
                    {
                        defaultSheetDef = GetSheetDef(PIn.Long(clinicPrefCur.ValueString), false);
                    }
                    if (clinicPrefCur != null)                   //If there was a row in the clinicpref table, add whatever the sheetdef was to the retval dictionary.
                    {
                        retVal.Add(sheetTypeEnum, defaultSheetDef);
                    }
                }
            }
            return(retVal);
        }
Exemplo n.º 5
0
 public static void Update(ClinicPref newPref, ClinicPref oldPref)
 {
     if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
     {
         Meth.GetVoid(MethodBase.GetCurrentMethod(), newPref, oldPref);
         return;
     }
     Crud.ClinicPrefCrud.Update(newPref, oldPref);
 }
Exemplo n.º 6
0
 ///<summary></summary>
 public static long Insert(ClinicPref clinicPref)
 {
     if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
     {
         clinicPref.ClinicPrefNum = Meth.GetLong(MethodBase.GetCurrentMethod(), clinicPref);
         return(clinicPref.ClinicPrefNum);
     }
     return(Crud.ClinicPrefCrud.Insert(clinicPref));
 }
Exemplo n.º 7
0
        ///<summary>Gets the ValueString as a boolean for this clinic's pref or gets the actual preference if it does not exist.</summary>
        public static bool GetBool(PrefName prefName, long clinicNum)
        {
            ClinicPref pref = GetPref(prefName, clinicNum);

            if (pref == null)
            {
                return(PrefC.GetBool(prefName));
            }
            return(PIn.Bool(pref.ValueString));
        }
Exemplo n.º 8
0
        ///<summary>Returns 0 if there is no clinicpref entry for the specified pref.</summary>
        public static long GetLong(PrefName prefName, long clinicNum)
        {
            //No need to check RemotingRole; no call to db.
            ClinicPref pref = GetPref(prefName, clinicNum);

            if (pref == null)
            {
                return(0);
            }
            return(PIn.Long(pref.ValueString));
        }
Exemplo n.º 9
0
        ///<summary>Gets the ValueString for this clinic's pref or gets the actual preference if it does not exist.</summary>
        public static string GetPrefValue(PrefName pref, long clinicNum)
        {
            //No need to check RemotingRole; no call to db.
            ClinicPref clinicPref = GetPrefAllClinics(pref).FirstOrDefault(x => x.ClinicNum == clinicNum);

            if (clinicPref == null)
            {
                return(PrefC.GetString(pref));
            }
            return(clinicPref.ValueString);
        }
Exemplo n.º 10
0
        public static bool TryGetLong(PrefName prefName, long clinicNum, out long prefNum)
        {
            //No need to check RemotingRole; no call to db.
            ClinicPref pref = GetPref(prefName, clinicNum);

            if (pref == null)
            {
                prefNum = 0;
                return(false);
            }
            prefNum = PIn.Long(pref.ValueString);
            return(true);
        }
Exemplo n.º 11
0
        ///<summary>Inserts a pref of type long for the specified clinic.  Throws an exception if the preference already exists.</summary>
        public static void InsertPref(PrefName prefName, long clinicNum, string valueAsString)
        {
            //No need to check RemotingRole; no call to db.
            if (GetFirstOrDefault(x => x.ClinicNum == clinicNum && x.PrefName == prefName) != null)
            {
                throw new ApplicationException("The PrefName " + prefName + " already exists for ClinicNum: " + clinicNum);
            }
            ClinicPref clinicPrefToInsert = new ClinicPref();

            clinicPrefToInsert.PrefName    = prefName;
            clinicPrefToInsert.ValueString = valueAsString;
            clinicPrefToInsert.ClinicNum   = clinicNum;
            Insert(clinicPrefToInsert);
        }
Exemplo n.º 12
0
        public static Dictionary <SheetTypeEnum, SheetDef> GetDefaultSheetDefsForClinic(long clinicNum)
        {
            //No need to check RemotingRole; no call to db.
            Dictionary <SheetTypeEnum, SheetDef> retVal = new Dictionary <SheetTypeEnum, SheetDef>();
            ClinicPref clinicPrefCur = ClinicPrefs.GetPref(Prefs.GetSheetDefPref(SheetTypeEnum.Rx), clinicNum);
            SheetDef   defaultRxDef  = SheetsInternal.GetSheetDef(SheetTypeEnum.Rx);

            if (clinicPrefCur != null && PIn.Long(clinicPrefCur.ValueString) != 0)         //If ValueString is 0 then we want to keep it as the internal sheet def.
            {
                defaultRxDef = GetSheetDef(PIn.Long(clinicPrefCur.ValueString), false);
            }
            if (clinicPrefCur != null)           //If there was a row in the clinicpref table, add whatever the sheetdef was to the retval dictionary.
            {
                retVal.Add(SheetTypeEnum.Rx, defaultRxDef);
            }
            return(retVal);
        }
Exemplo n.º 13
0
        ///<summary>Inserts a new clinic pref or updates the existing one.</summary>
        ///<returns>True if an insert or update was made, false otherwise.</returns>
        public static bool Upsert(PrefName pref, long clinicNum, string newValue)
        {
            //No need to check RemotingRole; no call to db.
            ClinicPref clinicPref = GetPref(pref, clinicNum);

            if (clinicPref == null)
            {
                InsertPref(pref, clinicNum, newValue);
                return(true);
            }
            if (clinicPref.ValueString == newValue)
            {
                return(false);
            }
            clinicPref.ValueString = newValue;
            Update(clinicPref);
            return(true);
        }