Exemplo n.º 1
0
        ///<summary>Updates one AlertCategoryLink 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(AlertCategoryLink alertCategoryLink, AlertCategoryLink oldAlertCategoryLink)
        {
            string command = "";

            if (alertCategoryLink.AlertCategoryNum != oldAlertCategoryLink.AlertCategoryNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "AlertCategoryNum = " + POut.Long(alertCategoryLink.AlertCategoryNum) + "";
            }
            if (alertCategoryLink.AlertType != oldAlertCategoryLink.AlertType)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "AlertType = " + POut.Int((int)alertCategoryLink.AlertType) + "";
            }
            if (command == "")
            {
                return(false);
            }
            command = "UPDATE alertcategorylink SET " + command
                      + " WHERE AlertCategoryLinkNum = " + POut.Long(alertCategoryLink.AlertCategoryLinkNum);
            Db.NonQ(command);
            return(true);
        }
Exemplo n.º 2
0
        ///<summary>Inserts one AlertCategoryLink into the database.  Provides option to use the existing priKey.</summary>
        public static long Insert(AlertCategoryLink alertCategoryLink, bool useExistingPK)
        {
            if (!useExistingPK && PrefC.RandomKeys)
            {
                alertCategoryLink.AlertCategoryLinkNum = ReplicationServers.GetKey("alertcategorylink", "AlertCategoryLinkNum");
            }
            string command = "INSERT INTO alertcategorylink (";

            if (useExistingPK || PrefC.RandomKeys)
            {
                command += "AlertCategoryLinkNum,";
            }
            command += "AlertCategoryNum,AlertType) VALUES(";
            if (useExistingPK || PrefC.RandomKeys)
            {
                command += POut.Long(alertCategoryLink.AlertCategoryLinkNum) + ",";
            }
            command +=
                POut.Long(alertCategoryLink.AlertCategoryNum) + ","
                + POut.Int((int)alertCategoryLink.AlertType) + ")";
            if (useExistingPK || PrefC.RandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                alertCategoryLink.AlertCategoryLinkNum = Db.NonQ(command, true, "AlertCategoryLinkNum", "alertCategoryLink");
            }
            return(alertCategoryLink.AlertCategoryLinkNum);
        }
Exemplo n.º 3
0
        ///<summary>Inserts one AlertCategoryLink into the database.  Provides option to use the existing priKey.  Doesn't use the cache.</summary>
        public static long InsertNoCache(AlertCategoryLink alertCategoryLink, bool useExistingPK)
        {
            bool   isRandomKeys = Prefs.GetBoolNoCache(PrefName.RandomPrimaryKeys);
            string command      = "INSERT INTO alertcategorylink (";

            if (!useExistingPK && isRandomKeys)
            {
                alertCategoryLink.AlertCategoryLinkNum = ReplicationServers.GetKeyNoCache("alertcategorylink", "AlertCategoryLinkNum");
            }
            if (isRandomKeys || useExistingPK)
            {
                command += "AlertCategoryLinkNum,";
            }
            command += "AlertCategoryNum,AlertType) VALUES(";
            if (isRandomKeys || useExistingPK)
            {
                command += POut.Long(alertCategoryLink.AlertCategoryLinkNum) + ",";
            }
            command +=
                POut.Long(alertCategoryLink.AlertCategoryNum) + ","
                + POut.Int((int)alertCategoryLink.AlertType) + ")";
            if (useExistingPK || isRandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                alertCategoryLink.AlertCategoryLinkNum = Db.NonQ(command, true, "AlertCategoryLinkNum", "alertCategoryLink");
            }
            return(alertCategoryLink.AlertCategoryLinkNum);
        }
 ///<summary>Inserts one AlertCategoryLink into the database.  Returns the new priKey.</summary>
 public static long Insert(AlertCategoryLink alertCategoryLink)
 {
     if (DataConnection.DBtype == DatabaseType.Oracle)
     {
         alertCategoryLink.AlertCategoryLinkNum = DbHelper.GetNextOracleKey("alertcategorylink", "AlertCategoryLinkNum");
         int loopcount = 0;
         while (loopcount < 100)
         {
             try {
                 return(Insert(alertCategoryLink, true));
             }
             catch (Oracle.ManagedDataAccess.Client.OracleException ex) {
                 if (ex.Number == 1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated"))
                 {
                     alertCategoryLink.AlertCategoryLinkNum++;
                     loopcount++;
                 }
                 else
                 {
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else
     {
         return(Insert(alertCategoryLink, false));
     }
 }
Exemplo n.º 5
0
        ///<summary>Updates one AlertCategoryLink in the database.</summary>
        public static void Update(AlertCategoryLink alertCategoryLink)
        {
            string command = "UPDATE alertcategorylink SET "
                             + "AlertCategoryNum    =  " + POut.Long(alertCategoryLink.AlertCategoryNum) + ", "
                             + "AlertType           =  " + POut.Int((int)alertCategoryLink.AlertType) + " "
                             + "WHERE AlertCategoryLinkNum = " + POut.Long(alertCategoryLink.AlertCategoryLinkNum);

            Db.NonQ(command);
        }
Exemplo n.º 6
0
 ///<summary>Returns true if Update(AlertCategoryLink,AlertCategoryLink) 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(AlertCategoryLink alertCategoryLink, AlertCategoryLink oldAlertCategoryLink)
 {
     if (alertCategoryLink.AlertCategoryNum != oldAlertCategoryLink.AlertCategoryNum)
     {
         return(true);
     }
     if (alertCategoryLink.AlertType != oldAlertCategoryLink.AlertType)
     {
         return(true);
     }
     return(false);
 }
Exemplo n.º 7
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <AlertCategoryLink> TableToList(DataTable table)
        {
            List <AlertCategoryLink> retVal = new List <AlertCategoryLink>();
            AlertCategoryLink        alertCategoryLink;

            foreach (DataRow row in table.Rows)
            {
                alertCategoryLink = new AlertCategoryLink();
                alertCategoryLink.AlertCategoryLinkNum = PIn.Long(row["AlertCategoryLinkNum"].ToString());
                alertCategoryLink.AlertCategoryNum     = PIn.Long(row["AlertCategoryNum"].ToString());
                alertCategoryLink.AlertType            = (OpenDentBusiness.AlertType)PIn.Int(row["AlertType"].ToString());
                retVal.Add(alertCategoryLink);
            }
            return(retVal);
        }
 ///<summary>Inserts one AlertCategoryLink into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(AlertCategoryLink alertCategoryLink)
 {
     if (DataConnection.DBtype == DatabaseType.MySql)
     {
         return(InsertNoCache(alertCategoryLink, false));
     }
     else
     {
         if (DataConnection.DBtype == DatabaseType.Oracle)
         {
             alertCategoryLink.AlertCategoryLinkNum = DbHelper.GetNextOracleKey("alertcategorylink", "AlertCategoryLinkNum");                  //Cacheless method
         }
         return(InsertNoCache(alertCategoryLink, true));
     }
 }
Exemplo n.º 9
0
 ///<summary>Inserts one AlertCategoryLink into the database.  Returns the new priKey.</summary>
 public static long Insert(AlertCategoryLink alertCategoryLink)
 {
     return(Insert(alertCategoryLink, false));
 }