Example #1
0
 ///<summary>Pass in new list and original list.  This will synch everything with Db.  Leave doCheckFeeSchedGroups set to true unless calling from
 ///FeeSchedGroups.</summary>
 public static bool SynchList(List <Fee> listNew, List <Fee> listDB, bool doCheckFeeSchedGroups = true)
 {
     if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
     {
         return(Meth.GetBool(MethodBase.GetCurrentMethod(), listNew, listDB, doCheckFeeSchedGroups));
     }
     if (PrefC.GetBool(PrefName.ShowFeeSchedGroups) && doCheckFeeSchedGroups)
     {
         FeeSchedGroups.SyncGroupFees(listNew, listDB);
     }
     return(Crud.FeeCrud.Sync(listNew, listDB, 0));
 }
Example #2
0
 /// <summary>Bulk Insert.  Only set doCheckFeeSchedGroups to false from FeeSchedGroups.</summary>
 public static void InsertMany(List <Fee> listFees, bool doCheckFeeSchedGroups = true)
 {
     if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
     {
         Meth.GetVoid(MethodBase.GetCurrentMethod(), listFees, doCheckFeeSchedGroups);
         return;
     }
     //Security.CurUser.UserNum gets set on MT by the DtoProcessor so it matches the user from the client WS.
     listFees.ForEach(x => x.SecUserNumEntry = Security.CurUser.UserNum);
     if (PrefC.GetBool(PrefName.ShowFeeSchedGroups) && doCheckFeeSchedGroups)
     {
         FeeSchedGroups.UpsertGroupFees(listFees);
     }
     Crud.FeeCrud.InsertMany(listFees);
 }
Example #3
0
        ///<summary>Only set doCheckFeeSchedGroups to false from FeeSchedGroups.</summary>
        public static void DeleteMany(List <long> listFeeNums, bool doCheckFeeSchedGroups = true)
        {
            if (listFeeNums.Count == 0)
            {
                return;
            }
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                Meth.GetVoid(MethodBase.GetCurrentMethod(), listFeeNums, doCheckFeeSchedGroups);
                return;
            }
            if (PrefC.GetBool(PrefName.ShowFeeSchedGroups) && doCheckFeeSchedGroups)
            {
                FeeSchedGroups.DeleteGroupFees(listFeeNums);
            }
            ClearFkey(listFeeNums);
            string command = "DELETE FROM fee WHERE FeeNum IN (" + string.Join(",", listFeeNums) + ")";

            Db.NonQ(command);
        }
Example #4
0
 ///<summary>Only set doCheckFeeSchedGroups to false from FeeSchedGroups.</summary>
 public static void Delete(Fee fee, bool doCheckFeeSchedGroups = true)
 {
     //Even though we do not run a query in this method, there is a lot of back and forth and we should get to the server early to ensure less chattiness.
     if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
     {
         Meth.GetVoid(MethodBase.GetCurrentMethod(), fee, doCheckFeeSchedGroups);
         return;
     }
     if (PrefC.GetBool(PrefName.ShowFeeSchedGroups) && doCheckFeeSchedGroups)
     {
         //If this fee isn't in a group don't bother checking.
         if (FeeSchedGroups.GetOneForFeeSchedAndClinic(fee.FeeSched, fee.ClinicNum) != null)
         {
             FeeSchedGroups.DeleteGroupFees(new List <long>()
             {
                 fee.FeeNum
             });
         }
     }
     Delete(fee.FeeNum);
 }
Example #5
0
 ///<summary>Only set doCheckFeeSchedGroups to false from FeeSchedGroups.</summary>
 public static void Update(Fee fee, bool doCheckFeeSchedGroups = true)
 {
     if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
     {
         Meth.GetVoid(MethodBase.GetCurrentMethod(), fee, doCheckFeeSchedGroups);
         return;
     }
     //Check if this fee is associated to a FeeSchedGroup and update the rest of the group as needed.
     if (PrefC.GetBool(PrefName.ShowFeeSchedGroups) && doCheckFeeSchedGroups)
     {
         //If this fee isn't in a group don't bother checking.
         if (FeeSchedGroups.GetOneForFeeSchedAndClinic(fee.FeeSched, fee.ClinicNum) != null)
         {
             FeeSchedGroups.UpsertGroupFees(new List <Fee>()
             {
                 fee
             });
         }
     }
     Crud.FeeCrud.Update(fee);
 }
Example #6
0
 ///<summary>Set doCheckFeeSchedGroups to false when calling this method from FeeSchedGroups to prevent infinitely looping.</summary>
 public static long Insert(Fee fee, bool doCheckFeeSchedGroups = true)
 {
     if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
     {
         fee.FeeNum = Meth.GetLong(MethodBase.GetCurrentMethod(), fee, doCheckFeeSchedGroups);
         return(fee.FeeNum);
     }
     //Security.CurUser.UserNum gets set on MT by the DtoProcessor so it matches the user from the client WS.
     fee.SecUserNumEntry = Security.CurUser.UserNum;
     if (PrefC.GetBool(PrefName.ShowFeeSchedGroups) && doCheckFeeSchedGroups)
     {
         //If this fee isn't in a group don't bother checking.
         if (FeeSchedGroups.GetOneForFeeSchedAndClinic(fee.FeeSched, fee.ClinicNum) != null)
         {
             FeeSchedGroups.UpsertGroupFees(new List <Fee>()
             {
                 fee
             });
         }
     }
     return(Crud.FeeCrud.Insert(fee));
 }
Example #7
0
        ///<summary>Only used by Fees.SynchList, this is basically a copy of the CRUD generated sync method with slight tweaks to work with FeeSchedGroups.
        ///Only calls the group helper methods that only modify the other fees in the group, the fess in listFeesNew and listFeesOld will be left to the fees.cs
        ///sync method to handle.</summary>
        public static void SyncGroupFees(List <Fee> listFeesNew, List <Fee> listFeesOld)
        {
            //No need to check RemotingRole; no call to db.
            //Adding items to lists changes the order of operation. All inserts are completed first, then updates, then deletes.
            List <Fee> listUpsert = new List <Fee>();
            List <Fee> listDel    = new List <Fee>();

            listFeesNew.Sort((Fee x, Fee y) => { return(x.FeeNum.CompareTo(y.FeeNum)); });          //Anonymous function, sorts by compairing PK.  Lambda expressions are not allowed, this is the one and only exception.  JS approved.
            listFeesOld.Sort((Fee x, Fee y) => { return(x.FeeNum.CompareTo(y.FeeNum)); });          //Anonymous function, sorts by compairing PK.  Lambda expressions are not allowed, this is the one and only exception.  JS approved.
            int idxNew = 0;
            int idxDB  = 0;
            Fee fieldNew;
            Fee fieldDB;

            //Because both lists have been sorted using the same criteria, we can now walk each list to determine which list contians the next element.  The next element is determined by Primary Key.
            //If the New list contains the next item it will be inserted.  If the DB contains the next item, it will be deleted.  If both lists contain the next item, the item will be updated.
            while (idxNew < listFeesNew.Count || idxDB < listFeesOld.Count)
            {
                fieldNew = null;
                if (idxNew < listFeesNew.Count)
                {
                    fieldNew = listFeesNew[idxNew];
                }
                fieldDB = null;
                if (idxDB < listFeesOld.Count)
                {
                    fieldDB = listFeesOld[idxDB];
                }
                //begin compare
                if (fieldNew != null && fieldDB == null)             //listNew has more items, listDB does not.
                //Make sure this fee is in a group before sending to the group update logic.
                {
                    if (FeeSchedGroups.GetOneForFeeSchedAndClinic(fieldNew.FeeSched, fieldNew.ClinicNum) != null)
                    {
                        listUpsert.Add(fieldNew);
                    }
                    idxNew++;
                    continue;
                }
                else if (fieldNew == null && fieldDB != null)             //listDB has more items, listNew does not.
                {
                    if (FeeSchedGroups.GetOneForFeeSchedAndClinic(fieldDB.FeeSched, fieldDB.ClinicNum) != null)
                    {
                        listDel.Add(fieldDB);
                    }
                    idxDB++;
                    continue;
                }
                else if (fieldNew.FeeNum < fieldDB.FeeNum)               //newPK less than dbPK, newItem is 'next'
                {
                    if (FeeSchedGroups.GetOneForFeeSchedAndClinic(fieldNew.FeeSched, fieldNew.ClinicNum) != null)
                    {
                        listUpsert.Add(fieldNew);
                    }
                    idxNew++;
                    continue;
                }
                else if (fieldNew.FeeNum > fieldDB.FeeNum)               //dbPK less than newPK, dbItem is 'next'
                {
                    if (FeeSchedGroups.GetOneForFeeSchedAndClinic(fieldDB.FeeSched, fieldDB.ClinicNum) != null)
                    {
                        listDel.Add(fieldDB);
                    }
                    idxDB++;
                    continue;
                }
                //Both lists contain the 'next' item, update required
                if (FeeSchedGroups.GetOneForFeeSchedAndClinic(fieldNew.FeeSched, fieldNew.ClinicNum) != null)
                {
                    listUpsert.Add(fieldNew);
                }
                idxNew++;
                idxDB++;
            }
            //Check for groups to update with changes.
            UpsertGroupFees(listUpsert);
            DeleteGroupFees(listDel);
        }