Beispiel #1
0
        ///<summary>Inserts one CommOptOut into the database.  Provides option to use the existing priKey.  Doesn't use the cache.</summary>
        public static long InsertNoCache(CommOptOut commOptOut, bool useExistingPK)
        {
            bool   isRandomKeys = Prefs.GetBoolNoCache(PrefName.RandomPrimaryKeys);
            string command      = "INSERT INTO commoptout (";

            if (!useExistingPK && isRandomKeys)
            {
                commOptOut.CommOptOutNum = ReplicationServers.GetKeyNoCache("commoptout", "CommOptOutNum");
            }
            if (isRandomKeys || useExistingPK)
            {
                command += "CommOptOutNum,";
            }
            command += "PatNum,CommType,CommMode) VALUES(";
            if (isRandomKeys || useExistingPK)
            {
                command += POut.Long(commOptOut.CommOptOutNum) + ",";
            }
            command +=
                POut.Long(commOptOut.PatNum) + ","
                + POut.Int((int)commOptOut.CommType) + ","
                + POut.Int((int)commOptOut.CommMode) + ")";
            if (useExistingPK || isRandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                commOptOut.CommOptOutNum = Db.NonQ(command, true, "CommOptOutNum", "commOptOut");
            }
            return(commOptOut.CommOptOutNum);
        }
Beispiel #2
0
        ///<summary>Inserts one CommOptOut into the database.  Provides option to use the existing priKey.</summary>
        public static long Insert(CommOptOut commOptOut, bool useExistingPK)
        {
            if (!useExistingPK && PrefC.RandomKeys)
            {
                commOptOut.CommOptOutNum = ReplicationServers.GetKey("commoptout", "CommOptOutNum");
            }
            string command = "INSERT INTO commoptout (";

            if (useExistingPK || PrefC.RandomKeys)
            {
                command += "CommOptOutNum,";
            }
            command += "PatNum,CommType,CommMode) VALUES(";
            if (useExistingPK || PrefC.RandomKeys)
            {
                command += POut.Long(commOptOut.CommOptOutNum) + ",";
            }
            command +=
                POut.Long(commOptOut.PatNum) + ","
                + POut.Int((int)commOptOut.CommType) + ","
                + POut.Int((int)commOptOut.CommMode) + ")";
            if (useExistingPK || PrefC.RandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                commOptOut.CommOptOutNum = Db.NonQ(command, true, "CommOptOutNum", "commOptOut");
            }
            return(commOptOut.CommOptOutNum);
        }
Beispiel #3
0
        ///<summary>Updates one CommOptOut in the database.</summary>
        public static void Update(CommOptOut commOptOut)
        {
            string command = "UPDATE commoptout SET "
                             + "PatNum       =  " + POut.Long(commOptOut.PatNum) + ", "
                             + "CommType     =  " + POut.Int((int)commOptOut.CommType) + ", "
                             + "CommMode     =  " + POut.Int((int)commOptOut.CommMode) + " "
                             + "WHERE CommOptOutNum = " + POut.Long(commOptOut.CommOptOutNum);

            Db.NonQ(command);
        }
Beispiel #4
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <CommOptOut> TableToList(DataTable table)
        {
            List <CommOptOut> retVal = new List <CommOptOut>();
            CommOptOut        commOptOut;

            foreach (DataRow row in table.Rows)
            {
                commOptOut = new CommOptOut();
                commOptOut.CommOptOutNum = PIn.Long(row["CommOptOutNum"].ToString());
                commOptOut.PatNum        = PIn.Long(row["PatNum"].ToString());
                commOptOut.CommType      = (OpenDentBusiness.CommOptOutType)PIn.Int(row["CommType"].ToString());
                commOptOut.CommMode      = (OpenDentBusiness.CommOptOutMode)PIn.Int(row["CommMode"].ToString());
                retVal.Add(commOptOut);
            }
            return(retVal);
        }
Beispiel #5
0
 ///<summary>Returns true if Update(CommOptOut,CommOptOut) 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(CommOptOut commOptOut, CommOptOut oldCommOptOut)
 {
     if (commOptOut.PatNum != oldCommOptOut.PatNum)
     {
         return(true);
     }
     if (commOptOut.CommType != oldCommOptOut.CommType)
     {
         return(true);
     }
     if (commOptOut.CommMode != oldCommOptOut.CommMode)
     {
         return(true);
     }
     return(false);
 }
Beispiel #6
0
        ///<summary>Updates one CommOptOut 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(CommOptOut commOptOut, CommOptOut oldCommOptOut)
        {
            string command = "";

            if (commOptOut.PatNum != oldCommOptOut.PatNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "PatNum = " + POut.Long(commOptOut.PatNum) + "";
            }
            if (commOptOut.CommType != oldCommOptOut.CommType)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "CommType = " + POut.Int((int)commOptOut.CommType) + "";
            }
            if (commOptOut.CommMode != oldCommOptOut.CommMode)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "CommMode = " + POut.Int((int)commOptOut.CommMode) + "";
            }
            if (command == "")
            {
                return(false);
            }
            command = "UPDATE commoptout SET " + command
                      + " WHERE CommOptOutNum = " + POut.Long(commOptOut.CommOptOutNum);
            Db.NonQ(command);
            return(true);
        }
Beispiel #7
0
 ///<summary>Inserts one CommOptOut into the database.  Returns the new priKey.</summary>
 public static long Insert(CommOptOut commOptOut)
 {
     return(Insert(commOptOut, false));
 }
Beispiel #8
0
 ///<summary>Inserts many CommOptOuts into the database.  Provides option to use the existing priKey.</summary>
 public static void InsertMany(List <CommOptOut> listCommOptOuts, bool useExistingPK)
 {
     if (!useExistingPK && PrefC.RandomKeys)
     {
         foreach (CommOptOut commOptOut in listCommOptOuts)
         {
             Insert(commOptOut);
         }
     }
     else
     {
         StringBuilder sbCommands = null;
         int           index      = 0;
         int           countRows  = 0;
         while (index < listCommOptOuts.Count)
         {
             CommOptOut    commOptOut = listCommOptOuts[index];
             StringBuilder sbRow      = new StringBuilder("(");
             bool          hasComma   = false;
             if (sbCommands == null)
             {
                 sbCommands = new StringBuilder();
                 sbCommands.Append("INSERT INTO commoptout (");
                 if (useExistingPK)
                 {
                     sbCommands.Append("CommOptOutNum,");
                 }
                 sbCommands.Append("PatNum,CommType,CommMode) VALUES ");
                 countRows = 0;
             }
             else
             {
                 hasComma = true;
             }
             if (useExistingPK)
             {
                 sbRow.Append(POut.Long(commOptOut.CommOptOutNum)); sbRow.Append(",");
             }
             sbRow.Append(POut.Long(commOptOut.PatNum)); sbRow.Append(",");
             sbRow.Append(POut.Int((int)commOptOut.CommType)); sbRow.Append(",");
             sbRow.Append(POut.Int((int)commOptOut.CommMode)); sbRow.Append(")");
             if (sbCommands.Length + sbRow.Length + 1 > TableBase.MaxAllowedPacketCount && countRows > 0)
             {
                 Db.NonQ(sbCommands.ToString());
                 sbCommands = null;
             }
             else
             {
                 if (hasComma)
                 {
                     sbCommands.Append(",");
                 }
                 sbCommands.Append(sbRow.ToString());
                 countRows++;
                 if (index == listCommOptOuts.Count - 1)
                 {
                     Db.NonQ(sbCommands.ToString());
                 }
                 index++;
             }
         }
     }
 }